Tuesday, February 27, 2007

Poor Man's Tracepoints and a call sequence of a C program

My C is quite rusty, so to help me figure out the flow of a program, I thought I'd do with gdb what Tony Loton did with JPDA. Quickly giving myself a refresher on gdb, I thought tracepoints are the easiest way to go. Except that they are available only for remote targets, and

  1. There's no gdbserver on my host platform (Cygwin)
  2. The target platform does have it (good news!), but it doesn't support tracepoints (and some say, that few if any stubs even support it...

So I wrote a silly Perl script to read ctags information, create breakpoints on every function entry, print the arguments and resume. I haven't bothered to figure out where to use pure MI vs. CLI commands, and in general I have no clue...

Now, what I think would be interesting is making this an add-on, using CDT (or, more generically, via Eclipse Debug Framework) and GEF... I envision something like a call graph (with exclusions of course, because it will become too big), which grows as you step through, displaying arguments. Could be a quick way to get a picture of how a program works before just reading the code and keeping stuff in your head...


In related news, upgrading to Eclipse 3.2.2 I lost the "Remote debugging" launch configuration. (Ironically, the reason for the attempted upgrade was to see whether a bug with hardcoded remote port has been fixed (it appeared that it's always 4305, no matter what you put in; while the default one is 1234, which is the kind of thing an idiot would have on his luggage.). Which brings me to the "Zero information content" of various blogs/articles out there (which this blog is trying not to be). Thank you, Bill Graham, for pointing out that "the 'vanilla' CDT from www.eclipse.org [...] doesn't support remote target debugging", thus leading me in my Google search to your article which doesn't tell me how to fix it, nor does it tell me much of anything... There, I vented. (The answer, BTW, is to get Target Management, who knew...)

3 comments:

Anonymous said...

keep up the good work -bobh

Staff said...

Displaying the call graph over time? Do you mean something like this:

http://www.ghs.com/products/images/TM_code_lg.gif

debedb said...

Yeah, kind of like that... Tell me more? :)