PR exp/13907:
authorTom Tromey <tromey@redhat.com>
Fri, 18 May 2012 15:31:42 +0000 (15:31 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 18 May 2012 15:31:42 +0000 (15:31 +0000)
* 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.

25 files changed:
gdb/ChangeLog
gdb/NEWS
gdb/c-valprint.c
gdb/defs.h
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/f-valprint.c
gdb/p-valprint.c
gdb/printcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/fun_addr.exp
gdb/testsuite/gdb.base/call-ar-st.exp
gdb/testsuite/gdb.base/call-strs.exp
gdb/testsuite/gdb.base/find.exp
gdb/testsuite/gdb.base/funcargs.exp
gdb/testsuite/gdb.base/pointers.exp
gdb/testsuite/gdb.base/printcmds.exp
gdb/testsuite/gdb.cp/casts.exp
gdb/testsuite/gdb.cp/classes.exp
gdb/testsuite/gdb.cp/virtbase.exp
gdb/testsuite/gdb.mi/mi-var-cmd.exp
gdb/testsuite/gdb.objc/basicclass.exp
gdb/valprint.c
gdb/valprint.h
gdb/value.h

index 3793661a8678506c339056e5064159ad7786027b..865b5bf264b2e270c1101cbdf8ff7e45676d33bd 100644 (file)
@@ -1,3 +1,21 @@
+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.
index b2e63b3acb0fcf484c48294cffff02b3ac1b7ff1..47b356a1bd5ab9ec11579c821173ebe0e2ab7634 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
      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
index 94118905852831b725f63dbe89c32ec18847af18..8b05f8fea180e9ae4129faa2c16370711485f8c1 100644 (file)
@@ -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)
index 004f3358cfd77faedd27dc737db265b866c1134b..229ad1b703276ec19f93b9ecd633c77d30416a47 100644 (file)
@@ -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,
index 4ee5c631a60345cace174e30ced6441ddd3319bc..0ebe882d5705c17b05186083d6671de6479515bb 100644 (file)
@@ -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.
index 7bfb9640a8bfb5f99fea4688c04b3e43fcfb4f88..b904f9b7b11698d627aba702ea44a7ab57407517 100644 (file)
@@ -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
index 229bfe30ac00761e97c135661c905e2bc43a5269..dc813830f8a107153a70d8a220f86720d8d23672 100644 (file)
@@ -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;
index be28f938d1b9b71793d013e53566f23b4ef8aff5..77d97213fa03fa0aa179ffe3662af949005aee32 100644 (file)
@@ -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)
index 523fad29411a3871ad420eb31b22584a1f26bd01..3c2d28c6f082ba559afe92c0f2836405d2796319 100644 (file)
@@ -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;
 }
 \f
 
index 9ef55877fdd273fbb6289ab8bf0feec01c14035d..bc92a840400091dcd5076041439335fa78f1ac32 100644 (file)
@@ -1,3 +1,22 @@
+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.
index 6dabf34dea1a6313befac96ae796d60b0bee773a..99249954532e614f81037db295b2a80949c53ac5 100644 (file)
@@ -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"
 
 
index 50ca37c1f51dc20decdc5f9a6174af887a966bc0..81501c26c9fdeb0e296e1ee5a5715862daeea363 100644 (file)
@@ -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
index 43d7ef67c8142d204d2487cec0292adfe32bf582..7c5c46eff4bb352728a03ab743c3eca2915eea45 100644 (file)
@@ -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 {
index 664481c6df924ab903472c1441aa2610607bb67e..ad54d65b888cb5287a135ef2c65a6f233c10f52e 100644 (file)
@@ -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" \
index 8998caace4c11ea85d8c03fb15b086006fb0b8c4..edc14e8610dfbde403017657e637ebaa7cdf77fa 100644 (file)
@@ -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 } {
index bd29581d325b0212e8cdfb4822ce371dc6c8f8c3..10901344b5cb6d3aa6b1e327c8ca0756d9547fba 100644 (file)
@@ -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>"
index 08a54b003d716118f4ba34a4c3bcfff5860dedae..0f35ba8511ed379df0537f1fac341bb1c571bf03 100644 (file)
@@ -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
index 7272a290dddb9b58dc09395eeb549e4a95c34b51..ee499d72f0d236bda03d04fe2ebc01bb40353bb2 100644 (file)
@@ -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)" \
index ae43630a1c263ae01e73ebb994ae8da85faf3f0a..36304b4be51cefc13e20abeeb2e0585f7c9e1336 100644 (file)
@@ -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"
index 6bc0076bad5d04d58beb4e289837e5cae197193b..939830f9ed39ead41dcfd0de22385c4cd4ac30b0 100644 (file)
@@ -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}" \
index f3ee77ad1c4ff3ad5e179fee99ae075030591e80..cadff9f39af07047f85b73fb44693cdd92c43934 100644 (file)
@@ -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 *" \
index c1892cafea1e10f542015ea3f53d0600af85ebf2..6ebffb0a2ccf9b7ed2a38009ec32e4be27bdf3f8 100644 (file)
@@ -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"
 
 #
index 6742fc16ecae4483ab8cf191c0db61d337df92e5..1384396e7bda3c043e72998560b77c96f49ec8a1 100644 (file)
@@ -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);
+}
+
 \f
 
 /* 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."), _("\
index 817e5cd48dec8664da19fafcb1336dc3c2f833df..b853b1af919b9d2056ccacc0ee0a9802a0f0983a 100644 (file)
@@ -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
index 6e5066c3afb526896e62e477e1e729b126924dad..25013d8855c668c526c6dd00feb9e7990f31c848 100644 (file)
@@ -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);
This page took 0.074176 seconds and 4 git commands to generate.