Re: [RFC patch]: Adjust the use of 'long' type in dwarf2.h header

Kai Tietz
2011-02-21T13:27:01Z

2011/2/21 Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>:
>  I was just wondering about all those
>  _("Text with some 0x" BFD_VMA_FMT "x\n"), adr);
> constructs:
>  If we do the translations on a 64-bit unix machine
> we will have translations for
> "Text with some 0xllx\n"
> but a mingw 64-bit executable will look for
> "Text with some 0xI64x\n"
> while a 32-bit system will look for
> "Text with some 0xlx\n"
> and in both cases, no translation will be found.
>
>  Wouldn't it be better to use something similar
> to paddress in src/gdb/utils.c
> let's call it dwarf_vma function,
> so that we have:
>  _("Text with some 0x%s\n"), dwarf_vma (adr));
> with a unique "Text with some 0x%s\n"
> string that gets internationalized correctly?
>
>
> Pierre Muller
> GDB pascal language maintainer
>
>
>> -----Message d'origine-----
>> De : gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] De la
>> part de Kai Tietz
>> Envoyé : jeudi 17 février 2011 15:22
>> À : GCC Patches; Binutils; gdb
>> Cc : Jakub Jelinek; Joel Brobecker
>> Objet : [RFC patch]: Adjust the use of 'long' type in dwarf2.h header
>>
>> Hello,
>>
>> This patch addresses issues I've seen in binutils about
>> cross-compilers and dwarf2 display via objdump -W on hosts, which have
>> sizeof (long) < target's sizeof(void *). Additionally same issue of
>> course can be seen on LLP64 targets, too.
>> Those issues are caused by the fact that the dwarf2.h header in
>> include/ is using unconditionally the type 'unsigned long' for
>> vma-scalars.
>>
>> This patch address additionally the binutils' dwarf.(c|h) files and
>> make them host bitness independent for gcc base toolchains supporting
>> the 'long long' type.
>>
>> I've tested the attached patches for gdb, binutils, and gcc on
>> i686-w64-mingw32, and x86_64-w64-mingw32 cross-toolchains hosted on
>> cygwin. And I didn't found until now regressions. Later this day I
>> want to do a regression test for linux64, too.
>>
>>
>> binutils, gdb, gcc
>>
>> ChangeLog include/
>>
>> 2011-02-17  Kai Tietz
>>
>>       * dwarf2.h (dw2_vma_t): New type.
>>       (dw2_svma_t): New type.
>>       (DW2_VMA_FMT): New macro specifying
>>       to be used width-sepecifier for printing
>>       new types.
>>
>>
>> ChangeLog binutils/
>>
>> 2011-02-17  Kai Tietz
>>
>>       * dwarf.c (read_leb128): Use dw2_vma_t instead of
>>       long type.
>>       (process_extended_line_op): Use for adr new type
>>       and print dw2 values via DW2_VMA_FMT.
>>       (fetch_indirect_string): Adjust offset's type.
>>       (decode_location_expression): Adjust argument types
>>       and uvalue type.
>>       (read_and_display_attr_value): Likewise.
>>       (read_and_display_attr): Likewise.
>>       (decode_location_expression): Adjust printf format.
>>       (process_debug_info): Likewise.
>>       (display_debug_lines_raw): Likewise.
>>       (display_debug_lines_decoded): Likewise.
>>       (display_debug_pubnames): Likewise.
>>       (display_debug_loc): Likewise.
>>       (display_debug_aranges): Likewise.
>>       * dwarf.h: Add include of dwarf2.h header and
>>       use of dw2_vma_t instead of long types.
>>       (read_leb128): Adjust return type.
>>
>>
>> Regards,
>> Kai
>>
>>
>> PS: On gdb there is at the moment in gdb/common part the include-path
>> to intl for libintl.h missing
>
>

Yes, I saw this too and it is a thorn here. But the issue about a
transformation function (like dwarf_vma) is that we have memory leaks
- as this function is to be used on some printf's more then once - as
static buffer would be overriden. Well printfs can be splitted into
smaller parts, but this then would make localization even harder.

Maybe it would be better here to remove those localizations?

Regards,
Kai

--
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination