[PATCH] Avoid crash with GCC trunk

Tom Tromey tromey@adacore.com
Thu May 6 16:42:51 GMT 2021


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-06  Tom Tromey  <tromey@adacore.com>

	* 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/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 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
      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.26.3



More information about the Gdb-patches mailing list