automating 'next' in gdb dubugger

Michael O'Donnell mod+blu at std.com
Sat Sep 16 11:28:15 EDT 2000




>'continue' would not shown the execution in sequence for each line
>of code.  It would execute upto breakpoint B and wait for further
>instructions.  I would like to see the 'next' command executed from
>A to B i.e.  to watch the sequence of execution.


Aha!  In that case you might be able to use some
sort of trick like this:


Pick the file and line where you want tracing to
terminate and ask GDB for info thus:

   info line someSourceFileName:someLineNumber

...and GDB should respond something like this:

   Line 20 of "someSourceFileName" starts at address 0x8048447 <main+23>
                                         and ends at 0x804844c <main+28>.

...you can then define a GDB procedure thus:

   (gdb) define crank
   Type commands for definition of "crank".
   End with a line saying just "end".
   >while ( $pc != $arg0 )
    >next
    >end
   >end


...and you should then be able to crank through all lines
until you hit the line in question by invoking your new
procedure and specifying the starting address of the
instructions corresponding to the line in question, thus:

   crank 0x8048447

...it will, of course, run very slowly and I'm not sure
it will take kindly to being interrupted, but it should
at least get you started.


Regards,
 -------------------------------------
 Michael O'Donnell     mod+blu at std.com
 -------------------------------------

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list