user220751
user220751

Reputation:

Using tui option of GDB

I am currently working with NS-2(A network Simulator) and I wanted to use the tui option of gdb such that i can view the course code while debugging. (Just like Visual studio)

As of now the source window is blank when i run "gdb -tui" . However I can see the file when i do a "list" in gdb, but I am not able to make it go automatically to the file and point to the break location.

Any Ideas how to do this?

Upvotes: 4

Views: 6186

Answers (4)

Sandeep Singh
Sandeep Singh

Reputation: 5191

Run your executable with gdb as:

$gdb -tui ./executable_name

The source code will appear as soon as you execute the gdb command: "run" on the gdb terminal.

It would be better if you put a breakpoint on some line (say: on main() function), then execute "run": The Source Code would be visible now.

Upvotes: 4

Johan
Johan

Reputation: 20763

You can always double check so that the elf-file contains correct data.

Let's say you break your program at some place, and there you will get some reading on the pc (program counter). That value can be cross checked with addr2line (in binutils) so you do have a correct source file.

Upvotes: 1

Peter Kovacs
Peter Kovacs

Reputation: 2725

While I'm not sure about the GDB TUI, if you're familiar with vi then be sure to check out CGDB. It is a TUI front-end to GDB using vi-like key bindings.

To set a break point in CGDB, just hit escape (of course), navigate to the line you want to break on, then hit the space bar!

Upvotes: 1

CodeRain
CodeRain

Reputation: 6582

Did you try the Ctrl-X A combination? It tells gdb to enter/leave the TUI mode.

Upvotes: 9

Related Questions