summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright year range in all GDB files.Joel Brobecker2020-01-01608-608/+608
| | | | | | gdb/ChangeLog: Update copyright year range in all GDB files.
* [PATCH] Adjust test gdb.ada/ptype_tagged_param.exp for when GNAT runtime ↵Simon Marchi2019-12-271-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | does not have debug info This test verifies that GDB correctly identifies the run-time type of "s" as being the type "Circle". However, that can only be done correctly if the GNAT runtime has been compiled and shipped with debug information, so that GDB can poke in its internal data structures. Currently the test fails when when running against a GNAT runtime without debug info. This is the case, for example, on Arch Linux using the distribution package. This patch adds a helper in lib/ada.exp to check whether the GNAT runtime has debug info or not. It then uses it in gdb.ada/ptype_tagged_param.exp to expect a different result, depending on whether we have debug info or not in the runtime. At first, I made it so we would XFAIL the test, in the absence of debug info, but then I thought that we might as well test for the output we expect in the absence of debug info instead. gdb/testsuite/ChangeLog: * lib/ada.exp (gnat_runtime_has_debug_info): New proc. * lib/gnat_debug_info_test.adb: New file. * gdb.ada/ptype_tagged_param.exp: Use gnat_runtime_has_debug_info, expect a different output if runtime does not have debug info.
* Normalize Ada ptype to use a single "?"Tom Tromey2019-12-104-0/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes -- notably with unchecked unions -- the Ada "ptype" code will print a "?" or "??" to indicate something unknown. The choice of what was printed was somewhat arbitrary, and in one case, Ada would print an empty string rather than "?". This patch normalizes the Ada code to use "?" rather than an empty string or "??". My reasoning here is that a single question mark is enough to convey unknown-ness. gdb/ChangeLog 2019-12-10 Tom Tromey <tromey@adacore.com> * ada-typeprint.c (print_choices): Use a single "?". (print_variant_part): Print "?" if the discriminant name is not known. gdb/testsuite/ChangeLog 2019-12-10 Tom Tromey <tromey@adacore.com> * gdb.ada/unchecked_union.exp: New file. * gdb.ada/unchecked_union/pck.adb: New file. * gdb.ada/unchecked_union/pck.ads: New file. * gdb.ada/unchecked_union/unchecked_union.adb: New file. * gdb-utils.exp (string_to_regexp): Also quote "?". Change-Id: I3403040780a155ffa2c44c8e6a04ba86bc810e29
* Propagate endianity to subrange typesTom Tromey2019-12-044-0/+123
| | | | | | | | | | | | | | | | | | | | A subrange type should inherit its endianity from its base type. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdbtypes.c (create_range_type): Inherit endianity from base type. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.ada/scalar_storage/storage.adb: New file. * gdb.ada/scalar_storage/pck.adb: New file. * gdb.ada/scalar_storage/pck.ads: New file. * gdb.ada/scalar_storage.exp: New file. Change-Id: I2998ab919dc28aeff097763c4242f9bfb90823a3
* Avoid crash in print_ada_task_infoTom Tromey2019-11-222-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | In MI mode, print_ada_task_info can crash in find_thread_ptid when trying to print an Ada task that is no longer alive. This patch avoids the problem by checking for this case. Because this is Ada-specific, and because Joel approved it internally, I am checking it in. gdb/ChangeLog 2019-11-22 Tom Tromey <tromey@adacore.com> * ada-tasks.c (ada_task_is_alive): Make parameter const. (print_ada_task_info): Don't try to fetch thread id if task is not alive. gdb/gdbserver/ChangeLog 2019-11-22 Tom Tromey <tromey@adacore.com> * gdb.ada/tasks.exp: Add -ada-task-info regression test. * gdb.ada/tasks/foo.adb: Add another stopping location. Change-Id: If25eae6507eebb7537eb8adbcbaa1fc1eec88f5c
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test callTom de Vries2019-10-3128-144/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurences in gdb.ada. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-31 Tom de Vries <tdevries@suse.de> * gdb.ada/array_bounds.exp: Drop superfluous 3rd argument to gdb_test. * gdb.ada/array_subscript_addr.exp: Same. * gdb.ada/arrayidx.exp: Same. * gdb.ada/arrayparam.exp: Same. * gdb.ada/arrayptr.exp: Same. * gdb.ada/boolean_expr.exp: Same. * gdb.ada/call_pn.exp: Same. * gdb.ada/complete.exp: Same. * gdb.ada/fixed_cmp.exp: Same. * gdb.ada/fun_addr.exp: Same. * gdb.ada/funcall_param.exp: Same. * gdb.ada/interface.exp: Same. * gdb.ada/mod_from_name.exp: Same. * gdb.ada/null_array.exp: Same. * gdb.ada/packed_array.exp: Same. * gdb.ada/packed_tagged.exp: Same. * gdb.ada/print_chars.exp: Same. * gdb.ada/print_pc.exp: Same. * gdb.ada/ptype_arith_binop.exp: Same. * gdb.ada/ptype_field.exp: Same. * gdb.ada/ptype_tagged_param.exp: Same. * gdb.ada/rec_return.exp: Same. * gdb.ada/ref_tick_size.exp: Same. * gdb.ada/str_ref_cmp.exp: Same. * gdb.ada/taft_type.exp: Same. * gdb.ada/tagged.exp: Same. * gdb.ada/type_coercion.exp: Same. * gdb.ada/uninitialized_vars.exp: Same. Change-Id: Ibb84a41573c7f21295f3fd42da9b96534205c5c4
* [gdb/testsuite] Fix gdb.ada/mi_task_arg.expTom de Vries2019-10-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | On openSUSE Leap 15.1, we have: ... FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output) ... The problem is that the stack-list-arguments command prints a frame argument 'self_id' for function system.tasking.stages.task_wrapper: ... frame={level="2",args=[{name="self_id",value="0x12345678"}] ... where none (args=[]) is expected. The frame argument is in fact correct. The FAIL does not show for say, fedora 30, because there the executable uses the system.tasking.stages.task_wrapper from /lib64/libgnarl-9.so. Adding "additional_flags=-bargs additional_flags=-shared additional_flags=-largs" to the flags argument of gdb_compile_ada gives us the same PASS, but installing libada7-debuginfo gets us the same FAIL again. Fix the FAIL by allowing the 'self_id' argument. Tested on x86_64-linux. Change-Id: I5aee5856fa6aeb0cc78aa4fe69deecba5b00b77a
* gdb/testsuite/ada: Handle missing debug info caseAndrew Burgess2019-10-071-7/+18
| | | | | | | | | | | | | | | | Update a test script to handle the case where missing Ada debug information means we can't catch exceptions. This was discussed on the list here: https://sourceware.org/ml/gdb-patches/2019-08/msg00607.html And is similar to code that already exists in the test scripts gdb.ada/catch_ex.exp and gdb.ada/mi_catch_ex.exp. gdb/testsuite/ChangeLog: * gdb.ada/catch_ex_std.exp: Handle being unabled to catch Ada exceptions due to missing debug information.
* Add $_ada_exception convenience variableTom Tromey2019-10-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the $_ada_exception convenience variable. It is set by the Ada exception catchpoints, and holds the address of the exception currently being thrown. This is useful because it allows more fine-grained filtering of exceptions than is possible using the existing "catch" syntax. This also simplifies Ada catchpoints somewhat; because the catchpoint must now carry the "kind", it's possible to remove many helper functions. gdb/ChangeLog 2019-10-02 Tom Tromey <tromey@adacore.com> * NEWS: Add $_ada_exception entry. * ada-lang.c (struct ada_catchpoint): Add constructor. <m_kind>: New member. (allocate_location_exception, re_set_exception): Remove "ex" parameter. (should_stop_exception): Compute $_ada_exception. (check_status_exception, print_it_exception) (print_one_exception, print_mention_exception): Remove "ex" parameter. (allocate_location_catch_exception, re_set_catch_exception) (check_status_exception, print_it_catch_exception) (print_one_catch_exception, print_mention_catch_exception) (print_recreate_catch_exception) (allocate_location_catch_exception_unhandled) (re_set_catch_exception_unhandled) (check_status_exception, print_it_catch_exception_unhandled) (print_one_catch_exception_unhandled) (print_mention_catch_exception_unhandled) (print_recreate_catch_exception_unhandled) (allocate_location_catch_assert, re_set_catch_assert) (check_status_assert, print_it_catch_assert) (print_one_catch_assert, print_mention_catch_assert) (print_recreate_catch_assert) (allocate_location_catch_handlers, re_set_catch_handlers) (check_status_handlers, print_it_catch_handlers) (print_one_catch_handlers, print_mention_catch_handlers) (print_recreate_catch_handlers): Remove. (create_ada_exception_catchpoint): Update. (initialize_ada_catchpoint_ops): Update. gdb/doc/ChangeLog 2019-10-02 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Set Catchpoints, Convenience Vars): Document $_ada_exception. gdb/testsuite/ChangeLog 2019-10-02 Tom Tromey <tromey@adacore.com> * gdb.ada/catch_ex_std.exp: Add $_ada_exception test.
* Do not expose stub types to PythonTom Tromey2019-09-264-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | dwarf2read.c will create stub types for Ada "Taft Amendment" types. These stub types can currently be exposed to Python code, where they show up as TYPE_CODE_VOID types (but that, mysteriously, can sometimes be used in other ways). While it's possible to work with such types by using strip_typedefs, this seemed unpleasant to me. This patch takes another approach instead, which is to try not to expose stub types to Python users. gdb/ChangeLog 2019-09-26 Tom Tromey <tromey@adacore.com> * python/py-type.c (type_to_type_object): Call check_typedef for stub types. gdb/testsuite/ChangeLog 2019-09-26 Tom Tromey <tromey@adacore.com> * gdb.ada/py_taft.exp: New file. * gdb.ada/py_taft/main.adb: New file. * gdb.ada/py_taft/pkg.adb: New file. * gdb.ada/py_taft/pkg.ads: New file.
* [gdb/testsuite] Require gnatmake 8 for gdb.ada/rename_subscript_param.expTom de Vries2019-09-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When running gdb.ada/rename_subscript_param.exp with gnatmake 7.4.1, we get: ... FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \ before changing its value FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \ after changing its value ... The commit last touching the test-case (afcfda091e) states: ... The test still fails with old compilers that do not properly generate debug info for this renaming: ... Fix this by requiring at least gnatmake 8 for the test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-09-14 Tom de Vries <tdevries@suse.de> PR teststuite/24599 * gdb.ada/rename_subscript_param.exp: Require gnatmake 8. * lib/ada.exp (gnatmake_version_at_least): New proc.
* Output the Ada task name in more messages.Philippe Waroquiers2019-09-122-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, we e.g. get: [Switching to task 2 "task_list(1)"] [Current task is 2 "task_list(1)"] instead of [Switching to task 2] [Current task is 2] The logic to produce the taskno optionally followed by the task name has been factorized in the task_to_str function. Task names are output between double quotes in the new messages, similarly to what GDB does for thread names. However, no quotes are put around task names in 'info tasks' Name column. This was discussed with Tom, that preferred no quotes there, while I was more in favour of visual consistency. I discussed with a few more users, which led to (exactly) 50% preferring quotes and 50% preferring no quotes :). To arrive to the decision to remove the quotes, the following "killing args" were used: * To have quotes or to not have quotes, that is the question; yes but not *THE* question :). * If there is not a clear majority that prefers quotes, better to not disturb the existing user basis for a (somewhat) irrelevant aspect. * The opinion of the reviewer has more weight. So, compared to the previous version, this version remotes the quotes in 'info tasks'. It improves the alignement of 'info tasks' output. With this patch, we get: (gdb) info task ID TID P-ID Pri State Name * 1 555555759030 48 Runnable main_task 2 555555759e30 1 48 Selective Wait mit (gdb) instead of (gdb) info task ID TID P-ID Pri State Name * 1 555555759030 48 Runnable main_task 2 555555759e30 1 48 Selective Wait mit (gdb) (e.g. the first one properly shows parent and priority under the correct header). This is version 4 of the 'task name' patch. Compared to version 3, the changes are: output task names between quotes but not in 'info tasks' gdb/ChangeLog 2019-09-12 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Announce that Ada task names are now shown at more places, and between quotes (except in info task output). * gdb/ada-tasks.c (task_to_str): New function. (display_current_task_id): Call task_to_str. (task_command_1): Likewise. (print_ada_task_info): In non-mi mode, Properly align headers and data when task-id length is > 9 (9 is the default for a 32 bits CORE_ADDR). gdb/doc/ChangeLog 2019-09-12 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Ada Tasks): Tell the task name is printed, update examples. gdb/testsuite/ChangeLog 2019-09-12 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/rdv_wait.exp: Update to new task names. * gdb.base/task_switch_in_core.exp: Likewise. * gdb.base/info_sources_base.c: Likewise.
* Fix latent bug in .debug_names file-name handlingTom Tromey2019-09-102-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | An internal Ada test case showed that the .debug_names code does not compute the same list of file names as the partial symbol reader. In particular, the partial symbol reader uses the DW_AT_name of the CU: /* Allocate a new partial symbol table structure. */ filename = dwarf2_string_attr (comp_unit_die, DW_AT_name, cu); if (filename == NULL) filename = ""; pst = create_partial_symtab (per_cu, filename); This patch changes the .debug_names reader to follow. gdb/ChangeLog 2019-09-10 Tom Tromey <tromey@adacore.com> * dwarf2read.c (dw2_get_file_names_reader): Add the CU's file name to the results. gdb/testsuite/ChangeLog 2019-09-10 Tom Tromey <tromey@adacore.com> * gdb.ada/dgopt.exp: New file. * gdb.ada/dgopt/x.adb: New file.
* Handle biased typesTom Tromey2019-09-036-1/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ada, the programmer can request that a range type with a non-zero base be stored in the minimal number of bits required for the range. This is done by biasing the values; so, for example, a range of -7..-4 may be stored as two bits with a bias of -7. This patch implements this for gdb. It is done by adding a bias to struct range_bounds and then adjusting a few spots to handle this. The test case is written to use -fgnat-encodings=minimal, but a future compiler patch will change the compiler to emit DW_AT_GNU_bias with -fgnat-encodings=gdb. It seemed good to get the gdb patch in first. Tested on x86-64 Fedora 29; plus a variety of targets using AdaCore's internal test suite. gdb/ChangeLog 2019-09-03 Tom Tromey <tromey@adacore.com> * ada-valprint.c (ada_val_print_num): Don't recurse for range types. (has_negatives): Unbias a range type bound. * dwarf2read.c (read_subrange_type): Handle DW_AT_GNU_bias. * gdbtypes.c (operator==): Handle new field. (create_range_type): Add "bias" parameter. (create_static_range_type, resolve_dynamic_range): Update. * gdbtypes.h (struct range_bounds) <bias>: New member. (create_range_type): Add bias parameter. * printcmd.c (print_scalar_formatted): Unbias range types. * value.c (unpack_long): Unbias range types. (pack_long): Bias range types. gdb/testsuite/ChangeLog 2019-09-03 Tom Tromey <tromey@adacore.com> * gdb.ada/bias.exp: New file. * gdb.ada/bias/bias.adb: New file. * gdb.ada/print_chars.exp: Add regression test. * gdb.ada/print_chars/foo.adb (My_Character): New type. (MC): New variable.
* Fix bug with character enumeration literalTom Tromey2019-08-153-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | gnat encodes character enumeration literals using a few different schemes. The gnat compiler documented the "QU" and "QW" encodings, but failed to document that a simpler encoding was used for certain characters. This patch updates gdb to handle this simple Q encoding. Note that wide character literals are still not handled. gdb/ChangeLog 2019-08-15 Tom Tromey <tromey@adacore.com> * ada-exp.y (convert_char_literal): Handle "Q%c" encoding. * ada-lang.c (ada_enum_name): Likewise. gdb/testsuite/ChangeLog 2019-08-15 Tom Tromey <tromey@adacore.com> * gdb.ada/char_enum.exp: Add regression tests. * gdb.ada/char_enum/foo.adb (Char_Enum_Type): Use '_' and '0'. (Char, Gchar): Update. * gdb.ada/char_enum/pck.ads (Global_Enum_Type): Use '+'.
* Allow nested function displaysTom Tromey2019-07-304-0/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | In Ada, it's possible to have nested functions. However, block.c:contained_in does not recognize this. Normally, this is no problem, but if gdb is stopped inside a nested function, then you can end up in the unexpected situation that "print" of an expression will work, whereas "display" of the same expression will not -- because contained_in returns 0. This patch simply removes the BLOCK_FUNCTION check from contained_in. The rationale here is that in languages without nested functions, this will not cause any issues. gdb/ChangeLog 2019-07-30 Tom Tromey <tromey@adacore.com> * block.c (contained_in): Remove BLOCK_FUNCTION check. gdb/testsuite/ChangeLog 2019-07-30 Tom Tromey <tromey@adacore.com> * gdb.ada/display_nested.exp: New file. * gdb.ada/display_nested/foo.adb: New file. * gdb.ada/display_nested/pack.adb: New file. * gdb.ada/display_nested/pack.ads: New file.
* gdb: Show type summary for anonymous structures from c_print_typedefAndrew Burgess2019-07-221-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently each language has a la_print_typedef method, this is only used for the "info types" command. The documentation for "info types" says: Print a brief description of all types whose names match the regular expression @var{regexp} (or all types in your program, if you supply no argument). However, if we consider this C code: typedef struct { int a; } my_type; Then currently with "info types" this will be printed like this: 3: typedef struct { int a; } my_type; I see two problems with this, first the indentation is clearly broken, second, if the struct contained more fields then it feels like the actual type names could easily get lost in the noise. Given that "info types" is about discovering type names, I think there is an argument to be made that we should focus on giving _only_ the briefest summary for "info types", and if the user wants to know more they can take the type name and plug it into "ptype". As such, I propose that a better output would be: 3: typedef struct {...} my_type; The user understands that there is a type called `my_type`, and that it's an alias for an anonymous structure type. The change to achieve this turns out to be pretty simple, but only effects languages that make use of c_print_typedef, which are C, C++, asm, minimal, d, go, objc, and opencl. Other languages will for now do whatever they used to do. The patch to change how anonymous structs are displayed also changes the display of anonymous enums, consider this code sample: typedef enum { AA, BB, CC } anon_enum_t; This used to be displayed like this: 3: typedef enum {AA, BB, CC} anon_enum_t; Which will quickly become cluttered for enums with a large number of values. The modified output looks like this: 3: typedef enum {...} anon_enum_t; Again, the user can always make use of ptype if they want to see the details of the anon_enum_t type. It is worth pointing out that this change (to use {...}) only effects anonymous structs and enums, named types don't change with this patch, consider this code: struct struct_t { int i; }; enum enum_t { AA, BB, CC }; The output from 'info types' remains unchanged, like this: 4: enum enum_t; 1: struct struct_t; An additional area of interest is how C++ handles anonymous types used within a typedef; enums are handled basically inline with how C handles them, but structs (and classes) are slightly different. The behaviour before the patch is different, and is unchanged by this patch. Consider this code compiled for C++: typedef struct { int i; } struct_t; Both before and after this patch, this is show by 'info types' as: 3: typedef struct_t struct_t; Unions are displayed similarly to structs in both C and C++, the handling of anonymous unions changes for C in the same way that it changes for anonymous structs. I did look at ada, as this is the only language to actually have some tests for "info types", however, as I understand it ada doesn't really support typedefs, however, by forcing the language we can see what ada would print. So, if we 'set language ada', then originally we printed this: 3: record a: int; end record Again the indentation is clearly broken, but we also have no mention of the type name at all, which is odd, but understandable given the lack of typedefs. If I make a similar change as I'm proposing for C, then we now get this output: 3: record ... end record Which is even less informative I think. However, the original output _is_ tested for in gdb.ada/info_auto_lang.exp, and its not clear to me if the change is a good one or not, so for now I have left this out. gdb/ChangeLog: * c-typeprint.c (c_print_typedef): Pass -1 instead of 0 to type_print. gdb/testsuite/ChangeLog: * gdb.ada/info_auto_lang.exp: Update expected results. * gdb.base/info-types.c: Add additional types to check. * gdb.base/info-types.exp: Update expected results.
* Change Ada catchpoints to be bp_catchpointTom Tromey2019-07-106-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like Pedro's earlier patches to change catchpoint to be of type bp_catchpoint, this changes the Ada catchpoints to follow. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-07-10 Tom Tromey <tromey@adacore.com> * ada-lang.h (is_ada_exception_catchpoint): Declare. * breakpoint.c (init_ada_exception_breakpoint): Register as bp_catchpoint. (print_one_breakpoint_location, print_one_breakpoint): Use is_ada_exception_catchpoint. * ada-lang.c (class ada_catchpoint_location): Pass bp_loc_software_breakpoint to bp_location constructor. (is_ada_exception_catchpoint): New function. gdb/testsuite/ChangeLog 2019-07-10 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_ex_cond.exp: Update expected results. * gdb.ada/mi_catch_ex_hand.exp: Update expected results. * gdb.ada/mi_catch_ex.exp: Update expected results. * gdb.ada/mi_catch_assert.exp: Update expected results. * gdb.ada/catch_ex.exp (catch_exception_info) (catch_exception_entry, catch_assert_entry) (catch_unhandled_entry): Update. * gdb.ada/catch_assert_if.exp: Update expected results.
* [gdb/testsuite] Mark ptype_union.exp as unsupported for cc-with-gdb-indexTom de Vries2019-06-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | When testing gdb with board cc-with-gdb-index, we run into: ... FAIL: gdb.ada/ptype_union.exp: ptype global FAIL: gdb.ada/ptype_union.exp: print global ... The index is not supported for Ada (PR24713), and cc-with-gdb-index does not add an index for Ada test-cases. However, this test-case compiles C sources, for which cc-with-gdb-index does add an index. In gdb we load the executable containing the index and set the language to Ada, resulting in gdb trying to handle something that is not supported. Fix the fail by marking this unsupported. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-21 Tom de Vries <tdevries@suse.de> PR testsuite/24518 PR ada/24713 * gdb.ada/ptype_union.exp: Mark as unsupported if executable contains index.
* Add intro comment to length_cond.expTom Tromey2019-06-191-0/+3
| | | | | | | | | | Pedro pointed out that the new length_cond.exp test did not have an intro comment. This adds one. gdb/testsuite/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * gdb.ada/length_cond.exp: Add intro comment.
* Fix crash when setting breakpoint conditionTom Tromey2019-06-194-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | gdb could crash when setting a breakpoint condition on a breakpoint when using the Ada language. The problem occurred because the ada_evaluate_subexp would try to evaluate the array to compute its attributes, but evaluating can't really be done at this time. This patch fixes the problem by arranging not to try to evaluate in EVAL_AVOID_SIDE_EFFECTS mode when computing an attribute. Tested on x86-64 Fedora 29. Because this is Ada-specific, and because Joel approved it internally, I am checking it in. gdb/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_evaluate_subexp) <case OP_ATR_FIRST>: Handle EVAL_AVOID_SIDE_EFFECTS specially. gdb/testsuite/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * gdb.ada/length_cond.exp: New file. * gdb.ada/length_cond/length_cond.adb: New file. * gdb.ada/length_cond/pck.adb: New file. * gdb.ada/length_cond/pck.ads: New file.
* Allow re-assigning to convenience variablesTom Tromey2019-06-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ada mode, re-assigning an array of a different size to a convenience variable will cause an error: (gdb) set lang ada (gdb) set $v := "abc" (gdb) set $v := "abcd" cannot assign arrays of different length However, this does not really make sense -- instead, it should always be possible to overwrite a convenience variable. This patch fixes this bug. This was reviewed off-list by Joel. I'm checking it in. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_evaluate_subexp) <case BINOP_ASSIGN>: Always allow assignment to an internalvar. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * gdb.ada/set_wstr.exp: Add reassignment test.
* Recognize _ in attribute namesTom Tromey2019-06-141-8/+10
| | | | | | | | | | | | | | | | | | | | | | Ada attribute names can contain "_", but the lexer currently does not allow this -- even though the "attributes" array lists some attributes spelled this way. This patch fixes the bug and adds test cases for the existing attributes. This was reviewed off-list by Joel. I'm checking it in. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * ada-lex.l: Allow "_" in attribute names. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * gdb.ada/formatted_ref.exp (test_p_x_addr): Check 'unchecked_access and 'unrestricted_access as well.
* Fix gdb.ada/vla.expTom Tromey2019-06-142-4/+9
| | | | | | | | | | | | | | | | | | | | | | | PR ada/24539 concerns a test failure in gdb.ada/vla.exp. The problem here is that different versions of Gnat emit the structure's fields in different orders -- with the order currently failing actually being the correct one. Joel pointed out that this can be fixed by simply adding the No_Component_Reordering pragma to the type in question, which is what this patch does. I've reported a Gnat compiler bug internally in hopes of getting the underlying problem fixed. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> PR ada/24539: * gdb.ada/vla.exp: Update tests. * gdb.ada/vla/vla.adb (Record_Type): Use No_Component_Reordering pragma.
* Fix failure in gdb.ada/complete.expTom Tromey2019-05-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | I noticed a failure in gdb.ada/complete.exp when testing locally: FAIL: gdb.ada/complete.exp: complete break ada This failed due to this output: [...] break ada/generated/gnatvsn.ads break ada/libgnat/s-excmac.ads break ada/sdefault.adb break ada/snames.adb break ada/snames.ads This patch updates the regexp to allow "/" and "-" to appear. gdb/testsuite/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * gdb.ada/complete.exp (test_gdb_no_completion): Add "/" and "-" to "break complete ada" test case's regexp.
* Add completion for Ada catch commandsTom Tromey2019-05-101-0/+4
| | | | | | | | | | | | | | | | | | This patch adds a completion function to the "catch exception" and "catch handlers" commands. Tested on x86-64 Fedora 29; reviewed off-list by Joel. gdb/ChangeLog 2019-05-10 Tom Tromey <tromey@adacore.com> * ada-lang.c (catch_ada_completer): New function. (_initialize_ada_language): Use it. gdb/testsuite/ChangeLog 2019-05-10 Tom Tromey <tromey@adacore.com> * gdb.ada/info_exc.exp: Add "complete" test.
* When debugging a mixed Ada/C program using this scenario:Xavier Roirand2019-05-085-0/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - set print frame-arguements all - an Ada function named pck.call_me calls a C function named break_me - you put a breakpoint in break_me and the program reaches this breakpoint. Now display the backtrace: (gdb) bt #0 break_me () at [...] #1 0x000000000040243e in pck.call_me ( s={P_ARRAY = 0x7fffffffe21c, P_BOUNDS = 0x41e6e8}) at [...] whereas we should expect: (gdb) bt #0 break_me () at [...] #1 0x000000000040243e in pck.call_me (s="test") at [...] The problem is that GDB prints the S parameter in the pck.call_me Ada function using the current language, so the C one, because the program is stopped in a C function, whereas it should use the pck.call_me frame one. This behavior is ok when user manually changes the language but it's not the right one when language is auto. This patch fixes this problem so now when using auto language, all Ada frame arguments are printed using Ada like syntax when the frame is part of Ada code, even if the program is stopped in a frame using a different language. If the user explicitly sets a language (using "set language ...") then no change here, all the Ada frame arguments are printed using this language. gdb/ChangeLog: * ada-valprint.c (ada_val_print_gnat_array): Remove language parameter and use Ada language definition instead. (ada_val_print_ptr): Remove unused language parameter. (ada_val_print_num): Remove language parameter and use Ada language definition instead. (ada_val_print_enum, ada_val_print_flt): Remove unused language parameter. (ada_val_print_struct_union, ada_val_print_ref): Remove language parameter and use Ada language definition instead. (ada_val_print_1): Update all ada_val_print_xxx calls. Remove language parameter. (ada_val_print): Update ada_val_print_1 call. gdb/testsuite/ChangeLog: * gdb.ada/frame_arg_lang.exp: New testcase. * gdb.ada/frame_arg_lang/bla.adb: New file. * gdb.ada/frame_arg_lang/pck.ads: New file. * gdb.ada/frame_arg_lang/pck.adb: New file. * gdb.ada/frame_arg_lang/foo.c: New file. Tested on x86_64-linux, no regressions.
* Fix VLA printing for AdaTom Tromey2019-05-082-0/+95
| | | | | | | | | | | | | | | | | | | | | | | | | While looking at a different Ada problem, I found that printing a record containing a VLA did not work properly. I tracked the problem down to dwarf2_evaluate_property trying, and failing, to compare two types that differed only in qualifiers. This patch changes dwarf2_evaluate_property to ignore qualifiers when comparing types. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-08 Tom Tromey <tromey@adacore.com> * dwarf2loc.c (dwarf2_evaluate_property) <PROP_ADDR_OFFSET>: Compare main types. gdb/testsuite/ChangeLog 2019-05-08 Tom Tromey <tromey@adacore.com> * gdb.ada/vla.exp: New file. * gdb.ada/vla/vla.adb: New file.
* Fix cast of character to enum type in AdaTom Tromey2019-05-033-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An internal bug report points out that, when a global character enum type is used, casting fails, like: (gdb) print global_char_enum'('F') $1 = 70 The bug here turns out to be that enumerators are qualified, so for example the mangled name might be "pck__QU48", rather than "QU48". This patch fixes the problem by only examining the suffix of the enumerator. This is ok because the type is already known, and because the mangling scheme ensures that there won't be clashes. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-03 Tom Tromey <tromey@adacore.com> * ada-exp.y (convert_char_literal): Check suffix of each enumerator. gdb/testsuite/ChangeLog 2019-05-03 Tom Tromey <tromey@adacore.com> * gdb.ada/char_enum/pck.ads (Global_Enum_Type): New type. * gdb.ada/char_enum/foo.adb: Use Global_Enum_Type. * gdb.ada/char_enum.exp: Add test.
* Fix bug in assignment to nested packed structureTom Tromey2019-05-012-0/+10
| | | | | | | | | | | | | | | | | | | | | | | A user at AdaCore found a case where assignment to a nested packed structure would fail. The bug is that ada_value_primitive_field doesn't account for the situation where a field is not packed relative to its containing structure, but where the structure itself is packed in its parent. gdb/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_primitive_field): Treat more fields as bitfields. gdb/testsuite/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * gdb.ada/packed_array_assign/aggregates.ads (Nested_Packed): New record. (NPR): New variable. * gdb.ada/packed_array_assign.exp: Add nested packed assignment test.
* Fix big-endian aggregate assignment in AdaTom Tromey2019-05-011-0/+5
| | | | | | | | | | | | | | | | | | | | A bug internal to AdaCore notes that assigning a non-scalar value to an element of a packed array will sometimes fail. The bug turns out to be that ada_value_assign incorrectly computes the starting point for the assignment. This patch fixes the problem. gdb/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_assign): Correctly compute starting offset for big-endian copies. gdb/testsuite/ChangeLog 2019-05-01 Tom Tromey <tromey@adacore.com> * gdb.ada/packed_array_assign.exp: Add packed assignment regression test.
* Fix "catch exception" with dynamic linkingTom Tromey2019-04-304-0/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an Ada program is dynamically linked against libgnat, and when one of the standard exceptions is used, the exception object may be referenced by the main executable using a copy relocation. In this situation, a "catch exception" for those exceptions will not manage to stop. This happens because, under the hood, "catch exception" creates an expression object that examines the object addresses -- but in this case, the address will be incorrect. This patch fixes the problem by arranging for these filter expressions to examine all the relevant minimal symbols. This way, the object from libgnat will be found as well. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-04-30 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_lookup_simple_minsyms): New function. (create_excep_cond_exprs): Iterate over program spaces. (ada_exception_catchpoint_cond_string): Examine all minimal symbols for exception types. gdb/testsuite/ChangeLog 2019-04-30 Tom Tromey <tromey@adacore.com> * lib/ada.exp (find_ada_tool): New proc. * lib/gdb.exp (gdb_compile_shlib): Allow .o files as inputs. * gdb.ada/catch_ex_std.exp: New file. * gdb.ada/catch_ex_std/foo.adb: New file. * gdb.ada/catch_ex_std/some_package.adb: New file. * gdb.ada/catch_ex_std/some_package.ads: New file.
* Print non-Ada unions without crashingTom Tromey2019-04-192-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ada-lang.c is a bit too eager trying to decode unions in the Ada style -- looking for discriminants and such. This causes crashes when printing a non-Ada union in Ada mode, something that can easily happen when printing a value from history or certain registers on AArch64. This patch fixes the bug by changing ada-lang.c to only apply special Ada treatment to types coming from an Ada CU. This in turn required a couple of surprising changes. First, some of the Ada code was already using HAVE_GNAT_AUX_INFO to decide whether a type had already been fixed -- such types had INIT_CPLUS_SPECIFIC called on them. This patch changes these spots to use the "none" identifier instead. This then required changing value_rtti_type to avoid changing the language-specific object attached to an Ada type, which seems like a good change regardless. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-04-19 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_is_variant_part, ada_to_fixed_type_1): Check ADA_TYPE_P. (empty_record, ada_template_to_fixed_record_type_1) (template_to_static_fixed_type) (to_record_with_fixed_variant_part): Use INIT_NONE_SPECIFIC. * cp-abi.c (value_rtti_type): Check HAVE_CPLUS_STRUCT. * gdbtypes.h (INIT_NONE_SPECIFIC, ADA_TYPE_P): New macros. gdb/testsuite/ChangeLog 2019-04-19 Tom Tromey <tromey@adacore.com> * gdb.ada/ptype_union.c: New file. * gdb.ada/ptype_union.exp: New file.
* Fix Ada "ptype" bug with array typesTom Tromey2019-03-184-0/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | Using ptype on an array type in Ada can sometimes show an incorrect high bound. This happens because ada_evaluate_subexp will create an array with an incorrect upper bound in the EVAL_AVOID_SIDE_EFFECTS case. This patch fixes the problem by arranging to always create such an array with valid bounds. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-03-18 Tom Tromey <tromey@adacore.com> * ada-lang.c (empty_array): Add "high" parameter. (ada_evaluate_subexp): Update. gdb/testsuite/ChangeLog 2019-03-18 Joel Brobecker <brobecker@adacore.com> Tom Tromey <tromey@adacore.com> * gdb.ada/ptype_array/pck.adb: New file. * gdb.ada/ptype_array/pck.ads: New file. * gdb.ada/ptype_array/foo.adb: New file. * gdb.ada/ptype_array.exp: New file.
* Update copyright year range in gdb.ada/mi_ref_changeable testcaseJoel Brobecker2019-02-234-4/+4
| | | | | | | | | | | | | | | | | | | | | | This patch fixes the copyright year range which escaped the 2019 update, because the patch was submitted in 2018, but only really pushed in 2019. Pushed: https://www.sourceware.org/ml/gdb-patches/2019-02/msg00109.html Submitted: https://www.sourceware.org/ml/gdb-patches/2018-12/msg00444.html We normally are pretty good at remembering those little things, but this one fell through the cracks. This commit fixes this, by re-running the copyright.py script and checking in the changes made by that script. gdb/testsuite/ChangeLog: * gdb.ada/mi_ref_changeable.exp: Update copyright year range. * gdb.ada/mi_ref_changeable/foo_rb20_056.adb: Likewise. * gdb.ada/mi_ref_changeable/pck.adb: Likewise. * gdb.ada/mi_ref_changeable/pck.ads: Likewise. * gdb.dwarf2/inlined_subroutine-inheritance.exp: Likewise.
* (Ada) fix GDB crash printing packed arrayJoel Brobecker2019-02-175-1/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trying to print a packed array sometimes leads to a crash (see attached testcase for an example of when this happens): | (gdb) p bad | [1] 65571 segmentation fault gdb -q foo Variable "bad" is declared in the debug information as an array where the array's type name has an XPnnn suffix: | .uleb128 0xc # (DIE (0x566) DW_TAG_typedef) | .long .LASF200 # DW_AT_name: "pck__t___XP1" | [loc info attributes snipped] | .long 0x550 # DW_AT_type | .byte 0x1 # DW_AT_alignment The signals to GDB that the debugging information follows a GNAT encoding used for packed arrays, and an in order to decode it, we need to find the type whose name is the same minus the "___XPnnn" suffix: "pck__t". For that, we make a call to ada-lang.c::standard_lookup, which is a simple function which essentially does: | /* Return the result of a standard (literal, C-like) lookup of NAME in | given DOMAIN, visible from lexical block BLOCK. */ | | [...] | sym = lookup_symbol_in_language (name, block, domain, language_c, 0); Unfortunately for us, while the intent of this call was to perform an exact-match lookup, in our case, it returns ... type pck__t___XP1 instead! In other words, it finds itself back. The reason why it finds this type is a confluence of two factors: (1) Forcing the lookup into language_c currently does not affect how symbol matching is done anymore, because we look at the symbol's language to determine which kind of matching should be done; (2) The lookup searches the local context (via block) first, beforei doing a more general lookup. And looking at the debug info for the main subprogram, we see that type "pck__t" is not declared there, only in the debug info for pck.ads. In other words, there is no way that we accidently find "pck__t" by random chance. I believe Pedro added a new function called ada_lookup_encoded_symbol for that specific purpose, so I started by replacing the lookup by language above by this. Unfortunately, still no joy. This was because, even though ada_lookup_encoded_symbol puts angle- brackets around the search name to signal that we want a verbatim search, we end up losing that information in the function called to compare a symbol with the search name: | static bool | do_full_match (const char *symbol_search_name, | const lookup_name_info &lookup_name, | completion_match_result *comp_match_res) | { | return full_match (symbol_search_name, ada_lookup_name (lookup_name)); ^^^^^^^^^^^^^^^ | <=> lookup_name.m_ada.m_encoded_name (no angle brackets) The way I fixed this was by introducing a new function called do_exact_match, and then adjust ada_get_symbol_name_matcher to return that function when seeing that we have a verbatim non-wild-match search. As it happens, this fixes an incorrect test in gdb.ada/homony.exp, where we were inserting a breakpoint on a symbol using the angle-brackets notation, and got 2 locations for that breakpoint... (gdb) b <homonym__get_value> Breakpoint 1 at 0x4029fc: <homonym__get_value>. (2 locations) ... each location being in a different function: (gdb) info break Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x00000000004029fc in homonym.get_value at /[...]/homonym.adb:32 1.2 y 0x0000000000402a3a in homonym.get_value at /[...]/homonym.adb:50 (gdb) x /i 0x00000000004029fc 0x4029fc <homonym__get_value+8>: movl $0x1d,-0x4(%rbp) (gdb) x /i 0x0000000000402a3a 0x402a3a <homonym__get_value__2+8>: movl $0x11,-0x4(%rbp) Since we used angle-brackets, we shouldn't be matching the second one, something this patch fixes. gdb/ChangeLog: * ada-lang.c (standard_lookup): Use ada_lookup_encoded_symbol instead of lookup_symbol_in_language (do_exact_match): New function. (ada_get_symbol_name_matcher): Return do_exact_match when doing a verbatim match. gdb/testsuite/ChangeLog: * gdb.ada/big_packed_array: New testcase. * gdb.ada/homonym.exp: Fix incorrect expected output for "break <homonym__get_value>" test. Tested on x86_64-linux.
* (Ada) -var-update crash for variable whose type is a reference to changeableJoel Brobecker2019-02-104-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following variable, which is a string whose value is not known at compile time, because it is the return value from a function call (Get_Name): A : String := Get_Name; If one tries to create a varobj for that variable, everything works as expected: | (gdb) -var-create a * a | ^done,name="a",numchild="19",value="[19] \"Some kind of string\"",type="<ref> array (1 .. 19) of character",thread-id="1",has_more="0" However, try then to request an update, regardless of whether the string has changed or not, and we get a crash: | -var-update a | ~"/[...]/gdb/varobj.c:1379: internal-error: bool install_new_value(varobj*, value*, bool): Assertion `!value_lazy (var->value.get ())' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? (y or n) " When the varobj gets created (-var-create), the expression is evaluated and transformed into a value. The debugging information describes our variables as a reference to an array of characters, so our value has the corresponding type. We then call varobj.c::install_new_value to store that value inside our varobj, and we see that this function pretty starts by determining weither our varobj is changeable, via: | changeable = varobj_value_is_changeable_p (var); (where 'var' is the varobj we are building, and where the function varobj_value_is_changeable_p simply dispatches to the Ada version of this routine: ada_value_is_changeable_p). At this point, the varobj doesn't have a value, yet, but it does have a type which was provided by varobj_create a little bit before install_new_value was called. So ada_value_is_changeable_p uses that to determine whether or not our type is changeable. Since our type is a reference to an array, and that the value of such objects is displayed as if there weren't a reference, it means that our object is changeable -- in other words, if an element of the string changes, then the "value" field of the varobj will change accordingly. But unfortunately, ada_value_is_changeable_p mistakenly returns false, because it is missing the handling of reference types. As a consequence of this, install_new_value doesn't feel it is necessary to fetch the value's contents, as explained by the following comment inside that function: /* The new value might be lazy. If the type is changeable, that is we'll be comparing values of this type, fetch the value now. Otherwise, on the next update the old value will be lazy, which means we've lost that old value. */ This means that a lazy value gets installed inside our varobj as a result of the mistake in ada_value_is_changeable_p. Another important detail is that, after determining whether our varobj is changeable or not, it then purposefully removes the reference layer from our value: /* We are not interested in the address of references, and given that in C++ a reference is not rebindable, it cannot meaningfully change. So, get hold of the real value. */ if (value) value = coerce_ref (value); The consequence of those two facts on shows up only later, when the user requests an update (-var-update). When doing so, GDB evaluates the expression again into a value which is once more a reference to a string, and then calls install_new_value again to install the new value and report any changes. This time around, the call to... | changeable = varobj_value_is_changeable_p (var); ... now gets a varobj which has a value, and one which had the reference layer removed! So, this time, we classify the varobj correctly, and say it is changeable. And because it is changeable, we then go into the section of code in install_new_value which checks for changes, where we need the varobj's value to not be lazy, as explained by the comment we quoted above. That's what the assertion was about. This patch fixes the issues by teaching ada_value_is_changeable_p to ignore reference layers when evaluating a given varobj's type. gdb/ChangeLog: * ada-varobj.c (ada_value_is_changeable_p): Add handling of TYPE_CODE_REF types. gdb/testsuite/ChangeLog: * gdb.ada/mi_ref_changeable: New testcase. Prior to this patch, this testcase reports 2 unresolved tests (due to GDB hitting the internal error). With this patch, all tests in this testcase pass. Tested on x86_64-linux, no regression.
* Update copyright year range in all GDB files.Joel Brobecker2019-01-01557-557/+557
| | | | | | | | | | | | | | | | This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
* Fix gdb.ada/fun_renaming.exp by using more unique names.Philippe Waroquiers2018-12-274-14/+16
| | | | | | | | | | | | | | | | | | | | | The test fails due to conflict between var 'next' and s-pooloc.adb next: (gdb) print next(1) Multiple matches for next [0] cancel [1] pack.next (integer) return integer at /bd/home/philippe/gdb/git/binutils-gdb/gdb/testsuite/gdb.ada/fun_renaming/pack.adb:19 [2] system.pool_local.next (system.address) return system.pool_local.acc_address at s-pooloc.adb:151 > FAIL: gdb.ada/fun_renaming.exp: print next(1) (timeout) Fix by making the names and renamings more unique. gdb/testsuite/ChangeLog 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/fun_renaming/pack.ads (Next): Rename to Fun_Rename_Test_Next. (Renamed_Next): Rename to Renamed_Fun_Rename_Test_Next. gdb.ada/fun_renaming/pack.adb (Next): Rename to Fun_Rename_Test_Next. gdb.ada/fun_renaming/fun_renaming.adb (N): Rename to Fun_Rename_Test_N. gdb.ada/fun_renaming.exp: Update accordingly.
* Fix gdb.ada/assign_arr.exp by using more unique names.Philippe Waroquiers2018-12-273-3/+3
| | | | | | | | | | | | | | | | | | | | | | The test fails (timeout) due to conflict between var 'input' and s-ststop.adb 'input': (gdb) print input.u2 := (0.25,0.5,0.75) Multiple matches for input [0] cancel [1] system.strings.stream_ops.storage_array_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return system.storage_elements.storage_array at s-ststop.adb:127 [2] system.strings.stream_ops.stream_element_array_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return ada.streams.stream_element_array at s-ststop.adb:127 [3] system.strings.stream_ops.string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return string at s-ststop.adb:127 [4] system.strings.stream_ops.wide_string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return wide_string at s-ststop.adb:127 [5] system.strings.stream_ops.wide_wide_string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return wide_wide_string at s-ststop.adb:127 [6] target_wrapper.input at /bd/home/philippe/gdb/git/info_t/gdb/testsuite/gdb.ada/assign_arr/target_wrapper.ads:24 > FAIL: gdb.ada/assign_arr.exp: print input.u2 := (0.25,0.5,0.75) (timeout) gdb/testsuite/ChangeLog 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/assign_arr/target_wrapper.ads (Input): Rename to Assign_Arr_Input. main_p324_051.adb: Update accordingly. gdb.ada/assign_arr.exp: Likewise.
* Improve gdb.ada/rename_subscript_param.exp by using more unique names.Philippe Waroquiers2018-12-272-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With old compilers, the test fails because no debug info is generated for 'B' and GDB finds some 'b' in atnat.h: (gdb) print b Multiple matches for b [0] cancel [1] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 [2] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 [3] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 > FAIL: gdb.ada/rename_subscript_param.exp: print b before changing its value (timeout) Avoid the timeout by renaming 'b' to rename_subscript_param_b. Also, change 'before' to 'after' in the gdb_test message that prints the value after changing it. The test still fails with old compilers that do not properly generate debug info for this renaming: (gdb) print rename_subscript_param_b No definition of "rename_subscript_param_b" in current context. (gdb) FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b before changing its value Note: if the compiler would generate the correct debug info, the test should succeed with the name B. However, waiting for this fix, changing the name ensures that the test fails directly, instead of causing a timeout. 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> PR ada/23381 * gdb.ada/rename_subscript_param/pkg.adb (B): Rename to Rename_Subscript_Param_B. All users updated. gdb.ada/rename_subscript_param.exp: Test names made unique. Note that PR ada/23381 is only fully fixed when using a recent compiler.
* Fix gdb.ada/packed_array_assign.exp by using more unique names.Philippe Waroquiers2018-12-272-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | The test gdb.ada/packed_array_assign fails due to conflict between component 'w' and system.dim.mks.w: (gdb) print pra := ((x => 2, y => 0, w => 17), pr, (x => 7, y => 1, w => 23)) Unknown component name: system.dim.mks.w. (gdb) FAIL: gdb.ada/packed_array_assign.exp: print pra := ((x => 2, y => 0, w => 17), pr, (x => 7, y => 1, w => 23)) Also, depending on the compiler version, the component w might be reordered and placed before components x and y. So, change the component order in the source, so that both an old compiler (GNATMAKE 6.3.0, gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516) and a new compiler (GNATMAKE Pro 20.0w (20181210-82), based on gcc 8.2.1) produce the same component order (checked by using -gnatR3s). So, update to test the new (more unique) names in the source order. 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/packed_array_assign/aggregates.ads (Packed_Rec): Rename components to Packed_Array_Assign_[X|Y|W]. Place component Packed_Array_Assign_W as first component, to ensure old and new compilers have the same representation. All users updated.
* Fix gdb.ada bp_fun_addr failure due to conflict between fun 'a' and ↵Philippe Waroquiers2018-12-242-7/+7
| | | | | | | | | | | | | | | | | | | | | | | s-dimmks.ads 'A'. The test fails (timeout) due to: (gdb) PASS: gdb.ada/bp_fun_addr.exp: break *a'address run Starting program: /bd/home/philippe/gdb/git/build_info_t/gdb/testsuite/outputs/gdb.ada/bp_fun_addr/a Multiple matches for a [0] cancel [1] a at /bd/home/philippe/gdb/git/info_t/gdb/testsuite/gdb.ada/bp_fun_addr/a.adb:18 [2] system.dim.mks.a at s-dimmks.ads:115 > FAIL: gdb.ada/bp_fun_addr.exp: run until breakpoint at a'address (timeout) testcase /home/philippe/gdb/git/build_info_t/gdb/testsuite/../../../info_t/gdb/testsuite/gdb.ada/bp_fun_addr.exp completed in 10 seconds Fix this by using a fun name that has more chances to be unique. 2018-12-24 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/bp_fun_addr/a.adb (a): Rename to bp_fun_addr. Filename a.adb changed to bp_fun_addr.adb. gdb.ada/bp_fun_addr.exp: Update test accordingly.
* Ensure deterministic result order in gdb.ada/info_auto_lang.expPhilippe Waroquiers2018-12-201-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | standard_ada_testfile, standard_test_file and the explicit csrcfile assignment in info_auto_lang.exp all gives similar pathnames prefix for a source, such as /home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.<something>. Note that the above pathnames contain ../ which appears when a relative pathname is used to call configure. In any case, the gnat compiler normalizes Ada sources path when compiling. So, the 'Ada' .o object are referencing a pathname such as /home/philippe/gdb/git/binutils-gdb/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb, while the 'C' .o object still references the not normalized pathname. As the results of 'info functions | ...' are sorted by pathname first, the order of the results depends on the comparison between different directories, leading to results that can change depending on these directories. => Ensure the result order is always the same, by normalising the C source file, which makes the results independent of the way configure is launched. Tested by running the testcase in 2 different builds, that without normalize were giving different results. Note: such 'set csrcfile' is used in 4 other tests mixing Ada and C. After discussion, it was deemed sufficient to just normalize the pathname for this test. gdb/testsuite/ChangeLog 2018-12-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/info_auto_lang.exp: Normalize some_c source file. Update order of results accordingly.
* Add a test to verify info [functions|variables|types]|rbreak respect ↵Philippe Waroquiers2018-11-204-0/+231
| | | | | | | | | | | language_mode. 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/info_auto_lang.exp: New testcase. * gdb.ada/info_auto_lang/global_pack.ads: New file. * gdb.ada/info_auto_lang/proc_in_ada.adb: New file. * gdb.ada/info_auto_lang/some_c.c: New file.
* (Ada) fix "error in expression" when using watch -location commandJoel Brobecker2018-11-014-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "watch -l EXPR" command with the language set to Ada currently fails with the following error: (gdb) watch -l global_var Error in expression, near ` 0x000000000062d2d8'. The error occurs because GDB internally translate the request into a watchpoint on a different expression: "* (TYPE *) ADDR" where TYPE and ADDR are the type and the address of the object returned by the expression's evaluation (resp.). So, in the example above, global_var being an integer stored at 0x000000000062d2d8, GDB tries to set a watchpoint on "* (integer *) 0x000000000062d2d8", which fails, because we try to parse this expression with Ada, when in fact it is not valid. This patch fixes the issue by implementing the la_watch_location_expression language method, using a syntax that the Ada parser recognizes ("{TYPE} ADDR"). gdb/ChangeLog: * ada-lang.c (ada_watch_location_expression): New function. (ada_language_defn): Set la_watch_location_expression to ada_watch_location_expression. gdb/testsuite/ChangeLog: * gdb.ada/watch_minus_l: New testcase.
* [gdb/testsuite] Fix capitalized test namesTom de Vries2018-10-184-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | At https://sourceware.org/gdb/wiki/GDBTestcaseCookbook\ #Follow_the_test_name_convention we find: .. Test names should start with a lower case and don't need to end with a period (they are not sentences). ... Fix some capitalized test names. Tested on x86_64-linux. 2018-10-18 Tom de Vries <tdevries@suse.de> * gdb.ada/bp_inlined_func.exp: Fix capitalized test name. * gdb.ada/excep_handle.exp: Same. * gdb.ada/mi_string_access.exp: Same. * gdb.ada/mi_var_union.exp: Same. * gdb.arch/arc-analyze-prologue.exp: Same. * gdb.arch/arc-decode-insn.exp: Same. * gdb.base/readnever.exp: Same. * gdb.fortran/printing-types.exp: Same. * gdb.guile/scm-lazy-string.exp: Same.
* Expect for "@" when doing "complete break ada" on gdb.ada/complete.expSergio Durigan Junior2018-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, gdb.ada/complete.exp's "complete break ada" test fails because the regexp used to match the command's output doesn't expect "@", but we have an output like: ... complete break ada break ada.assertions.assert break ada.calendar.arithmetic.difference break ada.calendar.arithmetic_operations.add break ada.calendar.arithmetic_operations.add.cold break ada.calendar.arithmetic_operations.add@plt break ada.calendar.arithmetic_operations.difference break ada.calendar.arithmetic_operations.difference@plt ... This patch adds "@" to the regexp, unbreaking the test. OK? gdb/testsuite/ChangeLog: 2018-09-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.ada/complete.exp: Expect for "@" when doing "complete break ada".
* (Ada) Fix resolving of homonym components in tagged typesJerome Guitton2018-09-104-3/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ada_value_struct_elt is used when displaying a component (say, 'N') of a record object (say, 'Obj') of type, say, 't1'. Now if Obj is tagged (Ada parlance: "tagged types" are what other object-oriented languages call "classes"), then 'N' may not be visible in the current view and we need to look for it in its actual type. We do that at the same time as resolving variable-length fields. This would typically be done by the following call to ada_value_struct_elt, with the last parameter check_tag set to 1: t1 = ada_to_fixed_type (ada_get_base_type (t1), NULL, address, NULL, 1); This is the general logic, but recently we introduced a special case to handle homonyms. Different components may have the same name in a tagged type. For instance: type Top_T is tagged record N : Integer := 1; end record; type Middle_T is new Top.Top_T with record N : Character := 'a'; end record; Middle_T extends Top_T and both define a (different) component with the same name ('N'). In such a case, using the actual type of a Middle_T object would create a confusion, since we would have two component 'N' in this actual type. So, to handle homonyms, we convert t1 to the actual type *if and only if* N cannot be found in the current view. For example, if Obj has been created as a Middle_T but is seen as a Top_T'Class at our point of execution, then "print Obj.N" will display the integer field defined in Top_T's declaration. Now, even if we find N in the current view, we still have to get a fixed type: for instance, the record can be unconstrained and we still need a fixed type to get the proper offset to each field. That is to say, in this case: type Dyn_Top_T (Disc : Natural) is tagged record S : Integer_Array (1 .. Disc) := (others => Disc); N : Integer := 1; end record; type Dyn_Middle_T is new Dyn_Top.Dyn_Top_T with record N : Character := 'a'; U : Integer := 42; end record; If we have an object Obj of type Dyn_Middle_T and we want to display U, we don't need to build, from its tag, a real type with all its real fields. In other words, we don't need to add the parent components: Disc, S, and the integer N. We only need to access U and it is directly visible in Dyn_Middle_T. So no tag handling. However, we do need to build a fixed-size type to have the proper offset to U (since this offset to U depends on the size of Obj.S, which itself is dynamic and depends on the value of Obj.Disc). We accidentally lost some of this treatment when we introduced the resolution of homonyms. This patch re-install this part by uncoupling the tag resolution from the "fixing" of variable-length components. This change also slightly simplifies the non-tagged case: in the non-tagged case, no need to set check_tag to 1, since we already know that there is no tag. gdb/ChangeLog: * ada-lang.c (ada_value_struct_elt): Call ada_to_fixed_type with check_tag to 1 if and only if the type is tagged and the component being searched cannot been found in the current view. Otherwise, always call ada_to_fixed_type with check_tag to 0. gdb/testsuite/ChangeLog: * gdb.ada/same_component_name: Add test for case of tagged record with variable-length fields.
* (Ada) Fix printing of access to unconstrained arraysXavier Roirand2018-09-104-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using this Ada code: type String_Access is access String; type Array_Of_String is array (1 .. 2) of String_Access; Aos : Array_Of_String := (new String'("ab"), new String'("cd")); When debugging with GDB, printing each Aos element displays: (gdb) print Aos(1) $2 = "ab" (gdb) print Aos(2) $3 = "cd" Whereas it should display: (gdb) print Aos(1) $2 = (foo_r118_024.string_access) 0x635018 (gdb) print Aos(2) $3 = (foo_r118_024.string_access) 0x635038 Notice that printing the entire array works: (gdb) print Aos $1 = (0x635018, 0x635038) The problem was located in ada_value_print function and due to the fact that the value_type used in this function was based on value_enclosing_type rather than value_type itself. In our example, the difference between the value_type and the value_enclosing_type of the value is that the value_type contains an additional typedef layer which is not present in the value_enclosing_type. This typedef layer is GNAT's way to specify that the element is, at the source level, an access to the unconstrained array, rather than the unconstrained array. Moreover, the value_enclosing_type is not really needed in that case and the value_type can be used instead in this function, and this patch fixes this. gdb/ChangeLog: * ada-valprint.c (ada_value_print): Use type instead of enclosing type. testsuite/ChangeLog: * gdb.ada/access_to_unbounded_array.exp: New testcase. * gdb.ada/access_to_unbounded_array/foo.adb: New file. * gdb.ada/access_to_unbounded_array/pack.adb: New file. * gdb.ada/access_to_unbounded_array/pack.ads: New file. Tested: x86_64-linux