Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix mi "-var-create" regression
@ 2012-10-10 20:05 Luis Gustavo
  2012-10-11 21:53 ` Sergio Durigan Junior
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Luis Gustavo @ 2012-10-10 20:05 UTC (permalink / raw)
  To: gdb-patches

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

Hi,

After the commit that fixed #13393 
(http://sourceware.org/bugzilla/show_bug.cgi?id=13393), certain calls to 
-var-create with "set print object on" started failing with a 
dereferencing error, like so:

(gdb)
-var-create - * $sp
^error,msg="Attempt to dereference a generic pointer."
(gdb)

This happens because in value.c:value_actual_type we have this check:

       if (TYPE_CODE (result) == TYPE_CODE_PTR
           || TYPE_CODE (result) == TYPE_CODE_REF)
         {
           struct type *real_type;

           real_type = value_rtti_indirect_type (value, NULL, NULL, NULL);
           if (real_type)
             {
               if (real_type_found)
                 *real_type_found = 1;
               result = real_type;
             }
         }

If we reach this point with result being a pointer of reference, we 
execute the if block. This will eventually lead to a call to 
valops.c:get_value_at, where we throw an error in case the target type 
is void (pointers usually have such a target type)

Anton does mention a particular problem with indirect pointers in #13393 
comment #8, but it is not clear if a bug ticket has been filed for that.

The following patch adds a check for target type void, and skips the 
problematic if block accordingly. This fixes the problem and does not 
seem to cause any regressions.

With "set print object off", everything works as it should.

Ok?

[-- Attachment #2: rtti-print-object.diff --]
[-- Type: text/x-patch, Size: 951 bytes --]

2012-10-10  Luis Machado  <lgustavo@codesourcery.com>

	* value.c (value_actual_type): Check for TYPE_CODE_VOID
	target types.

Index: gdb/gdb/value.c
===================================================================
--- gdb.orig/gdb/value.c	2012-10-10 16:38:21.872234906 -0300
+++ gdb/gdb/value.c	2012-10-10 16:42:49.560222099 -0300
@@ -850,8 +850,13 @@ value_actual_type (struct value *value,
   result = value_type (value);
   if (opts.objectprint)
     {
-      if (TYPE_CODE (result) == TYPE_CODE_PTR
+      /* If result's target type is TYPE_CODE_VOID, do not try fetching its rtti
+	 type.  GDB will try to dereference the void pointer and will throw an
+	 error when trying to do so.  */
+      if ((TYPE_CODE (result) == TYPE_CODE_PTR
 	  || TYPE_CODE (result) == TYPE_CODE_REF)
+	  && ((TYPE_TARGET_TYPE (result) != NULL)
+	      && TYPE_CODE (TYPE_TARGET_TYPE (result)) != TYPE_CODE_VOID))
         {
           struct type *real_type;
 

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

end of thread, other threads:[~2013-01-03 12:38 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10 20:05 [PATCH] Fix mi "-var-create" regression Luis Gustavo
2012-10-11 21:53 ` Sergio Durigan Junior
2012-10-11 22:10   ` Luis Machado
2012-10-17 17:29     ` Tom Tromey
2012-10-12 19:57 ` Marc Khouzam
2012-10-14 17:18 ` Joel Brobecker
2012-10-15 12:21   ` Luis Machado
2012-10-18  1:13     ` Tom Tromey
2012-10-19 13:14       ` Luis Machado
2012-10-28 22:44       ` Luis Machado
2012-10-30 20:36         ` Tom Tromey
2012-11-14 19:21           ` Luis Machado
2012-11-15 16:44             ` Marc Khouzam
2012-11-15 17:48               ` Joel Brobecker
2012-11-15 18:47                 ` Tom Tromey
2012-11-15 20:54                   ` Marc Khouzam
2012-11-15 21:13                     ` Tom Tromey
2012-11-15 23:28                     ` Luis Machado
2012-11-16  0:50                       ` Marc Khouzam
2012-11-16  2:10                         ` Luis Machado
2012-11-29 20:11         ` Andreas Schwab
2012-11-29 21:07           ` Joel Brobecker
2012-11-30  2:13             ` Luis Machado
2012-12-07  2:48               ` Joel Brobecker
2012-12-07  2:51                 ` Luis Machado
2012-12-26 12:31                   ` Luis Machado
2013-01-03  3:46                     ` Joel Brobecker
2013-01-03 12:30                       ` Luis Machado
2013-01-03 12:38                         ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox