public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python: Prevent value_from_contents_and_address from double-counting
@ 2008-10-18  1:47 ppluzhnikov
  0 siblings, 0 replies; only message in thread
From: ppluzhnikov @ 2008-10-18  1:47 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  4c863e3015b0b821d34b5c63f7569ff196e4bb7a (commit)
      from  82117a32994afeaacb5e3a432dd195e83e82c501 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 4c863e3015b0b821d34b5c63f7569ff196e4bb7a
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Fri Oct 17 18:44:03 2008 -0700

    Prevent value_from_contents_and_address from double-counting
    embedded_offset.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                                   |    5 ++
 gdb/testsuite/ChangeLog                         |    6 ++
 gdb/testsuite/gdb.python/python-prettyprint.c   |   29 ++++++++++++
 gdb/testsuite/gdb.python/python-prettyprint.exp |   57 +++++++++++++++--------
 gdb/testsuite/gdb.python/python-prettyprint.py  |    4 ++
 gdb/value.c                                     |    2 +-
 6 files changed, 82 insertions(+), 21 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8b19db3..80691bb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2008-10-17  Paul Pluzhnikov  <ppluzhnikov@google.com>
 
+	* value.c (value_from_contents_and_address): Don't
+	double-count embedded_offset.
+	
+2008-10-17  Paul Pluzhnikov  <ppluzhnikov@google.com>
+
 	* valprint.c (val_print_array_elements): Pass correct
 	element address to val_print.
 	
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8d0cf42..1079648 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -2,6 +2,12 @@
 	
 	* gdb.python/python-prettyprint.exp,
 	gdb.python/python-prettyprint.c,
+	gdb.python/python-prettyprint.py: Add C++ tests.
+	
+2008-10-17  Paul Pluzhnikov  <ppluzhnikov@google.com>
+	
+	* gdb.python/python-prettyprint.exp,
+	gdb.python/python-prettyprint.c,
 	gdb.python/python-prettyprint.py: New test for pretty
 	printing.
 	
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
index 90883cf..152b786 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.c
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -27,6 +27,17 @@ struct ss
   struct s b;
 };
 
+#ifdef __cplusplus
+struct S : public s {
+  int zs;
+};
+
+struct SS {
+  int zss;
+  S s;
+};
+#endif
+
 void init_s(struct s *s, int a)
 {
   s->a = a;
@@ -48,5 +59,23 @@ main ()
   init_ss(&ss, 1, 2);
   init_ss(ssa+0, 3, 4);
   init_ss(ssa+1, 5, 6);
+
+#ifdef __cplusplus
+  S cps;
+
+  cps.zs = 7;
+  init_s(&cps, 8);
+
+  SS cpss;
+  cpss.zss = 9;
+  init_s(&cpss.s, 10);
+
+  SS cpssa[2];
+  cpssa[0].zss = 11;
+  init_s(&cpssa[0].s, 12);
+  cpssa[1].zss = 13;
+  init_s(&cpssa[1].s, 14);
+#endif
+
   return 0;      /* break to inspect struct and union */
 }
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.exp b/gdb/testsuite/gdb.python/python-prettyprint.exp
index c36289a..f494c0e 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/python-prettyprint.exp
@@ -23,19 +23,10 @@ if $tracelevel then {
 set testfile "python-prettyprint"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile ${srcfile}"
-    return -1
-}
-
 
 # Start with a fresh gdb.
-
 gdb_exit
 gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test_multiple "python print 'hello, world!'" "verify python support" {
     -re "not supported.*$gdb_prompt $"	{
       unsupported "python support is disabled"
@@ -44,17 +35,43 @@ gdb_test_multiple "python print 'hello, world!'" "verify python support" {
     -re "$gdb_prompt $"	{}
 }
 
-if ![runto_main ] then {
-    perror "couldn't run to breakpoint"
-    return
-}
+proc run_lang_tests {lang} {
+    global srcdir subdir srcfile binfile testfile hex
+    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug $lang"] != "" } {
+	untested "Couldn't compile ${srcfile} in $lang mode"
+	return -1
+    }
 
-gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
-	 ".*Breakpoint.*"
-gdb_test "continue" ".*Breakpoint.*"
+    # Start with a fresh gdb.
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load ${binfile}
 
-gdb_test "source ${srcdir}/${subdir}/${testfile}.py" ""
 
-gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
-gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
-gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
+    if ![runto_main ] then {
+	perror "couldn't run to breakpoint"
+	return
+    }
+
+    gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
+	".*Breakpoint.*"
+    gdb_test "continue" ".*Breakpoint.*"
+    
+    gdb_test "source ${srcdir}/${subdir}/${testfile}.py" ""
+    
+    gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
+    gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
+    gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
+    
+    if {$lang == "c++"} {
+	gdb_test "print cps" "=  a=<8> b=<$hex>"
+	gdb_test "print cpss" " = {zss = 9, s =  a=<10> b=<$hex>}"
+	gdb_test "print cpssa\[0\]" " = {zss = 11, s =  a=<12> b=<$hex>}"
+	gdb_test "print cpssa\[1\]" " = {zss = 13, s =  a=<14> b=<$hex>}"
+	gdb_test "print cpssa" " = {{zss = 11, s =  a=<12> b=<$hex>}, {zss = 13, s =  a=<14> b=<$hex>}}"
+    }
+}
+
+run_lang_tests "c"
+run_lang_tests "c++"
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py
index 42f79f6..c5b7201 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.py
+++ b/gdb/testsuite/gdb.python/python-prettyprint.py
@@ -29,4 +29,8 @@ def pp_ss(val):
   return "a=<" + str(val["a"]) + "> b=<" + str(val["b"]) + ">"
 
 gdb.cli_pretty_printers['^struct s$']   = pp_s
+gdb.cli_pretty_printers['^s$']   = pp_s
+gdb.cli_pretty_printers['^S$']   = pp_s
+
 gdb.cli_pretty_printers['^struct ss$']  = pp_ss
+gdb.cli_pretty_printers['^ss$']  = pp_ss
diff --git a/gdb/value.c b/gdb/value.c
index d900c5b..64db377 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1829,7 +1829,7 @@ value_from_contents_and_address (struct type *type, const gdb_byte *valaddr,
   else
     memcpy (value_contents_raw (result), valaddr + embedded_offset,
 	    TYPE_LENGTH (type));
-  set_value_address (result, address + embedded_offset);
+  set_value_address (result, address);
   if (address != 0)
     VALUE_LVAL (result) = lval_memory;
   return result;


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-18  1:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-18  1:47 [SCM] archer-tromey-python: Prevent value_from_contents_and_address from double-counting ppluzhnikov

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