This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix a crash with maintenance print type for GNAT stuff


Hello,

The attached patch fixes a crash in GDB when running the "maintenance print type" command on a type tree that includes "GNAT stuff" (i.e. GNAT descriptive types). This occurs only with AdaCore's version of GDB because our dwarf2read.c:need_gnat_info's implementation sometimes returns true.

As a consequence I cannot write a meaningful regression testcase for this. The patch does not trigger regressions on x86_64-linux, though. Ok for master?

Thank you in advance!

gdb/ChangeLog:
2015-04-01  Pierre-Marie de Rodat  <derodat@adacore.com>

        * gdbtypes.c (print_gnat_stuff): Do not recurse on the
        descriptive type when there is none.

--
Pierre-Marie de Rodat
>From 96121045f9c03f36893fde658136d840be22aa1b Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <derodat@adacore.com>
Date: Tue, 10 Mar 2015 15:43:09 +0100
Subject: [PATCH] Fix printing for GNAT stuff for types that do not have descr.
 types

gdb/ChangeLog:
2015-04-01  Pierre-Marie de Rodat  <derodat@adacore.com>

	* gdbtypes.c (print_gnat_stuff): Do not recurse on the
	descriptive type when there is none.
---
 gdb/gdbtypes.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 217ec70..103b4e2 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3888,7 +3888,13 @@ print_gnat_stuff (struct type *type, int spaces)
 {
   struct type *descriptive_type = TYPE_DESCRIPTIVE_TYPE (type);
 
-  recursive_dump_type (descriptive_type, spaces + 2);
+  if (descriptive_type == NULL)
+    printfi_filtered (spaces + 2, "no descriptive type\n");
+  else
+    {
+      printfi_filtered (spaces + 2, "descriptive type\n");
+      recursive_dump_type (descriptive_type, spaces + 4);
+    }
 }
 
 static struct obstack dont_print_type_obstack;
-- 
2.3.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]