From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26234 invoked by alias); 20 Aug 2012 15:09:22 -0000 Received: (qmail 26224 invoked by uid 22791); 20 Aug 2012 15:09:16 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_HOSTKARMA_NO,TW_BJ,TW_YM X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Aug 2012 15:08:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B40411C7879; Mon, 20 Aug 2012 11:08:58 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RktMZ18qKtPd; Mon, 20 Aug 2012 11:08:58 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 63B8C1C774C; Mon, 20 Aug 2012 11:08:58 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 0391414561A; Mon, 20 Aug 2012 08:08:50 -0700 (PDT) Date: Mon, 20 Aug 2012 15:09:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: RFC: printing pointers to global (data) variable on Windows... Message-ID: <20120820150849.GQ2798@adacore.com> References: <20120816152255.GA2836@adacore.com> <87zk5umwj3.fsf@fleche.redhat.com> <20120816224524.GC2798@adacore.com> <87628hmwbr.fsf@fleche.redhat.com> <20120817231554.GF2798@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6c2NcOVqGQ03X4Wi" Content-Disposition: inline In-Reply-To: <20120817231554.GF2798@adacore.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2012-08/txt/msg00544.txt.bz2 --6c2NcOVqGQ03X4Wi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 307 > As mentioned on IRC, I just realize, now, the kind of project this is... > So, I went with the other solution, which is to mark the minimal symbols > from COFF/PE as size-less, and avoid the filtering in that case. > Attached is a patch that does that. Really attached, this time. Thanks, Tom. -- Joel --6c2NcOVqGQ03X4Wi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-WIP-Minimal-symbols-with-no-size-info.patch" Content-length: 5924 >From 9ddc3d640a76b98814d6599327406f25535fe3bb Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Sat, 18 Aug 2012 00:32:08 +0200 Subject: [PATCH] WIP: Minimal symbols with no size info. --- gdb/coff-pe-read.c | 6 ++++-- gdb/coffread.c | 5 ++++- gdb/minsyms.c | 7 ++++--- gdb/minsyms.h | 19 ++++++++++++------- gdb/printcmd.c | 1 + gdb/symtab.h | 4 ++++ 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 66c7c82..070c8f7 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -108,6 +108,7 @@ add_pe_exported_sym (char *sym_name, char *qualified_name = 0; int dll_name_len = strlen (dll_name); + struct minimal_symbol *msym; /* Generate a (hopefully unique) qualified name using the first part of the dll name, e.g. KERNEL32!AddAtomA. This matches the style @@ -125,8 +126,9 @@ add_pe_exported_sym (char *sym_name, xfree (qualified_name); /* Enter the plain name as well, which might not be unique. */ - prim_record_minimal_symbol (sym_name, vma, - section_data->ms_type, objfile); + msym = prim_record_minimal_symbol (sym_name, vma, + section_data->ms_type, objfile); + MSYMBOL_HAS_SIZE (msym) = 0; } /* Truncate a dll_name at the first dot character. */ diff --git a/gdb/coffread.c b/gdb/coffread.c index 0c7e6d9..ab8bd36 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -422,15 +422,18 @@ record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address, struct objfile *objfile) { struct bfd_section *bfd_section; + struct minimal_symbol *msym; /* We don't want TDESC entry points in the minimal symbol table. */ if (cs->c_name[0] == '@') return NULL; bfd_section = cs_to_bfd_section (cs, objfile); - return prim_record_minimal_symbol_and_info (cs->c_name, address, + msym = prim_record_minimal_symbol_and_info (cs->c_name, address, type, section, bfd_section, objfile); + MSYMBOL_HAS_SIZE (msym) = 0; + return msym; } /* coff_symfile_init () diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 1070fff..02b64ea 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -842,7 +842,7 @@ init_minimal_symbol_collection (void) /* See minsyms.h. */ -void +struct minimal_symbol * prim_record_minimal_symbol (const char *name, CORE_ADDR address, enum minimal_symbol_type ms_type, struct objfile *objfile) @@ -869,8 +869,8 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address, section = -1; } - prim_record_minimal_symbol_and_info (name, address, ms_type, - section, NULL, objfile); + return prim_record_minimal_symbol_and_info (name, address, ms_type, + section, NULL, objfile); } /* See minsyms.h. */ @@ -938,6 +938,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name, MSYMBOL_TARGET_FLAG_1 (msymbol) = 0; MSYMBOL_TARGET_FLAG_2 (msymbol) = 0; MSYMBOL_SIZE (msymbol) = 0; + MSYMBOL_HAS_SIZE (msymbol) = 1; /* See this function's documentation. */ /* The hash pointers must be cleared! If they're not, add_minsym_to_hash_table will NOT add this msymbol to the hash table. */ diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 8f0472f..76d7082 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -60,7 +60,14 @@ struct cleanup *make_cleanup_discard_minimal_symbols (void); though, to stash the pointer anywhere; as minimal symbols may be moved after creation. The memory for the returned minimal symbol is still owned by the minsyms.c code, and should not be freed. - + + By default, it is assumed that the symbol size can be determined, + which means that the "has_size" flag of the returned minimal symbol + is set to 1. But some symbol table formats such as the one used + in COFF/PE, for instance, do not include that piece of information. + In that case, the "has_size" flag of the returned symbol should be + unset. + Arguments are: NAME - the symbol's name @@ -89,13 +96,11 @@ struct minimal_symbol *prim_record_minimal_symbol_full - uses strlen to compute NAME_LEN, - passes COPY_NAME = 0, - passes SECTION = 0, - - and passes BFD_SECTION = NULL. - - This variant does not return the new symbol. */ + - and passes BFD_SECTION = NULL. */ -void prim_record_minimal_symbol (const char *, CORE_ADDR, - enum minimal_symbol_type, - struct objfile *); +struct minimal_symbol *prim_record_minimal_symbol (const char *, CORE_ADDR, + enum minimal_symbol_type, + struct objfile *); /* Like prim_record_minimal_symbol_full, but: - uses strlen to compute NAME_LEN, diff --git a/gdb/printcmd.c b/gdb/printcmd.c index d5b5b63..9e8cd65 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -680,6 +680,7 @@ build_address_symbolic (struct gdbarch *gdbarch, } if (msymbol != NULL + && MSYMBOL_HAS_SIZE (msymbol) && MSYMBOL_SIZE (msymbol) == 0 && MSYMBOL_TYPE (msymbol) != mst_text && MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc diff --git a/gdb/symtab.h b/gdb/symtab.h index 76120a3..f45f498 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -348,6 +348,9 @@ struct minimal_symbol unsigned int target_flag_1 : 1; unsigned int target_flag_2 : 1; + /* Should be zero if the size of the minimal symbol is not available. */ + unsigned int has_size : 1; + /* Minimal symbols with the same hash key are kept on a linked list. This is the link. */ @@ -362,6 +365,7 @@ struct minimal_symbol #define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1 #define MSYMBOL_TARGET_FLAG_2(msymbol) (msymbol)->target_flag_2 #define MSYMBOL_SIZE(msymbol) (msymbol)->size +#define MSYMBOL_HAS_SIZE(msymbol) (msymbol)->has_size #define MSYMBOL_TYPE(msymbol) (msymbol)->type #include "minsyms.h" -- 1.7.1 --6c2NcOVqGQ03X4Wi--