From patchwork Fri Dec 21 21:47:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 30811 Received: (qmail 24732 invoked by alias); 21 Dec 2018 21:47:31 -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 24674 invoked by uid 89); 21 Dec 2018 21:47:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=minsym, mst_text X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Dec 2018 21:47:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1545428845; x=1548020845; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Hi0/54FEpYJKlE/hKGOt4gzaC9+8wXpRkGN/aMjKpms=; b=e9qOrqfvaIu85e+RtZoCI2l8c5G27ajLEECFc7TNjduqnG8OuIYKddbwUQozFRzO 2KSWbmHdU2HOSLd+E6dTKKpbGF0lazRungmLGkCH6yAfAyOsEeMbMdv1gMphsABi 5IStFFKDVEhdtwy8K8CujP1PKX/HcL3Fg+eg3KYw3gM=; Received: from ESESSMB503.ericsson.se (Unknown_Domain [153.88.183.121]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id A9.35.01583.D6F5D1C5; Fri, 21 Dec 2018 22:47:25 +0100 (CET) Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 21 Dec 2018 22:47:25 +0100 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Fri, 21 Dec 2018 22:47:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hi0/54FEpYJKlE/hKGOt4gzaC9+8wXpRkGN/aMjKpms=; b=nHwynR3jtunUzEuwtcHfB65oLeCm5pt8U86w2UjU3ORwHDW+3jhOXCyZAI6SnTnu60dQTZEyCpgjE7+EYU3ixJzCWKXXivU/lcQvQHVaegKZRPnPDFwLdjUrtIBqx+mxc2q8/SVN8JAyFJmxCHCsWfEgk/4VX3Rv3y/Abn9oJPA= Received: from BYAPR15MB2390.namprd15.prod.outlook.com (52.135.198.30) by BYAPR15MB2341.namprd15.prod.outlook.com (52.135.197.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Fri, 21 Dec 2018 21:47:22 +0000 Received: from BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::a143:f30c:dd42:3af9]) by BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::a143:f30c:dd42:3af9%4]) with mapi id 15.20.1425.025; Fri, 21 Dec 2018 21:47:21 +0000 From: Simon Marchi To: "gdb-patches@sourceware.org" CC: Simon Marchi Subject: [PATCH] Add "set debug minsyms" command Date: Fri, 21 Dec 2018 21:47:21 +0000 Message-ID: <20181221214706.26981-1-simon.marchi@ericsson.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com X-IsSubscribed: yes While discussing this issue: https://sourceware.org/ml/gdb-patches/2018-12/threads.html#00082 I added a printf to be able to quickly see all minimal symbols recorded by GDB. I thought it would be useful to have it built-in, for the future. The output isn't particularly pretty. I found it more readable when making sure the fields were vertically aligned, which results in a lot of space wasted in the "type" column (the width is based on the length of the longest enumerator): minsym: recording minsym type: mst_data addr: 0x00000000004047c0 section: 2 name: __rt_psrelocs_end minsym: recording minsym type: mst_text addr: 0x0000000000402b88 section: 0 name: exit But since this is just debugging output, I think it doesn't really matter. Also, I didn't use paddress to print the address, because: 1. There is no gdbarch handy at this point 2. The address may not actually be an address, but any numerical value. Printing with paddress could change how it's displayed (e.g. mask certain bits) and could be misleading. I think it's better to print the actual raw value saved in the minimal symbol. gdb/ChangeLog: * minsyms.c: Include cli/cli-cmds.h. (debug_minsyms): New. (mst_str): New. (minimal_symbol_reader::record_full): Add debug output. (_initialize_minsyms): New. --- gdb/auto-load.c | 2 ++ gdb/elfread.c | 2 ++ gdb/minsyms.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 33d282afe83..e35fd29426b 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -1175,6 +1175,8 @@ load_auto_scripts_for_objfile (struct objfile *objfile) static void auto_load_new_objfile (struct objfile *objfile) { + std::vector c; + c.clear(); if (!objfile) { /* OBJFILE is NULL when loading a new "main" symbol-file. */ diff --git a/gdb/elfread.c b/gdb/elfread.c index 71e6fcca6ec..359089b166c 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -249,6 +249,8 @@ elf_symtab_read (minimal_symbol_reader &reader, continue; } + printf(" --- %s\n", sym->name); + /* Skip "special" symbols, e.g. ARM mapping symbols. These are symbols which do not correspond to objects in the symbol table, but have some other target-specific meaning. */ diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 0f854422e0f..98ce969eed0 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -53,6 +53,10 @@ #include "symbol.h" #include #include "safe-ctype.h" +#include "cli/cli-cmds.h" + +/* Value of the "set debug minsyms" configuration variable. */ +static int debug_minsyms = 0; /* See minsyms.h. */ @@ -1080,6 +1084,33 @@ minimal_symbol_reader::record (const char *name, CORE_ADDR address, record_with_info (name, address, ms_type, section); } +/* Convert an enumerator of type minimal_symbol_type to its string + representation. */ + +static const char * +mst_str (minimal_symbol_type t) +{ +#define MST_TO_STR(x) case x: return #x; + switch (t) + { + MST_TO_STR (mst_unknown); + MST_TO_STR (mst_text); + MST_TO_STR (mst_text_gnu_ifunc); + MST_TO_STR (mst_slot_got_plt); + MST_TO_STR (mst_data); + MST_TO_STR (mst_bss); + MST_TO_STR (mst_abs); + MST_TO_STR (mst_solib_trampoline); + MST_TO_STR (mst_file_text); + MST_TO_STR (mst_file_data); + MST_TO_STR (mst_file_bss); + + default: + return "mst_???"; + } +#undef MST_TO_STR +} + /* See minsyms.h. */ struct minimal_symbol * @@ -1112,6 +1143,11 @@ minimal_symbol_reader::record_full (const char *name, int name_len, if (ms_type == mst_file_text && startswith (name, "__gnu_compiled")) return (NULL); + if (debug_minsyms) + printf_unfiltered + ("minsym: recording minsym type: %-21s addr: 0x%016llx section: %-5d name: %s\n", + mst_str (ms_type), (long long) address, section, name); + if (m_msym_bunch_index == BUNCH_SIZE) { newobj = XCNEW (struct msym_bunch); @@ -1531,3 +1567,15 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym) return result; } + +void +_initialize_minsyms (void) +{ + add_setshow_boolean_cmd ("minsyms", class_maintenance, + &debug_minsyms, _("\ +Set minimal symbols debugging."), _("\ +Show minimal symbols debugging."), _("\ +When non-zero, debugging output related to minimal symbol is displayed."), + NULL, NULL, + &setdebuglist, &showdebuglist); +}