This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: printing pointers to global (data) variable on Windows...
> 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
>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;
}
/* 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