From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30652 invoked by alias); 22 Jul 2013 20:07:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30605 invoked by uid 89); 22 Jul 2013 20:07:09 -0000 X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_50,KAM_STOCKGEN,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,RDNS_NONE,TW_BT,TW_CP autolearn=no version=3.3.1 Received: from Unknown (HELO homiemail-a91.g.dreamhost.com) (208.113.200.5) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Jul 2013 20:07:07 +0000 Received: from homiemail-a91.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a91.g.dreamhost.com (Postfix) with ESMTP id 8763CAE069; Mon, 22 Jul 2013 13:06:38 -0700 (PDT) Received: from redwood.eagercon.com (c-50-148-128-197.hsd1.ca.comcast.net [50.148.128.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: eager@eagerm.com) by homiemail-a91.g.dreamhost.com (Postfix) with ESMTPSA id 60149AE059; Mon, 22 Jul 2013 13:06:38 -0700 (PDT) Message-ID: <51ED90E3.30801@eagerm.com> Date: Mon, 22 Jul 2013 20:07:00 -0000 From: Michael Eager User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Keith Seitz CC: "gdb-patches@sourceware.org ml" Subject: Re: [PATCH] Revised display-linkage-name References: <519D086A.50105@eagerm.com> <51BF47DB.6070709@eagerm.com> <51DD891D.7090009@eagerm.com> <51DF3F97.90805@redhat.com> <51E07263.6080605@eagerm.com> <51E6E797.30709@eagerm.com> <51ED705A.5000601@redhat.com> In-Reply-To: <51ED705A.5000601@redhat.com> Content-Type: multipart/mixed; boundary="------------040006030801070208020404" X-Virus-Found: No X-SW-Source: 2013-07/txt/msg00514.txt.bz2 This is a multi-part message in MIME format. --------------040006030801070208020404 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 795 On 07/22/13 10:48, Keith Seitz wrote: > On 07/17/2013 11:51 AM, Michael Eager wrote: >> void >> +annotate_linkage_name (void) >> +{ >> + if (annotation_level == 2) >> + printf_filtered (("\n\032\032linkage_name\n")); >> +} >> + > > This is still missing a (trivial) comment. [IIRC, we require comments for *all* functions, even if > they are pretty trivial.] The Changelog contains * annotate.c (annotate_linkage_name): New. * annotate.h (annotate_linkage_name): New decl. Is something else needed? > > I think with these minor things fixed, a global maintainer should give a final review (and approval). I believe that the attached updated patch addresses all of your comments. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 --------------040006030801070208020404 Content-Type: text/x-patch; name="0001-GDB-display-linkage-name-command.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-GDB-display-linkage-name-command.patch" Content-length: 23882 =46rom dffcd88d0f76ebe969b67eddacfc459373e2e5fb Mon Sep 17 00:00:00 2001 From: Michael Eager Date: Mon, 22 Jul 2013 12:56:42 -0700 Subject: [PATCH] GDB - display linkage name command --- gdb/NEWS | 14 ++++ gdb/ada-lang.c | 5 +- gdb/annotate.c | 7 ++ gdb/annotate.h | 2 + gdb/breakpoint.c | 31 +++++++ gdb/defs.h | 1 + gdb/disasm.c | 4 +- gdb/doc/gdb.texinfo | 28 ++++++- gdb/printcmd.c | 43 +++++++++- gdb/python/py-frame.c | 2 +- gdb/stack.c | 42 +++++++++- gdb/stack.h | 3 +- gdb/testsuite/gdb.cp/display-linkage-name.cc | 36 ++++++++ gdb/testsuite/gdb.cp/display-linkage-name.exp | 114 ++++++++++++++++++++++= ++++ gdb/top.c | 40 ++++++++- gdb/top.h | 2 + 16 files changed, 360 insertions(+), 14 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/display-linkage-name.cc create mode 100644 gdb/testsuite/gdb.cp/display-linkage-name.exp diff --git a/gdb/NEWS b/gdb/NEWS index e469f1e..ac62062 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -56,6 +56,20 @@ show range-stepping --configuration Display the details of GDB configure-time options. =20 +* New commands have been added to select whether to display the + linker symbol name for functions in addition to the name used in the + source. This may be useful when debugging programs where the compiler + prefixes characters to the source symbol, such as a leading underscore: + +set|show display-linkage-name [off|on] + + The default is "off", to not display the linkage name. + +set|show display-linkage-name-len + + Set the maximum number of characters to display in the linkage name, + if display-linkage-name is on. The default is 20. + * The command 'tsave' can now support new option '-ctf' to save trace buffer in Common Trace Format. =20 diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index dc5f2b6..3430e3f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11114,6 +11114,7 @@ is_known_support_routine (struct frame_info *frame) { struct symtab_and_line sal; char *func_name; + const char *linkname; enum language func_lang; int i; const char *fullname; @@ -11152,7 +11153,7 @@ is_known_support_routine (struct frame_info *frame) =20 /* Check whether the function is a GNAT-generated entity. */ =20 - find_frame_funname (frame, &func_name, &func_lang, NULL); + find_frame_funname (frame, &func_name, NULL, &func_lang, NULL); if (func_name =3D=3D NULL) return 1; =20 @@ -11227,7 +11228,7 @@ ada_unhandled_exception_name_addr_from_raise (void) char *func_name; enum language func_lang; =20 - find_frame_funname (fi, &func_name, &func_lang, NULL); + find_frame_funname (fi, &func_name, NULL, &func_lang, NULL); if (func_name !=3D NULL) { make_cleanup (xfree, func_name); diff --git a/gdb/annotate.c b/gdb/annotate.c index ccba5fe..84edeac 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -582,6 +582,13 @@ breakpoint_changed (struct breakpoint *b) } =20 void +annotate_linkage_name (void) +{ + if (annotation_level =3D=3D 2) + printf_filtered (("\n\032\032linkage_name\n")); +} + +void _initialize_annotate (void) { observer_attach_breakpoint_created (breakpoint_changed); diff --git a/gdb/annotate.h b/gdb/annotate.h index 72c4f19..33a9a0e 100644 --- a/gdb/annotate.h +++ b/gdb/annotate.h @@ -98,5 +98,7 @@ extern void annotate_elt_rep_end (void); extern void annotate_elt (void); extern void annotate_array_section_end (void); =20 +extern void annotate_linkage_name (void); + extern void (*deprecated_annotate_signalled_hook) (void); extern void (*deprecated_annotate_signal_hook) (void); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4d09b30..ba37c5e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5704,6 +5704,37 @@ print_breakpoint_location (struct breakpoint *b, ui_out_text (uiout, "in "); ui_out_field_string (uiout, "func", SYMBOL_PRINT_NAME (sym)); + if (display_linkage_name) + { + struct bound_minimal_symbol msymbol =3D + lookup_minimal_symbol_by_pc (loc->address); + + if (msymbol.minsym !=3D NULL + && strcmp (SYMBOL_LINKAGE_NAME (msymbol.minsym), + SYMBOL_PRINT_NAME (sym)) !=3D 0) + { + ui_out_text (uiout, " ["); + + if (strlen (SYMBOL_LINKAGE_NAME (msymbol.minsym)) + > display_linkage_name_len) + { + char *lname =3D alloca (display_linkage_name_len + 4); + + strncpy (lname, SYMBOL_LINKAGE_NAME (msymbol.minsym), + display_linkage_name_len); + lname[display_linkage_name_len] =3D '\0'; + strcat (lname, "..."); + ui_out_field_string (uiout, "linkage-name", lname); + } + else + { + ui_out_field_string (uiout, "linkage-name", + SYMBOL_LINKAGE_NAME (msymbol.minsym)); + } + + ui_out_text (uiout, "]"); + } + } ui_out_text (uiout, " "); ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what")); ui_out_text (uiout, "at "); diff --git a/gdb/defs.h b/gdb/defs.h index 014d7d4..15e9a54 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -336,6 +336,7 @@ extern int build_address_symbolic (struct gdbarch *, CORE_ADDR addr, int do_demangle,=20 char **name,=20 + char **linkname, int *offset,=20 char **filename,=20 int *line,=20=09 diff --git a/gdb/disasm.c b/gdb/disasm.c index e643c2d..396dce9 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -127,8 +127,8 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uio= ut, ui_out_text (uiout, pc_prefix (pc)); ui_out_field_core_addr (uiout, "address", gdbarch, pc); =20 - if (!build_address_symbolic (gdbarch, pc, 0, &name, &offset, &filena= me, - &line, &unmapped)) + if (!build_address_symbolic (gdbarch, pc, 0, &name, NULL, &offset, + &filename, &line, &unmapped)) { /* We don't care now about line, filename and unmapped. But we might in the future. */ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fae54e4..d230e01 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -15933,8 +15933,31 @@ line 1574. @} (@value{GDBP}) @end smallexample -@end table =20 +@kindex set display-linkage-name +@cindex list linkage names +@item set display-linkage-name +@itemx show display-linkage-name +Control displaying linker symbol names for functions. + +The default is @code{off}, which means that @value{GDBN} will only +display the function name used in the source. When @code{on}, @value{GDBN} +will also display the linkage name for the symbol name within brackets if = it is +different from the name in the source. + +The linkage name is the name used by the linker for a symbol. This may be +the same as the symbol's name in the source, or may be different if the co= mpiler +adds a prefix to the name (for example, an underscore) or modifies it, such +as by C@t{++} name mangling. + +This is different from "set print asm-demangle on" which only displays +the linkage name for C@t{++} symbols and does not display the source name. + +@kindex show display-linkage-name-len +@itemx show display-linkage-name-len @var{len} +Set the maximum number of characters of linkage name to display. The +@code{show} command displays the current setting. The default is @code{20= }. +@end table =20 @node Altering @chapter Altering Execution @@ -29250,6 +29273,9 @@ is not. @item what Some extra data, the exact contents of which are type-dependent. =20 +@item linkage-name +The name used by the linker for this function. + @end table =20 For example, here is what the output of @code{-break-insert} diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 99d4dba..de174d6 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -51,6 +51,7 @@ #include "cli/cli-utils.h" #include "format.h" #include "source.h" +#include "top.h" =20 #ifdef TUI #include "tui/tui.h" /* For tui_active et al. */ @@ -569,17 +570,19 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE= _ADDR addr, int do_demangle, char *leadin) { char *name =3D NULL; + char *linkname =3D NULL; char *filename =3D NULL; int unmapped =3D 0; int offset =3D 0; int line =3D 0; =20 - /* Throw away both name and filename. */ + /* Throw away name, linkname, and filename. */ struct cleanup *cleanup_chain =3D make_cleanup (free_current_contents, &= name); make_cleanup (free_current_contents, &filename); + make_cleanup (free_current_contents, &linkname); =20 - if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &offset, - &filename, &line, &unmapped)) + if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &linkname, + &offset, &filename, &line, &unmapped)) { do_cleanups (cleanup_chain); return 0; @@ -591,6 +594,28 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_= ADDR addr, else fputs_filtered ("<", stream); fputs_filtered (name, stream); + + /* Print linkage name after source name if requested and different. */ + if (display_linkage_name + && linkname !=3D NULL && strcmp (name, linkname) !=3D 0) + { + fputs_filtered (" [", stream); + + if (strlen (linkname) > display_linkage_name_len) + { + char *lname =3D alloca (display_linkage_name_len + 4); + + strncpy (lname, linkname, display_linkage_name_len); + lname[display_linkage_name_len] =3D '\0'; + strcat (lname, "..."); + fputs_filtered (lname, stream); + } + else + fputs_filtered (linkname, stream); + + fputs_filtered ("]", stream); + } + if (offset !=3D 0) fprintf_filtered (stream, "+%u", (unsigned int) offset); =20 @@ -623,6 +648,7 @@ build_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr, /* IN */ int do_demangle, /* IN */ char **name, /* OUT */ + char **linkname, /* OUT */ int *offset, /* OUT */ char **filename, /* OUT */ int *line, /* OUT */ @@ -637,6 +663,10 @@ build_address_symbolic (struct gdbarch *gdbarch, /* Let's say it is mapped (not unmapped). */ *unmapped =3D 0; =20 + /* Let's say the link name is the same as the symbol name. */ + if (linkname !=3D NULL) + *linkname =3D NULL; + /* Determine if the address is in an overlay, and whether it is mapped. */ if (overlay_debugging) @@ -740,6 +770,13 @@ build_address_symbolic (struct gdbarch *gdbarch, *line =3D sal.line; } } + + /* If we have both symbol names and they are different, let caller know.= */ + if (linkname !=3D NULL && msymbol !=3D NULL && symbol !=3D NULL + && strcmp (SYMBOL_LINKAGE_NAME (msymbol), + SYMBOL_LINKAGE_NAME (symbol)) !=3D 0) + *linkname =3D xstrdup (SYMBOL_LINKAGE_NAME (msymbol)); + return 0; } =20 diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index f960b08..6b48140 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -131,7 +131,7 @@ frapy_name (PyObject *self, PyObject *args) { FRAPY_REQUIRE_VALID (self, frame); =20 - find_frame_funname (frame, &name, &lang, NULL); + find_frame_funname (frame, &name, NULL, &lang, NULL); } =20 if (except.reason < 0) diff --git a/gdb/stack.c b/gdb/stack.c index 313d57f..49d6acb 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -55,6 +55,7 @@ #include "psymtab.h" #include "symfile.h" #include "python/python.h" +#include "top.h" =20 void (*deprecated_selected_frame_level_changed_hook) (int); =20 @@ -1000,15 +1001,20 @@ get_last_displayed_sal (struct symtab_and_line *sal) =20 =20 /* Attempt to obtain the FUNNAME, FUNLANG and optionally FUNCP of the func= tion - corresponding to FRAME. FUNNAME needs to be freed by the caller. */ + corresponding to FRAME. FUNNAME needs to be freed by the caller. + Set LINKNAME to linkage name (symbol used by linker) if LINKNAME is non= -null + and linkage name differs from source name. */ =20 void find_frame_funname (struct frame_info *frame, char **funname, - enum language *funlang, struct symbol **funcp) + const char **linkname, enum language *funlang, + struct symbol **funcp) { struct symbol *func; =20 *funname =3D NULL; + if (linkname !=3D NULL) + *linkname =3D NULL; *funlang =3D language_unknown; if (funcp) *funcp =3D NULL; @@ -1044,6 +1050,11 @@ find_frame_funname (struct frame_info *frame, char *= *funname, else memset (&msymbol, 0, sizeof (msymbol)); =20 + if (linkname !=3D NULL && msymbol.minsym !=3D NULL + && strcmp (SYMBOL_LINKAGE_NAME (msymbol.minsym), + SYMBOL_LINKAGE_NAME (func)) !=3D 0) + *linkname =3D SYMBOL_LINKAGE_NAME (msymbol.minsym); + if (msymbol.minsym !=3D NULL && (SYMBOL_VALUE_ADDRESS (msymbol.minsym) > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) @@ -1102,6 +1113,7 @@ print_frame (struct frame_info *frame, int print_leve= l, struct gdbarch *gdbarch =3D get_frame_arch (frame); struct ui_out *uiout =3D current_uiout; char *funname =3D NULL; + const char *linkname =3D NULL; enum language funlang =3D language_unknown; struct ui_file *stb; struct cleanup *old_chain, *list_chain; @@ -1115,7 +1127,7 @@ print_frame (struct frame_info *frame, int print_leve= l, stb =3D mem_fileopen (); old_chain =3D make_cleanup_ui_file_delete (stb); =20 - find_frame_funname (frame, &funname, &funlang, &func); + find_frame_funname (frame, &funname, &linkname, &funlang, &func); make_cleanup (xfree, funname); =20 annotate_frame_begin (print_level ? frame_relative_level (frame) : 0, @@ -1147,6 +1159,30 @@ print_frame (struct frame_info *frame, int print_lev= el, fprintf_symbol_filtered (stb, funname ? funname : "??", funlang, DMGL_ANSI); ui_out_field_stream (uiout, "func", stb); + + /* Print linkage name after source name if requested and different. */ + if ((display_linkage_name || ui_out_is_mi_like_p (uiout)) + && linkname !=3D NULL && strcmp (funname, linkname) !=3D 0) + { + annotate_linkage_name (); + ui_out_text (uiout, " ["); + + if (strlen (linkname) > display_linkage_name_len) + { + char *lname =3D alloca (display_linkage_name_len + 4); + + strncpy (lname, linkname, display_linkage_name_len); + lname[display_linkage_name_len] =3D '\0'; + strcat (lname, "..."); + ui_out_text (uiout, lname); + } + else + ui_out_text (uiout, linkname); + + ui_out_text (uiout, "]"); + ui_out_field_stream (uiout, "linkage_name", stb); + } + ui_out_wrap_hint (uiout, " "); annotate_frame_args (); =20=20=20=20=20=20=20 diff --git a/gdb/stack.h b/gdb/stack.h index 4badf19..9248c85 100644 --- a/gdb/stack.h +++ b/gdb/stack.h @@ -23,7 +23,8 @@ void select_frame_command (char *level_exp, int from_tty); =20 void find_frame_funname (struct frame_info *frame, char **funname, - enum language *funlang, struct symbol **funcp); + const char **linkname, enum language *funlang, + struct symbol **funcp); =20 typedef void (*iterate_over_block_arg_local_vars_cb) (const char *print_na= me, struct symbol *sym, diff --git a/gdb/testsuite/gdb.cp/display-linkage-name.cc b/gdb/testsuite/g= db.cp/display-linkage-name.cc new file mode 100644 index 0000000..d9db673 --- /dev/null +++ b/gdb/testsuite/gdb.cp/display-linkage-name.cc @@ -0,0 +1,36 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2013 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 . = */ + +void foo (const char *msg) +{ +} /* set breakpoint 1 here */ + +void fun_with_a_long_name (int i, const char *s, double d) +{ + foo ("Hello"); /* set breakpoint 2 here */ +} + +void goo (void) +{ + fun_with_a_long_name (1, "abc", 3.14); +} + +int main (void) +{ + goo(); + return 0; +} diff --git a/gdb/testsuite/gdb.cp/display-linkage-name.exp b/gdb/testsuite/= gdb.cp/display-linkage-name.exp new file mode 100644 index 0000000..19c6191 --- /dev/null +++ b/gdb/testsuite/gdb.cp/display-linkage-name.exp @@ -0,0 +1,114 @@ +# Copyright 2013 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 . + +# This file was written by Michael Eager (eager@eagercon.com). + +if { [skip_cplus_tests] } { continue } + +standard_testfile .cc + +if {[get_compiler_info "c++"]} { + return -1 +} + +if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] } { + return -1 +} + +# set break at functions + +set bp1 [gdb_get_line_number "set breakpoint 1 here"] +set bp2 [gdb_get_line_number "set breakpoint 2 here"] + +if {![gdb_breakpoint "foo"]} { + fail "set breakpoint foo" +} + +if {![gdb_breakpoint "fun_with_a_long_name"]} { + fail "set breakpoint fun_with_a_long_name" +} + +######################## +# Test with display-linkage-name off + +gdb_test_no_output "set display-linkage-name off" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[\t \]+What.* +1\[\t \]+breakpoint keep y.* in foo(.*) at .*$srcfile:$bp1.* +2\[\t \]+breakpoint keep y.* in fun_with_a_long_name(.*) at .*$srcfile= :$bp2.*" \ + "info breakpoint - display off" + +gdb_run_cmd +set test "break at fun_with_a_long_name" +gdb_continue_to_breakpoint "fun_with_a_long_name (.*) at.*$srcfile.$bp2" + +set bttable "#0 foo (.*) at.*\[\r\n\]" +append bttable "#1 $hex in fun_with_a_long_name (.*) at .*$srcfile:.*\[\r= \n\]" +append bttable "#2 $hex in goo (.*) at .*$srcfile:.*\[\r\n\]" +append bttable "#3 $hex in main (.*) at .*$srcfile:.*" + +gdb_test "backtrace" $bttable "backtrace - display off" + +######################## +# Test with display-linkage-name on + +gdb_test_no_output "set display-linkage-name on" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[\t \]+What.* +1\[\t \]+breakpoint keep y.* in foo(.*) \\\[_Z3fooPKc\\\] at .*$srcfil= e:$bp1.* +2\[\t \]+breakpoint keep y.* in fun_with_a_long_name(.*) \\\[_Z20fun_w= ith_a_long_\.\.\.\\\] at .*$srcfile:$bp2.*" \ + "info breakpoint - display on" + +gdb_run_cmd +set test "break at fun_with_a_long_name - display on" +gdb_continue_to_breakpoint "fun_with_a_long_name \\\[_Z20fun_with_a_long_.= ..\\\] (.*) at.*$srcfile.$bp2" + +set bttable "#0 foo \\\[_Z3fooPKc\\\] (.*) at.*\[\r\n\]" +append bttable "#1 $hex in fun_with_a_long_name \\\[_Z20fun_with_a_long_\= .\.\.\\\] (.*) at .*$srcfile:.*\[\r\n\]" +append bttable "#2 $hex in goo \\\[_Z3goov\\\] (.*) at .*$srcfile:.*\[\r\= n\]" +append bttable "#3 $hex in main (.*) at .*$srcfile:.*" + +gdb_test "backtrace" $bttable "backtrace - display on" + +######################## +# Test set/show display-linkage-name-len + +gdb_test "show display-linkage-name-len" \ + "Length of linkage names \\(symbol used by linker\\) to be displayed i= s 20." + +gdb_test_no_output "set display-linkage-name-len 10" "" + +gdb_test "show display-linkage-name-len" \ + "Length of linkage names \\(symbol used by linker\\) to be displayed i= s 10." + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[\t \]+What.* +1\[\t \]+breakpoint keep y.* in foo(.*) \\\[_Z3fooPKc\\\] at .*$srcfil= e:$bp1.* +2\[\t \]+breakpoint keep y.* in fun_with_a_long_name(.*) \\\[_Z20fun_w= i\.\.\.\\\] at .*$srcfile:$bp2.*" \ + "info breakpoint - display 10" + +gdb_run_cmd +set test "break at fun_with_a_long_name - display 10" +gdb_continue_to_breakpoint "fun_with_a_long_name \\\[_Z20fun_wi\.\.\.\\\] = (.*) at .*$srcfile:$bp2" + +set bttable "#0 foo \\\[_Z3fooPKc\\\] (.*) at.*\[\r\n\]" +append bttable "#1 $hex in fun_with_a_long_name \\\[_Z20fun_wi\.\.\.\\\] = (.*) at .*$srcfile:.*\[\r\n\]" +append bttable "#2 $hex in goo \\\[_Z3goov\\\] (.*) at .*$srcfile:.*\[\r\= n\]" +append bttable "#3 $hex in main (.*) at .*$srcfile:.*" + +gdb_test "backtrace" $bttable "backtrace - display 10" + diff --git a/gdb/top.c b/gdb/top.c index 46faaa7..c0f6f25 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -287,6 +287,29 @@ quit_cover (void) quit_command ((char *) 0, 0); } #endif /* defined SIGHUP */ + +/* Flag for whether we want to print linkage name for functions. + Length of linkage name to print. */ + +int display_linkage_name =3D 0; /* Default is no. */ +int display_linkage_name_len =3D 20; /* Default is first 20 chars. */ + +static void +show_display_linkage_name (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("\ +Whether to display linkage name (symbol used by linker) of functions is %s= .\n"), + value); +} +static void +show_display_linkage_name_len (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("\ +Length of linkage names (symbol used by linker) to be displayed is %s.\n"), + value); +} =0C /* Line number we are currently in, in a file which is being sourced. */ /* NOTE 1999-04-29: This variable will be static again, once we modify @@ -1809,7 +1832,22 @@ Use \"on\" to enable the notification, and \"off\" t= o disable it."), When set, GDB uses the specified path to search for data files."), set_gdb_datadir, NULL, &setlist, - &showlist); + &showlist); + + add_setshow_boolean_cmd ("display-linkage-name", class_support, &display= _linkage_name, _("\ +Set whether to display linkage name (symbol used by linker) for functions.= "), _("\ +Show whether to display linkage name (symbol used by linker) for functions= ."), NULL, + NULL, + show_display_linkage_name, + &setlist, &showlist); + + add_setshow_zinteger_cmd ("display-linkage-name-len", class_support, &di= splay_linkage_name_len, _("\ +Set number of characters of linkage name to display."), _("\ +Show number of characters of linkage name to display."), NULL, + NULL, + show_display_linkage_name_len, + &setlist, &showlist); + } =20 void diff --git a/gdb/top.h b/gdb/top.h index 2f70539..5acb311 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -26,6 +26,8 @@ extern int saved_command_line_size; extern FILE *instream; extern int in_user_command; extern int confirm; +extern int display_linkage_name; +extern int display_linkage_name_len; extern char gdb_dirbuf[1024]; extern int inhibit_gdbinit; extern const char gdbinit[]; --=20 1.8.1.4 --------------040006030801070208020404--