From 9e541c7918c184aa226c1544159e37b6387ef205 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 17 May 2021 13:07:25 -0600 Subject: [PATCH] Avoid crash with GCC trunk With GCC trunk, gdb.ada/access_to_packed_array.exp causes a GDB crash. The problem is that ptype tries to resolve a dynamic type. However, the inferior is not running, so there are no frames. This patch updates dwarf2_evaluate_loc_desc::get_frame_base to handle this situation. gdb/ChangeLog 2021-05-17 Tom Tromey * dwarf2/loc.c (dwarf2_evaluate_loc_desc::get_frame_base): Throw if frame is null. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2/loc.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 39cdb3a50ef..4589251f022 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-05-17 Tom Tromey + + * dwarf2/loc.c (dwarf2_evaluate_loc_desc::get_frame_base): Throw + if frame is null. + 2021-05-17 Tom Tromey * nat/linux-osdata.c (user_from_uid, time_from_time_t) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index aec50da4b6d..e816f926696 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -785,6 +785,9 @@ public: its length in LENGTH. */ void get_frame_base (const gdb_byte **start, size_t * length) override { + if (frame == nullptr) + error (_("frame address is not available.")); + /* FIXME: cagney/2003-03-26: This code should be using get_frame_base_address(), and then implement a dwarf2 specific this_base method. */ -- 2.30.2