aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-05-18 15:31:42 +0000
committerTom Tromey <tromey@redhat.com>2012-05-18 15:31:42 +0000
commit9cb709b6ba0111234528d4ead138d5b54fed6095 (patch)
treea7f5ace4300361d3c46c18e28cf185fc50e8db98 /gdb
parentb012acddd87cb89dc4b357adf458511232c58bfe (diff)
downloadgdb-9cb709b6ba0111234528d4ead138d5b54fed6095.zip
gdb-9cb709b6ba0111234528d4ead138d5b54fed6095.tar.gz
gdb-9cb709b6ba0111234528d4ead138d5b54fed6095.tar.bz2
PR exp/13907:
* valprint.h (struct value_print_options) <symbol_print>: New field. * valprint.c (user_print_options): Add default for symbol_print. (show_symbol_print): New function. (generic_val_print): Respect symbol_print. (_initialize_valprint): Add "print symbol" setting. * f-valprint.c (f_val_print): Respect symbol_print. * c-valprint.c (c_val_print): Respect symbol_print. * NEWS: Update. * printcmd.c (print_address_symbolic): Return int. Ignore some zero-size symbols. (print_address_demangle): Return int. * defs.h: (print_address_symbolic): Return int. * value.h (print_address_demangle): Return int. doc * gdb.texinfo (Print Settings): Document 'set print symbol'. testsuite * gdb.mi/mi-var-cmd.exp: Update. * gdb.objc/basicclass.exp (do_objc_tests): Update. * gdb.cp/virtbase.exp: Update. * gdb.cp/classes.exp (test_static_members): Update. * gdb.cp/casts.exp: Update. * gdb.base/pointers.exp: Update. * gdb.base/funcargs.exp (pointer_args): Update. (structs_by_reference): Update. * gdb.base/find.exp: Update. * gdb.base/call-strs.exp: Send "set print symbol off". * gdb.base/call-ar-st.exp: Update. * gdb.ada/fun_addr.exp: Update. * gdb.base/printcmds.exp (test_print_symbol): New proc. Call it. (test_print_repeats_10, test_print_strings) (test_print_char_arrays): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/NEWS6
-rw-r--r--gdb/c-valprint.c9
-rw-r--r--gdb/defs.h4
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo18
-rw-r--r--gdb/f-valprint.c5
-rw-r--r--gdb/p-valprint.c4
-rw-r--r--gdb/printcmd.c23
-rw-r--r--gdb/testsuite/ChangeLog19
-rw-r--r--gdb/testsuite/gdb.ada/fun_addr.exp2
-rw-r--r--gdb/testsuite/gdb.base/call-ar-st.exp2
-rw-r--r--gdb/testsuite/gdb.base/call-strs.exp1
-rw-r--r--gdb/testsuite/gdb.base/find.exp2
-rw-r--r--gdb/testsuite/gdb.base/funcargs.exp10
-rw-r--r--gdb/testsuite/gdb.base/pointers.exp2
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp97
-rw-r--r--gdb/testsuite/gdb.cp/casts.exp4
-rw-r--r--gdb/testsuite/gdb.cp/classes.exp4
-rw-r--r--gdb/testsuite/gdb.cp/virtbase.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cmd.exp6
-rw-r--r--gdb/testsuite/gdb.objc/basicclass.exp2
-rw-r--r--gdb/valprint.c25
-rw-r--r--gdb/valprint.h4
-rw-r--r--gdb/value.h6
25 files changed, 201 insertions, 80 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3793661..865b5bf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,23 @@
2012-05-18 Tom Tromey <tromey@redhat.com>
+ PR exp/13907:
+ * valprint.h (struct value_print_options) <symbol_print>: New
+ field.
+ * valprint.c (user_print_options): Add default for symbol_print.
+ (show_symbol_print): New function.
+ (generic_val_print): Respect symbol_print.
+ (_initialize_valprint): Add "print symbol" setting.
+ * f-valprint.c (f_val_print): Respect symbol_print.
+ * c-valprint.c (c_val_print): Respect symbol_print.
+ * NEWS: Update.
+ * printcmd.c (print_address_symbolic): Return int. Ignore some
+ zero-size symbols.
+ (print_address_demangle): Return int.
+ * defs.h: (print_address_symbolic): Return int.
+ * value.h (print_address_demangle): Return int.
+
+2012-05-18 Tom Tromey <tromey@redhat.com>
+
* valprint.c (val_print_string): Don't print leading space.
* p-valprint.c (pascal_val_print) <TYPE_CODE_PTR>: Optionally
print space before string or vtbl.
diff --git a/gdb/NEWS b/gdb/NEWS
index b2e63b3..47b356a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -147,6 +147,12 @@
resumes your program's execution, so it is like a printf that you
can insert dynamically at runtime instead of at compiletime.
+ ** "set print symbol"
+ "show print symbol"
+ Controls whether GDB attempts to display the symbol, if any,
+ corresponding to addresses it prints. This defaults to "on", but
+ you can set it to "off" to restore GDB's previous behavior.
+
* New targets
Renesas RL78 rl78-*-elf
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 9411890..8b05f8f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -268,7 +268,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
return;
}
- if (options->addressprint)
+ if (options->symbol_print)
+ want_space = print_address_demangle (options, gdbarch, addr,
+ stream, demangle);
+ else if (options->addressprint)
{
fputs_filtered (paddress (gdbarch, addr), stream);
want_space = 1;
@@ -296,7 +299,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
struct minimal_symbol *msymbol =
lookup_minimal_symbol_by_pc (vt_address);
- if ((msymbol != NULL)
+ /* If 'symbol_print' is set, we did the work above. */
+ if (!options->symbol_print
+ && (msymbol != NULL)
&& (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
{
if (want_space)
diff --git a/gdb/defs.h b/gdb/defs.h
index 004f335..229ad1b 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -583,8 +583,8 @@ extern int info_verbose;
extern void set_next_address (struct gdbarch *, CORE_ADDR);
-extern void print_address_symbolic (struct gdbarch *, CORE_ADDR,
- struct ui_file *, int, char *);
+extern int print_address_symbolic (struct gdbarch *, CORE_ADDR,
+ struct ui_file *, int, char *);
extern int build_address_symbolic (struct gdbarch *,
CORE_ADDR addr,
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 4ee5c63..0ebe882 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-18 Tom Tromey <tromey@redhat.com>
+
+ * gdb.texinfo (Print Settings): Document 'set print symbol'.
+
2012-05-14 Stan Shebs <stan@codesourcery.com>
* gdb.texinfo (Dynamic Printf): New subsection.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7bfb964..b904f9b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -8435,6 +8435,24 @@ does not show the symbol name and filename of the referent, even with
the appropriate @code{set print} options turned on.
@end quotation
+You can also enable @samp{/a}-like formatting all the time using
+@samp{set print symbol on}:
+
+@table @code
+@item set print symbol on
+Tell @value{GDBN} to print the symbol corresponding to an address, if
+one exists.
+
+@item set print symbol off
+Tell @value{GDBN} not to print the symbol corresponding to an
+address. In this mode, @value{GDBN} will still print the symbol
+corresponding to pointers to functions. This is the default.
+
+@item show print symbol
+Show whether @value{GDBN} will display the symbol corresponding to an
+address.
+@end table
+
Other settings control how different kinds of objects are printed:
@table @code
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 229bfe3..dc81383 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -322,7 +322,10 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
return;
}
- if (options->addressprint && options->format != 's')
+ if (options->symbol_print)
+ want_space = print_address_demangle (options, gdbarch, addr,
+ stream, demangle);
+ else if (options->addressprint && options->format != 's')
{
fputs_filtered (paddress (gdbarch, addr), stream);
want_space = 1;
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index be28f93..77d9721 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -226,7 +226,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct minimal_symbol *msymbol =
lookup_minimal_symbol_by_pc (vt_address);
- if ((msymbol != NULL)
+ /* If 'symbol_print' is set, we did the work above. */
+ if (!options->symbol_print
+ && (msymbol != NULL)
&& (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
{
if (want_space)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 523fad2..3c2d28c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -568,9 +568,10 @@ set_next_address (struct gdbarch *gdbarch, CORE_ADDR addr)
DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
or to interpret it as a possible C++ name and convert it back to source
form. However note that DO_DEMANGLE can be overridden by the specific
- settings of the demangle and asm_demangle variables. */
+ settings of the demangle and asm_demangle variables. Returns
+ non-zero if anything was printed; zero otherwise. */
-void
+int
print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
struct ui_file *stream,
int do_demangle, char *leadin)
@@ -589,7 +590,7 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
&filename, &line, &unmapped))
{
do_cleanups (cleanup_chain);
- return;
+ return 0;
}
fputs_filtered (leadin, stream);
@@ -616,6 +617,7 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
fputs_filtered (">", stream);
do_cleanups (cleanup_chain);
+ return 1;
}
/* Given an address ADDR return all the elements needed to print the
@@ -683,6 +685,13 @@ build_address_symbolic (struct gdbarch *gdbarch,
name_temp = SYMBOL_LINKAGE_NAME (symbol);
}
+ if (msymbol != NULL
+ && MSYMBOL_SIZE (msymbol) == 0
+ && MSYMBOL_TYPE (msymbol) != mst_text
+ && MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc
+ && MSYMBOL_TYPE (msymbol) != mst_file_text)
+ msymbol = NULL;
+
if (msymbol != NULL)
{
if (SYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL)
@@ -763,10 +772,9 @@ pc_prefix (CORE_ADDR addr)
/* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
controls whether to print the symbolic name "raw" or demangled.
- Global setting "addressprint" controls whether to print hex address
- or not. */
+ Return non-zero if anything was printed; zero otherwise. */
-void
+int
print_address_demangle (const struct value_print_options *opts,
struct gdbarch *gdbarch, CORE_ADDR addr,
struct ui_file *stream, int do_demangle)
@@ -778,8 +786,9 @@ print_address_demangle (const struct value_print_options *opts,
}
else
{
- print_address_symbolic (gdbarch, addr, stream, do_demangle, "");
+ return print_address_symbolic (gdbarch, addr, stream, do_demangle, "");
}
+ return 1;
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9ef5587..bc92a84 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,24 @@
2012-05-18 Tom Tromey <tromey@redhat.com>
+ * gdb.mi/mi-var-cmd.exp: Update.
+ * gdb.objc/basicclass.exp (do_objc_tests): Update.
+ * gdb.cp/virtbase.exp: Update.
+ * gdb.cp/classes.exp (test_static_members): Update.
+ * gdb.cp/casts.exp: Update.
+ * gdb.base/pointers.exp: Update.
+ * gdb.base/funcargs.exp (pointer_args): Update.
+ (structs_by_reference): Update.
+ * gdb.base/find.exp: Update.
+ * gdb.base/call-strs.exp: Send "set print symbol off".
+ * gdb.base/call-ar-st.exp: Update.
+ * gdb.ada/fun_addr.exp: Update.
+ * gdb.base/printcmds.exp (test_print_symbol): New proc.
+ Call it.
+ (test_print_repeats_10, test_print_strings)
+ (test_print_char_arrays): Update.
+
+2012-05-18 Tom Tromey <tromey@redhat.com>
+
* gdb.base/charset.exp (string_display): Update.
2012-05-18 Tom Tromey <tromey@redhat.com>
diff --git a/gdb/testsuite/gdb.ada/fun_addr.exp b/gdb/testsuite/gdb.ada/fun_addr.exp
index 6dabf34..9924995 100644
--- a/gdb/testsuite/gdb.ada/fun_addr.exp
+++ b/gdb/testsuite/gdb.ada/fun_addr.exp
@@ -31,7 +31,7 @@ clean_restart ${testfile}
# the inferior is *not* running (no frame).
gdb_test "print foo'address" \
- "= .* 0x\[0-9a-zA-Z\]+" \
+ "= .* 0x\[0-9a-zA-Z\]+ <foo>" \
"print foo'address"
diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp
index 50ca37c..81501c2 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -161,7 +161,7 @@ if {![gdb_skip_float_test "continuing to breakpoint 1220"] && \
#step
gdb_test "step" \
- "print_all_arrays \\(array_i=, array_c=.ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*call-ar-st.c:306\[ \t\r\n\]+306.*print_int_array\\(array_i\\);.*" \
+ "print_all_arrays \\(array_i=<integer_array.*>, array_c=<char_array.*> .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=<float_array.*>, array_d=<double_array.*>\\) at .*call-ar-st.c:306\[ \t\r\n\]+306.*print_int_array\\(array_i\\);.*" \
"step inside print_all_arrays"
#step -over
diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp
index 43d7ef6..7c5c46e 100644
--- a/gdb/testsuite/gdb.base/call-strs.exp
+++ b/gdb/testsuite/gdb.base/call-strs.exp
@@ -56,6 +56,7 @@ gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
+gdb_test_no_output "set print symbol off"
gdb_test_no_output "set width 0"
if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp
index 664481c..ad54d65 100644
--- a/gdb/testsuite/gdb.base/find.exp
+++ b/gdb/testsuite/gdb.base/find.exp
@@ -83,7 +83,7 @@ gdb_test "find /1 &int8_search_buf\[0\], +sizeof(int8_search_buf), 'a', 'a', 'a'
"max-count"
gdb_test "print \$_" \
- "${history_prefix}.*${hex_number}" \
+ "${history_prefix}.*${hex_number} <int8_search_buf\\+10>" \
"\$_"
gdb_test "print \$numfound" \
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 8998caa..edc14e8 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -332,7 +332,7 @@ proc pointer_args {} {
gdb_run_cmd
gdb_expect {
- -re ".* call3a \\(cp=$hex \"a.*\", sp=$hex, ip=$hex, lp=$hex\\) .*$gdb_prompt $" { pass "run to call3a" }
+ -re ".* call3a \\(cp=$hex <c> \"a.*\", sp=$hex <s>, ip=$hex <i>, lp=$hex <l>\\) .*$gdb_prompt $" { pass "run to call3a" }
-re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; }
timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; }
}
@@ -344,7 +344,7 @@ proc pointer_args {} {
# Continue; should stop at call3b and print actual arguments.
# Try dereferencing the arguments.
- if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b.*\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
+ if [gdb_test "cont" ".* call3b \\(ucp=$hex <uc> \"b.*\", usp=$hex <us>, uip=$hex <ui>, ulp=$hex <ul>\\) .*" "continue to call3b"] {
gdb_suppress_tests;
}
@@ -355,7 +355,7 @@ proc pointer_args {} {
# Continue; should stop at call3c and print actual arguments.
# Try dereferencing the arguments.
- if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
+ if [gdb_test "cont" ".* call3c \\(fp=$hex <f>, dp=$hex <d>\\) .*" "continue to call3c"] {
gdb_suppress_tests;
}
@@ -388,7 +388,7 @@ proc structs_by_reference {} {
gdb_run_cmd
gdb_expect {
- -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
+ -re ".* call4a \\(stp=$hex <st>\\) .*$gdb_prompt $" {
pass "run to call4a"
}
-re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; }
@@ -399,7 +399,7 @@ proc structs_by_reference {} {
# Continue; should stop at call4b and print actual arguments.
- gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
+ gdb_test "cont" ".* call4b \\(unp=$hex <un>\\) .*" "continue to call4b"
# Try dereferencing the arguments.
if { $target_sizeof_long == $target_sizeof_int } {
diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp
index bd29581..1090134 100644
--- a/gdb/testsuite/gdb.base/pointers.exp
+++ b/gdb/testsuite/gdb.base/pointers.exp
@@ -281,4 +281,4 @@ gdb_test "ptype ppppppC" "type = char \\*\\*\\*\\*\\*\\*" "ptype ppppppC"
# Regression test for a crash.
gdb_test "p instance.array_variable + 0" \
- " = \\(long (int )?\\*\\) 0x\[0-9a-f\]*"
+ " = \\(long (int )?\\*\\) 0x\[0-9a-f\]* <instance>"
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 08a54b0..0f35ba8 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -422,7 +422,7 @@ proc test_print_all_chars {} {
# repeat count, set to the default of 10.
proc test_print_repeats_10 {} {
- global gdb_prompt
+ global gdb_prompt decimal
for { set x 1; } { $x <= 16 } { incr x; } {
gdb_test_no_output "set print elements $x"
@@ -464,7 +464,7 @@ proc test_print_repeats_10 {} {
if { $aval < 16 } {
set xstr "${xstr}\[.\]\[.\]\[.\]"
}
- set string " = \[(\]unsigned char \[*\]\[)\] ${a}${xstr}";
+ set string " = \[(\]unsigned char \[*\]\[)\] <ctable2(\\+$decimal)?> ${a}${xstr}";
gdb_test "$command" "$string" "$command with print elements set to $x";
}
}
@@ -483,7 +483,7 @@ proc test_print_repeats_embedded_array {} {
}
proc test_print_strings {} {
- global gdb_prompt
+ global gdb_prompt decimal
# We accept "(unsigned char *) " before the string. char vs. unsigned char
# is already tested elsewhere.
@@ -509,71 +509,71 @@ proc test_print_strings {} {
gdb_test_no_output "set print elements 8"
gdb_test "p &ctable1\[0\]" \
- " = \\(unsigned char \\*\\) \"\""
+ " = \\(unsigned char \\*\\) <ctable1> \"\""
gdb_test "p &ctable1\[1\]" \
- " = \\(unsigned char \\*\\) \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..."
gdb_test "p &ctable1\[1*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..."
gdb_test "p &ctable1\[2*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..."
gdb_test "p &ctable1\[3*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..."
gdb_test "p &ctable1\[4*8\]" \
- " = \\(unsigned char \\*\\) \" !\\\\\"#\\\$%&'\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \" !\\\\\"#\\\$%&'\"..."
gdb_test "p &ctable1\[5*8\]" \
- " = \\(unsigned char \\*\\) \"\\(\\)\\*\\+,-./\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\(\\)\\*\\+,-./\"..."
gdb_test "p &ctable1\[6*8\]" \
- " = \\(unsigned char \\*\\) \"01234567\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"01234567\"..."
gdb_test "p &ctable1\[7*8\]" \
- " = \\(unsigned char \\*\\) \"89:;<=>\\?\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"89:;<=>\\?\"..."
gdb_test "p &ctable1\[8*8\]" \
- " = \\(unsigned char \\*\\) \"@ABCDEFG\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"@ABCDEFG\"..."
gdb_test "p &ctable1\[9*8\]" \
- " = \\(unsigned char \\*\\) \"HIJKLMNO\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"HIJKLMNO\"..."
gdb_test "p &ctable1\[10*8\]" \
- " = \\(unsigned char \\*\\) \"PQRSTUVW\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"PQRSTUVW\"..."
gdb_test "p &ctable1\[11*8\]" \
- " = \\(unsigned char \\*\\) \"XYZ\\\[\\\\\\\\\\\]\\^_\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"XYZ\\\[\\\\\\\\\\\]\\^_\"..."
gdb_test "p &ctable1\[12*8\]" \
- " = \\(unsigned char \\*\\) \"`abcdefg\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"`abcdefg\"..."
gdb_test "p &ctable1\[13*8\]" \
- " = \\(unsigned char \\*\\) \"hijklmno\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"hijklmno\"..."
gdb_test "p &ctable1\[14*8\]" \
- " = \\(unsigned char \\*\\) \"pqrstuvw\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"pqrstuvw\"..."
gdb_test "p &ctable1\[15*8\]" \
- " = \\(unsigned char \\*\\) \"xyz\[{|}\]+\\~\\\\177\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"xyz\[{|}\]+\\~\\\\177\"..."
gdb_test "p &ctable1\[16*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\200\\\\201\\\\202\\\\203\\\\204\\\\205\\\\206\\\\207\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\200\\\\201\\\\202\\\\203\\\\204\\\\205\\\\206\\\\207\"..."
gdb_test "p &ctable1\[17*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\210\\\\211\\\\212\\\\213\\\\214\\\\215\\\\216\\\\217\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\210\\\\211\\\\212\\\\213\\\\214\\\\215\\\\216\\\\217\"..."
gdb_test "p &ctable1\[18*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\220\\\\221\\\\222\\\\223\\\\224\\\\225\\\\226\\\\227\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\220\\\\221\\\\222\\\\223\\\\224\\\\225\\\\226\\\\227\"..."
gdb_test "p &ctable1\[19*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\230\\\\231\\\\232\\\\233\\\\234\\\\235\\\\236\\\\237\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\230\\\\231\\\\232\\\\233\\\\234\\\\235\\\\236\\\\237\"..."
gdb_test "p &ctable1\[20*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\240\\\\241\\\\242\\\\243\\\\244\\\\245\\\\246\\\\247\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\240\\\\241\\\\242\\\\243\\\\244\\\\245\\\\246\\\\247\"..."
gdb_test "p &ctable1\[21*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\250\\\\251\\\\252\\\\253\\\\254\\\\255\\\\256\\\\257\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\250\\\\251\\\\252\\\\253\\\\254\\\\255\\\\256\\\\257\"..."
gdb_test "p &ctable1\[22*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\260\\\\261\\\\262\\\\263\\\\264\\\\265\\\\266\\\\267\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\260\\\\261\\\\262\\\\263\\\\264\\\\265\\\\266\\\\267\"..."
gdb_test "p &ctable1\[23*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\270\\\\271\\\\272\\\\273\\\\274\\\\275\\\\276\\\\277\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\270\\\\271\\\\272\\\\273\\\\274\\\\275\\\\276\\\\277\"..."
gdb_test "p &ctable1\[24*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\300\\\\301\\\\302\\\\303\\\\304\\\\305\\\\306\\\\307\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\300\\\\301\\\\302\\\\303\\\\304\\\\305\\\\306\\\\307\"..."
gdb_test "p &ctable1\[25*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\310\\\\311\\\\312\\\\313\\\\314\\\\315\\\\316\\\\317\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\310\\\\311\\\\312\\\\313\\\\314\\\\315\\\\316\\\\317\"..."
gdb_test "p &ctable1\[26*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\320\\\\321\\\\322\\\\323\\\\324\\\\325\\\\326\\\\327\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\320\\\\321\\\\322\\\\323\\\\324\\\\325\\\\326\\\\327\"..."
gdb_test "p &ctable1\[27*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\330\\\\331\\\\332\\\\333\\\\334\\\\335\\\\336\\\\337\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\330\\\\331\\\\332\\\\333\\\\334\\\\335\\\\336\\\\337\"..."
gdb_test "p &ctable1\[28*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\340\\\\341\\\\342\\\\343\\\\344\\\\345\\\\346\\\\347\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\340\\\\341\\\\342\\\\343\\\\344\\\\345\\\\346\\\\347\"..."
gdb_test "p &ctable1\[29*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\350\\\\351\\\\352\\\\353\\\\354\\\\355\\\\356\\\\357\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\350\\\\351\\\\352\\\\353\\\\354\\\\355\\\\356\\\\357\"..."
gdb_test "p &ctable1\[30*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\360\\\\361\\\\362\\\\363\\\\364\\\\365\\\\366\\\\367\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\360\\\\361\\\\362\\\\363\\\\364\\\\365\\\\366\\\\367\"..."
gdb_test "p &ctable1\[31*8\]" \
- " = \\(unsigned char \\*\\) \"\\\\370\\\\371\\\\372\\\\373\\\\374\\\\375\\\\376\\\\377\"..."
+ " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\370\\\\371\\\\372\\\\373\\\\374\\\\375\\\\376\\\\377\"..."
}
proc test_print_int_arrays {} {
@@ -624,7 +624,7 @@ proc test_artificial_arrays {} {
proc test_print_char_arrays {} {
global gdb_prompt
- global hex
+ global hex decimal
gdb_test_no_output "set print elements 24"
gdb_test_no_output "set print address on"
@@ -632,17 +632,17 @@ proc test_print_char_arrays {} {
gdb_test "p arrays" \
" = {array1 = \"abc\", array2 = \"d\", array3 = \"e\", array4 = \"fg\", array5 = \"hij\"}"
- gdb_test "p parrays" " = \\(struct some_arrays \\*\\) $hex"
+ gdb_test "p parrays" " = \\(struct some_arrays \\*\\) $hex <arrays>"
gdb_test "p parrays->array1" " = \"abc\""
- gdb_test "p &parrays->array1" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"
+ gdb_test "p &parrays->array1" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex <arrays>"
gdb_test "p parrays->array2" " = \"d\""
- gdb_test "p &parrays->array2" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"
+ gdb_test "p &parrays->array2" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex <arrays\\+$decimal>"
gdb_test "p parrays->array3" " = \"e\""
- gdb_test "p &parrays->array3" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"
+ gdb_test "p &parrays->array3" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex <arrays\\+$decimal>"
gdb_test "p parrays->array4" " = \"fg\""
- gdb_test "p &parrays->array4" " = \\(unsigned char \\(\\*\\)\\\[2\\\]\\) $hex"
+ gdb_test "p &parrays->array4" " = \\(unsigned char \\(\\*\\)\\\[2\\\]\\) $hex <arrays\\+$decimal>"
gdb_test "p parrays->array5" " = \"hij\""
- gdb_test "p &parrays->array5" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"
+ gdb_test "p &parrays->array5" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex <arrays\\+$decimal>"
gdb_test_no_output "set print address off"
}
@@ -773,6 +773,16 @@ proc test_printf_with_dfp {} {
gdb_test "printf \"%DDf\\n\",1.2E6144dl" "1.200000000000000000000000000000000E\\+6144"
}
+proc test_print_symbol {} {
+ gdb_test_no_output "set print symbol on"
+
+ gdb_test "print &three" " = .* <three>"
+ gdb_test "print parrays" " = .* <arrays>"
+
+ # In case somebody adds tests after this.
+ gdb_test_no_output "set print symbol off"
+}
+
# Escape a left curly brace to prevent it from being interpreted as
# the beginning of a bound
proc gdb_test_escape_braces { args } {
@@ -840,3 +850,4 @@ test_print_array_constants
test_print_enums
test_printf
test_printf_with_dfp
+test_print_symbol
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index 7272a29..ee499d7 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -141,7 +141,7 @@ gdb_test "print dynamic_cast<Alpha &> (derived)" \
"dynamic_cast simple upcast to reference"
gdb_test "print dynamic_cast<Derived *> (ad)" \
- " = \\(Derived \\*\\) $nonzero_hex" \
+ " = \\(Derived \\*\\) ${nonzero_hex}( <vtable for Derived.*>)?" \
"dynamic_cast simple downcast"
gdb_test "print dynamic_cast<VirtuallyDerived *> (add)" \
@@ -157,7 +157,7 @@ gdb_test "print dynamic_cast<VirtuallyDerived &> (*ad)" \
"dynamic_cast to reference to non-existing base"
gdb_test "print dynamic_cast<DoublyDerived *> (add)" \
- " = \\(DoublyDerived \\*\\) $nonzero_hex" \
+ " = \\(DoublyDerived \\*\\) ${nonzero_hex}( <vtable for DoublyDerived.*>)?" \
"dynamic_cast unique downcast"
gdb_test "print dynamic_cast<Gamma *> (add)" \
diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index ae43630..36304b4 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -519,8 +519,8 @@ proc test_static_members {} {
gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
gdb_test_no_output "set foo.st = 200" ""
gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
- gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
- gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
+ gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex <Foo::st>"
+ gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex <Foo::st>"
gdb_test "print *\$" "\\$\[0-9\]+ = 200"
gdb_test_no_output "set print static-members off"
diff --git a/gdb/testsuite/gdb.cp/virtbase.exp b/gdb/testsuite/gdb.cp/virtbase.exp
index 6bc0076..939830f 100644
--- a/gdb/testsuite/gdb.cp/virtbase.exp
+++ b/gdb/testsuite/gdb.cp/virtbase.exp
@@ -72,10 +72,10 @@ gdb_test "print rtti_data" " = .*, data = 1\}"
# value history to check the pointer value is not changed. If it had
# been changed, then we'd not be able to find the real type anymore.
gdb_test "print virtual_middle_b" \
- " = \\(Virtual \\*\\) $hex" \
+ " = \\(Virtual \\*\\) $hex <virtual_o>" \
"print pointer to virtual base at non-zero offset of larger object"
gdb_test "print $" \
- " = \\(Virtual \\*\\) $hex" \
+ " = \\(Virtual \\*\\) $hex <virtual_o>" \
"print same pointer from history value"
gdb_test "print *$$" \
" = \\(Virtual\\) {<VirtualMiddleA> = {<VirtualBase> = {_vptr.VirtualBase = ${hex}( <vtable for Virtual.*>)?, x = 0}, _vptr.VirtualMiddleA = ${hex}( <vtable for Virtual.*>)?, y = \\{0 <repeats 300 times>\\}}, <VirtualMiddleB> = {_vptr.VirtualMiddleB = ${hex}( <vtable for Virtual.*>)?, y = 0}, _vptr.Virtual = ${hex}( <vtable for Virtual.*>)?, z = 0}" \
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index f3ee77a..cadff9f 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -377,11 +377,11 @@ mi_gdb_test "-var-update *" \
"assign same value to func (update)"
mi_gdb_test "-var-create array_ptr * array_ptr" \
- "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\",has_more=\"0\"" \
+ "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex <array>\",type=\"int \\*\",has_more=\"0\"" \
"create global variable array_ptr"
mi_gdb_test "-var-assign array_ptr array2" \
- "\\^done,value=\"$hex\"" \
+ "\\^done,value=\"$hex <array2>\"" \
"assign array to pointer"
mi_gdb_test "-var-update *" \
@@ -389,7 +389,7 @@ mi_gdb_test "-var-update *" \
"assign array to pointer (update)"
mi_gdb_test "-var-assign array_ptr array2" \
- "\\^done,value=\"$hex\"" \
+ "\\^done,value=\"$hex <array2>\"" \
"assign same array to pointer"
mi_gdb_test "-var-update *" \
diff --git a/gdb/testsuite/gdb.objc/basicclass.exp b/gdb/testsuite/gdb.objc/basicclass.exp
index c1892ca..6ebffb0 100644
--- a/gdb/testsuite/gdb.objc/basicclass.exp
+++ b/gdb/testsuite/gdb.objc/basicclass.exp
@@ -148,7 +148,7 @@ gdb_test "print self" \
" print self"
gdb_test "print \*self" \
- "\\$\[0-9\] = \{{?isa = 0x\[0-9a-f\]+}?, object = 0x0\}" \
+ "\\$\[0-9\] = \{{?isa = 0x\[0-9a-f\]+( <.*>)?}?, object = 0x0\}" \
" print contents of self"
#
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 6742fc1..1384396 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -85,7 +85,8 @@ struct value_print_options user_print_options =
1, /* static_field_print */
1, /* pascal_static_field_print */
0, /* raw */
- 0 /* summary */
+ 0, /* summary */
+ 1 /* symbol_print */
};
/* Initialize *OPTS to be a copy of the user print options. */
@@ -219,6 +220,16 @@ show_addressprint (struct ui_file *file, int from_tty,
{
fprintf_filtered (file, _("Printing of addresses is %s.\n"), value);
}
+
+static void
+show_symbol_print (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file,
+ _("Printing of symbols when printing pointers is %s.\n"),
+ value);
+}
+
/* A helper function for val_print. When printing in "summary" mode,
@@ -388,7 +399,9 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
return;
}
- if (options->addressprint)
+ if (options->symbol_print)
+ print_address_demangle (options, gdbarch, addr, stream, demangle);
+ else if (options->addressprint)
fputs_filtered (paddress (gdbarch, addr), stream);
}
break;
@@ -2600,6 +2613,14 @@ Show printing of addresses."), NULL,
show_addressprint,
&setprintlist, &showprintlist);
+ add_setshow_boolean_cmd ("symbol", class_support,
+ &user_print_options.symbol_print, _("\
+Set printing of symbol names when printing pointers."), _("\
+Show printing of symbol names when printing pointers."),
+ NULL, NULL,
+ show_symbol_print,
+ &setprintlist, &showprintlist);
+
add_setshow_zuinteger_cmd ("input-radix", class_support, &input_radix_1,
_("\
Set default input radix for entering numbers."), _("\
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 817e5cd..b853b1a 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -90,6 +90,10 @@ struct value_print_options
/* If nonzero, print the value in "summary" form. */
int summary;
+
+ /* If nonzero, when printing a pointer, print the symbol to which it
+ points, if any. */
+ int symbol_print;
};
/* The global print options set by the user. In general this should
diff --git a/gdb/value.h b/gdb/value.h
index 6e5066c..25013d8 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -491,9 +491,9 @@ extern void read_value_memory (struct value *val, int embedded_offset,
struct frame_info;
struct fn_field;
-extern void print_address_demangle (const struct value_print_options *,
- struct gdbarch *, CORE_ADDR,
- struct ui_file *, int);
+extern int print_address_demangle (const struct value_print_options *,
+ struct gdbarch *, CORE_ADDR,
+ struct ui_file *, int);
extern LONGEST value_as_long (struct value *val);
extern DOUBLEST value_as_double (struct value *val);