From patchwork Thu Mar 7 20:57:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31781 Received: (qmail 54080 invoked by alias); 7 Mar 2019 20:57:19 -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 53769 invoked by uid 89); 7 Mar 2019 20:57:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 20:57:15 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway32.websitewelcome.com (Postfix) with ESMTP id D2B0C7D6D1 for ; Thu, 7 Mar 2019 14:57:13 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 204nhy8eo2qH7204nhRqF3; Thu, 07 Mar 2019 14:57:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TJykcoM8EiWzYVhhuht7KvIZAH1KN0jUUyCUcifYWqo=; b=XLP+4o0f9sBFRRnbFjfhK1ZVys 9HM/e9Xo3ipuqmFYNpC2CNr74XSawWO4CKcOkB6cYu81Ti4rhoI5m7jsywpqjOOC2/Ckj/4P/GNrX e7N5msknLHGyiqzD+5LiByHus; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:53182 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h204n-002TOW-Ko; Thu, 07 Mar 2019 14:57:13 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 9/9] Change minimal_symbol inheritance Date: Thu, 7 Mar 2019 13:57:09 -0700 Message-Id: <20190307205709.21919-10-tom@tromey.com> In-Reply-To: <20190307205709.21919-1-tom@tromey.com> References: <20190307205709.21919-1-tom@tromey.com> This changes struct minimal_symbol to inherit from general_symbol_info and updates various macros to cope. Because MSYMBOL_SET_LANGUAGE and MSYMBOL_SET_NAMES were only used from a single spot, this patch removes them in favor of simply inlining their definitions. I consider this to be somewhat cleaner, not least because the "phony polymorphism" provided by such macros is not useful in practice. gdb/ChangeLog 2019-03-07 Tom Tromey * symtab.h (struct minimal_symbol): Derive from general_symbol_info. (MSYMBOL_VALUE, MSYMBOL_VALUE_RAW_ADDRESS) (MSYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_BYTES) (MSYMBOL_BLOCK_VALUE, MSYMBOL_VALUE_CHAIN, MSYMBOL_LANGUAGE) (MSYMBOL_SECTION, MSYMBOL_OBJ_SECTION, MSYMBOL_NATURAL_NAME) (MSYMBOL_LINKAGE_NAME, MSYMBOL_DEMANGLED_NAME) (MSYMBOL_SEARCH_NAME): Update. (MSYMBOL_SET_LANGUAGE, MSYMBOL_SET_NAMES): Remove. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Don't use memset. * minsyms.c (minimal_symbol_reader::record_full): Update. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/minsyms.c | 6 +++--- gdb/solib.c | 3 +-- gdb/symtab.h | 49 ++++++++++++++++++------------------------------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4f3c929cd72..669c1d13928 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1145,9 +1145,9 @@ minimal_symbol_reader::record_full (const char *name, int name_len, m_msym_bunch = newobj; } msymbol = &m_msym_bunch->contents[m_msym_bunch_index]; - MSYMBOL_SET_LANGUAGE (msymbol, language_auto, - &m_objfile->per_bfd->storage_obstack); - MSYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, m_objfile); + symbol_set_language (msymbol, language_auto, + &m_objfile->per_bfd->storage_obstack); + symbol_set_names (msymbol, name, name_len, copy_name, m_objfile->per_bfd); SET_MSYMBOL_VALUE_ADDRESS (msymbol, address); MSYMBOL_SECTION (msymbol) = section; diff --git a/gdb/solib.c b/gdb/solib.c index 791b94bc93a..017cd62eb77 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1501,9 +1501,8 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd, if (bfd_get_flavour (abfd) == bfd_target_elf_flavour && gdbarch_elf_make_msymbol_special_p (gdbarch)) { - struct minimal_symbol msym; + struct minimal_symbol msym {}; - memset (&msym, 0, sizeof (msym)); SET_MSYMBOL_VALUE_ADDRESS (&msym, symaddr); gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym); symaddr = MSYMBOL_VALUE_RAW_ADDRESS (&msym); diff --git a/gdb/symtab.h b/gdb/symtab.h index d354c95800d..85dc3710483 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -641,16 +641,8 @@ gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS)); between names and addresses, and vice versa. They are also sometimes used to figure out what full symbol table entries need to be read in. */ -struct minimal_symbol +struct minimal_symbol : public general_symbol_info { - - /* The general symbol info required for all types of symbols. - - The SYMBOL_VALUE_ADDRESS contains the address that this symbol - corresponds to. */ - - struct general_symbol_info mginfo; - /* Size of this symbol. dbx_end_psymtab in dbxread.c uses this information to calculate the end of the partial symtab based on the address of the last symbol plus the size of the last symbol. */ @@ -687,7 +679,7 @@ struct minimal_symbol struct minimal_symbol *demangled_hash_next; -/* True if this symbol is of some data type. */ + /* True if this symbol is of some data type. */ bool data_p () const; @@ -708,43 +700,38 @@ struct minimal_symbol #define MSYMBOL_HAS_SIZE(msymbol) ((msymbol)->has_size + 0) #define MSYMBOL_TYPE(msymbol) (msymbol)->type -#define MSYMBOL_VALUE(symbol) (symbol)->mginfo.value.ivalue +#define MSYMBOL_VALUE(symbol) (symbol)->value.ivalue /* The unrelocated address of the minimal symbol. */ -#define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0) +#define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0) /* The relocated address of the minimal symbol, using the section offsets from OBJFILE. */ #define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \ - ((symbol)->mginfo.value.address \ - + ANOFFSET ((objfile)->section_offsets, ((symbol)->mginfo.section))) + ((symbol)->value.address \ + + ANOFFSET ((objfile)->section_offsets, ((symbol)->section))) /* For a bound minsym, we can easily compute the address directly. */ #define BMSYMBOL_VALUE_ADDRESS(symbol) \ MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym) #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value) \ - ((symbol)->mginfo.value.address = (new_value)) -#define MSYMBOL_VALUE_BYTES(symbol) (symbol)->mginfo.value.bytes -#define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->mginfo.value.block -#define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->mginfo.value.chain -#define MSYMBOL_LANGUAGE(symbol) (symbol)->mginfo.language -#define MSYMBOL_SECTION(symbol) (symbol)->mginfo.section + ((symbol)->value.address = (new_value)) +#define MSYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes +#define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block +#define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain +#define MSYMBOL_LANGUAGE(symbol) (symbol)->language +#define MSYMBOL_SECTION(symbol) (symbol)->section #define MSYMBOL_OBJ_SECTION(objfile, symbol) \ - (((symbol)->mginfo.section >= 0) \ - ? (&(((objfile)->sections)[(symbol)->mginfo.section])) \ + (((symbol)->section >= 0) \ + ? (&(((objfile)->sections)[(symbol)->section])) \ : NULL) #define MSYMBOL_NATURAL_NAME(symbol) \ - (symbol_natural_name (&(symbol)->mginfo)) -#define MSYMBOL_LINKAGE_NAME(symbol) (symbol)->mginfo.name + (symbol_natural_name (symbol)) +#define MSYMBOL_LINKAGE_NAME(symbol) (symbol)->name #define MSYMBOL_PRINT_NAME(symbol) \ (demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol)) #define MSYMBOL_DEMANGLED_NAME(symbol) \ - (symbol_demangled_name (&(symbol)->mginfo)) -#define MSYMBOL_SET_LANGUAGE(symbol,language,obstack) \ - (symbol_set_language (&(symbol)->mginfo, (language), (obstack))) + (symbol_demangled_name (symbol)) #define MSYMBOL_SEARCH_NAME(symbol) \ - (symbol_search_name (&(symbol)->mginfo)) -#define MSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \ - symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name, \ - (objfile)->per_bfd) + (symbol_search_name (symbol)) #include "minsyms.h"