aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-06-05 07:42:12 -0600
committerTom Tromey <tom@tromey.com>2022-07-08 14:14:58 -0600
commitd19ca0b35c9536210c5e8bd30504489b7439f51f (patch)
treea488182e25b0d0a16eea68ab816c986988c28cfd /gdb/testsuite/gdb.python
parentfa17a6814113ac22d8059d61514aa2c6e29b0aae (diff)
downloadgdb-d19ca0b35c9536210c5e8bd30504489b7439f51f.zip
gdb-d19ca0b35c9536210c5e8bd30504489b7439f51f.tar.gz
gdb-d19ca0b35c9536210c5e8bd30504489b7439f51f.tar.bz2
Accept gdb.Value in more Python APIs
PR python/27000 points out that gdb.block_for_pc will accept a Python integer, but not a gdb.Value. This patch corrects this oversight. I looked at all uses of GDB_PY_LLU_ARG and fixed these up to use get_addr_from_python instead. I also looked at uses of GDB_PY_LL_ARG, but those seemed relatively unlikely to be useful with a gdb.Value, so I didn't change them. My thinking here is that a Value will typically come from inferior memory, and something like a line number is not too likely to be found this way. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27000
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp3
-rw-r--r--gdb/testsuite/gdb.python/py-shared.exp5
-rw-r--r--gdb/testsuite/gdb.python/python.exp3
4 files changed, 11 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 58f6cb0..1fbbc47 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -43,7 +43,7 @@ gdb_py_test_silent_cmd "python insn_list2 = arch.disassemble(pc, pc)" \
"disassemble no count" 0
gdb_py_test_silent_cmd "python insn_list3 = arch.disassemble(pc, count=1)" \
"disassemble no end" 0
-gdb_py_test_silent_cmd "python insn_list4 = arch.disassemble(pc)" \
+gdb_py_test_silent_cmd "python insn_list4 = arch.disassemble(gdb.Value(pc))" \
"disassemble no end no count" 0
gdb_test "python print (len(insn_list1))" "1" "test number of instructions 1"
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 6c7142c..7c36585 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -60,6 +60,9 @@ if {![runto_main]} {
set pc_val [get_integer_valueof "\$pc" 0]
gdb_py_test_silent_cmd "python blk = gdb.current_progspace ().block_for_pc (${pc_val})" \
"get block for the current \$pc" 1
+gdb_py_test_silent_cmd \
+ "python blk = gdb.current_progspace ().block_for_pc (gdb.Value(${pc_val}))" \
+ "get block for the current \$pc as value" 1
gdb_test "python print (blk.start <= ${pc_val})" "True" \
"block start is before \$pc"
gdb_test "python print (blk.end >= ${pc_val})" "True" \
diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp
index 2d33902..7075bc5 100644
--- a/gdb/testsuite/gdb.python/py-shared.exp
+++ b/gdb/testsuite/gdb.python/py-shared.exp
@@ -57,7 +57,10 @@ runto [gdb_get_line_number "Break to end."]
# Test gdb.solib_name
gdb_test "p &func1" "" "func1 address"
gdb_py_test_silent_cmd "python func1 = gdb.history(0)" "Aquire func1 address" 1
-gdb_test "python print (gdb.solib_name(int(func1)))" "py-shared-sl.sl" "test func1 solib location"
+gdb_test "python print (gdb.solib_name(int(func1)))" "py-shared-sl.sl" \
+ "test func1 solib location"
+gdb_test "python print (gdb.solib_name(func1))" "py-shared-sl.sl" \
+ "test func1 solib location using Value"
gdb_test "p &main" "" "main address"
gdb_py_test_silent_cmd "python main = gdb.history(0)" "Aquire main address" 1
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 7e0d4cb..8c0da6d 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -514,6 +514,9 @@ gdb_test "python print (pc_rtn > pc_call)" "True" \
gdb_test "python print (gdb.find_pc_line(pc_rtn).line >= line)" "True" \
"test find_pc_line with resume address"
+gdb_test "python print (gdb.find_pc_line(pc_rtn).line == gdb.find_pc_line(gdb.Value(pc_rtn)).line)" \
+ "True" \
+ "test find_pc_line using Value"
gdb_test_no_output "set variable \$cvar1 = 23" "set convenience variable"
gdb_test "python print(gdb.convenience_variable('cvar1'))" "23"