aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
AgeCommit message (Collapse)AuthorFilesLines
2021-01-01Update copyright year range in all GDB filesJoel Brobecker35-35/+35
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-23gdb: avoid accessing global C++ language implementation functionsAndrew Burgess1-3/+4
The function c_printchar is called from two places; it provides the implementation of language_defn::printchar and it is called from dwarf2_compute_name. It would be nice to rename c_printchar as language_defn::printchar and so avoid the trampoline. To achieve this, instead of calling c_printchar directly from the DWARF code, I lookup the C++ language object and call the printchar member function. In a later commit I can then rename c_printchar. There should be no user visible changes after this commit. gdb/ChangeLog: * dwarf2/read.c (dwarf2_compute_name): Call methods on C++ language object instead of calling global functions directly.
2020-12-14Be more careful when rewriting thick pointer array typeTom Tromey1-13/+58
To handle thick pointers with -fgnat-encodings=minimal, gdb will rewrite the underlying array type to remove the bounds. However, if the same DWARF type is used both for a thick pointer and for an ordinary array, this will have the side effect of removing the bounds from the array. This breaks the printing of objects of this type. This patch fixes the problem by copying the array type, its range, and its bounds. gdb/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (rewrite_array_type): New function. (quirk_ada_thick_pointer_struct): Use rewrite_array_type. gdb/testsuite/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * gdb.dwarf2/ada-thick-pointer.exp: New file.
2020-12-11gdb: factor out debug_prefixed_printf_condSimon Marchi1-12/+4
The same pattern happens often to define a "debug_printf" macro: #define displaced_debug_printf(fmt, ...) \ do \ { \ if (debug_displaced) \ debug_prefixed_printf ("displaced", __func__, fmt, ##__VA_ARGS__); \ } \ while (0) Move this pattern behind a helper macro, debug_prefixed_printf_cond and update the existing macros to use it. gdb/ChangeLog: * displaced-stepping.h (displaced_debug_printf): Use debug_prefixed_printf_cond. * dwarf2/read.c (dwarf_read_debug_printf): Likewise. (dwarf_read_debug_printf_v): Likewise. * infrun.h (infrun_debug_printf): Likewise. * linux-nat.c (linux_nat_debug_printf): Likewise. gdbsupport/ChangeLog: * common-debug.h (debug_prefixed_printf_cond): New. * event-loop.h (event_loop_debug_printf): Use debug_prefixed_printf_cond. Change-Id: I1ff48b98b8d1cc405d1c7e8da8ceadf4e3a17f99
2020-12-09Handle 128-bit constants for fixed pointTom Tromey1-34/+48
In some cases, GNAT can emit 128-bit constants for fixed-point types. This patch changes gdb to handle this scenario, by changing the low-level rational-reading functions in dwarf2/read.c to work directly with gdb_mpz values. (I'm not sure offhand if these 128-bit patches have gone into upstream GCC yet -- but they will eventually, and meanwhile I think it should be clear that this patch is otherwise harmless.) gdb/ChangeLog 2020-12-09 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (get_dwarf2_rational_constant): Change "numerator" and "denominator" to gdb_mpz. Handle block forms. (get_dwarf2_unsigned_rational_constant): Change "numerator" and "denominator" to gdb_mpz. (finish_fixed_point_type): Update. (has_zero_over_zero_small_attribute): Update.
2020-12-03gdb: fix logic of find_comp_unit and set_comp_unitSimon Marchi1-4/+6
The logic in find_comp_unit and set_comp_unit is reversed. When the BFD requires relocation, we want to put the comp_unit structure in the map where the comp_unit objects are not shared, that is the one indexed by objfile. If the BFD does not require relocation, then, we can share a single comp_unit structure for all users of that BFD, so we want to put it in the BFD-indexed map. The comments on top of dwarf2_frame_bfd_data and dwarf2_frame_objfile_data make that clear. Fix it by swapping the two in find_comp_unit and set_comp_unit. I don't have a test for this, because I don't see how to write one in a reasonable amount of time. gdb/ChangeLog: PR gdb/26876 * dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of dwarf2_frame_bfd_data and dwarf2_frame_objfile_data. Change-Id: I80c1ee7ad8425fa4947de65b170973d05f5a52ec
2020-12-01Search for DWZ files in debug-file-directories as wellSergio Durigan Junior1-7/+100
When Debian (and Ubuntu) builds its binaries, it (still) doesn't use dwz's "--relative" option. This causes their debuginfo files to carry a .gnu_debugaltlink section containing a full pathname to the DWZ alt debug file, like this: $ readelf -wk /usr/bin/cat Contents of the .gnu_debugaltlink section: Separate debug info file: /usr/lib/debug/.dwz/x86_64-linux-gnu/coreutils.debug Build-ID (0x14 bytes): ee 76 5d 71 97 37 ce 46 99 44 32 bb e8 a9 1a ef 99 96 88 db Contents of the .gnu_debuglink section: Separate debug info file: 06d3bee37b8c7e67b31cb2689cb351102ae73b.debug CRC value: 0x53267655 This usually works OK, because most of the debuginfo files installed via apt will be present in /usr/lib/debug anyway. However, imagine the following scenario: - You are using /usr/bin/cat, it crashes on you and generates a corefile. - You don't want/need to "apt install" the debuginfo file for coreutils from the repositories. Instead, you already have the debuginfo files in a separate directory (e.g., $HOME/dbgsym). - You start GDB and "set debug-file-directory $HOME/dbgsym/usr/lib/debug". You then get the following message: $ gdb -ex 'set debug-file-directory ./dbgsym/usr/lib/debug' -ex 'file /bin/cat' -ex 'core-file ./cat.core' GNU gdb (Ubuntu 10.1-0ubuntu1) 10.1 ... Reading symbols from /bin/cat... Reading symbols from /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id/bc/06d3bee37b8c7e67b31cb2689cb351102ae73b.debug... could not find '.gnu_debugaltlink' file for /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id/bc/06d3bee37b8c7e67b31cb2689cb351102ae73b.debug This error happens because GDB is trying to locate the build-id link (inside /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id) for the DWZ alt debug file, which doesn't exist. Arguably, this is a problem with how dh_dwz works in Debian, and it's something I'm also planning to tackle. But, back at the problem at hand. Besides not being able to find the build-id link in the directory mentioned above, GDB also tried to open the DWZ alt file using its filename. The problem here is that, since we don't have the distro's debuginfo installed, it can't find anything under /usr/lib/debug that satisfies it. It occurred to me that a good way to workaround this problem is to actually try to locate the DWZ alt debug file inside the debug-file-directories (that were likely provided by the user). So this is what the proposed patch does. The idea here is simple: get the filename extracted from the .gnu_debugaltlink section, and manipulate it in order to replace the initial part of the path (everything before "/.dwz/") by whatever debug-file-directories the user might have provided. I talked with Mark Wielaard and he agrees this is a sensible approach. In fact, apparently this is something that eu-readelf also does. I regtested this code, and no regressions were found. 2020-12-01 Sergio Durigan Junior <sergiodj@sergiodj.net> * dwarf2/read.c (dwz_search_other_debugdirs): New function. (dwarf2_get_dwz_file): Convert 'filename' to a std::string. Use dwz_search_other_debugdirs to search for DWZ files in the debug-file-directories provided by the user as well.
2020-11-30[gdb/symtab] Fix gdb.base/vla-optimized-out.exp with clangTom de Vries1-4/+9
Consider test-case gdb.base/vla-optimized-out.exp, compiled using clang-10. GDB fails to get the size of the vla a: ... (gdb) p sizeof (a)^M Cannot access memory at address 0x6^M (gdb) FAIL: gdb.base/vla-optimized-out.exp: o1: printed size of \ optimized out vla ... The relevant DWARF looks like this: the variable a: ... <2><12b>: Abbrev Number: 5 (DW_TAG_variable) <12c> DW_AT_name : a <132> DW_AT_type : <0x189> ... has type: ... <1><189>: Abbrev Number: 10 (DW_TAG_array_type) <18a> DW_AT_type : <0x198> <2><18e>: Abbrev Number: 11 (DW_TAG_subrange_type) <18f> DW_AT_type : <0x19f> <193> DW_AT_count : <0x117> ... with the count attribute equated to the value of this artificial variable: ... <2><117>: Abbrev Number: 4 (DW_TAG_variable) <118> DW_AT_location : 10 byte block: 75 1 10 ff ff ff ff f 1a 9f \ (DW_OP_breg5 (rdi): 1; DW_OP_constu: 4294967295; DW_OP_and; DW_OP_stack_value) <123> DW_AT_name : __vla_expr0 <127> DW_AT_type : <0x182> <12b> DW_AT_artificial : 1 ... The location description of the variable is terminated with DW_OP_stack_value, which according to the DWARF spec means that "the DWARF expression represents the actual value of the object, rather than its location". However, in attr_to_dynamic_prop, we set is_reference to true: ... baton->locexpr.is_reference = true; ... and use it in dwarf2_evaluate_property to dereference the value of the DWARF expression, which causes the access to memory at address 0x6. Fix this by ignoring the baton->locexpr.is_reference == true setting if the expression evaluation has ctx.location == DWARF_VALUE_STACK, such that we get: ... (gdb) p sizeof (a)^M $2 = 6^M (gdb) PASS: gdb.base/vla-optimized-out.exp: o1: printed size of \ optimized out vla ... Tested on x86_64-linux, with gcc. Tested the following test-cases (the ones mentioned in PR26905) on x86_64-linux with clang-10: - gdb.base/vla-optimized-out.exp - gdb.base/vla-ptr.exp - gdb.mi/mi-vla-c99 gdb/ChangeLog: 2020-11-30 Tom de Vries <tdevries@suse.de> PR symtab/26905 * dwarf2/loc.c (dwarf2_locexpr_baton_eval): Add and handle is_reference parameter. (dwarf2_evaluate_property): Update dwarf2_locexpr_baton_eval call. gdb/testsuite/ChangeLog: 2020-11-30 Tom de Vries <tdevries@suse.de> PR symtab/26905 * gdb.dwarf2/count.exp: Remove kfails.
2020-11-23gdbtypes.h: Get rid of the TYPE_FIXED_POINT_INFO macroJoel Brobecker1-2/+2
This is one step further towards the removal of all these macros. gdb/ChangeLog: * gdbtypes.h (struct type) <fixed_point_info, set_fixed_point_info>: New methods. (INIT_FIXED_POINT_SPECIFIC): Adjust. (TYPE_FIXED_POINT_INFO): Delete macro. (allocate_fixed_point_type_info): Change return type to void. * gdbtypes.c (copy_type_recursive): Replace the use of TYPE_FIXED_POINT_INFO by a call to the fixed_point_info method. (fixed_point_scaling_factor): Likewise. (allocate_fixed_point_type_info): Change return type to void. Adjust implementation accordingly. * dwarf2/read.c (finish_fixed_point_type): Replace the use of TYPE_FIXED_POINT_INFO by a call to the fixed_point_info method.
2020-11-20gdb: fix dwarf2/read.c build on solarisSimon Marchi1-2/+2
When building on solaris (gcc farm machine gcc211), I get: CXX dwarf2/read.o /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function 'void finish_fixed_point_type(type*, die_info*, dwarf2_cu*)': /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:18204:42: error: call of overloaded 'abs(LONGEST&)' is ambiguous *num_or_denom = 1 << abs (scale_exp); ^ In file included from /usr/include/stdlib.h:11:0, from ../gnulib/import/stdlib.h:36, from /opt/csw/include/c++/5.5.0/cstdlib:72, from /export/home/simark/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:90, from /export/home/simark/src/binutils-gdb/gdb/defs.h:28, from /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:31: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:163:16: note: candidate: long int std::abs(long int) inline long abs(long _l) { return labs(_l); } ^ /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:117:12: note: candidate: int std::abs(int) extern int abs(int); ^ I don't know why, but using std::abs instead of just abs fixes it. gdb/ChangeLog: * dwarf2/read.c (finish_fixed_point_type): Use std::abs instead of abs. Change-Id: I57b9098351f2a8b2d2f61e848b97f7b2dfe55908
2020-11-15Add support for printing value of DWARF-based fixed-point type objectsJoel Brobecker1-0/+211
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-12gdb/dwarf: fix call to dwarf2_queue_guard in dw2_do_instantiate_symtabSimon Marchi1-1/+1
It took me a while to understand why that would even compile: it looks like we pass a type name as a pointer, that makes no sense. By looking at the DWARF, I understood that the compiler actually interprets it as a function declaration. So the statement was doing nothing, no dwarf2_queue_guard was instantiated. Fix it by passing the right variable name. gdb/ChangeLog: * dwarf2/read.c (dw2_do_instantiate_symtab): Fix call to dwarf2_queue_guard. Change-Id: I3a7bdead9e8c39f8342a471f10181b85b8f0d801
2020-11-12gdb/dwarf: fix typo in dwarf2/read.cSimon Marchi1-1/+1
gdb/ChangeLog: * dwarf2/read.c (dw2_do_instantiate_symtab): Fix typo in comment. Change-Id: I6cb98768c04a537cf3d427648bddc57c631518e5
2020-11-12gdb: convert "set debug dwarf-read" to new styleSimon Marchi1-152/+114
Add dwarf_read_debug_printf and dwarf_read_debug_printf_v macros and use them throughout dwarf2/read.c. The second one is used for "verbose" prints, when the value of "set debug dwarf-read" is >= 2. gdb/ChangeLog: * dwarf2/read.c (dwarf_read_debug_printf, dwarf_read_debug_printf_v): New macros, use throughout the file. Change-Id: I694da69da2e1f2caa4c27a421a975790636411e2
2020-11-05Remove objfile parameter from abbrev_table::readTom Tromey3-13/+16
In a longer series that I am working on, I needed to remove the objfile parameter from abbrev_table::read. It seemed to me that this was a simple and relatively harmless patch, so I'm sending it now. gdb/ChangeLog 2020-11-05 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo) (cutu_reader::cutu_reader, cutu_reader::cutu_reader) (build_type_psymtabs_1): Update. * dwarf2/abbrev.h (struct abbrev_table): Remove objfile parameter. * dwarf2/abbrev.c (abbrev_table::read): Remove objfile parameter. Don't read section. Add assert.
2020-11-04Recognize names of array typesTom Tromey1-5/+21
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-04Only use stride for final element typeTom Tromey1-4/+12
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-04Synthesize array descriptors with -fgnat-encodings=minimalTom Tromey1-6/+322
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-04Rewrite leb.h:read_3_bytesTom Tromey1-8/+1
read_3_bytes assumes little-endian data, but in fact it depends on the BFD. This patch rewrites this function to use bfd_get_24 instead. 2020-11-04 Tom Tromey <tromey@adacore.com> * dwarf2/leb.h (read_3_bytes): Use bfd_get_24.
2020-11-02gdb, gdbserver, gdbsupport: fix leading space vs tabs issuesSimon Marchi11-558/+558
Many spots incorrectly use only spaces for indentation (for example, there are a lot of spots in ada-lang.c). I've always found it awkward when I needed to edit one of these spots: do I keep the original wrong indentation, or do I fix it? What if the lines around it are also wrong, do I fix them too? I probably don't want to fix them in the same patch, to avoid adding noise to my patch. So I propose to fix as much as possible once and for all (hopefully). One typical counter argument for this is that it makes code archeology more difficult, because git-blame will show this commit as the last change for these lines. My counter counter argument is: when git-blaming, you often need to do "blame the file at the parent commit" anyway, to go past some other refactor that touched the line you are interested in, but is not the change you are looking for. So you already need a somewhat efficient way to do this. Using some interactive tool, rather than plain git-blame, makes this trivial. For example, I use "tig blame <file>", where going back past the commit that changed the currently selected line is one keystroke. It looks like Magit in Emacs does it too (though I've never used it). Web viewers of Github and Gitlab do it too. My point is that it won't really make archeology more difficult. The other typical counter argument is that it will cause conflicts with existing patches. That's true... but it's a one time cost, and those are not conflicts that are difficult to resolve. I have also tried "git rebase --ignore-whitespace", it seems to work well. Although that will re-introduce the faulty indentation, so one needs to take care of fixing the indentation in the patch after that (which is easy). gdb/ChangeLog: * aarch64-linux-tdep.c: Fix indentation. * aarch64-ravenscar-thread.c: Fix indentation. * aarch64-tdep.c: Fix indentation. * aarch64-tdep.h: Fix indentation. * ada-lang.c: Fix indentation. * ada-lang.h: Fix indentation. * ada-tasks.c: Fix indentation. * ada-typeprint.c: Fix indentation. * ada-valprint.c: Fix indentation. * ada-varobj.c: Fix indentation. * addrmap.c: Fix indentation. * addrmap.h: Fix indentation. * agent.c: Fix indentation. * aix-thread.c: Fix indentation. * alpha-bsd-nat.c: Fix indentation. * alpha-linux-tdep.c: Fix indentation. * alpha-mdebug-tdep.c: Fix indentation. * alpha-nbsd-tdep.c: Fix indentation. * alpha-obsd-tdep.c: Fix indentation. * alpha-tdep.c: Fix indentation. * amd64-bsd-nat.c: Fix indentation. * amd64-darwin-tdep.c: Fix indentation. * amd64-linux-nat.c: Fix indentation. * amd64-linux-tdep.c: Fix indentation. * amd64-nat.c: Fix indentation. * amd64-obsd-tdep.c: Fix indentation. * amd64-tdep.c: Fix indentation. * amd64-windows-tdep.c: Fix indentation. * annotate.c: Fix indentation. * arc-tdep.c: Fix indentation. * arch-utils.c: Fix indentation. * arch/arm-get-next-pcs.c: Fix indentation. * arch/arm.c: Fix indentation. * arm-linux-nat.c: Fix indentation. * arm-linux-tdep.c: Fix indentation. * arm-nbsd-tdep.c: Fix indentation. * arm-pikeos-tdep.c: Fix indentation. * arm-tdep.c: Fix indentation. * arm-tdep.h: Fix indentation. * arm-wince-tdep.c: Fix indentation. * auto-load.c: Fix indentation. * auxv.c: Fix indentation. * avr-tdep.c: Fix indentation. * ax-gdb.c: Fix indentation. * ax-general.c: Fix indentation. * bfin-linux-tdep.c: Fix indentation. * block.c: Fix indentation. * block.h: Fix indentation. * blockframe.c: Fix indentation. * bpf-tdep.c: Fix indentation. * break-catch-sig.c: Fix indentation. * break-catch-syscall.c: Fix indentation. * break-catch-throw.c: Fix indentation. * breakpoint.c: Fix indentation. * breakpoint.h: Fix indentation. * bsd-uthread.c: Fix indentation. * btrace.c: Fix indentation. * build-id.c: Fix indentation. * buildsym-legacy.h: Fix indentation. * buildsym.c: Fix indentation. * c-typeprint.c: Fix indentation. * c-valprint.c: Fix indentation. * c-varobj.c: Fix indentation. * charset.c: Fix indentation. * cli/cli-cmds.c: Fix indentation. * cli/cli-decode.c: Fix indentation. * cli/cli-decode.h: Fix indentation. * cli/cli-script.c: Fix indentation. * cli/cli-setshow.c: Fix indentation. * coff-pe-read.c: Fix indentation. * coffread.c: Fix indentation. * compile/compile-cplus-types.c: Fix indentation. * compile/compile-object-load.c: Fix indentation. * compile/compile-object-run.c: Fix indentation. * completer.c: Fix indentation. * corefile.c: Fix indentation. * corelow.c: Fix indentation. * cp-abi.h: Fix indentation. * cp-namespace.c: Fix indentation. * cp-support.c: Fix indentation. * cp-valprint.c: Fix indentation. * cris-linux-tdep.c: Fix indentation. * cris-tdep.c: Fix indentation. * darwin-nat-info.c: Fix indentation. * darwin-nat.c: Fix indentation. * darwin-nat.h: Fix indentation. * dbxread.c: Fix indentation. * dcache.c: Fix indentation. * disasm.c: Fix indentation. * dtrace-probe.c: Fix indentation. * dwarf2/abbrev.c: Fix indentation. * dwarf2/attribute.c: Fix indentation. * dwarf2/expr.c: Fix indentation. * dwarf2/frame.c: Fix indentation. * dwarf2/index-cache.c: Fix indentation. * dwarf2/index-write.c: Fix indentation. * dwarf2/line-header.c: Fix indentation. * dwarf2/loc.c: Fix indentation. * dwarf2/macro.c: Fix indentation. * dwarf2/read.c: Fix indentation. * dwarf2/read.h: Fix indentation. * elfread.c: Fix indentation. * eval.c: Fix indentation. * event-top.c: Fix indentation. * exec.c: Fix indentation. * exec.h: Fix indentation. * expprint.c: Fix indentation. * f-lang.c: Fix indentation. * f-typeprint.c: Fix indentation. * f-valprint.c: Fix indentation. * fbsd-nat.c: Fix indentation. * fbsd-tdep.c: Fix indentation. * findvar.c: Fix indentation. * fork-child.c: Fix indentation. * frame-unwind.c: Fix indentation. * frame-unwind.h: Fix indentation. * frame.c: Fix indentation. * frv-linux-tdep.c: Fix indentation. * frv-tdep.c: Fix indentation. * frv-tdep.h: Fix indentation. * ft32-tdep.c: Fix indentation. * gcore.c: Fix indentation. * gdb_bfd.c: Fix indentation. * gdbarch.sh: Fix indentation. * gdbarch.c: Re-generate * gdbarch.h: Re-generate. * gdbcore.h: Fix indentation. * gdbthread.h: Fix indentation. * gdbtypes.c: Fix indentation. * gdbtypes.h: Fix indentation. * glibc-tdep.c: Fix indentation. * gnu-nat.c: Fix indentation. * gnu-nat.h: Fix indentation. * gnu-v2-abi.c: Fix indentation. * gnu-v3-abi.c: Fix indentation. * go32-nat.c: Fix indentation. * guile/guile-internal.h: Fix indentation. * guile/scm-cmd.c: Fix indentation. * guile/scm-frame.c: Fix indentation. * guile/scm-iterator.c: Fix indentation. * guile/scm-math.c: Fix indentation. * guile/scm-ports.c: Fix indentation. * guile/scm-pretty-print.c: Fix indentation. * guile/scm-value.c: Fix indentation. * h8300-tdep.c: Fix indentation. * hppa-linux-nat.c: Fix indentation. * hppa-linux-tdep.c: Fix indentation. * hppa-nbsd-nat.c: Fix indentation. * hppa-nbsd-tdep.c: Fix indentation. * hppa-obsd-nat.c: Fix indentation. * hppa-tdep.c: Fix indentation. * hppa-tdep.h: Fix indentation. * i386-bsd-nat.c: Fix indentation. * i386-darwin-nat.c: Fix indentation. * i386-darwin-tdep.c: Fix indentation. * i386-dicos-tdep.c: Fix indentation. * i386-gnu-nat.c: Fix indentation. * i386-linux-nat.c: Fix indentation. * i386-linux-tdep.c: Fix indentation. * i386-nto-tdep.c: Fix indentation. * i386-obsd-tdep.c: Fix indentation. * i386-sol2-nat.c: Fix indentation. * i386-tdep.c: Fix indentation. * i386-tdep.h: Fix indentation. * i386-windows-tdep.c: Fix indentation. * i387-tdep.c: Fix indentation. * i387-tdep.h: Fix indentation. * ia64-libunwind-tdep.c: Fix indentation. * ia64-libunwind-tdep.h: Fix indentation. * ia64-linux-nat.c: Fix indentation. * ia64-linux-tdep.c: Fix indentation. * ia64-tdep.c: Fix indentation. * ia64-tdep.h: Fix indentation. * ia64-vms-tdep.c: Fix indentation. * infcall.c: Fix indentation. * infcmd.c: Fix indentation. * inferior.c: Fix indentation. * infrun.c: Fix indentation. * iq2000-tdep.c: Fix indentation. * language.c: Fix indentation. * linespec.c: Fix indentation. * linux-fork.c: Fix indentation. * linux-nat.c: Fix indentation. * linux-tdep.c: Fix indentation. * linux-thread-db.c: Fix indentation. * lm32-tdep.c: Fix indentation. * m2-lang.c: Fix indentation. * m2-typeprint.c: Fix indentation. * m2-valprint.c: Fix indentation. * m32c-tdep.c: Fix indentation. * m32r-linux-tdep.c: Fix indentation. * m32r-tdep.c: Fix indentation. * m68hc11-tdep.c: Fix indentation. * m68k-bsd-nat.c: Fix indentation. * m68k-linux-nat.c: Fix indentation. * m68k-linux-tdep.c: Fix indentation. * m68k-tdep.c: Fix indentation. * machoread.c: Fix indentation. * macrocmd.c: Fix indentation. * macroexp.c: Fix indentation. * macroscope.c: Fix indentation. * macrotab.c: Fix indentation. * macrotab.h: Fix indentation. * main.c: Fix indentation. * mdebugread.c: Fix indentation. * mep-tdep.c: Fix indentation. * mi/mi-cmd-catch.c: Fix indentation. * mi/mi-cmd-disas.c: Fix indentation. * mi/mi-cmd-env.c: Fix indentation. * mi/mi-cmd-stack.c: Fix indentation. * mi/mi-cmd-var.c: Fix indentation. * mi/mi-cmds.c: Fix indentation. * mi/mi-main.c: Fix indentation. * mi/mi-parse.c: Fix indentation. * microblaze-tdep.c: Fix indentation. * minidebug.c: Fix indentation. * minsyms.c: Fix indentation. * mips-linux-nat.c: Fix indentation. * mips-linux-tdep.c: Fix indentation. * mips-nbsd-tdep.c: Fix indentation. * mips-tdep.c: Fix indentation. * mn10300-linux-tdep.c: Fix indentation. * mn10300-tdep.c: Fix indentation. * moxie-tdep.c: Fix indentation. * msp430-tdep.c: Fix indentation. * namespace.h: Fix indentation. * nat/fork-inferior.c: Fix indentation. * nat/gdb_ptrace.h: Fix indentation. * nat/linux-namespaces.c: Fix indentation. * nat/linux-osdata.c: Fix indentation. * nat/netbsd-nat.c: Fix indentation. * nat/x86-dregs.c: Fix indentation. * nbsd-nat.c: Fix indentation. * nbsd-tdep.c: Fix indentation. * nios2-linux-tdep.c: Fix indentation. * nios2-tdep.c: Fix indentation. * nto-procfs.c: Fix indentation. * nto-tdep.c: Fix indentation. * objfiles.c: Fix indentation. * objfiles.h: Fix indentation. * opencl-lang.c: Fix indentation. * or1k-tdep.c: Fix indentation. * osabi.c: Fix indentation. * osabi.h: Fix indentation. * osdata.c: Fix indentation. * p-lang.c: Fix indentation. * p-typeprint.c: Fix indentation. * p-valprint.c: Fix indentation. * parse.c: Fix indentation. * ppc-linux-nat.c: Fix indentation. * ppc-linux-tdep.c: Fix indentation. * ppc-nbsd-nat.c: Fix indentation. * ppc-nbsd-tdep.c: Fix indentation. * ppc-obsd-nat.c: Fix indentation. * ppc-ravenscar-thread.c: Fix indentation. * ppc-sysv-tdep.c: Fix indentation. * ppc64-tdep.c: Fix indentation. * printcmd.c: Fix indentation. * proc-api.c: Fix indentation. * producer.c: Fix indentation. * producer.h: Fix indentation. * prologue-value.c: Fix indentation. * prologue-value.h: Fix indentation. * psymtab.c: Fix indentation. * python/py-arch.c: Fix indentation. * python/py-bpevent.c: Fix indentation. * python/py-event.c: Fix indentation. * python/py-event.h: Fix indentation. * python/py-finishbreakpoint.c: Fix indentation. * python/py-frame.c: Fix indentation. * python/py-framefilter.c: Fix indentation. * python/py-inferior.c: Fix indentation. * python/py-infthread.c: Fix indentation. * python/py-objfile.c: Fix indentation. * python/py-prettyprint.c: Fix indentation. * python/py-registers.c: Fix indentation. * python/py-signalevent.c: Fix indentation. * python/py-stopevent.c: Fix indentation. * python/py-stopevent.h: Fix indentation. * python/py-threadevent.c: Fix indentation. * python/py-tui.c: Fix indentation. * python/py-unwind.c: Fix indentation. * python/py-value.c: Fix indentation. * python/py-xmethods.c: Fix indentation. * python/python-internal.h: Fix indentation. * python/python.c: Fix indentation. * ravenscar-thread.c: Fix indentation. * record-btrace.c: Fix indentation. * record-full.c: Fix indentation. * record.c: Fix indentation. * reggroups.c: Fix indentation. * regset.h: Fix indentation. * remote-fileio.c: Fix indentation. * remote.c: Fix indentation. * reverse.c: Fix indentation. * riscv-linux-tdep.c: Fix indentation. * riscv-ravenscar-thread.c: Fix indentation. * riscv-tdep.c: Fix indentation. * rl78-tdep.c: Fix indentation. * rs6000-aix-tdep.c: Fix indentation. * rs6000-lynx178-tdep.c: Fix indentation. * rs6000-nat.c: Fix indentation. * rs6000-tdep.c: Fix indentation. * rust-lang.c: Fix indentation. * rx-tdep.c: Fix indentation. * s12z-tdep.c: Fix indentation. * s390-linux-tdep.c: Fix indentation. * score-tdep.c: Fix indentation. * ser-base.c: Fix indentation. * ser-mingw.c: Fix indentation. * ser-uds.c: Fix indentation. * ser-unix.c: Fix indentation. * serial.c: Fix indentation. * sh-linux-tdep.c: Fix indentation. * sh-nbsd-tdep.c: Fix indentation. * sh-tdep.c: Fix indentation. * skip.c: Fix indentation. * sol-thread.c: Fix indentation. * solib-aix.c: Fix indentation. * solib-darwin.c: Fix indentation. * solib-frv.c: Fix indentation. * solib-svr4.c: Fix indentation. * solib.c: Fix indentation. * source.c: Fix indentation. * sparc-linux-tdep.c: Fix indentation. * sparc-nbsd-tdep.c: Fix indentation. * sparc-obsd-tdep.c: Fix indentation. * sparc-ravenscar-thread.c: Fix indentation. * sparc-tdep.c: Fix indentation. * sparc64-linux-tdep.c: Fix indentation. * sparc64-nbsd-tdep.c: Fix indentation. * sparc64-obsd-tdep.c: Fix indentation. * sparc64-tdep.c: Fix indentation. * stabsread.c: Fix indentation. * stack.c: Fix indentation. * stap-probe.c: Fix indentation. * stubs/ia64vms-stub.c: Fix indentation. * stubs/m32r-stub.c: Fix indentation. * stubs/m68k-stub.c: Fix indentation. * stubs/sh-stub.c: Fix indentation. * stubs/sparc-stub.c: Fix indentation. * symfile-mem.c: Fix indentation. * symfile.c: Fix indentation. * symfile.h: Fix indentation. * symmisc.c: Fix indentation. * symtab.c: Fix indentation. * symtab.h: Fix indentation. * target-float.c: Fix indentation. * target.c: Fix indentation. * target.h: Fix indentation. * tic6x-tdep.c: Fix indentation. * tilegx-linux-tdep.c: Fix indentation. * tilegx-tdep.c: Fix indentation. * top.c: Fix indentation. * tracefile-tfile.c: Fix indentation. * tracepoint.c: Fix indentation. * tui/tui-disasm.c: Fix indentation. * tui/tui-io.c: Fix indentation. * tui/tui-regs.c: Fix indentation. * tui/tui-stack.c: Fix indentation. * tui/tui-win.c: Fix indentation. * tui/tui-winsource.c: Fix indentation. * tui/tui.c: Fix indentation. * typeprint.c: Fix indentation. * ui-out.h: Fix indentation. * unittests/copy_bitwise-selftests.c: Fix indentation. * unittests/memory-map-selftests.c: Fix indentation. * utils.c: Fix indentation. * v850-tdep.c: Fix indentation. * valarith.c: Fix indentation. * valops.c: Fix indentation. * valprint.c: Fix indentation. * valprint.h: Fix indentation. * value.c: Fix indentation. * value.h: Fix indentation. * varobj.c: Fix indentation. * vax-tdep.c: Fix indentation. * windows-nat.c: Fix indentation. * windows-tdep.c: Fix indentation. * xcoffread.c: Fix indentation. * xml-syscall.c: Fix indentation. * xml-tdesc.c: Fix indentation. * xstormy16-tdep.c: Fix indentation. * xtensa-config.c: Fix indentation. * xtensa-linux-nat.c: Fix indentation. * xtensa-linux-tdep.c: Fix indentation. * xtensa-tdep.c: Fix indentation. gdbserver/ChangeLog: * ax.cc: Fix indentation. * dll.cc: Fix indentation. * inferiors.h: Fix indentation. * linux-low.cc: Fix indentation. * linux-nios2-low.cc: Fix indentation. * linux-ppc-ipa.cc: Fix indentation. * linux-ppc-low.cc: Fix indentation. * linux-x86-low.cc: Fix indentation. * linux-xtensa-low.cc: Fix indentation. * regcache.cc: Fix indentation. * server.cc: Fix indentation. * tracepoint.cc: Fix indentation. gdbsupport/ChangeLog: * common-exceptions.h: Fix indentation. * event-loop.cc: Fix indentation. * fileio.cc: Fix indentation. * filestuff.cc: Fix indentation. * gdb-dlfcn.cc: Fix indentation. * gdb_string_view.h: Fix indentation. * job-control.cc: Fix indentation. * signals.cc: Fix indentation. Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-01Change end_psymtab_common to a methodTom Tromey1-2/+2
This changes end_psymtab_common to be a method on partial_symtab. This seems a little cleaner to me. gdb/ChangeLog 2020-11-01 Tom Tromey <tom@tromey.com> * dbxread.c (dbx_end_psymtab): Update. * dwarf2/read.c (process_psymtab_comp_unit_reader) (build_type_psymtabs_reader): Update. * xcoffread.c (xcoff_end_psymtab): Update. * ctfread.c (scan_partial_symbols): Update. * psymtab.c (sort_pst_symbols): Remove. (partial_symtab::end): Rename from end_psymtab_common. Inline sort_pst_symbols. * psympriv.h (struct partial_symtab) <end>: New method. (end_psymtab_common): Don't declare.
2020-11-01Remove parameter from end_psymtab_commonTom Tromey1-3/+2
The objfile parameter to end_psymtab_common is no longer needed, so this removes it. gdb/ChangeLog 2020-11-01 Tom Tromey <tom@tromey.com> * dbxread.c (dbx_end_psymtab): Update. * dwarf2/read.c (process_psymtab_comp_unit_reader): Update. (build_type_psymtabs_reader): Update. * xcoffread.c (xcoff_end_psymtab): Update. * ctfread.c (scan_partial_symbols): Update. * psympriv.h (end_psymtab_common): Update. * psymtab.c (end_psymtab_common): Remove objfile parameter. (sort_pst_symbols): Likewise.
2020-11-01Remove init_psymbol_listTom Tromey1-2/+0
init_psymbol_list is now empty, and so this removes it. gdb/ChangeLog 2020-11-01 Tom Tromey <tom@tromey.com> * dbxread.c (dbx_symfile_read): Update. * dwarf2/read.c (dwarf2_build_psymtabs): Update. * xcoffread.c (xcoff_initial_scan): Update. * psympriv.h (init_psymbol_list): Don't declare. * psymtab.c (init_psymbol_list): Remove.
2020-10-26[gdb/symtab] Read CU base address for enqueued CUTom de Vries1-0/+2
Consider the test-case contained in this patch. It consists of two CUs: - cu1, containing a DW_TAG_variable DIE foo - cu2, containing a DW_TAG_base_type DIE int where the variable foo has type int, in other words, there's an inter-CU reference. When expanding the symtab for cu1, expansion of the symtab for cu2 is enqueued, and later processed by process_full_comp_unit. However, processing of .debug_ranges fails because the range is specified relative to a base address which is considered not to be present because !cu->base_address.has_value (), and we run into this case in dwarf2_ranges_process: ... if (!base.has_value ()) { /* We have no valid base address for the ranges data. */ complaint (_("Invalid .debug_ranges data (no base address)")); return 0; } ... Fix this in process_full_comp_unit by setting cu->base_address. Tested on x86_64-linux. gdb/ChangeLog: 2020-10-26 Tom de Vries <tdevries@suse.de> * dwarf2/read.c (process_full_comp_unit): Call dwarf2_find_base_address. gdb/testsuite/ChangeLog: 2020-10-26 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/enqueued-cu-base-addr.exp: New file.
2020-10-22gdb/dwarf: fix reading subprogram with DW_AT_specification (PR gdb/26693)Simon Marchi1-6/+16
Fix a regression introduced by commit 7188ed02d2a7 ("Replace dwarf2_per_cu_data::cu backlink with per-objfile map"). This patch targets both master and gdb-10-branch, since this is a regression from GDB 9. Analysis -------- The DWARF generated by the included test case looks like: 0x0000000b: DW_TAG_compile_unit DW_AT_language [DW_FORM_sdata] (4) 0x0000000d: DW_TAG_base_type DW_AT_name [DW_FORM_string] ("int") DW_AT_byte_size [DW_FORM_data1] (0x04) DW_AT_encoding [DW_FORM_sdata] (5) 0x00000014: DW_TAG_subprogram DW_AT_name [DW_FORM_string] ("apply") 0x0000001b: DW_TAG_subprogram DW_AT_specification [DW_FORM_ref4] (0x00000014 "apply") DW_AT_low_pc [DW_FORM_addr] (0x0000000000001234) DW_AT_high_pc [DW_FORM_data8] (0x0000000000000020) 0x00000030: DW_TAG_template_type_parameter DW_AT_name [DW_FORM_string] ("T") DW_AT_type [DW_FORM_ref4] (0x0000000d "int") 0x00000037: NULL 0x00000038: NULL Simply loading the file in GDB makes it crash: $ ./gdb -nx --data-directory=data-directory testsuite/outputs/gdb.dwarf2/pr26693/pr26693 [1] 15188 abort (core dumped) ./gdb -nx --data-directory=data-directory The crash happens here, where htab (a dwarf2_cu::die_hash field) is unexpectedly NULL while generating partial symbols: #0 0x000055555fa28188 in htab_find_with_hash (htab=0x0, element=0x7fffffffbfa0, hash=27) at /home/simark/src/binutils-gdb/libiberty/hashtab.c:591 #1 0x000055555cb4eb2e in follow_die_offset (sect_off=(unknown: 27), offset_in_dwz=0, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22951 #2 0x000055555cb4edfb in follow_die_ref (src_die=0x0, attr=0x7fffffffc130, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22968 #3 0x000055555caa48c5 in partial_die_full_name (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8441 #4 0x000055555caa4d79 in add_partial_symbol (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8469 #5 0x000055555caa7d8c in add_partial_subprogram (pdi=0x621000157e70, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8737 #6 0x000055555caa265c in scan_partial_symbols (first_die=0x621000157e00, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8230 #7 0x000055555ca98e3f in process_psymtab_comp_unit_reader (reader=0x7fffffffc6b0, info_ptr=0x60600009650d "\003int", comp_unit_die=0x621000157d10, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7614 #8 0x000055555ca9aa2c in process_psymtab_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, want_partial_unit=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7712 #9 0x000055555caa051a in dwarf2_build_psymtabs_hard (per_objfile=0x613000009f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8073 The special thing about this DWARF is that the subprogram at 0x1b is a template specialization described with DW_AT_specification, and has no DW_AT_name in itself. To compute the name of this subprogram, partial_die_full_name needs to load the full DIE for this partial DIE. The name is generated from the templated function name and the actual tempalate parameter values of the specialization. To load the full DIE, partial_die_full_name creates a dummy DWARF attribute of form DW_FORM_ref_addr that points to our subprogram's DIE, and calls follow_die_ref on it. This eventually causes load_full_comp_unit to be called for the exact same CU we are currently making partial symbols for: #0 load_full_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, skip_partial=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:9238 #1 0x000055555cb4e943 in follow_die_offset (sect_off=(unknown: 27), offset_in_dwz=0, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22942 #2 0x000055555cb4edfb in follow_die_ref (src_die=0x0, attr=0x7fffffffc130, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22968 #3 0x000055555caa48c5 in partial_die_full_name (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8441 #4 0x000055555caa4d79 in add_partial_symbol (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8469 #5 0x000055555caa7d8c in add_partial_subprogram (pdi=0x621000157e70, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8737 #6 0x000055555caa265c in scan_partial_symbols (first_die=0x621000157e00, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8230 #7 0x000055555ca98e3f in process_psymtab_comp_unit_reader (reader=0x7fffffffc6b0, info_ptr=0x60600009650d "\003int", comp_unit_die=0x621000157d10, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7614 #8 0x000055555ca9aa2c in process_psymtab_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, want_partial_unit=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7712 #9 0x000055555caa051a in dwarf2_build_psymtabs_hard (per_objfile=0x613000009f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8073 load_full_comp_unit creates a cutu_reader for the CU. Since a dwarf2_cu object already exists for the CU, load_full_comp_unit is expected to find it and pass it to cutu_reader, so that cutu_reader doesn't create a new dwarf2_cu for the CU. And this is the difference between before and after the regression. Before commit 7188ed02d2a7, the dwarf2_per_cu_data -> dwarf2_cu link was a simple pointer in dwarf2_per_cu_data. This pointer was set up when starting the read the partial symbols. So it was already available at that point where load_full_comp_unit gets called. Post-7188ed02d2a7, this link is per-objfile, kept in the dwarf2_per_objfile::m_dwarf2_cus hash map. The entry is only put in the hash map once the partial symbols have been successfully read, when cutu_reader::keep is called. Therefore, it is _not_ set at the point load_full_comp_unit is called. As a consequence, a new dwarf2_cu object gets created and initialized by load_full_comp_unit (including initializing that dwarf2_cu::die_hash field). Meanwhile, the dwarf2_cu object created and used by the callers up the stack does not get initialized for full symbol reading, and the dwarf2_cu::die_hash field stays unexpectedly NULL. Solution -------- Since the caller of load_full_comp_unit knows about the existing dwarf2_cu object for the CU we are reading (the one load_full_comp_unit is expected to find), we can simply make it pass it down, instead of having load_full_comp_unit look up the per-objfile map. load_full_comp_unit therefore gets a new `existing_cu` parameter. All other callers get updated to pass `per_objfile->get_cu (per_cu)`, so the behavior shouldn't change for them, compared to the current HEAD. A test is added, which is the bare minimum to reproduce the issue. Notes ----- The original problem was reproduced by downloading https://github.com/oneapi-src/oneTBB/releases/download/v2020.3/tbb-2020.3-lin.tgz and loading libtbb.so in GDB. This code was compiled with the Intel C/C++ compiler. I was not able to reproduce the issue using GCC, I think because GCC puts a DW_AT_name in the specialized subprogram, so there's no need for partial_die_full_name to load the full DIE of the subprogram, and the faulty code doesn't execute. gdb/ChangeLog: PR gdb/26693 * dwarf2/read.c (load_full_comp_unit): Add existing_cu parameter. (load_cu): Pass existing CU. (process_imported_unit_die): Likewise. (follow_die_offset): Likewise. gdb/testsuite/ChangeLog: PR gdb/26693 * gdb.dwarf2/template-specification-full-name.exp: New test. Change-Id: I57c8042f96c45f15797a3848e4d384181c56bb44
2020-10-17Have partial symbol tables own psymbol vectorsTom Tromey2-51/+26
Currently pointers to all partial symbols are stored in two vectors; and then indices into these vectors are stored in each partial_symtab. This patch changes this so that each partial symtab instead has vectors of symbols. add_psymbol_to_list can now be changed into a method on partial_symtab as well. My main motivation for doing this is that I am looking into calling sort_pst_symbols in the background. However, I haven't actually implemented this yet. (Also this may make it more feasible to also sort the static psymbols, though I haven't tried that either.) Also, though, this lets us remove the "current_global_psymbols" vector, because now the callers can simply refer directly to the psymtab that they are modifying (formerly this was implicit). The main drawback of this patch is that it increases the size of partial symtab. gdb/ChangeLog 2020-10-17 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_end_psymtab): Use partial_symtab::empty. (scan_xcoff_symtab): Update. * psymtab.h (class psymtab_storage) <global_psymbols, static_psymbols, current_global_psymbols, current_static_psymbols>: Remove. * psymtab.c (require_partial_symbols, find_pc_sect_psymbol) (match_partial_symbol, lookup_partial_symbol): Update. (print_partial_symbols): Change parameters. (dump_psymtab, recursively_search_psymtabs) (psym_fill_psymbol_map, psym_find_compunit_symtab_by_address) (sort_pst_symbols, partial_symtab::partial_symtab): Update. (concat): Remove. (end_psymtab_common): Simplify. (append_psymbol_to_list): Change parameters. (partial_symtabs::add_psymbol): Rename from add_psymbol_to_list. (init_psymbol_list): Simplify. (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. * psympriv.h (struct partial_symtab) <empty>: New method. <globals_offset, n_global_syms, statics_offset, n_static_syms>: Remove. <global_psymbols, static_psymbols>: New members. <add_psymbol>: New methods. (add_psymbol_to_list): Don't declare. (psymbol_placement): Move earlier. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Change parameters. (mdebug_expand_psymtab): Update. * dwarf2/read.c (process_psymtab_comp_unit_reader) (add_partial_symbol): Update. * dwarf2/index-write.c (write_psymbols): Change parameters. (write_one_signatured_type): Update. (recursively_count_psymbols): Update. (recursively_write_psymbols): Update. (class debug_names) <recursively_write_psymbols>: Update. <write_psymbols>: Change parameters. <write_one_signatured_type>: Update. * dbxread.c (read_dbx_symtab): Update. (dbx_end_psymtab): Use partial_symtab::empty. * ctfread.c (struct ctf_context) <pst>: New member. (create_partial_symtab): Set it. (ctf_psymtab_type_cb, ctf_psymtab_var_cb): Update. (scan_partial_symbols): Use the psymtab's context. Update.
2020-10-09Fix bit offset regressionTom Tromey1-5/+5
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-10-02DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries.nitachra3-4/+91
GDB complaints "During symbol reading: unrecognized DW_MACFINO opcode 0xb" with the testcase given below. Clang is emitting DW_MACRO_define_strx and DW_MACRO_undef_strx entries in .debug_macro section which are not supported in GDB. This patch handles them. DW_MACRO_define_strx and DW_MACRO_undef_strx are added in DWARFv5. They have two operands. The first operand encodes the line number of the #define or #undef macro directive. The second operand identifies a string; it is represented using an unsigned LEB128 encoded value, which is interpreted as a zero-based index into an array of offsets in the .debug_str_offsets section. This is as per the section 6.3.2.1 of Dwarf Debugging Information Format Version 5. Test case used: #define MAX_SIZE 10 int main(void) { int size = 0; size = size + MAX_SIZE; printf("\n The value of size is [%d]\n",size); return 0; } clang -gdwarf-5 -fdebug-macro macro.c -o macro.out Before the patch: gdb/new_gdb/binutils-gdb/build/bin/gdb -q macro.out -ex "set complaints 1" -ex "start" Reading symbols from macro.out... During symbol reading: unrecognized DW_MACFINO opcode 0xb Temporary breakpoint 1 at 0x4004df: file macro.c, line 7. Starting program: /home/nitika/workspace/macro.out Temporary breakpoint 1, main () at macro.c:7 7 int size = 0; (gdb) Tested by running the testsuite before and after the patch with -gdwarf-5 and there is no increase in the number of test cases that fails. Used clang 11.0.0. gdb/ChangeLog: * dwarf2/macro.c (dwarf_decode_macro_bytes): Handle DW_MACRO_define_strx and DW_MACRO_undef_strx. (dwarf_decode_macros): Likewise * dwarf2/read.c (dwarf_decode_macros): Pass str_offsets_base in the parameters which is the value of DW_AT_str_offsets_base. * dwarf2/macro.h (dwarf_decode_macros): Modify the definition to include str_offsets_base.
2020-09-30[gdb] Fix regression in dwarf2_nameTom de Vries1-0/+2
Since commit 2c830f5475 "Change some uses of DW_STRING to string method" we have these regressions: ... FAIL: gdb.base/info-types-c++.exp: info types FAIL: gdb.cp/anon-struct.exp: print type of t::t FAIL: gdb.cp/anon-struct.exp: print type of X::t2 FAIL: gdb.cp/anon-struct.exp: print type of X::t2::t2 FAIL: gdb.cp/anon-struct.exp: print type of t3::~t3 ... Fix these in dwarf2_name by updating attr_name each time attr is updated. Tested on x86_64-linux. gdb/ChangeLog: 2020-09-30 Tom de Vries <tdevries@suse.de> PR symtab/26683 * dwarf2/read.c (dwarf2_name): Update attr_name after attr is updated.
2020-09-30Fix regression in variant part handlingTom Tromey1-2/+2
My series to change DWARF attribute handling to be type-safe introduced a regression in gdb.ada/variant.exp. handle_variant was using as_unsigned on an attribute with DW_FORM_sdata. This patch changes it to use constant_value instead. 2020-09-30 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (handle_variant): Use constant_value.
2020-09-29Remove DW_UNSNDTom Tromey2-89/+86
This removes DW_UNSND, replacing uses with either as_unsigned or constant_value, depending primarily on whether or not the form is already known to be appropriate. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (lookup_dwo_id, get_type_unit_group) (read_file_scope, dwarf2_get_pc_bounds) (dwarf2_record_block_ranges, dwarf2_add_field, get_alignment) (read_structure_type, handle_struct_member_die) (read_enumeration_type, read_array_type, read_set_type) (read_tag_pointer_type, read_tag_reference_type) (read_subroutine_type, read_base_type, read_subrange_type) (read_full_die_1, partial_die_info::read) (partial_die_info::read, by, new_symbol) (dwarf2_const_value_data, dwarf2_const_value_attr) (dump_die_shallow, dwarf2_fetch_constant_bytes) (prepare_one_comp_unit): Update. * dwarf2/attribute.h (DW_UNSND): Remove.
2020-09-29Add attribute::as_boolean methodTom Tromey3-15/+31
This adds a new attribute::as_boolean method, and updates the reader to use it. The main benefit of this change is that now the code will respect the attribute's form. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_func_scope, prototyped_function_p) (read_subroutine_type, partial_die_info::read) (dwarf2_flag_true_p, new_symbol, dump_die_shallow) (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <as_boolean>: Declare. * dwarf2/attribute.c (attribute::as_boolean): New method.
2020-09-29Add attribute::as_virtuality methodTom Tromey3-2/+30
This adds a new attribute::as_virtuality method and changes the DWARF reader to use it. This also ensures that the attibute's form will now be respected. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_add_field, dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <as_virtuality>: New method. * dwarf2/attribute.c (attribute::as_virtuality): New method.
2020-09-29Change die_info methods to check the attribute's formTom Tromey1-5/+17
This changes two die_info methods to check the form of the attribute before using it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Check the attribute's form.
2020-09-29Change is_valid_DW_AT_defaulted to a method on attributeTom Tromey3-21/+32
This changes is_valid_DW_AT_defaulted to be a method on struct attribute. Now it correctly respects the form of the attribute. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c. (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <defaulted>: Declare. * dwarf2/attribute.c (attribute::defaulted): New method, from is_valid_DW_AT_defaulted.
2020-09-29Add attribute::as_unsigned methodTom Tromey2-12/+21
This introduces a new attribute::as_unsigned method and changes a few spots to use it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dw2_get_file_names_reader) (dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list) (dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton) (dwarf2_symbol_mark_computed): Use as_unsigned. * dwarf2/attribute.h (struct attribute) <as_unsigned>: New method. <form_is_section_offset>: Update comment.
2020-09-29Change how accessibility is handled in dwarf2/read.cTom Tromey1-22/+19
dwarf2/read.c uses dwarf2_default_access_attribute to check for the default access attribute. This patch simplifies the code by moving more of the access processing into this function, changing its name to reflect the difference. This also ensures that the attribute's form is respected, by changing to code to use the constant_value method. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_access_attribute): Rename from dwarf2_default_access_attribute. Look up attribute. (dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn): Update.
2020-09-29Change how reprocessing is doneTom Tromey2-32/+37
Currently gdb keeps a vector of attributes that require reprocessing. However, now that there is a reprocessing flag in the attribute, we can remove the vector and instead simply loop over attributes a second time. Normally there are not many attributes, so this should be reasonably cheap. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (skip_one_die): Update. (read_full_die_1): Change how reprocessing is done. (partial_die_info::read): Update. (read_attribute_value): Remove need_reprocess parameter. (read_attribute): Likewise. * dwarf2/attribute.h (struct attribute) <requires_reprocessing_p>: New method.
2020-09-29Remove DW_ADDRTom Tromey3-9/+25
This removes DW_ADDR in favor of accessor methods. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_reprocess, read_attribute_value) (dwarf2_const_value_attr, dump_die_shallow) (dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <form_is_ref>: Update comment. <set_address>: New method. (DW_ADDR): Remove. * dwarf2/attribute.c (attribute::form_is_ref): Update comment. (attribute::as_string, attribute::as_address): Add assert.
2020-09-29Add reprocessing flag to struct attributeTom Tromey3-6/+57
Some forms require "reprocessing" -- a second pass to update their value appropriately. In this case, we'll set the unsigned value on the attribute, and then later set it to the correct value. To handle this, we introduce a reprocessing flag to attribute. Then, we manage this flag to ensure that setting and unsetting is done properly. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo): Use OBSTACK_ZALLOC. (read_attribute_reprocess, read_attribute_value): Update. (read_attribute): Clear requires_reprocessing. * dwarf2/attribute.h (struct attribute) <as_unsigned_reprocess, form_requires_reprocessing>: New methods. <string_init>: Clear requires_reprocessing. <set_unsigned_reprocess>: New method. <name>: Shrink by one bit. <requires_reprocessing>: New member. * dwarf2/attribute.c (attribute::form_requires_reprocessing): New method.
2020-09-29Use setter for attribute's unsigned valueTom Tromey3-26/+59
This adds form_is_unsigned and an unsigned setter method to struct attribute, and updates the remaining code. Now DW_UNSND is no longer used as an lvalue. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_value): Update. * dwarf2/attribute.h (struct attribute) <form_is_unsigned, set_unsigned>: New methods. * dwarf2/attribute.c (attribute::form_is_unsigned): New method.
2020-09-29Remove DW_SNDTom Tromey2-9/+27
This removes DW_SND in favor of accessors on struct attribute. These accessors check that the form is appropriate. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (get_alignment, read_array_order) (read_attribute_value, dwarf2_const_value_attr) (dump_die_shallow, dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <as_signed, set_signed>: New methods. (DW_SND): Remove.
2020-09-29Remove DW_SIGNATURETom Tromey2-6/+20
This removes DW_SIGNATURE in favor of methods on struct attribute. As usual, the methods check the form, which DW_SIGNATURE did not do. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_value, lookup_die_type) (dump_die_shallow, follow_die_sig, get_DW_AT_signature_type): Update. * dwarf2/attribute.h (struct attribute) <as_signature, set_signature>: New methods. (DW_SIGNATURE): Remove.
2020-09-29Remove DW_BLOCKTom Tromey3-74/+109
This removes the DW_BLOCK accessor in favor of methods on struct attribute. The methods, unlike the access, check the form. Note that DW_FORM_data16 had to be handled by form_is_block, because in practice that is how we store values of this form. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_call_site_scope) (handle_data_member_location, dwarf2_add_member_fn) (mark_common_block_symbol_computed, attr_to_dynamic_prop) (partial_die_info::read, read_attribute_value) (var_decode_location, dwarf2_const_value_attr, dump_die_shallow) (dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_constant_bytes) (dwarf2_symbol_mark_computed): Update. * dwarf2/attribute.h (struct attribute) <as_block, set_block>: New methods. (DW_BLOCK): Remove. * dwarf2/attribute.c (attribute::form_is_block): Add DW_FORM_data16.
2020-09-29Remove DW_STRING and DW_STRING_IS_CANONICALTom Tromey3-49/+67
This removes DW_STRING and DW_STRING_IS_CANONICAL, replacing them with accessor methods on struct attribute. The new code ensures that a string value will only ever be used when the form allows it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo) (read_attribute_reprocess, read_attribute_value, read_attribute) (dwarf2_const_value_attr, dwarf2_name, dump_die_shallow) (dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <form_is_string>: Declare. <set_string_noncanonical, set_string_canonical>: New methods. <string_is_canonical>: Update comment. <canonical_string_p>: Add assert. (DW_STRING, DW_STRING_IS_CANONICAL): Remove. * dwarf2/attribute.c (attribute::form_is_string): New method. (attribute::string): Use it.
2020-09-29Remove some uses of DW_STRING_IS_CANONICALTom Tromey2-4/+14
This removes the rvalue uses of DW_STRING_IS_CANONICAL, replacing them with an accessor method. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (anonymous_struct_prefix, dwarf2_name) (dump_die_shallow): Use canonical_string_p. * dwarf2/attribute.h (struct attribute) <canonical_string_p>: New method.
2020-09-29Change some uses of DW_STRING to string methodTom Tromey1-28/+36
This changes some of the simpler spots to use attribute::string rather than DW_STRING. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (partial_die_info::read) (dwarf2_const_value_attr, anonymous_struct_prefix, ) (dwarf2_name, dwarf2_fetch_constant_bytes): Use attribute::as_string.
2020-09-29Avoid using DW_* macros in dwarf2/attribute.cTom Tromey1-5/+5
There's no need to use the DW_* accessor macros in dwarf2/attribute.c, and this is a necessary step toward our goal of removing them entirely. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/attribute.c (attribute::address): Don't use DW_UNSND or DW_ADDR. (attribute::string): Don't use DW_STRING. (attribute::get_ref_die_offset): Don't use DW_UNSND. (attribute::constant_value): Don't use DW_UNSND or DW_SND.
2020-09-29Rename struct attribute accessorsTom Tromey3-16/+16
This removes the "value_" prefix from the struct value accessors. This seemed unnecessarily wordy to me. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_find_base_address, read_call_site_scope) (dwarf2_get_pc_bounds, dwarf2_record_block_ranges) (partial_die_info::read, dwarf2_string_attr, new_symbol): Update. * dwarf2/attribute.h (struct attribute): Rename methods. * dwarf2/attribute.c (attribute::as_address): Rename from value_as_address. (attribute::as_string): Rename from value_as_string.
2020-09-29Add attribute::value_as_string methodTom Tromey1-5/+0
The full DIE reader checks that an attribute has a "string" form in some spots, but the partial DIE reader does not. This patch brings the two readers in sync for one specific case, namely when examining the linkage name. This avoids regressions in an existing DWARF test case. A full fix for this problem would be preferable. An accessor like DW_STRING should always check the form. However, I haven't attempted that in this series. Also the fact that the partial and full readers can disagree like this is a design flaw. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (partial_die_info::read) <case DW_AT_linkage_name>: Use value_as_string. (dwarf2_string_attr): Use value_as_string. * dwarf2/attribute.h (struct attribute) <value_as_string>: Declare method. * dwarf2/attribute.c (attribute::value_as_string): New method.