aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
AgeCommit message (Collapse)AuthorFilesLines
2021-03-02Rewrite GNAT-encoded fixed point types in DWARF readerTom Tromey1-64/+21
gdb currently supports two different styles of fixed-point. The original style, where fixed point types are "GNAT encoded", is handled primarily in the Ada code. The newer style, encoded using DWARF, is handled by the core of gdb. This patch changes gdb to read the GNAT encodings in the DWARF reader as well. This removes some code and unifies the two paths. As a result, GNAT-encoded fixed-point now works a bit better. One possible drawback of this change is that, if someone uses stabs, then fixed-point might now stop working. I consider stabs to be fully obsolete, though, so I don't intend to address this. gdb/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * ada-lang.c (cast_from_gnat_encoded_fixed_point_type) (cast_to_gnat_encoded_fixed_point_type): Remove. (ada_value_cast, ada_evaluate_subexp): Update. (gnat_encoded_fixed_point_type_info) (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Remove. * ada-lang.h (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Don't declare. * ada-typeprint.c (print_gnat_encoded_fixed_point_type): Remove. (ada_print_type): Update. * ada-valprint.c (ada_value_print_num): Update. * dwarf2/read.c (ada_get_gnat_encoded_number) (ada_get_gnat_encoded_ratio): New functions. (finish_fixed_point_type): Use them. Add parameters. (GNAT_FIXED_POINT_SUFFIX): New define. (gnat_encoded_fixed_point_type_info): New function. (read_base_type): Handle gnat encodings. gdb/testsuite/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points.exp: Remove most special cases for minimal encodings.
2021-02-11gdb: Remove arm-symbianelf supportAlan Modra1-2/+1
Since it has gone from bfd/. * arm-symbian-tdep.c: Delete. * NEWS: Mention arm-symbian removal. * Makefile.in: Remove arm-symbian-tdep entries. * configure.tgt: Remove arm*-*-symbianelf*. * doc/gdb.texinfo: Remove mention of SymbianOS. * osabi.c (gdb_osabi_names): Remove "Symbian". * osabi.h (enum gdb_osabi): Remove GDB_OSABI_SYMBIAN. * testsuite/gdb.base/ending-run.exp: Remove E32Main handling. * testsuite/gdb.ada/catch_ex_std.exp: Remove arm*-*-symbianelf* handling. * testsuite/gdb.base/dup-sect.exp: Likewise. * testsuite/gdb.base/long_long.exp: Likewise. * testsuite/gdb.base/solib-weak.exp: Likewise. * testsuite/gdb.guile/scm-section-script.exp: Likewise. * testsuite/gdb.python/py-section-script.exp: Likewise. * testsuite/lib/dwarf.exp: Likewise. * testsuite/lib/gdb.exp: Likewise.
2021-01-28[gdb/testsuite] Fix gdb.ada/out_of_line_in_inlined.exp with -m32 and gcc-10Tom de Vries1-2/+1
When running test-case gdb.ada/out_of_line_in_inlined.exp with target board unix/-m32 on a system with gcc-10 default compiler, we run into: ... (gdb) break foo_o224_021.child1.child2^M Breakpoint 1 at 0x804ba59: foo_o224_021.child1.child2. (3 locations)^M (gdb) FAIL: gdb.ada/out_of_line_in_inlined.exp: scenario=all: \ break foo_o224_021.child1.child2 ... The test does not expect the "3 locations" part. Fix this by using gdb_breakpoint instead of gdb_test. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-01-28 Tom de Vries <tdevries@suse.de> * gdb.ada/out_of_line_in_inlined.exp: Use gdb_breakpoint.
2021-01-25Fix fixed-point regression with recent GCCTom Tromey3-0/+12
A recent version of GCC changed how fixed-point types are described. For example, a denominator in one test case now looks like: GNU_denominator (exprloc) [ 0] implicit_value: 16 byte block: 00 00 b8 9d 0d 69 55 a0 01 00 00 00 00 00 00 00 ... the difference being that this now uses exprloc and emits a DW_OP_implicit_value for the 16-byte block. (DWARF 5 still uses DW_FORM_data16.) This change was made here: https://gcc.gnu.org/pipermail/gcc-patches/2020-December/560897.html This patch updates gdb to handle this situation. Note that, before GCC 11, this test would not give the same answer. Earlier versions of GCC fell back to GNAT encodings for this case. gdb/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (get_mpz): New function. (get_dwarf2_rational_constant): Use it. gdb/testsuite/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points.exp: Add regression test. * gdb.ada/fixed_points/fixed_points.adb (FP5_Var): New variable. * gdb.ada/fixed_points/pck.adb (Delta5, FP5_Type): New.
2021-01-25Specially handle array contexts in Ada expression resolutionTom Tromey1-0/+5
A user noticed that the Ada expression code in gdb did not automatically disambiguate an enumerator in an array context. That is, an expression like "print array(enumerator)" is not ambiguous, even if "enumerator" is declared in multiple enumerations, because the correct one can be found by examining the array's index type. This patch changes the Ada expression resolution code to handle this case. gdb/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * ada-lang.c (resolve_subexp): Handle array context. gdb/testsuite/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * gdb.ada/local-enum.exp: Add enumerator resolution test.
2021-01-25Add test case for symbol menu for local enumeratorsTom Tromey2-0/+111
Ada will normally present a menu to the user to allow manual disambiguation of symbols. The AdaCore internal GDB had a bug that prevented this from happening. Although this bug is not in the FSF GDB, it seemed worthwhile to write a test case to ensure this. gdb/testsuite/ChangeLog 2021-01-25 Tom Tromey <tromey@adacore.com> * gdb.ada/local-enum.exp: New file. * gdb.ada/local-enum/local.adb: New file.
2021-01-08Pass void_context_p to parse_expressionTom Tromey4-0/+121
An earlier patch pointed out that nothing in GDB sets void_context_p when parsing an expression. This patch fixes this omission. "print" and "call" differ in that the former will print a value that has void type, while the latter will not. AdaCore has had a patch for a long time that uses this distinction to help with overload resolution. In particular, in a "call" context, a procedure will be chosen, while in a "print" context, a zero-argument function will be chosen instead. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-01-08 Tom Tromey <tromey@adacore.com> * parse.c (parse_expression): Add void_context_p parameter. Use parse_exp_in_context. * printcmd.c (print_command_1): Change voidprint to bool. Pass to parse_expression. (print_command, call_command): Update. * expression.h (parse_expression): Add void_context_p parameter. gdb/testsuite/ChangeLog 2021-01-08 Tom Tromey <tromey@adacore.com> * gdb.ada/voidctx/pck.adb: New file. * gdb.ada/voidctx/pck.ads: New file. * gdb.ada/voidctx/voidctx.adb: New file. * gdb.ada/voidctx.exp: New file.
2021-01-07Fix regression in Ada aggregate assignmentTom Tromey1-0/+3
A recent upstream patch of mine caused a regression in aggregate assignment. The bug was that add_component_interval didn't properly update the array contents in one resize case. I found furthermore that there was no test case that would provoke this failure. This patch fixes the bug and introduces a test. gdb/ChangeLog 2021-01-07 Tom Tromey <tromey@adacore.com> * ada-lang.c (add_component_interval): Start loop using vector's updated size. gdb/testsuite/ChangeLog 2021-01-07 Tom Tromey <tromey@adacore.com> * gdb.ada/assign_arr.exp: Add 'others' test.
2021-01-06Fix fixed-point binary operation type handlingTom Tromey3-0/+23
Testing showed that gdb was not correctly handling some fixed-point binary operations correctly. Addition and subtraction worked by casting the result to the type of left hand operand. So, "fixed+int" had a different type -- and different value -- from "int+fixed". Furthermore, for multiplication and division, it does not make sense to first cast both sides to the fixed-point type. For example, this can prevent "f * 1" from yielding "f", if 1 is not in the domain of "f". Instead, this patch changes gdb to use the value. (This is somewhat different from Ada semantics, as those can yield a "universal fixed point".) This includes a new test case. It is only run in "minimal" mode, as the old-style fixed point works differently, and is obsolete, so I have no plans to change it. gdb/ChangeLog 2021-01-06 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>: Do not cast result. * valarith.c (fixed_point_binop): Handle multiplication and division specially. * valops.c (value_to_gdb_mpq): New function. (value_cast_to_fixed_point): Use it. gdb/testsuite/ChangeLog 2021-01-06 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points/pck.ads (Delta4): New constant. (FP4_Type): New type. (FP4_Var): New variable. * gdb.ada/fixed_points/fixed_points.adb: Update. * gdb.ada/fixed_points.exp: Add tests for binary operators.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker641-641/+641
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-12-18Run fixed_points.exp with -fgnat-encodings=minimalTom Tromey1-61/+73
This changes the test case gdb.ada/fixed_points.exp to also be run with -fgnat-encodings=minimal. This change pointed out that the test case had a few incorrect expected outputs; these are fixed as well. Note that the Overprecise_Object test only uses the non-legacy output with GCC trunk. gdb/testsuite/ChangeLog 2020-12-18 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points.exp: Also run with -fgnat-encodings=minimal. Update expected output.
2020-12-14[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlibTom de Vries1-2/+1
When running test-case gdb.base/info-shared.exp, I see in gdb.log: ... Executing on host: \ gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c ... The -fPIC comes from the test-case: ... if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ [list additional_flags=-fPIC]] != "" } { ... but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib. The proc gdb_compile_shlib adds the -fpic or similar dependent on platform and compiler. However, in some cases it doesn't add anything, which is probably why all those test-case pass -fPIC. Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and ensuring that gdb_compile_shlib takes care of adding it, if required. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-12-14 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to pass -fPIC. * gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib. * gdb.base/break-probes.exp: Same. * gdb.base/ctxobj.exp: Same. * gdb.base/dso2dso.exp: Same. * gdb.base/global-var-nested-by-dso.exp: Same. * gdb.base/info-shared.exp: Same. * gdb.base/jit-reader-simple.exp: Same. * gdb.base/print-file-var.exp: Same. * gdb.base/skip-solib.exp: Same. * gdb.btrace/dlopen.exp: Same.
2020-12-14Handle block-local names for AdaTom Tromey2-2/+31
GNAT can generate a mangled name with "B_N" (where N is a number) in the middle, like "hello__B_1__fourth.0". This is used for names local to a block. Multiple levels of block-local name can also occur, a possibility that was neglected by v1 of this patch. This patch changes gdb to handle these names. The wild name matcher is updated a straightforward way. The full matcher is rewritten. The hash function is updated to ensure that this works. This version does not seem to have the performance problems that affected v1. In particular, the previously-slow "bt" problem has been fixed. gdb/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * dictionary.c (language_defn::search_name_hash): Ignore "B". * ada-lang.c (advance_wild_match): Ignore "B". (full_match): Remove. (do_full_match): Rewrite. gdb/testsuite/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * gdb.ada/nested.exp: Add new tests. * gdb.ada/nested/hello.adb (Fourth, Fifth): New procedures.
2020-12-13[gdb/testsuite] Handle ada in gdb_compile_shlibTom de Vries1-18/+3
The single test-case in the testsuite that creates an ada shared library is gdb.ada/catch_ex_std.exp. The test-case does use gdb_compile_shlib, but with a few tweaks that make sure things are properly handled for ada. Move the ada-specific code to gdb_compile_shlib, such that gdb_compile_sh can be used for ada shared libs without tweaks. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-12-13 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_compile_shlib): Handle ada. * gdb.ada/catch_ex_std.exp: Use gdb_compile_shlib to compile from source to shared lib. Add ada to options.
2020-12-13[gdb/testsuite] Avoid gnatbind/gnatlink in gdb.ada/catch_ex_std.expTom de Vries1-48/+23
There's a single test-case in the testsuite that explicitly calls gnatbind and gnatlink: gdb.ada/catch_ex_std.exp. Instead, use gnatmake and pass specific gnatbind and gnatlink options using gnatmake passthrough options -bargs and -largs. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-12-13 Tom de Vries <tdevries@suse.de> * gdb.ada/catch_ex_std.exp: Use gnatmake -bargs and -largs instead of calling gnatbind and gnatlink.
2020-12-08[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp for -m32Tom de Vries1-2/+4
When running test-case gdb.ada/mi_task_arg.exp with target board unix/-m32, I run into: ... (gdb) ^M Expecting: ^(-stack-list-arguments 1[^M ]+)?(\^done,stack-args=\[ \ frame={level="0",args=\[\]}, \ frame={level="1",args=\[{name="<_task>",value="0x[0-9A-Fa-f]+"}\]}, \ frame={level="2",args=\[({name="self_id",value="0x[0-9A-Fa-f]+"})?\]},.*[^M ]+[(]gdb[)] ^M [ ]*) -stack-list-arguments 1^M ^done,stack-args=[ \ frame={level="0",args=[]}, \ frame={level="1",args=[{name="<_task>",value="0x808abf0"}]}, \ frame={level="2",args=[{name="self_id",value="<optimized out>"}]}, \ frame={level="3",args=[]},frame={level="4",args=[]}]^M (gdb) ^M FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output) ... The problem is that we're expecting a $hex for the value of self_id, but instead get <optimized out>. Looking at the debug info for self_id: ... <1><12a1f>: Abbrev Number: 84 (DW_TAG_subprogram) <12a20> DW_AT_name : system__tasking__stages__task_wrapper ... <2><12a35>: Abbrev Number: 61 (DW_TAG_formal_parameter) <12a36> DW_AT_name : self_id <12a40> DW_AT_location : 0x459e (location list) ... it refers to location information here: ... 0000459e 08053060 080531ac (DW_OP_fbreg: 0) 000045aa 0805327c 080532a5 (DW_OP_fbreg: 0) 000045b6 08053320 08053324 (DW_OP_fbreg: 0) ... while the pc used to retrieve the location information is 0x080531c5: ... $ gdb -batch outputs/gdb.ada/mi_task_arg/task_switch \ -ex "break 57" -ex run -ex bt ... #0 task_switch.break_me () at task_switch.adb:57 #1 0x0804aaae in task_switch.caller (<_task>=0x808abf0) \ at task_switch.adb:51 #2 0x080531c5 in system.tasking.stages.task_wrapper \ (self_id=<optimized out>) at s-tassta.adb:1295 ... which indeed falls outside of the ranges listed in the location info. Fix this by accepting <optimized out> as valid value of self_id. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-12-08 Tom de Vries <tdevries@suse.de> * gdb.ada/mi_task_arg.exp: Accept <optimized out> as valid value of self_id.
2020-11-23[gdb/testsuite] Fix minimal encodings KPASSesTom de Vries3-6/+9
With current master I see a couple of KPASSes: ... KPASS: gdb.ada/enum_idx_packed.exp: scenario=minimal: ptype small \ (PRMS minimal encodings) ... KPASS: gdb.ada/mod_from_name.exp: scenario=minimal: print xp \ (PRMS minimal encodings) KPASS: gdb.ada/pckd_arr_ren.exp: scenario=minimal: print var \ (PRMS minimal encodings) ... The corresponding setup_kfail is called for everything before gnat 11. However, the test-cases also PASS for me with gnat-4.8, gnat-7.5.0 and gnat-8.4.0. Fix the KPASSes by limiting the setup_kfail to gnat 9 and 10. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-11-23 Tom de Vries <tdevries@suse.de> * gdb.ada/enum_idx_packed.exp: Limit setup_kfail to gnat 9 and 10. * gdb.ada/mod_from_name.exp: Same. * gdb.ada/pckd_arr_ren.exp: Same.
2020-11-15Add support for fixed-point type comparison operatorsJoel Brobecker1-1/+1
This patch adds support for binary comparison operators with fixed-point type values. gdb/ChangeLog: * valarith.c (fixed_point_binop): Add BINOP_EQUAL and BINOP_LESS handling. (value_less): Add fixed-point handling. gdb/testsuite/ChangeLog: * gdb.ada/fixed_cmp.exp: Add -fgnat-encodings=minimal testing. * gdb.dwarf2/dw2-fixed-point.c (pck__fp1_var2): New global. (main): Add reference to pck__fp1_var2. * gdb.dwarf2/dw2-fixed-point.exp: Add comparison operator testing.
2020-11-15Add ptype support for DWARF-based fixed-point typesJoel Brobecker1-0/+36
Note that the ptype information printed for types described via pure DWARF debug info is slightly less informative as the one printed when the information is encoded in the type's name, via the GNAT encoding. As a result, the output in the case of DWARF-described fixed point types is slightly different. In pratice, this is no real loss because the information not available in DWARF has no bearing on how the type is actually stored in memory. gdb/ChangeLog: * ada-typeprint.c (ada_print_type): Add handing of fixed-point range types. * c-typeprint.c (c_type_print_varspec_prefix) (c_type_print_varspec_suffix, c_type_print_base_1): Add TYPE_CODE_FIXED_POINT handling. * p-typeprint.c (pascal_type_print_varspec_prefix) (pascal_type_print_varspec_suffix): Likewise. * typeprint.c (print_type_fixed_point): New function. * typeprint.h (print_type_fixed_point): Add declaration. gdb/testsuite/ChangeLog: * gdb.ada/fixed_points.exp: Add ptype tests. * gdb.dwarf2/dw2-fixed-point.exp: Likewise.
2020-11-15Add support for printing value of DWARF-based fixed-point type objectsJoel Brobecker5-15/+86
This commit introduces a new kind of type, meant to describe fixed-point types, using a new code added specifically for this purpose (TYPE_CODE_FIXED_POINT). It then adds handling of fixed-point base types in the DWARF reader. And finally, as a first step, this commit adds support for printing the value of fixed-point type objects. Note that this commit has a known issue: Trying to print the value of a fixed-point object with a format letter (e.g. "print /x NAME") causes the wrong value to be printed because the scaling factor is not applied. Since the fix for this issue is isolated, and this is not a regression, the fix will be made in a pach of its own. This is meant to simplify review and archeology. Also, other functionalities related to fixed-point type handling (ptype, arithmetics, etc), will be added piecemeal as well, for the same reasons (faciliate reviews and archeology). Related to this, the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test program with -fgnat-encodings=all, so as to force the use of GNAT encodings, rather than rely on the compiler's default to use them. The intent is to enhance this testcase to also test the pure DWARF approach using -fgnat-encodings=minimal as soon as the corresponding suport gets added in. Thus, the modification to the testcase is made in a way that it prepares this testcase to be tested in both modes. gdb/ChangeLog: * ada-valprint.c (ada_value_print_1): Add fixed-point type handling. * dwarf2/read.c (get_dwarf2_rational_constant) (get_dwarf2_unsigned_rational_constant, finish_fixed_point_type) (has_zero_over_zero_small_attribute): New functions. read_base_type, set_die_type): Add fixed-point type handling. * gdb-gdb.py.in: Add fixed-point type handling. * gdbtypes.c: #include "gmp-utils.h". (create_range_type, set_type_code): Add fixed-point type handling. (init_fixed_point_type): New function. (is_integral_type, is_scalar_type): Add fixed-point type handling. (print_fixed_point_type_info): New function. (recursive_dump_type, copy_type_recursive): Add fixed-point type handling. (fixed_point_type_storage): New typedef. (fixed_point_objfile_key): New static global. (allocate_fixed_point_type_info, is_fixed_point_type): New functions. (fixed_point_type_base_type, fixed_point_scaling_factor): New functions. * gdbtypes.h: #include "gmp-utils.h". (enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum. (union type_specific) <fixed_point_info>: New field. (struct fixed_point_type_info): New struct. (INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros. (init_fixed_point_type, is_fixed_point_type) (fixed_point_type_base_type, fixed_point_scaling_factor) (allocate_fixed_point_type_info): Add declarations. * valprint.c (generic_val_print_fixed_point): New function. (generic_value_print): Add fixed-point type handling. * value.c (value_as_address, unpack_long): Add fixed-point type handling. gdb/testsuite/ChangeLog: * gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all. * gdb.ada/fixed_points.exp: Add fixed-point variables printing tests. * gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb: New files. * gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck. * gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp: New files.
2020-11-10Fix bug in gdb.ada/bias.expTom Tromey2-6/+6
While working on a different bug in the Ada support, I found that the gdb.ada/bias.exp test is slightly incorrect. In particular, it is using a range type, which it then overflows during an operation. This patch changes the test so that the computed values remain in range. gdb/testsuite/ChangeLog 2020-11-10 Tom Tromey <tromey@adacore.com> * gdb.ada/bias.exp: Update. * gdb.ada/bias/bias.adb (X): Change value.
2020-11-04Handle __XVL fields in Ada type printingTom Tromey2-18/+6
Sometimes the Ada compiler will emit an "__XVL" name for a field. The Ada compiler describes: -- Second, the variable-length fields themselves are represented by -- replacing the type by a special access type. The designated type of -- this access type is the original variable-length type, and the fact -- that this field has been transformed in this way is signalled by -- encoding the field name as: -- field___XVL Currently gdb describes such fields as having "access" type, but this is inaccurate. This patch changes gdb to avoid printing "access" in this case. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-typeprint.c (ada_print_type): Handle __XVL fields. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/funcall_ref.exp: Update. * gdb.ada/var_rec_arr.exp: Update.
2020-11-04Print Ada type name in more casesTom Tromey3-0/+113
In some cases the name of an Ada type cannot be decoded by decoded_type_name. For example, the name "p__complex_variable_record_type__T9s" in the included test case is rejected due to the "T". This causes ptype to display the full contents of a record type -- when in fact the name is available and ought to be printed. Fixing this in decoded_type_name isn't possible because the "__T" name is not the real name of the type -- it is just a compiler-assigned name of convenience. This patch fixes the problem by using the resolved type's name when the original type's name isn't suitable. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-typeprint.c (ada_print_type): Handle __T types. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/rec_ptype.exp: New file. * gdb.ada/rec_ptype/main.adb: New file. * gdb.ada/rec_ptype/p.ads: New file.
2020-11-04Recognize names of array typesTom Tromey3-0/+6
With -fgnat-encodings=minimal, Gnat will emit DW_TAG_array_type that has a name -- and this is the only time the name is emitted for the type. (For comparison, in C a typedef would be emitted in this situation.) This patch changes gdb to recognize the name of an array type. This is limited to Ada, to avoid any potential problems if some rogue DWARF happens to name an array type in some other language, and to avoid loading unnecessary partial DIEs. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (add_partial_symbol, process_die): Handle DW_TAG_array_type. (is_type_tag_for_partial): Add "lang" parameter. (load_partial_dies, new_symbol): Handle DW_TAG_array_type. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/tick_length_array_enum_idx.exp: Add ptype test. * gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb (PT_Full): New variable. * gdb.ada/tick_length_array_enum_idx/pck.adb (Full_PT): New type.
2020-11-04Use bit stride when taking slice of arrayTom Tromey4-0/+137
Testing with -fgnat-encodings=minimal showed that the Ada code failed to use the bit stride of an array when taking a slice. This patch fixes the oversight. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_slice_from_ptr): Use bit size. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/array_of_variant.exp: New file. * gdb.ada/array_of_variant/p.adb: New file. * gdb.ada/array_of_variant/pck.ads: New file. * gdb.ada/array_of_variant/pck.adb: New file.
2020-11-04Only use stride for final element typeTom Tromey3-0/+13
A DWARF array type may specify a stride. Currently, the DWARF reader applies this stride to every dimension of an array. However, this seems incorrect to me -- only the innermost array ought to use the stride, while outer arrays should compute a stride based on the size of the inner arrays. This patch arranges to apply the stride only to the innermost array type. This fixes a bug noticed when running some Ada tests with -fgnat-encodings=minimal. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (read_array_type): Only apply stride to innermost array. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/enum_idx_packed.exp: Add test. * gdb.ada/enum_idx_packed/foo.adb (Multi_Access): New variable. * gdb.ada/enum_idx_packed/pck.ads (Short) (Multi_Dimension, Multi_Dimension_Access): New types.
2020-11-04Fix bit strides for -fgnat-encodings=minimalTom Tromey1-41/+80
With -fgnat-encodings=minimal, the enum_idx_packed.exp test will fail. In this test case, we have an array (with dynamic length) of arrays, and the inner array has a bit stride. In this situation, the outer array's bit stride must be updated to account for the entire bit length of the inner array. Here, again, some tests must be kfail'd when an older version of GNAT is in use. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdbtypes.c (update_static_array_size): Handle bit stride. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/enum_idx_packed.exp: Test two forms of -fgnat-encodings.
2020-11-04Resolve dynamic type in ada_value_struct_eltTom Tromey4-13/+45
An internal AdaCore test case showed that gdb mishandled a case of assigning to an array element in a packed array inside a variant record. This problem can only be seen with -fgnat-encodings=minimal, which isn't yet widely used. This patch fixes the bug, and also updates an existing test to check this case. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_struct_elt): Resolve dynamic type. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/set_pckd_arr_elt.exp: Also test -fgnat-encodings=minimal. Add tests. * gdb.ada/set_pckd_arr_elt/foo.adb (Foo): Add VA variable. Call Update_Small a second time. * gdb.ada/set_pckd_arr_elt/pck.adb (New_Variant): New function. * gdb.ada/set_pckd_arr_elt/pck.ads (Buffer, Variant) (Variant_Access): New types. (New_Variant): Declare.
2020-11-04Reject slicing a packed arrayTom Tromey1-0/+1
In Ada mode, gdb rejects slicing a packed array. However, with -fgnat-encodings=minimal, gdb will instead print incorrect results. This patch changes gdb to also reject slicing a packed array in this mode. FWIW I believe that this rejection is a gdb limitation. Removing it looked complicated, though, and meanwhile my main goal for the time being is to bring the DWARF encodings up to par with Gnat encodings. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_is_any_packed_array_type): New function. (ada_evaluate_subexp) <case TERNOP_SLICE>: Use it. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/mod_from_name.exp: Test printing slice.
2020-11-04Synthesize array descriptors with -fgnat-encodings=minimalTom Tromey16-282/+363
When -fgnat-encodings=minimal, the compiler will avoid the special GNAT-specific "encodings" format, and instead emit ordinary DWARF as much as possible. When emitting DWARF for thick pointers to arrays, the compiler emits something like: <1><11db>: Abbrev Number: 7 (DW_TAG_array_type) <11dc> DW_AT_name : (indirect string, offset: 0x1bb8): string <11e0> DW_AT_data_location: 2 byte block: 97 6 (DW_OP_push_object_address; DW_OP_deref) <11e3> DW_AT_type : <0x1173> <11e7> DW_AT_sibling : <0x1201> <2><11eb>: Abbrev Number: 8 (DW_TAG_subrange_type) <11ec> DW_AT_type : <0x1206> <11f0> DW_AT_lower_bound : 6 byte block: 97 23 8 6 94 4 (DW_OP_push_object_address; DW_OP_plus_uconst: 8; DW_OP_deref; DW_OP_deref_size: 4) <11f7> DW_AT_upper_bound : 8 byte block: 97 23 8 6 23 4 94 4 (DW_OP_push_object_address; DW_OP_plus_uconst: 8; DW_OP_deref; DW_OP_plus_uconst: 4; DW_OP_deref_size: 4) If you read between the lines, the "array" is actually a structure with two elements. One element is a pointer to the array data, and the other structure describes the bounds of the array. However, the compiler doesn't emit this explicitly, but instead hides it behind these location expressions. gdb can print such objects, but currently there is no way to construct one. So, this patch adds some code to the DWARF reader to recognize this construct, and then synthesize an array descriptor. This descriptor is then handled by the existing Ada code. Internally, we've modified GCC to emit the structure type explicitly (we will of course be sending this upstream). In this case, the array still has the DW_AT_data_location, though. This patch also modifies gdb to ignore the data location in this case -- this is preferred because the location only serves to confuse the Ada code that already knows where to find the data. In the future I hope to move some of this handling to the gdb core, so that Ada-specific hacks are not needed; however I have not yet done this. Because parallel types are not emitted with -fgnat-encodings=minimal, some changes to the Ada code were also required. The change ina ada-valprint.c was needed to avoid infinite recursion when trying to print a constrained packed array. And, there didn't seem to be any need for a recursive call here -- the value could simply be returned instead. Finally, gdb.ada/frame_arg_lang.exp no longer works in C mode, because we drop back to the structure approach now. As mentioned earlier, future work should probably fix this again; meanwhile, this doesn't seem to be a big problem, because it is what is currently done (users as a rule don't use -fgnat-encodings=minimal -- which is what I am ultimately trying to fix). Note that a couple of tests have an added KFAIL. Some -fgnat-encodings=minimal changes have landed in GNAT, and you need something very recent to pass all the tests. I'm using git gcc to accomplish this. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (recognize_bound_expression) (quirk_ada_thick_pointer): New functions. (read_array_type): Call quirk_ada_thick_pointer. (set_die_type): Add "skip_data_location" parameter. (quirk_ada_thick_pointer): New function. (process_structure_scope): Call quirk_ada_thick_pointer. * ada-lang.c (ada_is_unconstrained_packed_array_type) (decode_packed_array_bitsize): Handle thick pointers without parallel types. (ada_is_gnat_encoded_packed_array_type): Rename from ada_is_packed_array_type. (ada_is_constrained_packed_array_type): Update. * ada-valprint.c (ada_val_print_gnat_array): Remove. (ada_value_print_1): Use ada_get_decoded_value. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/O2_float_param.exp: Test different -fgnat-encodings values. * gdb.ada/access_to_unbounded_array.exp: Test different -fgnat-encodings values. * gdb.ada/big_packed_array.exp: Test different -fgnat-encodings values. * gdb.ada/arr_enum_idx_w_gap.exp: Test different -fgnat-encodings values. * gdb.ada/array_ptr_renaming.exp: Test different -fgnat-encodings values. * gdb.ada/array_of_variable_length.exp: Test different -fgnat-encodings values. * gdb.ada/arrayparam.exp: Test different -fgnat-encodings values. * gdb.ada/arrayptr.exp: Test different -fgnat-encodings values. * gdb.ada/frame_arg_lang.exp: Revert -fgnat-encodings=minimal change. * gdb.ada/mi_string_access.exp: Test different -fgnat-encodings values. * gdb.ada/mod_from_name.exp: Test different -fgnat-encodings values. * gdb.ada/out_of_line_in_inlined.exp: Test different -fgnat-encodings values. * gdb.ada/packed_array.exp: Test different -fgnat-encodings values. * gdb.ada/pckd_arr_ren.exp: Test different -fgnat-encodings values. * gdb.ada/unc_arr_ptr_in_var_rec.exp: Test different -fgnat-encodings values. * gdb.ada/variant_record_packed_array.exp: Test different -fgnat-encodings values.
2020-11-04Fix decoding of multi-dimensional constrained packed arraysTom Tromey4-2/+122
Printing a multi-dimensional constrained packed array in Ada would not show the correct values. The bug here is that, when decoding the type of such an array, only the innermost dimension's element bitsize would be correct. For outer dimensions, the bitsize must account for the size of each sub-array, but this was not done. This patch fixes the problem by arranging to compute these sizes after decoding the array type. I've included a bit more test case than is strictly necessary -- the current test here was derived from an internal test, and this patch brings the two into sync. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (recursively_update_array_bitsize): New function. (decode_constrained_packed_array_type): Call it. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/enum_idx_packed.exp: Add tests. * gdb.ada/enum_idx_packed/foo.adb: Add variables. * gdb.ada/enum_idx_packed/pck.adb: Add functions. * gdb.ada/enum_idx_packed/pck.ads: Add types, function declarations.
2020-11-01avoid unwarranted assumption in gdb.ada/fixed_points/fixed_points.adbJoel Brobecker1-2/+1
The test program being used declares a fixed-point type (Base_Fixed_Point_Type) Base_Fixed_Point_Type whose (scaled) range is System.Min_Int .. System.Max_Int. is an unwarranted assumption because the range is implementation-defined. It means the compiler is therefore free to reject that declaration. We noticed this while one of my coworkers was working on enhancing GNAT to support 128bit integers. The bulk of the work has been done, but one side-effect is that there is a small gap in this particular area where the compiler is now rejecting this code. We will eventually plug that gap, but in meantime, since the testcase itself doesn't really need such a large range, this commit simply adjusts the test program to use hard-coded bounds for the range whose value are more reasonable. gdb/testsuite/ChangeLog: * gdb.ada/fixed_points/fixed_points.adb: Replace use of System.Min_Int and System.Max_Int with smaller hardcoded constants.
2020-10-28[gdb/testsuite] Fix re-read FAILs with -readnowTom de Vries1-0/+8
When running the testsuite with target board readnow, we run into: ... FAIL: gdb.ada/exec_changed.exp: start second FAIL: gdb.ada/exec_changed.exp: start just first FAIL: gdb.base/reread.exp: opts= "" "" : run to foo() second time FAIL: gdb.base/reread.exp: opts= "" "" : second pass: run to foo() second time FAIL: gdb.base/reread.exp: opts= "-fPIE" "ldflags=-pie" : \ run to foo() second time FAIL: gdb.base/reread.exp: opts= "-fPIE" "ldflags=-pie" : second pass: \ run to foo() second time ... These are FAILs due to PR26800. Mark these as KFAILs. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-28 Tom de Vries <tdevries@suse.de> * gdb.ada/exec_changed.exp: Add KFAILs for -readnow. * gdb.base/reread.exp: Same.
2020-10-26Don't inherit range-type signed-ness from underlying typeTom Tromey4-0/+113
A recent commit changed gdb to inherit the signed-ness of a range type from its underlying type: commit cfabbd351a174406fd5aa063303f5c8bf9266bbc Author: Tom Tromey <tom@tromey.com> Date: Sat Oct 17 11:41:59 2020 -0600 Make range types inherit signed-ness from base type This passed testing -- but unfortunately, additional testing at AdaCore showed that this change was incorrect. GNAT, at least, can emit an unsigned range type whose underlying type is signed. This patch reverts the code change from the above. I chose not to reintroduce the FIXME comments, because now we know that they are incorrect. Instead, this patch also adds a comment to create_range_type. A new test case is included as well. 2020-10-26 Tom Tromey <tromey@adacore.com> * gdbtypes.c (create_range_type): Revert previous patch. Add comment. gdb/testsuite/ChangeLog 2020-10-26 Tom Tromey <tromey@adacore.com> * gdb.ada/unsigned_range/foo.adb: New file. * gdb.ada/unsigned_range/pack.adb: New file. * gdb.ada/unsigned_range/pack.ads: New file. * gdb.ada/unsigned_range.exp: New file.
2020-10-14[gdb/testsuite] Fix gdb.ada/mi_catch_ex{,_hand}.exp FAILsTom de Vries2-0/+2
The test-case gdb.ada/mi_catch_ex.exp tests two scenarios. The two scenarios are separated by: - a mi_run_to_main (before commit b75d55d4d2 "Eliminate mi_run_to_main, introduce mi_clean_restart") - a mi_runto_main (after that commit) The now removed mi_run_to_main contained a mi_delete_breakpoints, while mi_runto_main does not, which causes FAILs in the second scenario. Fix this by adding the missing mi_delete_breakpoints in the test-case, and likewise in gdb.ada/mi_catch_ex_hand.exp. Reg-tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-14 Tom de Vries <tdevries@suse.de> PR testsuite/26732 * gdb.ada/mi_catch_ex.exp: Do mi_delete_breakpoints before running scenario 2. * gdb.ada/mi_catch_ex_hand.exp: Same.
2020-10-13Eliminate mi_run_to_main, introduce mi_clean_restartPedro Alves13-107/+29
Since we now have mi_runto_main which is like runto_main, eliminate mi_run_to_main, in favor of a new MI clean_restart counterpart -- mi_clean_restart -- and mi_runto_main. This makes MI testcases look a bit more like CLI testcases. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_clean_restart): New. (mi_run_to_main): Delete. All callers adjust to use mi_clean_restart / mi_runto_main. Change-Id: I34920bab4fea1f23fb752928c2969c1f6ad714b6
2020-10-13'runto main' -> 'runto_main' throughoutPedro Alves2-2/+2
This commit does 's/runto main/runto_main/g' throughout. gdb/testsuite/ChangeLog: * gdb.ada/fun_in_declare.exp: Use "runto_main" instead of "runto main". * gdb.ada/small_reg_param.exp: Likewise. * gdb.arch/powerpc-d128-regs.exp: Likewise. * gdb.base/annota1.exp: Likewise. * gdb.base/anon.exp: Likewise. * gdb.base/breakpoint-in-ro-region.exp: Likewise. * gdb.base/dprintf-non-stop.exp: Likewise. * gdb.base/dprintf.exp: Likewise. * gdb.base/gdb11530.exp: Likewise. * gdb.base/gdb11531.exp: Likewise. * gdb.base/gnu_vector.exp: Likewise. * gdb.base/interrupt-noterm.exp: Likewise. * gdb.base/memattr.exp: Likewise. * gdb.base/step-over-syscall.exp: Likewise. * gdb.base/watch-cond-infcall.exp: Likewise. * gdb.base/watch-read.exp: Likewise. * gdb.base/watch-vfork.exp: Likewise. * gdb.base/watch_thread_num.exp: Likewise. * gdb.base/watchpoint-stops-at-right-insn.exp: Likewise. * gdb.guile/scm-frame-inline.exp: Likewise. * gdb.linespec/explicit.exp: Likewise. * gdb.opt/inline-break.exp: Likewise. * gdb.python/py-frame-inline.exp: Likewise. * gdb.reverse/break-precsave.exp: Likewise. * gdb.reverse/break-reverse.exp: Likewise. * gdb.reverse/consecutive-precsave.exp: Likewise. * gdb.reverse/consecutive-reverse.exp: Likewise. * gdb.reverse/finish-precsave.exp: Likewise. * gdb.reverse/finish-reverse.exp: Likewise. * gdb.reverse/fstatat-reverse.exp: Likewise. * gdb.reverse/getresuid-reverse.exp: Likewise. * gdb.reverse/i386-precsave.exp: Likewise. * gdb.reverse/i386-reverse.exp: Likewise. * gdb.reverse/i386-sse-reverse.exp: Likewise. * gdb.reverse/i387-env-reverse.exp: Likewise. * gdb.reverse/i387-stack-reverse.exp: Likewise. * gdb.reverse/insn-reverse.exp: Likewise. * gdb.reverse/machinestate-precsave.exp: Likewise. * gdb.reverse/machinestate.exp: Likewise. * gdb.reverse/pipe-reverse.exp: Likewise. * gdb.reverse/readv-reverse.exp: Likewise. * gdb.reverse/recvmsg-reverse.exp: Likewise. * gdb.reverse/rerun-prec.exp: Likewise. * gdb.reverse/s390-mvcle.exp: Likewise. * gdb.reverse/solib-precsave.exp: Likewise. * gdb.reverse/solib-reverse.exp: Likewise. * gdb.reverse/step-precsave.exp: Likewise. * gdb.reverse/step-reverse.exp: Likewise. * gdb.reverse/time-reverse.exp: Likewise. * gdb.reverse/until-precsave.exp: Likewise. * gdb.reverse/until-reverse.exp: Likewise. * gdb.reverse/waitpid-reverse.exp: Likewise. * gdb.reverse/watch-precsave.exp: Likewise. * gdb.reverse/watch-reverse.exp: Likewise. * gdb.threads/kill.exp: Likewise. * gdb.threads/tid-reuse.exp: Likewise. Change-Id: I70f457253836019880b4d7fb981936afa56724c2
2020-10-09Fix bit offset regressionTom Tromey2-5/+8
The type-safe attribute patch introduced a regression that can occur when the DW_AT_bit_offset value is negative. This can happen with some Ada programs. This patch fixes the problem. It also fixes a minor oddity in the existing scalar storage test -- this test was intended to assign a smaller number of bits to the field. 2020-10-09 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (dwarf2_add_field): Handle signed offsets. gdb/testsuite/ChangeLog 2020-10-09 Tom Tromey <tromey@adacore.com> * gdb.ada/scalar_storage/storage.adb (Another_Range): New type. (Rec): Add field. Fix range. * gdb.ada/scalar_storage.exp: Update.
2020-09-02Do not auto-dereference null pointers in Ada MI varobjTom Tromey3-11/+25
The Ada varobj code automatically dereferences access types. This is often handy, but it also does so for null pointers -- showing children with empty values. These children are weird, but even weirder when a variant type is involved, because only the non-varying parts of the type are displayed. This behavior conflicts a bit with my ongoing quest to move the Ada code to use DWARF rather than gnat encodings, in that reproducing this behavior with the DWARF code seems rather hacky. So, this patch instead changes the Ada varobj code so that it does not automatically dereference null pointers. As this patch only affects Ada, and it was already reviewed internally by Joel, I am checking it in. 2020-09-02 Tom Tromey <tromey@adacore.com> * ada-varobj.c (ada_varobj_get_ptr_number_of_children): Return 0 for null pointers. (ada_varobj_adjust_for_child_access): Special-case null pointers. gdb/testsuite/ChangeLog 2020-09-02 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_var_access.exp: Test children of access variable. * gdb.ada/mi_var_access/mi_access.adb: Add new stop markers. * gdb.ada/mi_var_array.exp: Update.
2020-08-17Fix MI crash with Ada string accessTom Tromey4-0/+138
I happened to notice that using -var-create at a certain spot in an Ada program caused a crash. This happens because ada_get_decoded_value can return NULL -- in particular, deeper in the code it can hit this return in ada_type_of_array: descriptor = desc_bounds (arr); if (value_as_long (descriptor) == 0) return NULL; This patch avoids the crash by handling this NULL return. gdb/ChangeLog 2020-08-17 Tom Tromey <tromey@adacore.com> * ada-varobj.c (ada_varobj_decode_var): Handle case where ada_get_decoded_value returns NULL. gdb/testsuite/ChangeLog 2020-08-17 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_var_access.exp: New file. * gdb.ada/mi_var_access/mi_access.adb: New file. * gdb.ada/mi_var_access/pck.adb: New file. * gdb.ada/mi_var_access/pck.ads: New file.
2020-08-13Add skip_ada_tests to more Ada testcasesPedro Alves144-0/+288
This adds missing skip_ada_tests checks to Ada testcases, using the exact same pattern the existing files that do check it use. gdb/testsuite/ChangeLog: * gdb.ada/access_tagged_param.exp: Check skip_ada_tests. * gdb.ada/access_to_packed_array.exp: Likewise. * gdb.ada/access_to_unbounded_array.exp: Likewise. * gdb.ada/addr_arith.exp: Likewise. * gdb.ada/arr_acc_idx_w_gap.exp: Likewise. * gdb.ada/arr_arr.exp: Likewise. * gdb.ada/arr_enum_idx_w_gap.exp: Likewise. * gdb.ada/array_bounds.exp: Likewise. * gdb.ada/array_of_variable_length.exp: Likewise. * gdb.ada/array_ptr_renaming.exp: Likewise. * gdb.ada/array_subscript_addr.exp: Likewise. * gdb.ada/arraydim.exp: Likewise. * gdb.ada/arrayparam.exp: Likewise. * gdb.ada/arrayptr.exp: Likewise. * gdb.ada/assign_1.exp: Likewise. * gdb.ada/assign_arr.exp: Likewise. * gdb.ada/atomic_enum.exp: Likewise. * gdb.ada/attr_ref_and_charlit.exp: Likewise. * gdb.ada/bad-task-bp-keyword.exp: Likewise. * gdb.ada/bias.exp: Likewise. * gdb.ada/boolean_expr.exp: Likewise. * gdb.ada/bp_c_mixed_case.exp: Likewise. * gdb.ada/bp_enum_homonym.exp: Likewise. * gdb.ada/bp_inlined_func.exp: Likewise. * gdb.ada/bp_on_var.exp: Likewise. * gdb.ada/bp_range_type.exp: Likewise. * gdb.ada/bp_reset.exp: Likewise. * gdb.ada/call_pn.exp: Likewise. * gdb.ada/catch_assert_if.exp: Likewise. * gdb.ada/catch_ex.exp: Likewise. * gdb.ada/catch_ex_std.exp: Likewise. * gdb.ada/char_enum.exp: Likewise. * gdb.ada/char_param.exp: Likewise. * gdb.ada/complete.exp: Likewise. * gdb.ada/cond_lang.exp: Likewise. * gdb.ada/convvar_comp.exp: Likewise. * gdb.ada/dgopt.exp: Likewise. * gdb.ada/disc_arr_bound.exp: Likewise. * gdb.ada/display_nested.exp: Likewise. * gdb.ada/dot_all.exp: Likewise. * gdb.ada/dyn_loc.exp: Likewise. * gdb.ada/dyn_stride.exp: Likewise. * gdb.ada/excep_handle.exp: Likewise. * gdb.ada/expr_delims.exp: Likewise. * gdb.ada/expr_with_funcall.exp: Likewise. * gdb.ada/exprs.exp: Likewise. * gdb.ada/fin_fun_out.exp: Likewise. * gdb.ada/fixed_cmp.exp: Likewise. * gdb.ada/formatted_ref.exp: Likewise. * gdb.ada/frame_arg_lang.exp: Likewise. * gdb.ada/frame_args.exp: Likewise. * gdb.ada/fullname_bp.exp: Likewise. * gdb.ada/fun_addr.exp: Likewise. * gdb.ada/fun_in_declare.exp: Likewise. * gdb.ada/fun_overload_menu.exp: Likewise. * gdb.ada/fun_renaming.exp: Likewise. * gdb.ada/funcall_char.exp: Likewise. * gdb.ada/funcall_param.exp: Likewise. * gdb.ada/funcall_ptr.exp: Likewise. * gdb.ada/funcall_ref.exp: Likewise. * gdb.ada/homonym.exp: Likewise. * gdb.ada/info_addr_mixed_case.exp: Likewise. * gdb.ada/info_auto_lang.exp: Likewise. * gdb.ada/info_exc.exp: Likewise. * gdb.ada/info_types.exp: Likewise. * gdb.ada/int_deref.exp: Likewise. * gdb.ada/interface.exp: Likewise. * gdb.ada/iwide.exp: Likewise. * gdb.ada/lang_switch.exp: Likewise. * gdb.ada/length_cond.exp: Likewise. * gdb.ada/maint_with_ada.exp: Likewise. * gdb.ada/mi_catch_assert.exp: Likewise. * gdb.ada/mi_catch_ex.exp: Likewise. * gdb.ada/mi_catch_ex_hand.exp: Likewise. * gdb.ada/mi_dyn_arr.exp: Likewise. * gdb.ada/mi_ex_cond.exp: Likewise. * gdb.ada/mi_exc_info.exp: Likewise. * gdb.ada/mi_interface.exp: Likewise. * gdb.ada/mi_prot.exp: Likewise. * gdb.ada/mi_ref_changeable.exp: Likewise. * gdb.ada/mi_string_access.exp: Likewise. * gdb.ada/mi_task_arg.exp: Likewise. * gdb.ada/mi_task_info.exp: Likewise. * gdb.ada/mi_var_array.exp: Likewise. * gdb.ada/mi_var_union.exp: Likewise. * gdb.ada/mi_variant.exp: Likewise. * gdb.ada/minsyms.exp: Likewise. * gdb.ada/mod_from_name.exp: Likewise. * gdb.ada/nested.exp: Likewise. * gdb.ada/null_array.exp: Likewise. * gdb.ada/optim_drec.exp: Likewise. * gdb.ada/out_of_line_in_inlined.exp: Likewise. * gdb.ada/packed_array_assign.exp: Likewise. * gdb.ada/packed_tagged.exp: Likewise. * gdb.ada/pp-rec-component.exp: Likewise. * gdb.ada/print_chars.exp: Likewise. * gdb.ada/print_pc.exp: Likewise. * gdb.ada/ptr_typedef.exp: Likewise. * gdb.ada/ptype_arith_binop.exp: Likewise. * gdb.ada/ptype_array.exp: Likewise. * gdb.ada/ptype_field.exp: Likewise. * gdb.ada/ptype_tagged_param.exp: Likewise. * gdb.ada/ptype_union.exp: Likewise. * gdb.ada/py_range.exp: Likewise. * gdb.ada/py_taft.exp: Likewise. * gdb.ada/rdv_wait.exp: Likewise. * gdb.ada/rec_comp.exp: Likewise. * gdb.ada/rec_return.exp: Likewise. * gdb.ada/ref_param.exp: Likewise. * gdb.ada/ref_tick_size.exp: Likewise. * gdb.ada/rename_subscript_param.exp: Likewise. * gdb.ada/repeat_dyn.exp: Likewise. * gdb.ada/same_component_name.exp: Likewise. * gdb.ada/same_enum.exp: Likewise. * gdb.ada/scalar_storage.exp: Likewise. * gdb.ada/set_wstr.exp: Likewise. * gdb.ada/small_reg_param.exp: Likewise. * gdb.ada/str_binop_equal.exp: Likewise. * gdb.ada/str_ref_cmp.exp: Likewise. * gdb.ada/str_uninit.exp: Likewise. * gdb.ada/sub_variant.exp: Likewise. * gdb.ada/sym_print_name.exp: Likewise. * gdb.ada/taft_type.exp: Likewise. * gdb.ada/tagged.exp: Likewise. * gdb.ada/tagged_access.exp: Likewise. * gdb.ada/task_bp.exp: Likewise. * gdb.ada/task_switch_in_core.exp: Likewise. * gdb.ada/tasks.exp: Likewise. * gdb.ada/tick_last_segv.exp: Likewise. * gdb.ada/tick_length_array_enum_idx.exp: Likewise. * gdb.ada/type_coercion.exp: Likewise. * gdb.ada/unc_arr_ptr_in_var_rec.exp: Likewise. * gdb.ada/unchecked_union.exp: Likewise. * gdb.ada/uninitialized_vars.exp: Likewise. * gdb.ada/var_arr_attrs.exp: Likewise. * gdb.ada/var_arr_typedef.exp: Likewise. * gdb.ada/var_rec_arr.exp: Likewise. * gdb.ada/variant-record.exp: Likewise. * gdb.ada/variant.exp: Likewise. * gdb.ada/variant_record_packed_array.exp: Likewise. * gdb.ada/varsize_limit.exp: Likewise. * gdb.ada/whatis_array_val.exp: Likewise. * gdb.ada/widewide.exp: Likewise. * gdb.ada/win_fu_syms.exp: Likewise.
2020-07-24[gdb/testsuite] Require gnatmake-8 for gdb.ada/mi_prot.expTom de Vries1-0/+3
With gcc-7, I run into: ... gcc -c -I./ -gnata -Isrc/gdb/testsuite/gdb.ada/mi_prot -g -lm -I- \ src/gdb/testsuite/gdb.ada/mi_prot/prot.adb^M prot.adb:21:04: info: "Obj_Type" is frozen here, aspects evaluated at this \ point^M prot.adb:23:09: visibility of aspect for "Obj_Type" changes after freeze \ point^M gnatmake: "src/gdb/testsuite/gdb.ada/mi_prot/prot.adb" compilation error^M compiler exited with status 1 ... FAIL: gdb.ada/mi_prot.exp: compilation prot.adb ... Fix this by requiring gnatmake-8 for this test-case. Tested on x86_64-linux, with gnatmake-7, gnatmake-8 and gnatmake-11. gdb/testsuite/ChangeLog: 2020-07-24 Tom de Vries <tdevries@suse.de> PR testsuite/26293 * gdb.ada/mi_prot.exp: Require gnatmake-8.
2020-07-22Fix crash in -stack-list-argumentsTom Tromey4-0/+134
-stack-list-arguments will crash when stopped in an Ada procedure that has an argument with a certain name ("_objectO" -- which can only be generated by the compiler). The bug occurs because lookup_symbol will fail in this case. This patch changes -stack-list-arguments to mirror what is done with arguments elsewhere. (As an aside, I don't understand why this lookup is even needed, but I assume it is some stabs thing?) In the longer term I think it would be good to share this code between MI and the CLI. However, due to the upcoming release, I preferred a more local fix. gdb/ChangeLog 2020-07-22 Tom Tromey <tromey@adacore.com> * mi/mi-cmd-stack.c (list_args_or_locals): Use lookup_symbol_search_name. gdb/testsuite/ChangeLog 2020-07-22 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_prot.exp: New file. * gdb.ada/mi_prot/pkg.adb: New file. * gdb.ada/mi_prot/pkg.ads: New file. * gdb.ada/mi_prot/prot.adb: New file.
2020-07-08Use read_memory in ada_exception_message_1Tom Tromey2-2/+2
Testing using the internal AdaCore test suite showed a regression from the target string reading changes. In particular, now ada_exception_message_1 can get the wrong answer in some cases. In particular, when an Ada exception catchpoint is hit, sometimes the exception name will be incorrect. The case I was seeing changed from the correct: Catchpoint 2, CONSTRAINT_ERROR (catch C_E) at [...] to: Catchpoint 2, CONSTRAINT_ERROR (catch C_EE) at [...] I was not able to reproduce this failure with the Fedora gnat. Perhaps it is related to some local change to gnat; I do not know. Meanwhile, because ada_exception_message_1 knows the length of the string to read, we can use read_memory here. This fixes the bug. I've updated the test suite to at least exercise this code path. However, as mentioned above, the new test does not actually provoke the failure. gdb/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_exception_message_1): Use read_memory. gdb/testsuite/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * gdb.ada/catch_ex/foo.adb: Pass string to raise. * gdb.ada/catch_ex.exp: Examine catchpoint text.
2020-06-10[gdb/symtab] Enable ada .gdb_indexTom de Vries1-5/+0
Currently the .gdb_index is not enabled for ada executables (PR24713). Fix this by adding the required support in write_psymbols, similar to how that is done for .debug_names in debug_names::insert. Tested on x86_64-linux, with native and target board cc-with-gdb-index. gdb/ChangeLog: 2020-06-10 Tom de Vries <tdevries@suse.de> PR ada/24713 * dwarf2/index-write.c (struct mapped_symtab): Add m_string_obstack. (write_psymbols): Enable .gdb_index for ada. * dwarf2/read.c: Remove comment stating .gdb_index is unsupported for ada. gdb/testsuite/ChangeLog: 2020-06-10 Tom de Vries <tdevries@suse.de> * gdb.ada/ptype_union.exp: Remove PR24713 workaround.
2020-05-26Handle indexing Ada arrays with enum indicesTom Tromey1-0/+3
In Ada, like C, an enum can assign values to the constants. However, unlike C (or any other language supported by gdb), the enum type can also be used as the range of an array. In this case, the user's code references the enum constants, but the compiler translates these to the position of the constant in the enum. So for example one might write: type Enum_With_Gaps is ( LIT0, LIT1, LIT2, LIT3, LIT4 ); for Enum_With_Gaps use ( LIT0 => 3, LIT1 => 5, LIT2 => 8, LIT3 => 13, LIT4 => 21 ); Then index an array like "array(LIT3)" -- but this will be the 4th element in an array of 5 elements, not the 13th element in an array of 19 (assuming I did the math right) elements. gdb supports this to some degree, with the only missing piece being indexing into such an array. This patch implements this missing feature, and also fixes an existing bug, which is that in some situations I believe gdb would mis-compute the resulting array's length. The approach taken here is to try to integrate this feature into the core of gdb. My view is that much of the Ada support should be better integrated with gdb, rather than being "on the side". This, I think, would help avoid code duplication at least. So, I try to take steps toward this goal when possible. Because other languages generally don't allow the user to specify the index type of an array, I simply made the core of gdb unconditionally apply discrete_position when computing the range of such an array. This is a no-op for ordinary types, but applies the enum value-to-position transformation for TYPE_CODE_ENUM. gdb/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_print_array_index): Change type. Call val_atr. (ada_value_ptr_subscript): Don't call pos_atr on the lower bound. (val_atr): New function. (value_val_atr): Use it. * ada-valprint.c (print_optional_low_bound): Change low bound handling for enums. (val_print_packed_array_elements): Don't call discrete_position. * gdbtypes.c (get_discrete_bounds) <TYPE_CODE_RANGE>: Call discrete_position for enum types. * language.c (default_print_array_index): Change type. * language.h (struct language_defn) <la_print_array_index>: Add index_type parameter, change type of index_value. (LA_PRINT_ARRAY_INDEX): Add index_type parameter. (default_print_array_index): Update. * valprint.c (maybe_print_array_index): Don't call value_from_longest. Update. (value_print_array_elements): Don't call discrete_position. gdb/testsuite/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * gdb.ada/arr_acc_idx_w_gap.exp: Add tests.
2020-05-26Fix bugs in 'val and 'pos with range typesTom Tromey3-2/+9
In Ada, the 'val and 'pos attributes can be used to map from an enumeration constant to its position in the enum and vice versa. These operators did not work properly when the type in question was a subrange of an enum type with "holes". gdb/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE. * gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE. gdb/testsuite/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests. * gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New type. * gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New variable.
2020-05-20Fix array_char_idx.expTom Tromey1-1/+3
Newer versions of GCC can statically initialize an array in the array_char_idx.exp test case. This leads to a spurious failure. This patch fixes the problem by having the test case recognize both possible results. I'm checking this in. gdb/testsuite/ChangeLog 2020-05-20 Tom Tromey <tromey@adacore.com> * gdb.ada/array_char_idx.exp: Recognize initialized array.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.adaTom de Vries3-16/+25
In gdb.ada we have these duplicate test-names: ... DUPLICATE: gdb.ada/catch_ex.exp: continuing to program completion DUPLICATE: gdb.ada/mi_catch_ex.exp: breakpoint at main DUPLICATE: gdb.ada/mi_catch_ex.exp: mi runto main DUPLICATE: gdb.ada/mi_catch_ex_hand.exp: breakpoint at main DUPLICATE: gdb.ada/mi_catch_ex_hand.exp: mi runto main ... Fix these using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.ada/catch_ex.exp: Use with_test_prefix. * gdb.ada/mi_catch_ex.exp: Same. * gdb.ada/mi_catch_ex_hand.exp: Same.
2020-05-11[gdb/testsuite] Change kfail into xfail in gdb.ada/packed_tagged.expTom de Vries1-2/+2
Test-case gdb.ada/packed_tagged.exp contains a kfail: ... setup_kfail "gnat compiler bug" *-*-* ... Kfails are used to indicate problems in gdb, xfails are used to indicate problems in the environment. A bug in the gnat compiler is a problem in the environment rather than gdb. Fix this by changing the kfail into an xfail. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> * gdb.ada/packed_tagged.exp: Change kfail into xfail.