[PATCH][PR gdb/24351] Fix wrong format specification in display_selector()
Simon Marchi
simon.marchi@polymtl.ca
Thu Mar 28 21:12:00 GMT 2019
On 2019-03-28 11:46, Jon Turney wrote:
> On 17/03/2019 18:44, Simon Marchi wrote:
>> On 2019-03-17 05:48, ÐÐ»Ð°Ð´Ð¸Ð¼Ð¸Ñ ÐаÑÑÑÑнов wrote:
>>> There are a wrong format strings in function display_selector() in
>>> file windows-nat.c. This leads to build error using Cygwin on
>>> Windows.
>>> LDT_ENTRY.HighWord is a DWORD, which is unsigned long int, so the
>>> format specification should be for long int, not simply int.
>>>
>>> gdb/ChangeLog:
>>> 2019-03-17 Vladimir Martyanov <vilgeforce@gmail.com>
>>>
>>> Â Â Â PR gdb/24351
>>> Â Â Â * windows-nat.c (display_selector): Format specifications fixed
>>>
>>> Patch and changelog files are attached
>>
>> Thanks, this LGTM. I altavista'ed and it looks like this is the right
>> thing to do to print DWORDs. It also builds fine with
>> i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc on Linux.
>
> Thanks for looking at this. But did you test this with
> x86_64-pc-cygwin? It fails to build for me:
>
>> ../../gdb/windows-nat.c: In function âint display_selector(HANDLE,
>> DWORD)â:
>> ../../gdb/windows-nat.c:1099:65: error: format â%lxâ expects argument
>> of type âlong unsigned intâ, but argument 2 has type âunsigned intâ
>> [-Werror=format=]
>> printf_filtered ("Unknown type 0x%lx",info.HighWord.Bits.Type);
>> ~~~~~~~~~~~~~~~~~~~~~~~^
>> ../../gdb/windows-nat.c:1106:74: error: format â%ldâ expects argument
>> of type âlong intâ, but argument 2 has type âunsigned intâ
>> [-Werror=format=]
>> printf_filtered ("Priviledge level = %ld. ",
>> info.HighWord.Bits.Dpl);
>
> I believe this is because, unfortunately, DWORD is not long on 64-bit
> Cygwin, because that is LP64 (See [1]).
>
> I think the only portable way to write this (short of introducing
> inttypes.h PRI_-style macros) is to explicitly cast DWORD type values
> to unsigned long or unsigned int, and use the appropriate format (e.g.
> see [2] for a similar patch I wrote for xserver)
>
> Patch attached.
>
> [1] https://cygwin.com/faq.html#faq.programming.64bitporting
> [2]
> https://cgit.freedesktop.org/xorg/xserver/commit/?id=aa83c61f510121da20b56e8f7de700193f7d16b5
Thanks for the patch, I pushed it.
Simon
More information about the Gdb-patches
mailing list