aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2024-02-11 17:40:59 +0100
committerHannes Domani <ssbssa@yahoo.de>2024-02-11 17:46:33 +0100
commit39a61855d4e42d0b97e4eef22674d829864798e3 (patch)
tree1161d05bb91774d230abb7807c4d218b792b53d8 /gdb
parent775204fc4b2cbddb2b2e6a0cd6e6e9e731da5a83 (diff)
downloadgdb-39a61855d4e42d0b97e4eef22674d829864798e3.zip
gdb-39a61855d4e42d0b97e4eef22674d829864798e3.tar.gz
gdb-39a61855d4e42d0b97e4eef22674d829864798e3.tar.bz2
Fix crash when calling Frame.static_link
If you try to call Frame.static_link for a frame without debug info, gdb crashes: ``` Temporary breakpoint 1, 0x000000013f821650 in main () (gdb) py print(gdb.selected_frame().static_link()) This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. ``` The problem was a missing check if get_frame_block returns nullptr inside frame_follow_static_link. With this, it works: ``` Temporary breakpoint 1, 0x000000013f941650 in main () (gdb) py print(gdb.selected_frame().static_link()) None ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31366 Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/frame.c3
-rw-r--r--gdb/testsuite/gdb.python/py-frame.exp14
2 files changed, 17 insertions, 0 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index 4a46ccb..87fb3d7 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -3127,6 +3127,9 @@ frame_info_ptr
frame_follow_static_link (frame_info_ptr frame)
{
const block *frame_block = get_frame_block (frame, nullptr);
+ if (frame_block == nullptr)
+ return {};
+
frame_block = frame_block->function_block ();
const struct dynamic_prop *static_link = frame_block->static_link ();
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index 16177c8..ddb1829 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -179,3 +179,17 @@ gdb_test "python print(gdb.selected_frame().language())" "c" \
gdb_test "python print(gdb.selected_frame().read_register(list()))" \
".*Invalid type for register.*" \
"test Frame.read_register with list"
+
+# Compile again without debug info.
+gdb_exit
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {}] } {
+ return -1
+}
+
+if {![runto_main]} {
+ return 0
+}
+
+# Test if Frame.static_link works for a frame without debug info.
+gdb_test "python print(gdb.selected_frame().static_link())" "None" \
+ "test Frame.static_link for a frame without debug info"