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]

Re: embedded_offset missing in c-valprint.c


>>>>> "Emmanuel" == Emmanuel Thomà <Emmanuel.Thome@gmail.com> writes:

Emmanuel> Could you please consider the attached patch to c-valprint.c ?

Looks good to me.

I updated the existing pretty-printer test case with one based on the
info you provided.

Your patch is small enough not to need any paperwork, but if you plan to
do more work on gdb, I suggest getting started with that process.  If
you want I can send you the form.

Your patch was also missing a ChangeLog entry.

I'm checking in the appended to the trunk and the 7.2 branch.
Thanks!

I built and regtested this on x86-64 (compile farm).

Tom

2010-07-13  Emmanuel Thomà <Emmanuel.Thome@gmail.com>

	* c-valprint.c (c_val_print): Add embedded_offset to address in
	call to val_print_array_elements.

2010-07-13  Tom Tromey  <tromey@redhat.com>

	* gdb.python/py-prettyprint.c (struct arraystruct): New struct.
	(main): Use it.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Add test.

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 4e5a95f..f0895a4 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -222,7 +222,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		{
 		  i = 0;
 		}
-	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
+	      val_print_array_elements (type, valaddr + embedded_offset,
+					address + embedded_offset, stream,
 					recurse, original_value, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index f461bb1..66a9014 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -29,6 +29,12 @@ struct ss
   struct s b;
 };
 
+struct arraystruct
+{
+  int y;
+  struct s x[2];
+};
+
 struct ns {
   const char *null_str;
   int length;
@@ -199,6 +205,7 @@ main ()
 {
   struct ss  ss;
   struct ss  ssa[2];
+  struct arraystruct arraystruct;
   string x = make_string ("this is x");
   zzz_type c = make_container ("container");
   zzz_type c2 = make_container ("container2");
@@ -214,6 +221,10 @@ main ()
   init_ss(ssa+1, 5, 6);
   memset (&nullstr, 0, sizeof nullstr);
 
+  arraystruct.y = 7;
+  init_s (&arraystruct.x[0], 23);
+  init_s (&arraystruct.x[1], 24);
+
   struct ns  ns;
   ns.null_str = "embedded\0null\0string";
   ns.length = 20;
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index f435fb7..3b2aadd 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -76,6 +76,8 @@ proc run_lang_tests {lang} {
     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>>}"
     
+    gdb_test "print arraystruct" " = {$nl *y = 7, *$nl *x = { a=<23> b=<$hex>,  a=<24> b=<$hex>} *$nl *}"
+
     if {$lang == "c++"} {
 	gdb_test "print cps" "=  a=<8> b=<$hex>"
 	gdb_test "print cpss" " = {$nl *zss = 9, *$nl *s =  a=<10> b=<$hex>$nl}"


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