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: Wed, 05 Sep 2012 14:44:00 -0000 [thread overview]
Message-ID: <20120905144406.GC2853@adacore.com> (raw)
In-Reply-To: <20120821153627.GS2798@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]
Hello,
Here is a new version of the patch implementing Tom's idea of
flagging size-less minimal symbols... On platforms where he size
isn't set, i's a bit of a give-and-take, fixing the problem reported,
at the cost of finding some symbols that we were previously fitering
out (by luck or accident). I think it's for the best.
gdb/ChangeLog:
* symtab.h (struct minimal_symbol) [has_size]: New field.
(MSYMBOL_SIZE): Adjust to forbid macro from being used as lvalue.
(SET_MSYMBOL_SIZE, MSYMBOL_HAS_SIZE): New macros.
* printcmd.c (build_address_symbolic): Only filter out zero-sized
minimal symbols if the symbol's size is actually known.
* minsyms.c (prim_record_minimal_symbol_full): Adjust setting
of msymbol's size field. Add comment.
(install_minimal_symbols): Use SET_MSYMBOL_SIZE to set the
minimal symbol size.
* elfread.c (elf_symtab_read, elf_rel_plt_read): Use
SET_MSYMBOL_SIZE to set the minimal symbol size.
Tested on all of AdaCore's supported platforms via our testsuite.
Also tested on x86_64-linux using the official testsuite.
OK to commit?
Thanks,
--
Joel
[-- Attachment #2: 0001-Name-of-symbol-missing-when-printing-global-variable.patch --]
[-- Type: text/x-diff, Size: 5295 bytes --]
From b70bf2abc01142b7d93c6fd834d9926bdc9eea9c Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 22 Aug 2012 20:29:13 +0200
Subject: [PATCH] Name of symbol missing when printing global variable's address
The build_address_symbolic funnction filters out data symbols if
their size is set to zero. But the problem is that the COFF symbol
table (for instance) does not provide any size information, leaving
the size to its default value of zero, thus always triggering
the filter.
This shows up when trying to print the address of a global variable
when debugging a Windows executable, for instance.
gdb/ChangeLog:
* symtab.h (struct minimal_symbol) [has_size]: New field.
(MSYMBOL_SIZE): Adjust to forbid macro from being used as lvalue.
(SET_MSYMBOL_SIZE, MSYMBOL_HAS_SIZE): New macros.
* printcmd.c (build_address_symbolic): Only filter out zero-sized
minimal symbols if the symbol's size is actually known.
* minsyms.c (prim_record_minimal_symbol_full): Adjust setting
of msymbol's size field. Add comment.
(install_minimal_symbols): Use SET_MSYMBOL_SIZE to set the
minimal symbol size.
* elfread.c (elf_symtab_read, elf_rel_plt_read): Use
SET_MSYMBOL_SIZE to set the minimal symbol size.
---
gdb/elfread.c | 6 +++---
gdb/minsyms.c | 6 ++++--
gdb/printcmd.c | 1 +
gdb/symtab.h | 14 +++++++++++++-
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 76120a3..041d8cf 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -348,6 +348,11 @@ struct minimal_symbol
unsigned int target_flag_1 : 1;
unsigned int target_flag_2 : 1;
+ /* Nonzero iff the size of the minimal symbol has been set.
+ Symbol size information can sometimes not be determined, because
+ the object file format may not carry that piece of information. */
+ unsigned int has_size : 1;
+
/* Minimal symbols with the same hash key are kept on a linked
list. This is the link. */
@@ -361,7 +366,14 @@ 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_SIZE(msymbol) ((msymbol)->size + 0)
+#define SET_MSYMBOL_SIZE(msymbol, sz) \
+ do \
+ { \
+ (msymbol)->size = sz; \
+ (msymbol)->has_size = 1; \
+ } while (0)
+#define MSYMBOL_HAS_SIZE(msymbol) ((msymbol)->has_size + 0)
#define MSYMBOL_TYPE(msymbol) (msymbol)->type
#include "minsyms.h"
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/minsyms.c b/gdb/minsyms.c
index 1070fff..2bad947 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -937,7 +937,9 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
MSYMBOL_TYPE (msymbol) = ms_type;
MSYMBOL_TARGET_FLAG_1 (msymbol) = 0;
MSYMBOL_TARGET_FLAG_2 (msymbol) = 0;
- MSYMBOL_SIZE (msymbol) = 0;
+ /* Do not use the SET_MSYMBOL_SIZE macro to initialize the size,
+ as it would also set the has_size flag. */
+ msymbol->size = 0;
/* The hash pointers must be cleared! If they're not,
add_minsym_to_hash_table will NOT add this msymbol to the hash table. */
@@ -1233,7 +1235,7 @@ install_minimal_symbols (struct objfile *objfile)
SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0;
MSYMBOL_TARGET_FLAG_1 (&msymbols[mcount]) = 0;
MSYMBOL_TARGET_FLAG_2 (&msymbols[mcount]) = 0;
- MSYMBOL_SIZE (&msymbols[mcount]) = 0;
+ SET_MSYMBOL_SIZE (&msymbols[mcount], 0);
MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown;
SYMBOL_SET_LANGUAGE (&msymbols[mcount], language_unknown);
diff --git a/gdb/elfread.c b/gdb/elfread.c
index f3967d7..516cbd0 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -570,7 +570,7 @@ elf_symtab_read (struct objfile *objfile, int type,
elf_sym = (elf_symbol_type *) sym->udata.p;
if (elf_sym)
- MSYMBOL_SIZE(msym) = elf_sym->internal_elf_sym.st_size;
+ SET_MSYMBOL_SIZE (msym, elf_sym->internal_elf_sym.st_size);
msym->filename = filesymname;
gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
@@ -594,7 +594,7 @@ elf_symtab_read (struct objfile *objfile, int type,
sym->section, objfile);
if (mtramp)
{
- MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym);
+ SET_MSYMBOL_SIZE (mtramp, MSYMBOL_SIZE (msym));
mtramp->created_by_gdb = 1;
mtramp->filename = filesymname;
gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp);
@@ -689,7 +689,7 @@ elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
1, address, mst_slot_got_plt, got_plt,
objfile);
if (msym)
- MSYMBOL_SIZE (msym) = ptr_size;
+ SET_MSYMBOL_SIZE (msym, ptr_size);
}
do_cleanups (back_to);
--
1.7.1
next prev parent reply other threads:[~2012-09-05 14:44 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
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 [this message]
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=20120905144406.GC2853@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