Re: [PATCH 7/9] Add ptype support for DWARF-based fixed-point types

Simon Marchi
2020-11-16T00:16:19Z

On 2020-11-15 2:09 a.m., Joel Brobecker wrote:
>>>> + gdb_test_no_output "set language $lang" \
>>>> + "set language to $lang for ptype test"
>>>> +
>>>> + gdb_test "ptype pck__fp1_var" $fp1_re
>>>> +
>>>> + gdb_test "ptype pck__fp2_var" $fp2_re
>>>> +
>>>> + gdb_test "ptype pck__fp3_var" $fp3_re
>>>> +
>>>> + if { $lang == "modula-2" || $lang == "pascal" } {
>>>> + setup_xfail "*-*-*" "not supported by language"
>>>> + }
>>>
>>> Can you give more details about this? What prevents these languages
>>> from printing <range type>? I'm confused, because as far as I can tell
>>> C doesn't support range types more than these two languages, and it's
>>> able to print <range type>.
>>
>> Both trigger the following error:
>>
>> (gdb) ptype pck__fp1_range_var
>> type = [Invalid type code in symbol table.
>>
>> It didn't seem to be worth the effort of going any further than that,
>> because I didn't didn't think either language would have fixed point
>> types.
>
> I should probably expand a bit: I tried to make the implementation
> of this feature as generic as possible, so that all current and
> future languages that provide support for these kinds of types can
> benefit from it with as little work as possible. For some reason,
> this doesn't work for M2 and Pascal, and the decision I made at
> the time was to ignore these issues on the basis that these are errors
> a real user is unlikely to hit.

My guess is that it works for C just because of this single case in its
type print function:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/c-typeprint.c;h=10631fff9a8006baf885dcd03720074d5f95f8b9;hb=5778e0dd5d7bb872398a136b6504b9b99d5ce434#l1683

If it's a matter of just adding this case to the m2 and pascal in their
type print functions, I think it would be nice simply to avoid the
special case in the test. If it's anything more complex than that, then
I agree with you that it's not worth it.

Simon