This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to resume step/next/cont within a breakpoint command list ?


Hi

  I wish to implement printf-like debugging with gdb, that is :

  a) suspend execution when some point is reached
  b) execute some print gdb command
  c) resume execution until 
     + the end of the current instruction/line if the current breakpoint was
reached while single stepping (step/next)
     + the next breakpoint is reached when the current breakpoint was 
reached during continous execution (run/continue).

  a) and b) are easy to perform with breakpoints and command lists.
  But I don't see how to express c) with existing gdb commands.
  
Thank for any advice
Philippe Waille


(gdb) break 11
Breakpoint 1 at 0x8048396: file test.c, line 11.

***************************************************************************
This breaks continous execution :
***************************************************************************

(gdb) command 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>silent
>print "reached line 11"
>end
(gdb) cont
Continuing.
$2 = "reached line 11"
(gdb) cont
Continuing.
$3 = "reached line 11"

 
***************************************************************************
This breaks single step execution :
***************************************************************************

(gdb) command 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>print "reached line 11"
>continue               
>end
(gdb) break main
Breakpoint 2 at 0x8048385: file test.c, line 8.
(gdb) run
Starting program: /tmp/test_gdb/test

Breakpoint 2, main () at test.c:8
8           i = 1;
(gdb) next
9           while (i<30) {
(gdb) next
10              y = i;
(gdb) next
$1 = "reached line 11"
$2 = "reached line 11"
$3 = "reached line 11"
$4 = "reached line 11"
$5 = "reached line 11"
...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]