2013-09-04 10:25:28 +00:00
|
|
|
#
|
|
|
|
# \brief GDB command line arguments for setting a breakpoint in the 'main()' function
|
|
|
|
# \author Christian Prochaska
|
|
|
|
# \date 2013-09-04
|
|
|
|
#
|
|
|
|
|
|
|
|
proc gdb_main_breakpoint_cmds { target_binary_name } {
|
|
|
|
|
|
|
|
#
|
|
|
|
# We set a break in the 'main()' function of a dynamically linked
|
|
|
|
# application by using the following gdb command sequence. It's important that
|
|
|
|
# the 'main()' breakpoint gets set before the 'sharedlibrary' command is
|
|
|
|
# executed. Otherwise the breakpoint would get set in ld.lib.so's main()
|
|
|
|
# function.
|
|
|
|
#
|
|
|
|
|
|
|
|
set gdb_cmds ""
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# don't ask for y/n when loading a new symbol file
|
|
|
|
append gdb_cmds {-ex "set interactive-mode off" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# load the symbols of ld.lib.so
|
|
|
|
append gdb_cmds {-ex "symbol-file bin/ld.lib.so" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
|
|
|
# set a breakpoint in the 'call_program_main()' function
|
|
|
|
append gdb_cmds {-ex "b call_program_main" }
|
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# continue execution until the breakpoint triggers
|
|
|
|
append gdb_cmds {-ex "c" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
|
|
|
# delete the 'call_program_main()' breakpoint
|
2013-09-04 10:25:28 +00:00
|
|
|
append gdb_cmds {-ex "delete 1" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# load the symbols of the test application
|
|
|
|
append gdb_cmds "-ex \"symbol-file bin/$target_binary_name\" "
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# set a breakpoint in the application's 'main()' function
|
2014-02-21 12:13:45 +00:00
|
|
|
append gdb_cmds {-ex "b main()" }
|
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# load the symbols of loaded shared libraries
|
|
|
|
append gdb_cmds {-ex "sharedlibrary" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# continue execution until the breakpoint triggers
|
|
|
|
append gdb_cmds {-ex "c" }
|
2014-02-21 12:13:45 +00:00
|
|
|
|
2013-09-04 10:25:28 +00:00
|
|
|
# delete the 'main()' breakpoint
|
|
|
|
append gdb_cmds {-ex "delete 2" }
|
|
|
|
|
|
|
|
return $gdb_cmds
|
|
|
|
}
|