RFC: printing pointers to global (data) variable on Windows...

Joel Brobecker brobecker@adacore.com
Mon Sep 10 22:13:00 GMT 2012


> Joel> @@ -1233,7 +1235,7 @@ install_minimal_symbols (struct objfile *objfile)
> Joel>        SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0;
> Joel>        MSYMBOL_TARGET_FLAG_1 (&msymbols[mcount]) = 0;
> Joel>        MSYMBOL_TARGET_FLAG_2 (&msymbols[mcount]) = 0;
> Joel> -      MSYMBOL_SIZE (&msymbols[mcount]) = 0;
> Joel> +      SET_MSYMBOL_SIZE (&msymbols[mcount], 0);
> 
> I tend to think this hunk should not use SET_MSYMBOL_SIZE.
> Maybe it even ought to use memset instead of what it currently does.
> 
> Or, if SET_MSYMBOL_SIZE is correct here, a comment would be helpful.

Intuitively, I do not think that it really matters. But I prefer
the idea of memset-ting the whole object to zero, and it's actually
something I have been wanting to do anyways. So here are two patches.
The first one just adjusts install_minimal_symbols to use memset instead
of the various macros.

gdb/ChangeLog:

        * minsyms.c (install_minimal_symbols): Use memset to fill entire
        minimal_symbol struct object, rather than setting some of its
        fields one by one.

And the second is the initial patch, adjusted to the first one.

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.
        * elfread.c (elf_symtab_read, elf_rel_plt_read): Use
        SET_MSYMBOL_SIZE to set the minimal symbol size.

Tested on x86_64-linux. OK to apply?

Thanks!
-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-install_minimal_symbols-use-memset-instead-of-settin.patch
Type: text/x-diff
Size: 1441 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20120910/914364c8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Name-of-symbol-missing-when-printing-global-variable.patch
Type: text/x-diff
Size: 4755 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20120910/914364c8/attachment-0001.bin>


More information about the Gdb-patches mailing list