Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

automating 'next' in gdb dubugger





>'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).




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org