tags:

views:

567

answers:

1

I have a set of basic breakpoints defined in a user-defined fn setup in my .gdbinit. So, every time i start gdb, I have to execute that fn. to set all my brkpoints , before I start debugging. Can I configure my .gdbinit so that whenever it starts , it first executes my user-defined fn setup ?

A: 

Just call it by function name:

My .gdbinit:

define setup    
  echo Foobar\n
end   

setup #This is the function call

And when I run it:

$ gdb
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Foobar
(gdb)
Kimvais
Not working for me - gives this error:.No symbol table is loaded. Use the "file" command.No symbol table is loaded. Use the "file" command.No symbol table is loaded. Use the "file" command.No symbol table is loaded. Use the "file" command./home/sbhowmick/.gdbinit:83: Error in sourced command file:No executable file specified.Use the "file" or "exec-file" command.Using host libthread_db library "/lib/tls/libthread_db.so.1".I'm using GNU gdb Red Hat Linux (6.3.0.0-1.138.el3rh)
shan23
My .gdbinit file looks like this:define setup br fn1 br fn2enddefine some_other_fn ...endsetup
shan23
This is because you don't have the binary file loaded, if you are defining breakpoints, the binary must be loaded already when starting GDB, e.g. you must define "file a.out" or smtg like that in your .gdbinit before setting the breakpoints or run "gdb a.out" or so.
Kimvais