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

Simon Marchi simark@simark.ca
Tue Nov 10 23:00:21 GMT 2020


On 2020-11-08 1:30 a.m., Joel Brobecker wrote:
> diff --git a/gdb/testsuite/gdb.ada/fixed_points.exp b/gdb/testsuite/gdb.ada/fixed_points.exp
> index 655ee95..6455d35 100644
> --- a/gdb/testsuite/gdb.ada/fixed_points.exp
> +++ b/gdb/testsuite/gdb.ada/fixed_points.exp
> @@ -55,8 +55,47 @@ gdb_test "ptype Overprecise_Object" \
>  gdb_test "print fp1_var" \
>           " = 0.25"
>
> +set test "ptype fp1_var"
> +gdb_test_multiple "$test" $test {
> +    -re "type = <1-byte fixed point \\(small = 0\\.0625\\)>\r\n$gdb_prompt $" {
> +        pass $test
> +    }
> +    -re "type = delta 0\\.1 <'small = 0\\.0625>\r\n$gdb_prompt $" {
> +        # The (legacy) output we obtain when the compiler described
> +        # our fixed point types using the GNAT encodings rather than
> +        # standard DWARF.  OK as well.
> +        pass $test
> +    }
> +}

Instead of setting a "test" variable, you can use $gdb_test_name inside
gdb_test_multiple.

> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
> index 27c549c..2e72bff 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
> @@ -142,3 +142,47 @@ gdb_test "print pck.fp1_range_var" \
>
>  gdb_test "print /x pck.fp1_range_var" \
>           " = 0x1"
> +
> +# Set the language to LANG and do a ptype test on pck__fp1_var,
> +# pck__fp2_var and pck__fp3_var, verifying that the output matches
> +# FP1_RE, FP2_RE, FP2_RE (resp.).
> +
> +proc do_ptype_test {lang fp1_re fp2_re fp3_re fp1_range_re} {
> +    with_test_prefix "$lang" {

Suggest using

  with_test_prefix "lang=$lang"

> +        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>.

> diff --git a/gdb/typeprint.h b/gdb/typeprint.h
> index 8936b9a..339c746 100644
> --- a/gdb/typeprint.h
> +++ b/gdb/typeprint.h
> @@ -151,6 +151,8 @@ class typedef_hash_table
>
>  void print_type_scalar (struct type * type, LONGEST, struct ui_file *);
>
> +void print_type_fixed_point (struct type *type, struct ui_file *stream);

For new code, IWBN to follow the standard of putting the doc in the
header file, even though the other functions in that file don't follow
it.

Simon


More information about the Gdb-patches mailing list