public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: 2008-10-17 Paul Pluzhnikov <ppluzhnikov@google.com>
@ 2008-10-17 20:30 ppluzhnikov
0 siblings, 0 replies; 2+ messages in thread
From: ppluzhnikov @ 2008-10-17 20:30 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via 9e52872c079e8d3c76f6f5aafed28a0300f28e42 (commit)
from 4d6117a23b69e43cb55641da7a91db00b1747fea (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 9e52872c079e8d3c76f6f5aafed28a0300f28e42
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date: Fri Oct 17 13:29:57 2008 -0700
2008-10-17 Paul Pluzhnikov <ppluzhnikov@google.com>
* valprint.c (val_print_array_elements): Pass correct
element address to val_print.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 5 +++++
gdb/valprint.c | 9 ++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0a27243..8b19db3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-17 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * valprint.c (val_print_array_elements): Pass correct
+ element address to val_print.
+
2008-10-17 Tom Tromey <tromey@redhat.com>
* value.h (value_address): Update comment.
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 45bfe33..f49e5ab 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1117,6 +1117,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
for (; i < len && things_printed < print_max; i++)
{
+ size_t elt_offset = i * eltlen;
if (i != 0)
{
if (prettyprint_arrays)
@@ -1136,7 +1137,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
rep1 = i + 1;
reps = 1;
while ((rep1 < len) &&
- !memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen))
+ !memcmp (valaddr + elt_offset, valaddr + rep1 * eltlen, eltlen))
{
++reps;
++rep1;
@@ -1144,7 +1145,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
if (reps > repeat_count_threshold)
{
- val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
+ val_print (elttype, valaddr + elt_offset, 0,
+ address + elt_offset, stream, format,
deref_ref, recurse + 1, pretty, current_language);
annotate_elt_rep (reps);
fprintf_filtered (stream, " <repeats %u times>", reps);
@@ -1155,7 +1157,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
}
else
{
- val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
+ val_print (elttype, valaddr + elt_offset, 0,
+ address + elt_offset, stream, format,
deref_ref, recurse + 1, pretty, current_language);
annotate_elt ();
things_printed++;
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [SCM] archer-tromey-python: 2008-10-17 Paul Pluzhnikov <ppluzhnikov@google.com>
@ 2008-10-17 20:52 ppluzhnikov
0 siblings, 0 replies; 2+ messages in thread
From: ppluzhnikov @ 2008-10-17 20:52 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via 82117a32994afeaacb5e3a432dd195e83e82c501 (commit)
from 9e52872c079e8d3c76f6f5aafed28a0300f28e42 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 82117a32994afeaacb5e3a432dd195e83e82c501
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date: Fri Oct 17 13:52:02 2008 -0700
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.
-----------------------------------------------------------------------
Summary of changes:
gdb/testsuite/ChangeLog | 7 +++
gdb/testsuite/gdb.python/python-prettyprint.c | 52 ++++++++++++++++++++
gdb/testsuite/gdb.python/python-prettyprint.exp | 60 +++++++++++++++++++++++
gdb/testsuite/gdb.python/python-prettyprint.py | 32 ++++++++++++
4 files changed, 151 insertions(+), 0 deletions(-)
create mode 100644 gdb/testsuite/gdb.python/python-prettyprint.c
create mode 100644 gdb/testsuite/gdb.python/python-prettyprint.exp
create mode 100644 gdb/testsuite/gdb.python/python-prettyprint.py
First 500 lines of diff:
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 0eeef68..8d0cf42 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2008-10-16 Tom Tromey <tromey@redhat.com>
* gdb.python/Makefile.in: New file.
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
new file mode 100644
index 0000000..90883cf
--- /dev/null
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -0,0 +1,52 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+struct s
+{
+ int a;
+ int *b;
+};
+
+struct ss
+{
+ struct s a;
+ struct s b;
+};
+
+void init_s(struct s *s, int a)
+{
+ s->a = a;
+ s->b = &s->a;
+}
+
+void init_ss(struct ss *s, int a, int b)
+{
+ init_s(&s->a, a);
+ init_s(&s->b, b);
+}
+
+int
+main ()
+{
+ struct ss ss;
+ struct ss ssa[2];
+
+ init_ss(&ss, 1, 2);
+ init_ss(ssa+0, 3, 4);
+ init_ss(ssa+1, 5, 6);
+ 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
new file mode 100644
index 0000000..c36289a
--- /dev/null
+++ b/gdb/testsuite/gdb.python/python-prettyprint.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests the mechanism
+# exposing values to Python.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+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"
+ return -1
+ }
+ -re "$gdb_prompt $" {}
+}
+
+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>>}"
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py
new file mode 100644
index 0000000..42f79f6
--- /dev/null
+++ b/gdb/testsuite/gdb.python/python-prettyprint.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests python pretty
+# printers.
+
+python
+
+def pp_s(val):
+ a = val["a"]
+ b = val["b"]
+ if a.address() != b:
+ raise Exception("&a(%s) != b(%s)" % (str(a.address()), str(b)))
+ return " a=<" + str(val["a"]) + "> b=<" + str(val["b"]) + ">"
+
+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['^struct ss$'] = pp_ss
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-17 20:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17 20:30 [SCM] archer-tromey-python: 2008-10-17 Paul Pluzhnikov <ppluzhnikov@google.com> ppluzhnikov
2008-10-17 20:52 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).