Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb: apply "next" to selected frame instead of innermost frame

Tags:

c

linux

gdb

In gdb, when you run next command. It apply to innermost frame instead of selected frame. How to ask to gdb to break in next line of the selected frame?

For exemple:

Set a breakpoint in a sub-function:

(gdb) b subfunc
Breakpoint 1 at 0x400f09: file prog.c, line 94.
(gdb) c
Continuing.

Breakpoint 1 at 0x400f09: file prog.c, line 94.
94      void subfunc() {

Change selected frame:

(gdb) up
#1  0x0000000000400f7e in main (argc=1, argv=0x7fffffffe468) at prog.c:70
70          subfunc();

I want to stop at line 71 of prog.c:

(gdb) n
95          i = 0;

... but it stop line 95 of prog.c.

like image 585
Jérôme Pouiller Avatar asked Dec 17 '15 12:12

Jérôme Pouiller


People also ask

What does BT do in GDB?

To print a backtrace of the entire stack, use the backtrace command, or its alias bt . This command will print one line per frame for frames in the stack. By default, all stack frames are printed. You can stop the backtrace at any time by typing the system interrupt character, normally Ctrl-c .

What is stack frame in GDB?

Stack frames are regions of memory allocated on the stack to hold the local variables of functions each time they are called. When one function calls another, a new stack frame is allocated and placed on top of the current function's stack frame. When a function returns, its stack frame is de-allocated.

How does GDB backtrace work?

A backtrace is a summary of how your program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame zero), followed by its caller (frame one), and on up the stack. Print a backtrace of the entire stack: one line per frame for all frames in the stack.

How do I set a breakpoint in GDB?

Breakpoints are set with the break command (abbreviated b ). The debugger convenience variable `$bpnum' records the number of the breakpoint you've set most recently; see section Convenience variables, for a discussion of what you can do with convenience variables.


1 Answers

I finally found what I want. advance allow to continue until a particular line. Thus advance +1 do the job. It can be abbreviated adv +1.

like image 157
Jérôme Pouiller Avatar answered Oct 30 '22 12:10

Jérôme Pouiller