aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-06-07 07:05:02 -0600
committerTom Tromey <tromey@adacore.com>2022-07-15 09:26:54 -0600
commit72be9d6be7de305b34ac298f1466167b9aba9bc2 (patch)
tree44543f544c27b7d0006baa6559e72e2d49f4eba0 /gdb/testsuite
parentc4a3dbaf1132105586586617a59d0e7566eefd41 (diff)
downloadgdb-72be9d6be7de305b34ac298f1466167b9aba9bc2.zip
gdb-72be9d6be7de305b34ac298f1466167b9aba9bc2.tar.gz
gdb-72be9d6be7de305b34ac298f1466167b9aba9bc2.tar.bz2
Add 'summary' mode to Value.format_string
This adds a 'summary' mode to Value.format_string and to gdb.print_options. For the former, it lets Python code format values using this mode. For the latter, it lets a printer potentially detect if it is being called in a backtrace with 'set print frame-arguments' set to 'scalars'. I considered adding a new mode here to let a pretty-printer see whether it was being called in a 'backtrace' context at all, but I'm not sure if this is really desirable.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.py2
2 files changed, 8 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 58bbe85..c432de9 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -1127,6 +1127,12 @@ proc test_print_options {} {
"print in binary to fetch options"
gdb_test "python print(saved_options\['format'\] == 't')" "True" \
"format was set"
+
+ check_format_string "a_point_t" "summary=True" \
+ "No Data" \
+ "print in summary mode"
+ gdb_test "python print(saved_options\['summary'\])" "True" \
+ "summary was set"
}
# Run all the tests in common for both C and C++.
diff --git a/gdb/testsuite/gdb.python/py-format-string.py b/gdb/testsuite/gdb.python/py-format-string.py
index aa7b104..b7e8346 100644
--- a/gdb/testsuite/gdb.python/py-format-string.py
+++ b/gdb/testsuite/gdb.python/py-format-string.py
@@ -28,6 +28,8 @@ class PointPrinter(object):
def to_string(self):
global saved_options
saved_options = gdb.print_options()
+ if saved_options["summary"]:
+ return "No Data"
return "Pretty Point (%s, %s)" % (self.val["x"], self.val["y"])