return -1
}
-# Do whatever is necessary to make sure that the shared library is
-# loaded for remote targets.
-gdb_load_shlib ${lib_so}
+### First GDB session.
+with_test_prefix "first session" {
+ # Do whatever is necessary to make sure that the shared library is
+ # loaded for remote targets.
+ gdb_load_shlib ${lib_so}
-### First GDB session.
+ # Run to foo to make sure foo refers to the function, and not foo@PLT.
+ if ![runto foo qualified] then {
+ return
+ }
-# Run to foo to make sure foo refers to the function, and not foo@PLT.
-if ![runto foo qualified] then {
- return
-}
+ with_shared_gdb {
-with_shared_gdb {
+ set session_options $exec_options
- set session_options $exec_options
+ # Rather than start a new session, declare the current session the
+ # shared one. Otherwise, get_func_info would compile an executable
+ # in a temp dir, which means -Wl,-rpath,\\\$ORIGIN no longer finds
+ # the shared lib.
+ share_gdb ${srcdir}/${subdir}/$srcfile $session_options
- # Rather than start a new session, declare the current session the
- # shared one. Otherwise, get_func_info would compile an executable
- # in a temp dir, which means -Wl,-rpath,\\\$ORIGIN no longer finds
- # the shared lib.
- share_gdb ${srcdir}/${subdir}/$srcfile $session_options
+ get_func_info foo $session_options
+ get_func_info bar $session_options
- get_func_info foo $session_options
- get_func_info bar $session_options
+ # Using our running GDB session, determine sizes of several types.
+ set long_size [get_sizeof "long" -1]
+ set addr_size [get_sizeof "void *" -1]
+ set struct_A_size [get_sizeof "g_A" -1]
+ set struct_B_size [get_sizeof "g_B" -1]
- # Using our running GDB session, determine sizes of several types.
- set long_size [get_sizeof "long" -1]
- set addr_size [get_sizeof "void *" -1]
- set struct_A_size [get_sizeof "g_A" -1]
- set struct_B_size [get_sizeof "g_B" -1]
+ # Retrieve struct offset of MBR in struct TP
+ proc get_offsetof { tp mbr } {
+ return [get_integer_valueof "&((${tp} *) 0)->${mbr}" -1]
+ }
- # Retrieve struct offset of MBR in struct TP
- proc get_offsetof { tp mbr } {
- return [get_integer_valueof "&((${tp} *) 0)->${mbr}" -1]
+ # Use running GDB session to get struct offsets
+ set A_a [get_offsetof A a]
+ set A_x [get_offsetof A x]
+ set B_a [get_offsetof B a]
+ set B_b [get_offsetof B b]
+ set B_x2 [get_offsetof B x2]
}
-
- # Use running GDB session to get struct offsets
- set A_a [get_offsetof A a]
- set A_x [get_offsetof A x]
- set B_a [get_offsetof B a]
- set B_b [get_offsetof B b]
- set B_x2 [get_offsetof B x2]
}
if { $long_size == -1 || $addr_size == -1 \
### Second GDB session.
-clean_restart $binfile
+with_test_prefix "second session" {
+ clean_restart $binfile
-# Again, do whatever is necessary to make sure that the shared library is
-# loaded for remote targets.
-gdb_load_shlib ${lib_so}
+ # Again, do whatever is necessary to make sure that the shared library is
+ # loaded for remote targets.
+ gdb_load_shlib ${lib_so}
-if ![runto_main] then {
- return
-}
-
-# Step into foo so that we can finish out of it.
-gdb_test "step" "foo .. at .* foo end.*" "step into foo"
+ if ![runto_main] then {
+ return
+ }
-# Finishing out of foo will create a value that will later need to
-# be preserved when restarting the program.
-gdb_test "finish" "= \\(class B \\*\\) ${::hex} .*" "finish out of foo"
+ # Step into foo so that we can finish out of it.
+ gdb_test "step" "foo .. at .* foo end.*" "step into foo"
-# Dereferencing and printing the return value isn't necessary
-# for reproducing the bug, but we should make sure that the
-# return value is what we expect it to be.
-gdb_test "p *$" { = {<A> = {a = 8, x = 9}, b = 10, x2 = 11}} \
- "dereference return value"
+ # Finishing out of foo will create a value that will later need to
+ # be preserved when restarting the program.
+ gdb_test "finish" "= \\(class B \\*\\) ${::hex} .*" "finish out of foo"
-# The original PR28030 reproducer stepped back into the shared object,
-# so we'll do the same here:
-gdb_test "step" "bar \\(.*" "step into bar"
+ # Dereferencing and printing the return value isn't necessary
+ # for reproducing the bug, but we should make sure that the
+ # return value is what we expect it to be.
+ gdb_test "p *$" { = {<A> = {a = 8, x = 9}, b = 10, x2 = 11}} \
+ "dereference return value"
+ # The original PR28030 reproducer stepped back into the shared object,
+ # so we'll do the same here:
+ gdb_test "step" "bar \\(.*" "step into bar"
+}
### Third GDB session.
-# We don't want a clean restart here since that will be too clean.
-# The original reproducer for PR28030 set a breakpoint in the shared
-# library and then restarted via "run". The command below does roughly
-# the same thing. It's at this step that an internal error would
-# occur for PR28030. The "message" argument tells runto to turn on
-# the printing of PASSes while runto is doing its job.
-runto "bar" message
+with_test_prefix "third session" {
+ # We don't want a clean restart here since that will be too clean.
+ # The original reproducer for PR28030 set a breakpoint in the shared
+ # library and then restarted via "run". The command below does roughly
+ # the same thing. It's at this step that an internal error would
+ # occur for PR28030. The "message" argument tells runto to turn on
+ # the printing of PASSes while runto is doing its job.
+ runto "bar" message
+}
# Test FinishBreakpoint in normal conditions
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
+with_test_prefix "normal conditions" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
-if ![runto_main] then {
- return 0
-}
+ if ![runto_main] then {
+ return 0
+ }
-set python_file [gdb_remote_download host \
- ${srcdir}/${subdir}/${testfile}.py]
+ set python_file [gdb_remote_download host \
+ ${srcdir}/${subdir}/${testfile}.py]
-gdb_test_no_output "set confirm off" "disable confirmation"
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 1"
-gdb_breakpoint "increase_1"
-gdb_test "continue" "Breakpoint .*at.*" "continue to the function to finish"
+ gdb_test_no_output "set confirm off" "disable confirmation"
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
+ gdb_breakpoint "increase_1"
+ gdb_test "continue" "Breakpoint .*at.*" "continue to the function to finish"
-# set FinishBreakpoint
+ # set FinishBreakpoint
-gdb_test "python finishbp_default = gdb.FinishBreakpoint ()" \
- "Temporary breakpoint.*" "set FinishBreakpoint with default frame value"
-gdb_test "python finishbp = MyFinishBreakpoint (gdb.parse_and_eval ('a'), gdb.newest_frame ())" \
- "Temporary breakpoint.*" "set FinishBreakpoint"
-gdb_test "python print (finishbp.return_value)" "None.*" \
- "check return_value at init"
+ gdb_test "python finishbp_default = gdb.FinishBreakpoint ()" \
+ "Temporary breakpoint.*" "set FinishBreakpoint with default frame value"
+ gdb_test "python finishbp = MyFinishBreakpoint (gdb.parse_and_eval ('a'), gdb.newest_frame ())" \
+ "Temporary breakpoint.*" "set FinishBreakpoint"
+ gdb_test "python print (finishbp.return_value)" "None.*" \
+ "check return_value at init"
-# check normal bp hit
+ # check normal bp hit
-gdb_test "continue" "MyFinishBreakpoint stop with.*return_value is: -5.*#0.*increase.*" \
- "check MyFinishBreakpoint hit"
-gdb_test "python print (finishbp.return_value)" "-5.*" "check return_value"
+ gdb_test "continue" "MyFinishBreakpoint stop with.*return_value is: -5.*#0.*increase.*" \
+ "check MyFinishBreakpoint hit"
+ gdb_test "python print (finishbp.return_value)" "-5.*" "check return_value"
-gdb_test "python print (finishbp_default.hit_count)" "1.*" "check finishBP on default frame has been hit"
-gdb_test "python print (finishbp.is_valid())" "False.*"\
- "ensure that finish bp is invalid afer normal hit"
+ gdb_test "python print (finishbp_default.hit_count)" "1.*" "check finishBP on default frame has been hit"
+ gdb_test "python print (finishbp.is_valid())" "False.*"\
+ "ensure that finish bp is invalid afer normal hit"
-# check FinishBreakpoint in main no allowed
+ # check FinishBreakpoint in main no allowed
-gdb_test "finish" "main.*" "return to main()"
-gdb_test "python MyFinishBreakpoint (None, gdb.selected_frame ())" \
- "ValueError: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
- "check FinishBP not allowed in main"
+ gdb_test "finish" "main.*" "return to main()"
+ gdb_test "python MyFinishBreakpoint (None, gdb.selected_frame ())" \
+ "ValueError: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \
+ "check FinishBP not allowed in main"
+}
#
# Test FinishBreakpoint with no debug symbol
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
+with_test_prefix "no debug symbol" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 2"
-set cond_line [gdb_get_line_number "Condition Break."]
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
+ set cond_line [gdb_get_line_number "Condition Break."]
-if ![runto_main] then {
- return 0
-}
+ if ![runto_main] then {
+ return 0
+ }
-gdb_test "print do_nothing" "no debug info.*" "ensure that shared lib has no debug info"
-gdb_breakpoint "do_nothing" {temporary}
-gdb_test "continue" "Temporary breakpoint .*in \\.?do_nothing.*" \
- "continue to do_nothing"
+ gdb_test "print do_nothing" "no debug info.*" "ensure that shared lib has no debug info"
+ gdb_breakpoint "do_nothing" {temporary}
+ gdb_test "continue" "Temporary breakpoint .*in \\.?do_nothing.*" \
+ "continue to do_nothing"
-gdb_test "python finishBP = SimpleFinishBreakpoint(gdb.newest_frame())" \
- "SimpleFinishBreakpoint init" \
- "set finish breakpoint for no debug symbol test"
-gdb_test "continue" "SimpleFinishBreakpoint stop.*" "check FinishBreakpoint hit"
-gdb_test "python print (finishBP.return_value)" "None" "check return value without debug symbol"
+ gdb_test "python finishBP = SimpleFinishBreakpoint(gdb.newest_frame())" \
+ "SimpleFinishBreakpoint init" \
+ "set finish breakpoint for no debug symbol test"
+ gdb_test "continue" "SimpleFinishBreakpoint stop.*" "check FinishBreakpoint hit"
+ gdb_test "python print (finishBP.return_value)" "None" "check return value"
+}
#
# Test FinishBreakpoint in function returned by longjmp
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
-
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 3"
-
-if ![runto call_longjmp_1] then {
- return
+with_test_prefix "function returned by longjump" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
+
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
+
+ if ![runto call_longjmp_1] then {
+ return
+ }
+
+ gdb_test "python finishbp = SimpleFinishBreakpoint(gdb.newest_frame())" \
+ "SimpleFinishBreakpoint init" \
+ "set finish breakpoint for longjmp test"
+ gdb_test "break [gdb_get_line_number "after longjmp."]" "Breakpoint.* at .*" \
+ "set BP after the jump"
+ gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" \
+ "check FinishBP out of scope notification"
+ gdb_test "python print (finishbp.is_valid())" "False.*"\
+ "ensure that finish bp is invalid after out of scope notification"
}
-gdb_test "python finishbp = SimpleFinishBreakpoint(gdb.newest_frame())" \
- "SimpleFinishBreakpoint init" \
- "set finish breakpoint for longjmp test"
-gdb_test "break [gdb_get_line_number "after longjmp."]" "Breakpoint.* at .*" \
- "set BP after the jump"
-gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" \
- "check FinishBP out of scope notification"
-gdb_test "python print (finishbp.is_valid())" "False.*"\
- "ensure that finish bp is invalid afer out of scope notification"
-
#
# Test FinishBreakpoint in BP condition evaluation
# (finish in dummy frame)
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
+with_test_prefix "finish in dummy frame" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 4"
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
-if ![runto_main] then {
- return 0
+ if ![runto_main] then {
+ return 0
+ }
+
+ gdb_test "break ${cond_line} if test_1(i,8)" "Breakpoint .* at .*" \
+ "set a conditional BP"
+ gdb_test "python TestBreakpoint()" "TestBreakpoint init" \
+ "set FinishBP in a breakpoint condition"
+ gdb_test "continue" \
+ "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
+ "don't allow FinishBreakpoint on dummy frames"
+ gdb_test "print i" "8" \
+ "check stopped location"
}
-
-gdb_test "break ${cond_line} if test_1(i,8)" "Breakpoint .* at .*" \
- "set a conditional BP"
-gdb_test "python TestBreakpoint()" "TestBreakpoint init" \
- "set FinishBP in a breakpoint condition"
-gdb_test "continue" \
- "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
- "don't allow FinishBreakpoint on dummy frames"
-gdb_test "print i" "8" \
- "check stopped location for stop in dummy frame case"
#
# Test FinishBreakpoint in BP condition evaluation
# (finish in normal frame)
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
+with_test_prefix "finish in normal frame" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 5"
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
-if ![runto_main] then {
- return 0
-}
+ if ![runto_main] then {
+ return 0
+ }
-gdb_test "break ${cond_line} if test(i,8)" \
- "Breakpoint .* at .*" "set conditional BP"
-gdb_test "python TestBreakpoint()" "TestBreakpoint init" "set BP in condition"
+ gdb_test "break ${cond_line} if test(i,8)" \
+ "Breakpoint .* at .*" "set conditional BP"
+ gdb_test "python TestBreakpoint()" "TestBreakpoint init" "set BP in condition"
-gdb_test "continue" \
- "test don't stop: 1.*test don't stop: 2.*test stop.*Error in testing breakpoint condition.*The program being debugged stopped while in a function called from GDB.*" \
- "stop in condition function"
+ gdb_test "continue" \
+ "test don't stop: 1.*test don't stop: 2.*test stop.*Error in testing breakpoint condition.*The program being debugged stopped while in a function called from GDB.*" \
+ "stop in condition function"
-gdb_test "continue" "Continuing.*" "finish condition evaluation"
-gdb_test "continue" "Breakpoint.*" "stop at conditional breakpoint"
-gdb_test "print i" "8" \
- "check stopped location for stop in normal frame case"
+ gdb_test "continue" "Continuing.*" "finish condition evaluation"
+ gdb_test "continue" "Breakpoint.*" "stop at conditional breakpoint"
+ gdb_test "print i" "8" \
+ "check stopped location"
+}
#
# Test FinishBreakpoint in explicit inferior function call
#
-clean_restart ${testfile}
-gdb_load_shlib ${lib_sl}
-
-gdb_test "source $python_file" "Python script imported.*" \
- "import python scripts, 6"
+with_test_prefix "explicit inferior function call" {
+ clean_restart ${testfile}
+ gdb_load_shlib ${lib_sl}
-if ![runto_main] then {
- return 0
-}
+ gdb_test "source $python_file" "Python script imported.*" \
+ "import python scripts"
-# return address in dummy frame
+ if ![runto_main] then {
+ return 0
+ }
-gdb_test "python TestExplicitBreakpoint('increase_1')" "Breakpoint.*at.*" \
- "prepare TestExplicitBreakpoint, return addr in dummy frame"
-gdb_test "print increase_1(&i)" \
- "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
- "don't allow FinishBreakpoint on dummy frames, return address in dummy frame"
+ # return address in dummy frame
-# return address in normal frame
+ gdb_test "python TestExplicitBreakpoint('increase_1')" "Breakpoint.*at.*" \
+ "prepare TestExplicitBreakpoint, return addr in dummy frame"
+ gdb_test "print increase_1(&i)" \
+ "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
+ "don't allow FinishBreakpoint on dummy frames, return address in dummy frame"
-delete_breakpoints
-gdb_test "python TestExplicitBreakpoint(\"increase_1\")" "Breakpoint.*at.*" \
- "prepare TestExplicitBreakpoint, return addr in normal frame"
-gdb_test "print increase(&i)" \
- "SimpleFinishBreakpoint init.*SimpleFinishBreakpoint stop.*The program being debugged stopped while in a function called from GDB.*" \
- "FinishBP stop at during explicit function call"
+ # return address in normal frame
+ delete_breakpoints
+ gdb_test "python TestExplicitBreakpoint(\"increase_1\")" "Breakpoint.*at.*" \
+ "prepare TestExplicitBreakpoint, return addr in normal frame"
+ gdb_test "print increase(&i)" \
+ "SimpleFinishBreakpoint init.*SimpleFinishBreakpoint stop.*The program being debugged stopped while in a function called from GDB.*" \
+ "FinishBP stop"
+}
#
# Test FinishBreakpoint when inferior exits
#
-if ![runto "test_exec_exit"] then {
- return 0
-}
+with_test_prefix "inferior exit" {
+ if ![runto "test_exec_exit"] then {
+ return 0
+ }
-gdb_test_no_output "set var self_exec = 0" "switch to exit() test"
-gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exit()"
-gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" "catch out of scope after exit"
+ gdb_test_no_output "set var self_exec = 0" "switch to exit() test"
+ gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exit()"
+ gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" "catch out of scope after exit"
+}
#
# Test FinishBreakpoint when inferior execs
#
-if ![runto "test_exec_exit"] then {
- return 0
-}
+with_test_prefix "inferior exec" {
+ if ![runto "test_exec_exit"] then {
+ return 0
+ }
-gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exec"
-gdb_test "catch exec" "Catchpoint.*\(exec\).*"
-gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" "catch out of scope after exec"
+ gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exec"
+ gdb_test "catch exec" "Catchpoint.*\(exec\).*"
+ gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" "catch out of scope after exec"
+}