From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: printing pointers to global (data) variable on Windows...
Date: Mon, 20 Aug 2012 15:09:00 -0000 [thread overview]
Message-ID: <20120820150849.GQ2798@adacore.com> (raw)
In-Reply-To: <20120817231554.GF2798@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 307 bytes --]
> 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
[-- Attachment #2: 0001-WIP-Minimal-symbols-with-no-size-info.patch --]
[-- Type: text/x-diff, Size: 5923 bytes --]
From 9ddc3d640a76b98814d6599327406f25535fe3bb Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
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;
}
\f
/* 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
next prev parent reply other threads:[~2012-08-20 15:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 15:23 Joel Brobecker
2012-08-16 20:07 ` Tom Tromey
2012-08-16 22:45 ` Joel Brobecker
2012-08-17 14:23 ` Tom Tromey
2012-08-17 23:16 ` Joel Brobecker
2012-08-20 15:09 ` Joel Brobecker [this message]
2012-08-20 17:50 ` Tom Tromey
2012-08-21 15:28 ` Joel Brobecker
2012-08-20 17:48 ` Tom Tromey
2012-08-21 15:36 ` Joel Brobecker
2012-09-05 14:44 ` Joel Brobecker
2012-09-06 1:28 ` asmwarrior
2012-09-06 1:44 ` Joel Brobecker
2012-09-06 2:03 ` asmwarrior
2012-09-10 19:08 ` Tom Tromey
2012-09-10 22:13 ` Joel Brobecker
2012-09-11 13:49 ` Tom Tromey
2012-09-11 21:27 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120820150849.GQ2798@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox