tags:

views:

278

answers:

5

When I run gdb with a debug binary(gdb binary name).. I dunno where is the source code for that debug binary is present... But I can set the breakpoint in main and debug the code with correct src code.. I dunno from where the gdb is taking the source code from ... The source code is not present in CWD.... how to find from which location the gdb is taking the code....?

+1  A: 

You can use gdb command:

info source
skwllsp
where do the gdb stores this source code location? Is it in the executable itself?
suresh
In executable itself that was built with debugging information.
skwllsp
+1  A: 

Use the gdb "show directories" command to see the source search path.

anon
+1  A: 

use

(gdb) show directories

if you don't know where those directories get set check into your .gdbinit if there are statements like

directory /path/to/source

see also this other SO Thread about gdb

fabrizioM
+1  A: 

The binary is probably compiled with "-g" - i.e. debugging.

diciu
That does not mean the source is compiled into the binary.
anon
But it does mean that references to the original source are kept. I've tried this on my system and it works.
diciu
+2  A: 

This information is kept in binary in DWARF2 format. So, in order to see DWARF2 information, you can use dwarfdump utility. Needed information is kept in DW_AT_comp_dir field.

Marko Kevac