mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
edae3fd660
New in this version: - Add a PY_MAJOR_VERSION check in configure.ac / AC_TRY_LIBPYTHON. If the user passes --with-python=python2, this will cause a configure failure saying that GDB only supports Python 3. Support for Python 2 is a maintenance burden for any patches touching Python support. Among others, the differences between Python 2 and 3 string and integer types are subtle. It requires a lot of effort and thinking to get something that behaves correctly on both. And that's if the author and reviewer of the patch even remember to test with Python 2. See this thread for an example: https://sourceware.org/pipermail/gdb-patches/2021-December/184260.html So, remove Python 2 support. Update the documentation to state that GDB can be built against Python 3 (as opposed to Python 2 or 3). Update all the spots that use: - sys.version_info - IS_PY3K - PY_MAJOR_VERSION - gdb_py_is_py3k ... to only keep the Python 3 portions and drop the use of some now-removed compatibility macros. I did not update the configure script more than just removing the explicit references to Python 2. We could maybe do more there, like check the Python version and reject it if that version is not supported. Otherwise (with this patch), things will only fail at compile time, so it won't really be clear to the user that they are trying to use an unsupported Python version. But I'm a bit lost in the configure code that checks for Python, so I kept that for later. Change-Id: I75b0f79c148afbe3c07ac664cfa9cade052c0c62
147 lines
5.1 KiB
Plaintext
147 lines
5.1 KiB
Plaintext
# This testcase is part of GDB, the GNU debugger.
|
|
#
|
|
# Copyright 2016-2022 Free Software Foundation, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Skip this test if btrace is disabled.
|
|
|
|
if { [skip_btrace_tests] } {
|
|
untested "skipping btrace tests"
|
|
return -1
|
|
}
|
|
|
|
load_lib gdb-python.exp
|
|
|
|
standard_testfile
|
|
|
|
if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
|
|
|
|
# Skip this test if python is disabled.
|
|
|
|
if { [skip_python_tests] } {
|
|
untested "skipping python tests"
|
|
return -1
|
|
}
|
|
|
|
if ![runto_main ] then {
|
|
return -1
|
|
}
|
|
|
|
with_test_prefix "no or double record" {
|
|
gdb_test "python print(gdb.current_recording())" "None"
|
|
|
|
gdb_test_no_output "python gdb.start_recording(\"btrace\")"
|
|
gdb_test "python gdb.start_recording(\"btrace\")" \
|
|
".*gdb\.error: The process is already being recorded\..*" \
|
|
"already recording"
|
|
|
|
gdb_test_no_output "python gdb.stop_recording()" "first"
|
|
gdb_test "python gdb.stop_recording()" \
|
|
".*gdb\.error: No recording is currently active\..*" "second"
|
|
}
|
|
|
|
with_test_prefix "preopened record btrace" {
|
|
gdb_test_no_output "record btrace"
|
|
gdb_test "python print(gdb.current_recording().method)" "btrace"
|
|
gdb_test "python print(gdb.current_recording().format)" "pt|bts"
|
|
gdb_test_no_output "python gdb.stop_recording()"
|
|
}
|
|
|
|
with_test_prefix "prepare record" {
|
|
gdb_test_no_output "python r = gdb.start_recording(\"btrace\")"
|
|
gdb_test "python print(r.method)" "btrace"
|
|
gdb_test "python print(r.format)" "pt|bts"
|
|
gdb_test "stepi 100" ".*"
|
|
gdb_test_no_output "python insn = r.instruction_history"
|
|
gdb_test_no_output "python call = r.function_call_history"
|
|
gdb_test_no_output "python i = insn\[0\]"
|
|
gdb_test_no_output "python c = call\[0\]"
|
|
}
|
|
|
|
with_test_prefix "replay begin" {
|
|
gdb_test "python print(r.replay_position)" "None"
|
|
gdb_test "python r.goto(r.begin)"
|
|
gdb_test "python print(r.replay_position.number)" "1"
|
|
}
|
|
|
|
with_test_prefix "replay end" {
|
|
gdb_test "python r.goto(r.end)"
|
|
gdb_test "python print(r.replay_position)" "None"
|
|
}
|
|
|
|
with_test_prefix "instruction " {
|
|
gdb_test "python print(i.number)" "1"
|
|
gdb_test "python print(i.sal)" "symbol and line for .*"
|
|
gdb_test "python print(i.pc)" "$decimal"
|
|
gdb_test "python print(repr(i.data))" "<memory at $hex>"
|
|
gdb_test "python print(i.decoded)" ".*"
|
|
gdb_test "python print(i.size)" "$decimal"
|
|
gdb_test "python print(i.is_speculative)" "False"
|
|
}
|
|
|
|
with_test_prefix "function call" {
|
|
gdb_test "python print(c.number)" "1"
|
|
gdb_test "python print(c.symbol)" "main"
|
|
gdb_test "python print(c.level)" "$decimal"
|
|
gdb_test "python print(len(c.instructions))" "$decimal"
|
|
gdb_test "python print(c.up)" "None"
|
|
gdb_test "python print(c.prev)" "None"
|
|
gdb_test "python print(c == c.next.prev)" "True"
|
|
}
|
|
|
|
with_test_prefix "list" {
|
|
gdb_test "python print(len(insn))" "100"
|
|
gdb_test "python print(len(insn\[23:65\]))" "42"
|
|
gdb_test "python print(insn\[17:\]\[2\].number)" "20"
|
|
gdb_test "python print(i in insn)" "True"
|
|
gdb_test "python print(i in call)" "False"
|
|
gdb_test "python print(c in insn)" "False"
|
|
gdb_test "python print(c in call)" "True"
|
|
gdb_test "python print(insn.index(i))" "0"
|
|
gdb_test "python print(insn.count(i))" "1"
|
|
}
|
|
|
|
with_test_prefix "sublist" {
|
|
gdb_test_no_output "python s1 = insn\[3:72:5\]"
|
|
gdb_test_no_output "python s2 = s1\[2:13:3\]"
|
|
gdb_test_no_output "python s3 = s1\[13:2:-3\]"
|
|
gdb_test_no_output "python s4 = insn\[::-1\]"
|
|
|
|
gdb_test "python print(\[i.number for i in s1\])" "\\\[4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69\\\]"
|
|
gdb_test "python print(\[i.number for i in s2\])" "\\\[14, 29, 44, 59\\\]"
|
|
gdb_test "python print(\[i.number for i in s3\])" "\\\[69, 54, 39, 24\\\]"
|
|
|
|
gdb_test "python print(len(s1))" "14"
|
|
gdb_test "python print(len(s2))" "4"
|
|
gdb_test "python print(len(s3))" "4"
|
|
gdb_test "python print(len(s4))" "100"
|
|
|
|
gdb_test "python print(s4\[5\].number)" "95"
|
|
gdb_test "python print(s4\[-5\].number)" "5"
|
|
gdb_test "python print(s4\[100\].number)" ".*IndexError.*"
|
|
gdb_test "python print(s4\[-101\].number)" ".*IndexError.*"
|
|
}
|
|
|
|
with_test_prefix "level" {
|
|
gdb_test_no_output "python gdb.stop_recording()"
|
|
gdb_test "break inner" "Breakpoint.*"
|
|
gdb_test "continue" "Continuing\..*"
|
|
gdb_test_no_output "record btrace"
|
|
gdb_test "step" "outer ().*" "step one"
|
|
gdb_test "step" "main ().*" "step two"
|
|
gdb_test "python print(gdb.current_recording().function_call_history\[0\].level)" "1"
|
|
gdb_test "python print(gdb.current_recording().function_call_history\[1\].level)" "0"
|
|
}
|