From patchwork Mon Mar 31 19:10:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 361 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id AF633360098 for ; Mon, 31 Mar 2014 12:10:45 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 569F4452042A; Mon, 31 Mar 2014 12:10:45 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 14C814520418 for ; Mon, 31 Mar 2014 12:10:45 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject :in-reply-to:references; q=dns; s=default; b=e/JiwL0dfahJ8+/ttAV iwW2WbMF65Cxu+vbrmlG5xfoL4eZMvEJ3LpFnQxOIZzbycEs2dFVQErQ8ssBp8Vk JmuXbeGQCRjHz+1R2/ivt/sgcIYJ/jmCkWFFbehXCrwj8fITzhH+/I9HS1QI8LEF Bqt1Kq448pe7hG0K/1YN/zkQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject :in-reply-to:references; s=default; bh=yEHWmTm7OSHDK6BvRVWTQM9m3 ag=; b=srHFekKQMDVgWNAQbD6Njkn4/wO1TXOjJPdQplBKS/kcvf/Z5bSsJO82M 7nZGVOIBCSChXYNeyNpLEx091uVx4g2AM53gqrmPk9yq4vf0hdQdNZIOh6235SV4 04kHBrgaKFYK7DlRv6b+WXMzO3tZRQ2aUEuLsIJwVZ8B4bI05U= Received: (qmail 14425 invoked by alias); 31 Mar 2014 19:10:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14413 invoked by uid 89); 31 Mar 2014 19:10:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oa0-f74.google.com Received: from mail-oa0-f74.google.com (HELO mail-oa0-f74.google.com) (209.85.219.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 31 Mar 2014 19:10:39 +0000 Received: by mail-oa0-f74.google.com with SMTP id i7so1691102oag.5 for ; Mon, 31 Mar 2014 12:10:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject:in-reply-to :references; bh=n7FJdcGsRAD8ugFzrsxZCkGZbk988LiQAdM9YJnbDiY=; b=ltQtIsOP7ygNIugBXjI1DxavTyaJQ3M8AAzYR0S1D8j9s8vChUwaAVcmEs8+aNdkRc RHlZ/E2w6lYkeW//MtvEXSXC/DQzRzC9YWSZZbOvQCSz1o4Kk27hfNYCKYqSJn80LGmw J+k1oSLzeWaFnY6lSA9SG688hCaRDsckF8ugPtQGL+SqPaZvXfUH8c9QXFoJUt7+Ye56 vcXq6fg/Etif5yfR6T+uUObMiLqrRwvXTvpVOe6gUVEWd6QcoTLoU3lToHwh3ZUnRYXp s0c1ed4lBiskGD109V/ZZUomLWVGMoP0Zj23LRmlYht16+WuaAvL11xH1mWHe2Nek+Hs 332A== X-Gm-Message-State: ALoCoQnup4gDBA24jglUtjPqyRy1T57Ch9wgi0dSEbH0EutkHJQoho/1i+qz40LQz77/ota0bMyFvcvaZKgKqmOGCV5C5XVgbMDISnLGhkp985UAJ0D75Lwoxz3Kw5AcTbW/ERfnTiCL1zUGOlSEcHjafaYD7XVKK3eozusy+6UY99CPVW+EFjH7DyF+K8/8ZBlsYIaVeRcibQZI3QOryqeKjDBqZYTkCQ== X-Received: by 10.42.240.19 with SMTP id ky19mr9476937icb.4.1396293037655; Mon, 31 Mar 2014 12:10:37 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id i30si2817001yhc.0.2014.03.31.12.10.37 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Mar 2014 12:10:37 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 1715B31C230; Mon, 31 Mar 2014 12:10:36 -0700 (PDT) From: Doug Evans MIME-Version: 1.0 Message-ID: <21305.48556.419222.690512@ruffy.mtv.corp.google.com> Date: Mon, 31 Mar 2014 12:10:36 -0700 To: Pedro Alves , gdb-patches Subject: Re: [PATCH, doc RFA] New option: set print symbol-loading In-Reply-To: References: <530E2C51.8090306@redhat.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Doug Evans writes: > On Wed, Feb 26, 2014 at 10:02 AM, Pedro Alves wrote: > > On 02/24/2014 11:50 PM, Doug Evans wrote: > >> + if (print_symbol_loading_p (from_tty, 0, 0)) > >> + { > >> + if (pattern != NULL) > >> + printf_unfiltered (_("Loading symbols for shared libraries.\n")); > >> + else > >> + printf_unfiltered (_("Loading symbols for shared libraries: %s\n"), > >> + pattern); > > > > then/else looks reversed here. > > Blech. Thanks. Here is what I committed. 2014-03-31 Doug Evans New option "set print symbol-loading". * NEWS: Mention it. * solib.c (solib_read_symbols): Only print symbol loading messages if requested. (solib_add): If symbol loading is in "brief" mode, notify user symbols are being loaded. (reload_shared_libraries_1): Ditto. * symfile.c (print_symbol_loading_off): New static global. (print_symbol_loading_brief): New static global. (print_symbol_loading_full): New static global. (print_symbol_loading_enums): New static global. (print_symbol_loading): New static global. (print_symbol_loading_p): New function. (symbol_file_add_with_addrs): Only print symbol loading messages if requested. (_initialize_symfile): Register "print symbol-loading" set/show command. * symfile.h (print_symbol_loading_p): Declare. doc/ * gdb.texinfo (Symbols): Document set/show print symbol-loading. testsuite/ * gdb.base/print-symbol-loading-lib.c: New file. * gdb.base/print-symbol-loading-main.c: New file. * gdb.base/print-symbol-loading.exp: New file. diff --git a/gdb/NEWS b/gdb/NEWS index 2a384ba..df233fc 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -28,6 +28,13 @@ info auto-load guile-scripts [regexp] * New options +set print symbol-loading (off|brief|full) +show print symbol-loading + Control whether to print informational messages when loading symbol + information for a file. The default is "full", but when debugging + programs with large numbers of shared libraries the amount of output + becomes less useful. + set guile print-stack (none|message|full) show guile print-stack Show a stack trace when an error is encountered in a Guile script. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 0bf33b7..b218769 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -16184,6 +16184,28 @@ is printed as follows: @item show opaque-type-resolution Show whether opaque types are resolved or not. +@kindex set print symbol-loading +@cindex print messages when symbols are loaded +@item set print symbol-loading +@itemx set print symbol-loading full +@itemx set print symbol-loading brief +@itemx set print symbol-loading off +The @code{set print symbol-loading} command allows you to control the +printing of messages when @value{GDBN} loads symbol information. +By default a message is printed for the executable and one for each +shared library, and normally this is what you want. However, when +debugging apps with large numbers of shared libraries these messages +can be annoying. +When set to @code{brief} a message is printed for each executable, +and when @value{GDBN} loads a collection of shared libraries at once +it will only print one message regardless of the number of shared +libraries. When set to @code{off} no messages are printed. + +@kindex show print symbol-loading +@item show print symbol-loading +Show whether messages will be printed when a @value{GDBN} command +entered from the keyboard causes symbol information to be loaded. + @kindex maint print symbols @cindex symbol dump @kindex maint print psymbols diff --git a/gdb/solib.c b/gdb/solib.c index 3350bfd..e0afca0 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -650,7 +650,7 @@ solib_read_symbols (struct so_list *so, int flags) so->so_name); else { - if (from_tty || info_verbose) + if (print_symbol_loading_p (from_tty, 0, 1)) printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name); so->symbols_loaded = 1; } @@ -905,6 +905,17 @@ solib_add (char *pattern, int from_tty, { struct so_list *gdb; + if (print_symbol_loading_p (from_tty, 0, 0)) + { + if (pattern != NULL) + { + printf_unfiltered (_("Loading symbols for shared libraries: %s\n"), + pattern); + } + else + printf_unfiltered (_("Loading symbols for shared libraries.\n")); + } + current_program_space->solib_add_generation++; if (pattern) @@ -1277,6 +1288,9 @@ reload_shared_libraries_1 (int from_tty) struct so_list *so; struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); + if (print_symbol_loading_p (from_tty, 0, 0)) + printf_unfiltered (_("Loading symbols for shared libraries.\n")); + for (so = so_list_head; so != NULL; so = so->next) { char *filename, *found_pathname = NULL; diff --git a/gdb/symfile.c b/gdb/symfile.c index aee7ef5..64a83c6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -143,6 +143,20 @@ DEF_VEC_O (registered_sym_fns); static VEC (registered_sym_fns) *symtab_fns = NULL; +/* Values for "set print symbol-loading". */ + +const char print_symbol_loading_off[] = "off"; +const char print_symbol_loading_brief[] = "brief"; +const char print_symbol_loading_full[] = "full"; +static const char *print_symbol_loading_enums[] = +{ + print_symbol_loading_off, + print_symbol_loading_brief, + print_symbol_loading_full, + NULL +}; +static const char *print_symbol_loading = print_symbol_loading_full; + /* If non-zero, shared library symbols will be added automatically when the inferior is created, new libraries are loaded, or when attaching to the inferior. This is almost always what users will @@ -156,6 +170,31 @@ static VEC (registered_sym_fns) *symtab_fns = NULL; int auto_solib_add = 1; +/* Return non-zero if symbol-loading messages should be printed. + FROM_TTY is the standard from_tty argument to gdb commands. + If EXEC is non-zero the messages are for the executable. + Otherwise, messages are for shared libraries. + If FULL is non-zero then the caller is printing a detailed message. + E.g., the message includes the shared library name. + Otherwise, the caller is printing a brief "summary" message. */ + +int +print_symbol_loading_p (int from_tty, int exec, int full) +{ + if (!from_tty && !info_verbose) + return 0; + + if (exec) + { + /* We don't check FULL for executables, there are few such + messages, therefore brief == full. */ + return print_symbol_loading != print_symbol_loading_off; + } + if (full) + return print_symbol_loading == print_symbol_loading_full; + return print_symbol_loading == print_symbol_loading_brief; +} + /* True if we are reading a symbol table. */ int currently_reading_symtab = 0; @@ -1112,7 +1151,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags, struct objfile *objfile; const int from_tty = add_flags & SYMFILE_VERBOSE; const int mainline = add_flags & SYMFILE_MAINLINE; - const int should_print = ((from_tty || info_verbose) + const int should_print = (print_symbol_loading_p (from_tty, mainline, 1) && (readnow_symbol_files || (add_flags & SYMFILE_NO_READ) == 0)); @@ -3985,4 +4024,18 @@ each global debug-file-directory component prepended."), NULL, show_debug_file_directory, &setlist, &showlist); + + add_setshow_enum_cmd ("symbol-loading", no_class, + print_symbol_loading_enums, &print_symbol_loading, + _("\ +Set printing of symbol loading messages."), _("\ +Show printing of symbol loading messages."), _("\ +off == turn all messages off\n\ +brief == print messages for the executable,\n\ + and brief messages for shared libraries\n\ +full == print messages for the executable,\n\ + and messages for each shared library."), + NULL, + NULL, + &setprintlist, &showprintlist); } diff --git a/gdb/symfile.h b/gdb/symfile.h index 8e2569d..ff25028 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -503,6 +503,8 @@ extern bfd *gdb_bfd_open_maybe_remote (const char *); extern int get_section_index (struct objfile *, char *); +extern int print_symbol_loading_p (int from_tty, int mainline, int full); + /* Utility functions for overlay sections: */ extern enum overlay_debugging_state { diff --git a/gdb/testsuite/gdb.base/print-symbol-loading-lib.c b/gdb/testsuite/gdb.base/print-symbol-loading-lib.c new file mode 100644 index 0000000..1e31e53 --- /dev/null +++ b/gdb/testsuite/gdb.base/print-symbol-loading-lib.c @@ -0,0 +1,21 @@ +/* Copyright 2010-2014 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 +lib (void) +{ +} diff --git a/gdb/testsuite/gdb.base/print-symbol-loading-main.c b/gdb/testsuite/gdb.base/print-symbol-loading-main.c new file mode 100644 index 0000000..8379b58 --- /dev/null +++ b/gdb/testsuite/gdb.base/print-symbol-loading-main.c @@ -0,0 +1,25 @@ +/* Copyright 2010-2014 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +extern void lib (void); + +int +main (void) +{ + lib (); + return 0; +} diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp new file mode 100644 index 0000000..a080ce1 --- /dev/null +++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp @@ -0,0 +1,144 @@ +# Copyright 2012-2014 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 . + +# Test the "print symbol-loading" option. + +if {[skip_shlib_tests]} { + return 0 +} + +standard_testfile print-symbol-loading-main.c +set libfile print-symbol-loading-lib +set srcfile_lib ${libfile}.c +set binfile_lib [standard_output_file ${libfile}.so] +set gcorefile ${binfile}.gcore +set objfile [standard_output_file ${testfile}.o] + +if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != "" + || [gdb_compile ${srcdir}/${subdir}/${srcfile} ${objfile} object {debug}] != "" } { + untested ${testfile}.exp + return -1 +} +set opts [list debug shlib=${binfile_lib}] +if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { + untested ${testfile}.exp + return -1 +} + +clean_restart ${binfile} +gdb_load_shlibs ${binfile_lib} + +# Does this gdb support gcore? +set test "help gcore" +gdb_test_multiple $test $test { + -re "Undefined command: .gcore.*\r\n$gdb_prompt $" { + # gcore command not supported -- nothing to test here. + unsupported "gdb does not support gcore on this target" + return -1 + } + -re "Save a core file .*\r\n$gdb_prompt $" { + pass $test + } +} + +if ![runto lib] { + return -1 +} + +if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { + return -1 +} + +proc test_load_core { print_symbol_loading } { + global binfile binfile_lib gcorefile srcdir subdir + with_test_prefix "core ${print_symbol_loading}" { + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_test_no_output "set print symbol-loading $print_symbol_loading" + if { ${print_symbol_loading} != "off" } { + gdb_test "file $binfile" "Reading symbols from.*done\\." "file" + } else { + gdb_test_no_output "file $binfile" "file" + } + # Rename the shared lib so gdb can't find it. + remote_exec host "mv -f ${binfile_lib} ${binfile_lib}.save" + gdb_test "core ${gcorefile}" "Core was generated by .*" \ + "re-load generated corefile" + # Now put it back and use "set solib-search-path" to trigger + # loading of symbols. + remote_exec host "mv -f ${binfile_lib}.save ${binfile_lib}" + set test_name "load shared-lib" + switch "${print_symbol_loading}" { + "off" { + gdb_test_no_output "set solib-search-path [file dirname ${binfile_lib}]" \ + ${test_name} + } + "brief" { + gdb_test "set solib-search-path [file dirname ${binfile_lib}]" \ + "Loading symbols for shared libraries\\." \ + ${test_name} + } + "full" { + gdb_test "set solib-search-path [file dirname ${binfile_lib}]" \ + "Reading symbols from.*Loaded symbols for.*" \ + ${test_name} + } + } + gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" + } +} + +test_load_core off +test_load_core brief +test_load_core full + +# Now test the sharedlibrary command. + +proc test_load_shlib { print_symbol_loading } { + global binfile + with_test_prefix "shlib ${print_symbol_loading}" { + clean_restart ${binfile} + gdb_test_no_output "set auto-solib-add off" + if ![runto_main] { + return -1 + } + gdb_test_no_output "set print symbol-loading $print_symbol_loading" + set test_name "load shared-lib" + switch ${print_symbol_loading} { + "off" { + gdb_test_no_output "sharedlibrary .*" \ + ${test_name} + } + "brief" { + gdb_test "sharedlibrary .*" \ + "Loading symbols for shared libraries: \\.\\*" \ + ${test_name} + } + "full" { + gdb_test "sharedlibrary .*" \ + "Reading symbols from.*Loaded symbols for.*" \ + ${test_name} + } + } + gdb_breakpoint "lib" + gdb_continue_to_breakpoint "lib" + gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" + } +} + +test_load_shlib off +test_load_shlib brief +test_load_shlib full