public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix a crash with maintenance print type for GNAT stuff
@ 2015-04-01 10:03 Pierre-Marie de Rodat
  2015-04-01 14:25 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre-Marie de Rodat @ 2015-04-01 10:03 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

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

[-- Attachment #2: 0001-Fix-printing-for-GNAT-stuff-for-types-that-do-not-ha.patch --]
[-- Type: text/x-diff, Size: 1108 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a crash with maintenance print type for GNAT stuff
  2015-04-01 10:03 [PATCH] Fix a crash with maintenance print type for GNAT stuff Pierre-Marie de Rodat
@ 2015-04-01 14:25 ` Joel Brobecker
  2015-04-24 14:14   ` Pierre-Marie de Rodat
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2015-04-01 14:25 UTC (permalink / raw)
  To: Pierre-Marie de Rodat; +Cc: GDB Patches

> 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?

I was telling Pierre-Marie at the time that I thought the patch
to be sufficiently self-evident that we could submit it without
a testcase.

> 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.

Give it a week, and if no one objects, then go ahead and push.
Thanks!

Patch intentionally left below for easy reference, but no further
comment below (so, no need to keep scrolling down unless you're
looking for the patch).

> >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
> 


-- 
Joel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a crash with maintenance print type for GNAT stuff
  2015-04-01 14:25 ` Joel Brobecker
@ 2015-04-24 14:14   ` Pierre-Marie de Rodat
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre-Marie de Rodat @ 2015-04-24 14:14 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: GDB Patches

On 04/01/2015 04:25 PM, Joel Brobecker wrote:
> Give it a week, and if no one objects, then go ahead and push.
> Thanks!

Finally pushed. Thank you for the review!

-- 
Pierre-Marie de Rodat

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-24 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 10:03 [PATCH] Fix a crash with maintenance print type for GNAT stuff Pierre-Marie de Rodat
2015-04-01 14:25 ` Joel Brobecker
2015-04-24 14:14   ` Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).