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]

[3/5] make value_primitive_field respect virtual bases


I'm checking this one in.

value_primitive_field doesn't do the right thing for virtual base
classes.  I didn't see any reason it should be this way, though, so this
patch changes it to do the right thing.

This code should work in all cases since concrete base classes are
handled in the obvious way by cp-abi implementations.
(And, I neglected to mention, this series was built and regtested on
x86-64 Fedora 16.)

Tom

>From 6879db0d57471de89c5c8b4a2c61212f56bc7a71 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Mon, 27 Feb 2012 11:56:10 -0700
Subject: [PATCH 3/5] 	* value.c (value_primitive_field): Handle
 virtual base classes.

---
 gdb/value.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/value.c b/gdb/value.c
index 85ea970..68e5f02 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -41,6 +41,7 @@
 #include "python/python.h"
 #include <ctype.h>
 #include "tracepoint.h"
+#include "cp-abi.h"
 
 /* Prototypes for exported functions.  */
 
@@ -2549,11 +2550,18 @@ value_primitive_field (struct value *arg1, int offset,
       /* This field is actually a base subobject, so preserve the
 	 entire object's contents for later references to virtual
 	 bases, etc.  */
+      int boffset;
 
       /* Lazy register values with offsets are not supported.  */
       if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
 	value_fetch_lazy (arg1);
 
+      boffset = baseclass_offset (arg_type, fieldno,
+				  value_contents (arg1),
+				  value_embedded_offset (arg1),
+				  value_address (arg1),
+				  arg1);
+
       if (value_lazy (arg1))
 	v = allocate_value_lazy (value_enclosing_type (arg1));
       else
@@ -2564,8 +2572,7 @@ value_primitive_field (struct value *arg1, int offset,
 	}
       v->type = type;
       v->offset = value_offset (arg1);
-      v->embedded_offset = (offset + value_embedded_offset (arg1)
-			    + TYPE_FIELD_BITPOS (arg_type, fieldno) / 8);
+      v->embedded_offset = offset + value_embedded_offset (arg1) + boffset;
     }
   else
     {
-- 
1.7.7.6


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