Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting GDB to display the entirety of multi-line statements

Tags:

gdb

GDB, at least as it's configured by default on my Ubuntu 9.04 box, doesn't handle multi-line statements well. When I'm stepping through code, GDB only displays the last line of the current statement, even if that statement spans multiple lines.

I'm aware that I could use DDD or emacs as a frontend for GDB, but I'd prefer to solve this problem within GDB, if that's possible.

Does anyone know if there's a way to get GDB to do the right thing here?

like image 629
Justin L. Avatar asked Jul 13 '09 23:07

Justin L.


People also ask

What is stack in GDB?

All the stack frames are allocated in a region of memory called the call stack . When your program stops, the GDB commands for examining the stack allow you to see all of this information. One of the stack frames is selected by GDB and many GDB commands refer implicitly to the selected frame.

What are the three commands used in GDB to examine and move within the stack?

Able to view and traverse the function call stack using the where, up, down and frame commands.

How do you set exits in GDB?

To exit GDB, use the quit command (abbreviated q ), or type an end-of-file character (usually C-d ). If you do not supply expression , GDB will terminate normally; otherwise it will terminate using the result of expression as the error code.

How do I list breakpoints in GDB?

You can see these breakpoints with the GDB maintenance command `maint info breakpoints' . Using the same format as `info breakpoints' , display both the breakpoints you've set explicitly, and those GDB is using for internal purposes. Internal breakpoints are shown with negative breakpoint numbers.


2 Answers

How about running GDB with the text user interface?

gdb -tui

It makes a world of difference to the ease of use of GDB.

like image 141
John Carter Avatar answered Sep 21 '22 18:09

John Carter


I'm afraid the answer is "no, there is no way to get gdb to do what you want". The line info in the symbol tables associates each code instruction with a single source line (not a source statement). gdb has no way of knowing that several source lines are associated with the same source statement.

like image 28
Michael Snyder Avatar answered Sep 18 '22 18:09

Michael Snyder