From 65f82b1972cca3476b3ef6abf1d9923d34f5d4f5 Mon Sep 17 00:00:00 2001 From: Carl Love Date: Thu, 22 Jul 2021 13:33:59 -0500 Subject: [PATCH] Improve forward progress test in python.exp The test steps into func2 and than does an up to get back to the previous frame. The test checks that the line number you are at after the up command is greater than the line where the function was called from. The assembly/codegen for the powerpc target includes a NOP after the branch-link. func2 (); /* Break at func2 call site. / 10000694: 59 00 00 48 bl 100006ec 10000698: 00 00 00 60 nop return 0; / Break to end. */ 1000069c: 00 00 20 39 li r9,0 The PC at the instruction following the branch-link is 0x10000698 which GDB.find_pc_line() maps to the same line number as the bl instruction. GDB did move past the branch-link location thus making forward progress. The following proposed fix adds an additional PC check to see if forward progress was made. The line test is changed from greater than to greater than or equal. --- gdb/testsuite/gdb.python/python.exp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index d9fd60f3dd4..bc670ce25c1 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -496,12 +496,27 @@ if ![runto_main] then { runto [gdb_get_line_number "Break at func2 call site."] gdb_py_test_silent_cmd "python line = gdb.selected_frame().find_sal().line" "Get line number of func2 call site" 1 + +gdb_py_test_silent_cmd "python pc_call = gdb.selected_frame().pc()" \ + "Get pc of func2 call site" 1 + gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line == line)" "True" "test find_pc_line at func2 call site" gdb_py_test_silent_cmd "step" "Step into func2" 1 gdb_py_test_silent_cmd "up" "Step out of func2" 1 -gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line > line)" "True" "test find_pc_line with resume address" +# The point of the following test is to see if gdb has advanced past the +# location where the branch to a function was made. +set test_name "test find_pc_line with resume address" + +gdb_py_test_silent_cmd "python pc_rtn = gdb.selected_frame().pc()" \ + "Get pc at func2 return site" 1 + +gdb_test "python print (pc_rtn > pc_call)" "True" \ + "test resume address greater then call address" + +gdb_test "python print (gdb.find_pc_line(pc_rtn).line >= line)" "True" \ + "test find_pc_line with resume address" gdb_test_no_output "set variable \$cvar1 = 23" "set convenience variable" gdb_test "python print(gdb.convenience_variable('cvar1'))" "23" -- 2.30.2