From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56790 invoked by alias); 7 Jun 2018 16:20:07 -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 56621 invoked by uid 89); 7 Jun 2018 16:20:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 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.2 spammy= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Jun 2018 16:20:04 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway32.websitewelcome.com (Postfix) with ESMTP id C761519EF5 for ; Thu, 7 Jun 2018 11:20:02 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QxdqfzWKXSjJAQxdqfZNTP; Thu, 07 Jun 2018 11:20:02 -0500 X-Authority-Reason: nr=8 Received: from 75-166-19-45.hlrn.qwest.net ([75.166.19.45]:33878 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fQxdq-000Qfd-BB; Thu, 07 Jun 2018 11:20:02 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v3 3/6] Introduce partial_symbol::address Date: Thu, 07 Jun 2018 16:20:00 -0000 Message-Id: <20180607161955.9800-4-tom@tromey.com> In-Reply-To: <20180607161955.9800-1-tom@tromey.com> References: <20180607161955.9800-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fQxdq-000Qfd-BB X-Source-Sender: 75-166-19-45.hlrn.qwest.net (bapiya.Home) [75.166.19.45]:33878 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-06/txt/msg00172.txt.bz2 This introduces a partial_symbol::address method. This method takes an objfile argument. This is necessary so that we can later relocate a partial symbol at its point of use. It also adds a "raw" form of the accessor, to compute the unrelocated value; and a method to be used for setting the field. Note that the new method doesn't actually perform any relocation yet. That will come in a subsequent patch. However, the comments are written to reflect the intended, rather than the temporary, semantics. gdb/ChangeLog 2018-06-07 Tom Tromey * psympriv.h (struct partial_symbol) : New methods. * psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol) (fixup_psymbol_section, relocate_psymtabs): Update. (print_partial_symbols): Add 'objfile' parameter. Update. (dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map): Update. --- gdb/ChangeLog | 10 ++++++++++ gdb/psympriv.h | 20 ++++++++++++++++++++ gdb/psymtab.c | 43 +++++++++++++++++++++++-------------------- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/gdb/psympriv.h b/gdb/psympriv.h index f3cb0a6ba15..ec2d9923c1b 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -44,6 +44,26 @@ struct partial_symbol : public general_symbol_info return nullptr; } + /* Return the unrelocated address of this partial symbol. */ + CORE_ADDR raw_address () const + { + return value.address; + } + + /* Return the address of this partial symbol, relocated according to + the offsets provided in OBJFILE. */ + CORE_ADDR address (struct objfile *objfile) const + { + return value.address; + } + + /* Set the address of this partial symbol. The address must be + unrelocated. */ + void set_address (CORE_ADDR addr) + { + value.address = addr; + } + /* Name space code. */ ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS; diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 9a06d68f91e..58df3c69a78 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -267,7 +267,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, object's symbol table. */ p = find_pc_sect_psymbol (objfile, tpst, pc, section); if (p != NULL - && (p->value.address == BMSYMBOL_VALUE_ADDRESS (msymbol))) + && (p->address (objfile) == BMSYMBOL_VALUE_ADDRESS (msymbol))) return tpst; /* Also accept the textlow value of a psymtab as a @@ -275,7 +275,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, symbol tables with line information but no debug symbols (e.g. those produced by an assembler). */ if (p != NULL) - this_addr = p->value.address; + this_addr = p->address (objfile); else this_addr = tpst->textlow; @@ -333,7 +333,8 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, object's symbol table. */ p = find_pc_sect_psymbol (objfile, pst, pc, section); if (p == NULL - || (p->value.address != BMSYMBOL_VALUE_ADDRESS (msymbol))) + || (p->address (objfile) + != BMSYMBOL_VALUE_ADDRESS (msymbol))) goto next; } @@ -425,10 +426,10 @@ find_pc_sect_psymbol (struct objfile *objfile, if (p->domain == VAR_DOMAIN && p->aclass == LOC_BLOCK - && pc >= p->value.address - && (p->value.address > best_pc + && pc >= p->address (objfile) + && (p->address (objfile) > best_pc || (psymtab->textlow == 0 - && best_pc == 0 && p->value.address == 0))) + && best_pc == 0 && p->address (objfile) == 0))) { if (section != NULL) /* Match on a specific section. */ { @@ -437,7 +438,7 @@ find_pc_sect_psymbol (struct objfile *objfile, section)) continue; } - best_pc = p->value.address; + best_pc = p->address (objfile); best = p; } } @@ -448,10 +449,10 @@ find_pc_sect_psymbol (struct objfile *objfile, if (p->domain == VAR_DOMAIN && p->aclass == LOC_BLOCK - && pc >= p->value.address - && (p->value.address > best_pc + && pc >= p->address (objfile) + && (p->address (objfile) > best_pc || (psymtab->textlow == 0 - && best_pc == 0 && p->value.address == 0))) + && best_pc == 0 && p->address (objfile) == 0))) { if (section != NULL) /* Match on a specific section. */ { @@ -460,7 +461,7 @@ find_pc_sect_psymbol (struct objfile *objfile, section)) continue; } - best_pc = p->value.address; + best_pc = p->address (objfile); best = p; } } @@ -486,7 +487,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) case LOC_STATIC: case LOC_LABEL: case LOC_BLOCK: - addr = psym->value.address; + addr = psym->address (objfile); break; default: /* Nothing else will be listed in the minsyms -- no use looking @@ -813,13 +814,15 @@ psym_relocate (struct objfile *objfile, { fixup_psymbol_section (psym, objfile); if (psym->section >= 0) - psym->value.address += ANOFFSET (delta, psym->section); + psym->set_address (psym->raw_address () + + ANOFFSET (delta, psym->section)); } for (partial_symbol *psym : objfile->static_psymbols) { fixup_psymbol_section (psym, objfile); if (psym->section >= 0) - psym->value.address += ANOFFSET (delta, psym->section); + psym->set_address (psym->raw_address () + + ANOFFSET (delta, psym->section)); } objfile->psymbol_map.clear (); @@ -883,7 +886,7 @@ psym_forget_cached_source_info (struct objfile *objfile) } static void -print_partial_symbols (struct gdbarch *gdbarch, +print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile, struct partial_symbol **p, int count, const char *what, struct ui_file *outfile) { @@ -967,7 +970,7 @@ print_partial_symbols (struct gdbarch *gdbarch, break; } fputs_filtered (", ", outfile); - fputs_filtered (paddress (gdbarch, (*p)->value.address), outfile); + fputs_filtered (paddress (gdbarch, (*p)->raw_address ()), outfile); fprintf_filtered (outfile, "\n"); p++; } @@ -1032,13 +1035,13 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, } if (psymtab->n_global_syms > 0) { - print_partial_symbols (gdbarch, + print_partial_symbols (gdbarch, objfile, &objfile->global_psymbols[psymtab->globals_offset], psymtab->n_global_syms, "Global", outfile); } if (psymtab->n_static_syms > 0) { - print_partial_symbols (gdbarch, + print_partial_symbols (gdbarch, objfile, &objfile->static_psymbols[psymtab->statics_offset], psymtab->n_static_syms, "Static", outfile); } @@ -1475,7 +1478,7 @@ psym_fill_psymbol_map (struct objfile *objfile, if (psym->aclass == LOC_STATIC) { - CORE_ADDR addr = psym->value.address; + CORE_ADDR addr = psym->raw_address (); if (seen_addrs->find (addr) == seen_addrs->end ()) { seen_addrs->insert (addr); @@ -1718,7 +1721,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name, { struct partial_symbol psymbol; - psymbol.value.address = coreaddr; + psymbol.set_address (coreaddr); psymbol.section = -1; psymbol.domain = domain; psymbol.aclass = theclass; -- 2.13.6