简体   繁体   中英

debugging exe using gdb

after trying a couple of alternatives to debug a exe fairly unsuccessfully decided to try gdb to debug a executable on the windows env.

The options that are being used to compile the exe look like this

/nologo /Z7  /Zi /MT /W3 /GX /O2 /D /DEBUG

These are the options that I am using to load the executable into gdb

target exec setup
run -debug ( this is the option against which I would like to perform some debugging)

I need a way to either load the source/symbols into GDB since I am unable to set any valid breakpoints otherwise.

This is what I have tried, in order to set breakpoints ( other than the usual way)

(gdb) set breakpoint pending on
(gdb) break runInstaller.c:6318
 No symbol table is loaded.  Use the "file" command.
 Breakpoint 2 (runInstaller.c:6318) pending.
 (gdb) pwd
 Working directory C:\
 (gdb) info b
  Num     Type           Disp Enb Address    What
  1       breakpoint     keep y   <PENDING>  WinMain
  2       breakpoint     keep y   <PENDING>  runInstaller.c:6318

I have tried this to load the executable;

(gdb) file setup
 Reading symbols from setup...(no debugging symbols found)...done.

It is due to the above errors I realise that the executable is not compiled with the debugging options, so it there a gcc -g equivalent in gdb or are there better way s of loading the symbols/source code into gdb.

Edit 1: Whenever I try to add a breakpoint I see the following error:

(gdb) b main_helper
 Function "main_helper" not defined.
 Make breakpoint pending on future shared library load? (y or [n]) y
 Breakpoint 5 (main_helper) pending.

The setup file which you are currently using does not have the symbol table which is required to debug. When you are generating the executable binary you need to generate the symbol table as well. Ex. when we are generating the executable file for ac program we compile with the argument -g.

gcc setup.c -o setup -g 

-g tells the gcc compiler to generate the symbol table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM