aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
AgeCommit message (Collapse)AuthorFilesLines
2023-03-18Unify arch_pointer_type and init_pointer_typeTom Tromey1-1/+1
This unifies arch_pointer_type and init_pointer_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_decfloat_type and init_decfloat_typeTom Tromey1-1/+1
This unifies arch_decfloat_type and init_decfloat_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_float_type and init_float_typeTom Tromey1-1/+1
This unifies arch_float_type and init_float_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_boolean_type and init_boolean_typeTom Tromey1-1/+1
This unifies arch_boolean_type and init_boolean_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_character_type and init_character_typeTom Tromey1-4/+4
This unifies arch_character_type and init_character_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_integer_type and init_integer_typeTom Tromey2-4/+10
This unifies arch_integer_type and init_integer_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove init_typeTom Tromey1-13/+18
This removes init_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove alloc_typeTom Tromey1-7/+8
This removes alloc_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-17Fix line table regressionTom Tromey1-1/+2
Simon pointed out a line table regression, and after a couple of false starts, I was able to reproduce it by hand using his instructions. The bug is that most of the code in do_mixed_source_and_assembly uses unrelocated addresses, but one spot does: pc = low; ... after the text offset has been removed. This patch fixes the problem by introducing a new type to represent unrelocated addresses in the line table. This prevents this sort of bug to some degree (it's still possible to manipulate a CORE_ADDR in a bad way, this is unavoidable). However, this did let the compiler flag a few spots in that function, and now it's not possible to compare an unrelocated address from a line table with an ordinary CORE_ADDR. Regression tested on x86-64 Fedora 36, though note this setup never reproduced the bug in the first place. I also tested it by hand on the disasm-optim test program.
2023-03-14Add methods and operators to gdb_mpzTom Tromey1-26/+20
This adds various methods and operators to gdb_mpz, as a step toward hiding the implementation. This only adds the operators that were needed. Many more could be added as required.
2023-03-11Change linetables to be objfile-independentTom Tromey1-3/+2
This changes linetables to not add the text offset to the addresses they contain. I did this in a few steps, necessarily combined together in one patch: I renamed the 'pc' member to 'm_pc', added the appropriate accessors, and then recompiled. Then I fixed all the errors. Where possible I generally chose to use the raw_pc accessor, as it is less expensive. Note that this patch discounts the possibility that the text section offset might cause wraparound in the addresses in the line table. However, this was already discounted -- in particular, objfile_relocate1 did not re-sort the table in this scenario. (There was a bug open about this, but as far as I can tell this has never happened, it's not even clear what inspired that bug.) Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-09gdb, gdbserver, gdbsupport: fix whitespace issuesSimon Marchi2-15/+15
Replace spaces with tabs in a bunch of places. Change-Id: If0f87180f1d13028dc178e5a8af7882a067868b0
2023-03-07Clean up attribute reprocessingTom Tromey1-104/+101
I ran across the attribute reprocessing code recently and noticed that it unconditionally sets members of the CU when reading a DIE. Also, each spot reading attributes needs to be careful to "reprocess" them as a separate step. This seemed excessive to me, because while reprocessing applies to any DIE, setting the CU members is only necessary for the toplevel DIE in any given CU. This patch introduces a new read_toplevel_die function and changes a few spots to call it. This is easily done because reading the toplevel DIE is already special. I left the reprocessing flag and associated checks in attribute. It could be stripped out, but I am not sure it would provide much value (maybe some iota of performance). Regression tested on x86-64 Fedora 36.
2023-03-07Fix selfcheck regression due to new maint commandTom Tromey1-2/+2
Simon points out that the new maint command, intended to fix a regression, also introduces a new regression in "maint selftest". This patch fixes the error. I did a full regression test on x86-64 Fedora 36.
2023-03-07Ensure index cache entry written in testTom Tromey1-0/+15
Now that index cache files are written in the background, one test in index-cache.exp is racy -- it assumes that the cache file will have been written during startup. This patch fixes the problem by introducing a new maintenance command to wait for all pending writes to the index cache. Approved-By: Simon Marchi <simon.marchi@efficios.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-03-01gdb: update some copyright years (2022 -> 2023)Simon Marchi2-2/+2
The copyright years in the ROCm files (e.g. solib-rocm.c) are wrong, they end in 2022 instead of 2023. I suppose because I posted (or at least prepared) the patches in 2022 but merged them in 2023, and forgot to update the year. I found a bunch of other files that are in the same situation. Fix them all up. Change-Id: Ia55f5b563606c2ba6a89046f22bc0bf1c0ff2e10 Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-01Use const for dwarf2_property_batonTom Tromey2-5/+5
Once a baton is stored in a struct type, it doesn't make sense to modify it. This patch constifies the API. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-01Make gdb property batons type-safeTom Tromey1-8/+4
gdbtypes treats dynamic property batons as 'void *', but in actuality the only users all use dwarf2_property_baton. This patch changes this code to be type-safe. If a new type is needed here, it seems like that too could be done in a type-safe way. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-27gdb: don't treat empty enums as flag enumsAndrew Burgess1-0/+2
In C++ it is possible to use an empty enum as a strong typedef. For example, a user could write: enum class my_type : unsigned char {}; Now my_type can be used like 'unsigned char' except the compiler will not allow implicit conversion too and from the native 'unsigned char' type. This is used in the standard library for things like std::byte. Currently, when GDB prints a value of type my_type, it looks like this: (gdb) print my_var $1 = (unknown: 0x4) Which isn't great. This gets worse when we consider something like: std::vector<my_type> vec; When using a pretty-printer, this could look like this: std::vector of length 2, capacity 2 = {(unknown: 0x2), (unknown: 0x4)} Clearly not great. This is described in PR gdb/30148. The problem here is in dwarf2/read.c, we assume all enums are flag enums unless we find an enumerator with a non-flag like value. Clearly an empty enum contains no non-flag values, so we assume the enum is a flag enum. I propose adding an extra check here; that is, an empty enum should never be a flag enum. With this the above cases look more like: (gdb) print my_var $1 = 4 and: std::vector of length 2, capacity 2 = {2, 4} Which look much better. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30148 Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-24Write the DWARF index in the backgroundTom Tromey4-19/+101
The new DWARF cooked indexer interacts poorly with the DWARF index cache. In particular, the cache will require gdb to wait for the cooked index to be finalized. As this happens in the foreground, it means that users with this setting enabled will see a slowdown. This patch changes gdb to write the cache entry a worker thread. (As usual, in the absence of threads, this work is simply done immediately in the main thread.) Some care is taken to ensure that this can't crash, and that gdb will not exit before the task is complete. To avoid use-after-free problems, the DWARF per-BFD object explicitly waits for the index cache task to complete. To avoid gdb exiting early, an exit observer is used to wait for all such pending tasks. In normal use, neither of these waits will be very visible. For users using "-batch" to pre-generate the index, though, it would be. However I don't think there is much to be done about this, as it was the status quo ante.
2023-02-24Only use the per-BFD object to write a DWARF indexTom Tromey5-60/+48
The DWARF index does not need access to the objfile or per-objfile objects when writing -- it's entirely based on the objfile-independent per-BFD data. This patch implements this idea by changing the entire API to only be passed the per-BFD object. This simplifies some lifetime reasoning for the next patch. This patch removes some code that ensures that the BFD came from a file. It seems to me that checking for the existence of a build-id is good enough for the index cache.
2023-02-20[gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producerTom de Vries1-1/+7
Currently we only trust epilogue unwind info only for gcc >= 4.5.0. This has the effect that we don't trust epilogue unwind info for: - unknown producers (CU without DW_AT_producer attribute) - non-gcc producers (say, clang). Instead, only distrust epilogue unwind info only for gcc < 4.5.0.
2023-02-19Convert block_linkage_function to methodTom Tromey2-4/+4
This converts block_linkage_function to be a method. This was mostly written by script.
2023-02-19Convert more block functions to methodsTom Tromey1-2/+2
This converts block_scope, block_set_scope, block_using, and block_set_using to be methods. These are all done at once to make it easier to also convert block_initialize_namespace at the same time. This was mostly written by script.
2023-02-18Fix "start" for D, Rust, etcTom Tromey3-24/+62
The new DWARF indexer broke "start" for some languages. For D, it is broken because, while the code in cooked_index_shard::add specifically excludes Ada, it fails to exclude D. This means that the C "main" will be detected as "main" here -- whereas what is intended is for the code in find_main_name to use d_main_name to find the name. The Rust compiler, on the other hand, uses DW_AT_main_subprogram. However, the code in dwarf2_build_psymtabs_hard fails to create a fully-qualified name, so the name always ends up as plain "main". For D and Ada, a very simple approach suffices: remove the check against "main" from cooked_index_shard::add. This also has the benefit of slightly speeding up DWARF indexing. I assume this approach will work for Pascal and Modula-2 as well, but I don't have a way to test those at present. For Rust, though, this is not sufficient. And, computing the fully-qualified name in dwarf2_build_psymtabs_hard will crash, because cooked_index_entry::full_name uses the canonical name -- and that is not computed until after canonicalization. However, we don't want to wait for canonicalization to be done before computing the main name. That would remove any benefit from doing canonicalization is the background. This patch solves this dilemma by noticing that languages using DW_AT_main_subprogram are, currently, disjoint from languages requiring canonicalization. Because of this, we can add a parameter to full_name to let us avoid crashes, slowdowns, and races here. This is kind of tricky and ugly, so I've tried to comment it sufficiently. While doing this, I had to change gdb.dwarf2/main-subprogram.exp. A different possibility here would be to ignore the canonicalization needs of C in this situation, because those only affect certain types. However, I chose this approach because the test case is artificial anyhow. A long time ago, in an earlier threading attempt, I changed the global current_language to be a function (hidden behind a macro) to let us attempt lazily computing the current language. Perhaps this approach could still be made to work. However, that also seemed rather tricky, more so than this patch. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30116
2023-02-17Avoid manual memory management in go-lang.cTom Tromey1-1/+1
I noticed a couple of spots in go-lang.c that could be improved by using unique_ptr. Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-15Have value::bits_synthetic_pointer return boolTom Tromey1-3/+3
This changes value::bits_synthetic_pointer to return bool and fixes up some fallout from this. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_stack to boolTom Tromey1-1/+1
This changes value::m_stack to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_initialized to boolTom Tromey2-5/+5
This changes value::m_initialized to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_lazy to boolTom Tromey1-1/+1
This changes value::m_lazy to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15gdb/dwarf2: split .debug_names reading code to own fileSimon Marchi3-1028/+1085
Move everything related to reading .debug_names from read.c to read-debug-names.c. The only entry point exposed by read-debug-names.{c,h} is dwarf2_read_debug_names. Change-Id: I18b23f3c7a61b14abc3a46e4bf559bc2d078e8bc Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15gdb/dwarf2: split .gdb_index reading code to own fileSimon Marchi3-845/+923
Move everything related to reading .gdb_index from read.c to read-gdb-index.c. The only entry point exposed by read-gdb-index.{c,h} is dwarf2_read_gdb_index. Change-Id: I1e32c8f0720086538de8d2f612f27545377099bc Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15gdb/dwarf2: move some things to read.hSimon Marchi2-160/+193
The following 2 patches move .gdb_index and .debug_names reading code to their own file. Prepare this by exposing some things used by that code to read.h. Change-Id: If8ef135758a2ff0ab3b765cc92596da8189f3bbd Approved-By: Tom Tromey <tom@tromey.com>
2023-02-14gdb/dwarf2: rename some things, index -> gdb_indexSimon Marchi1-34/+35
This renaming helps make it clearer that these entites (classes, functions) are specific to .gdb_index only, they are not shared with the .debug_names handling. Change-Id: I1a3cf3dbf450b62d1a0879d9aedd26397abdfd13 Approved-By: Tom Tromey <tom@tromey.com>
2023-02-13Remove deprecated_lval_hackTom Tromey2-4/+4
This removes deprecated_lval_hack and the VALUE_LVAL macro, replacing all uses with a call to value::lval. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn various value copying-related functions into methodsTom Tromey1-2/+2
This patch turns a grab bag of value functions to methods of value. These are done together because their implementations are interrelated. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn many optimized-out value functions into methodsTom Tromey2-13/+13
This turns many functions that are related to optimized-out or availability-checking to be methods of value. The static function value_entirely_covered_by_range_vector is also converted to be a private method. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_copy into a methodTom Tromey1-1/+1
This turns value_copy into a method of value. Much of this was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn remaining value_contents functions into methodsTom Tromey1-6/+6
This turns the remaining value_contents functions -- value_contents, value_contents_all, value_contents_for_printing, and value_contents_for_printing_const -- into methods of value. It also converts the static functions require_not_optimized_out and require_available to be private methods. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_incref and value_decref into methodsTom Tromey2-5/+5
This changes value_incref and value_decref to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_bits_synthetic_pointer into a methodTom Tromey1-2/+2
This changes value_bits_synthetic_pointer to be a method of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn some value_contents functions into methodsTom Tromey3-6/+6
This turns value_contents_raw, value_contents_writeable, and value_contents_all_raw into methods on value. The remaining functions will be changed later in the series; they were a bit trickier and so I didn't include them in this patch. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_zero into static "constructor"Tom Tromey1-1/+1
This turns value_zero into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_optimized_out_value into static "constructor"Tom Tromey2-6/+6
This turns allocate_optimized_out_value into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_computed_value into static "constructor"Tom Tromey2-2/+2
This turns allocate_computed_value into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_value into a static "constructor"Tom Tromey3-5/+5
This changes allocate_value to be a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_address and set_value_address functions into methodsTom Tromey2-5/+5
This changes the value_address and set_value_address functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_initialized and set_value_initialized functions into methodsTom Tromey1-1/+1
This changes the value_initialized and set_value_initialized functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_computed_closure and value_computed_funcs functions into methodsTom Tromey2-9/+9
This changes the value_computed_funcs and value_computed_closure functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_stack and set_value_stack functions into methodsTom Tromey1-1/+1
This changes the value_stack and set_value_stack functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>