aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
AgeCommit message (Collapse)AuthorFilesLines
2024-07-15gdb: pass program space to get_current_source_symtab_and_lineSimon Marchi1-1/+3
Make the current program space reference bubble up one level. Change-Id: I6ba6dc4a2cb188720cbb61b84ab5c954aac105c6 Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
2024-04-25gdb: remove gdbcmd.hSimon Marchi4-4/+4
Most files including gdbcmd.h currently rely on it to access things actually declared in cli/cli-cmds.h (setlist, showlist, etc). To make things easy, replace all includes of gdbcmd.h with includes of cli/cli-cmds.h. This might lead to some unused includes of cli/cli-cmds.h, but it's harmless, and much faster than going through the 170 or so files by hand. Change-Id: I11f884d4d616c12c05f395c98bbc2892950fb00f Approved-By: Tom Tromey <tom@tromey.com>
2024-04-22gdb: move `enum compile_i_scope_types` to compile/compile.hSimon Marchi2-0/+29
Move it out of defs.h, adjust the includes here and there. Change-Id: I11901fdce55d54f5e51723e123cef154cfb1bbc5 Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-03Revert "gdb/compile: Use std::filesystem::remove_all in cleanup"Lancelot SIX1-7/+9
This reverts commit 7bba0ad08576309763e3f41193eaa93025e10b8b. Tom de Vries reported that 7bba0ad0857 (gdb/compile: Use std::filesystem::remove_all in cleanup) broke builds with gcc-7.5.0 which mostly supports c++17, but not std::filesystem[1]. As this change is not critical, revert it to maintain compatibility. [1] https://inbox.sourceware.org/gdb-patches/a06e6483-aa2e-4b8a-854f-e369a1e961ea@suse.de/ Change-Id: I58150bd27600c95052bdf1bbbd6b44718a5a0bbf Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31420 Approved-By: Tom Tromey <tom@tromey.com>
2024-04-03gdb/compile: Use std::filesystem::remove_all in cleanupLancelot SIX1-9/+7
In a previous review, I noticed that some code in gdb/compile/compile.c could use c++17's `std::filesystem::remove_all` instead of using some `system ("rm -rf ...");`. This patch implements this. Note that I use the noexcept overload of std::filesystem::remove_all and explicitly check for an error code. This means that this code called during the cleanup procedure cannot throw, and does not risk preventing other cleanup functions to be called. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31420 Change-Id: If5668bf3e15e66c020e5c3b4fa999f861690e4cf Approved-By: Tom Tromey <tom@tromey.com>
2024-03-26gdb, gdbserver, gdbsupport: remove includes of early headersSimon Marchi9-9/+0
Now that defs.h, server.h and common-defs.h are included via the `-include` option, it is no longer necessary for source files to include them. Remove all the inclusions of these files I could find. Update the generation scripts where relevant. Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837 Approved-By: Pedro Alves <pedro@palves.net>
2024-03-14Pass alignment when using GCC_C_FE_VERSION_2Tom Tromey1-1/+5
When the GCC compiler plugin responds with GCC_C_FE_VERSION_2, gdb can use the new 'finish_record_with_alignment' method. This lets gdb pass alignment information to the compiler, which in turn fixes the test case included in this patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31397
2024-02-27Rewrite final cleanupsTom Tromey1-18/+12
This patch rewrites final cleanups to use std::function and otherwise be more C++-ish.
2024-02-15Move lookup_name_info creation into basic_lookup_transparent_typeTom Tromey1-7/+6
I noticed that basic_lookup_transparent_type calls two different functions that both proceed to create a lookup_name_info. It's more efficient to create this object in the outermost layer possible. Making this change required a few related changes, resulting in this patch. There are still more changes of this sort that could be made. Regression tested on x86-64 Fedora 38.
2024-02-01Rename SEARCH_ALLTom Tromey1-1/+1
The constant SEARCH_ALL conflicts with a define in a Windows header. This patch renames the constant to SEARCH_ALL_DOMAINS to avoid the conflict. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31307
2024-01-28Use domain_search_flags in lookup_symbol et alTom Tromey4-21/+23
This changes lookup_symbol and associated APIs to accept domain_search_flags rather than a domain_enum. Note that this introduces some new constants to Python and Guile. I chose to break out the documentation patch for this, because the internals here do not change until a later patch, and it seemed simpler to patch the docs just once, rather than twice.
2024-01-28Replace search_domain with domain_search_flagsTom Tromey1-1/+1
This patch changes gdb to replace search_domain with domain_search_flags everywhere. search_domain is removed.
2024-01-19gdb: remove SYMBOL_*_OPS macrosSimon Marchi1-6/+5
Remove SYMBOL_BLOCK_OPS, SYMBOL_COMPUTED_OPS and SYMBOL_REGISTER_OPS, in favor of methods on struct symbol. More changes could be done here to improve the design and make things safer, but I just wanted to do a straightforward change to remove the macros for now. Change-Id: I27adb74a28ea3c0dc9a85c2953413437cd95ad21 Reviewed-by: Kevin Buettner <kevinb@redhat.com>
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess17-17/+17
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-11-29Use C++17 [[fallthrough]] attributeTom Tromey3-3/+3
This changes gdb to use the C++17 [[fallthrough]] attribute rather than special comments. This was mostly done by script, but I neglected a few spellings and so also fixed it up by hand. I suspect this fixes the bug mentioned below, by switching to a standard approach that, presumably, clang supports. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23159 Approved-By: John Baldwin <jhb@FreeBSD.org> Approved-By: Luis Machado <luis.machado@arm.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21Remove some type field accessor macrosTom Tromey1-3/+4
This removes TYPE_FIELD_PRIVATE, TYPE_FIELD_PROTECTED, TYPE_FIELD_IGNORE, and TYPE_FIELD_VIRTUAL. In c-varobj.c, match_accessibility can be removed entirely now. Note that the comment before this function was incorrect. Acked-By: Simon Marchi <simon.marchi@efficios.com> Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-11-21gdb: Replace gdb::optional with std::optionalLancelot Six1-2/+2
Since GDB now requires C++17, we don't need the internally maintained gdb::optional implementation. This patch does the following replacing: - gdb::optional -> std::optional - gdb::in_place -> std::in_place - #include "gdbsupport/gdb_optional.h" -> #include <optional> This change has mostly been done automatically. One exception is gdbsupport/thread-pool.* which did not use the gdb:: prefix as it already lives in the gdb namespace. Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9 Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21gdb: Use C++17's std::make_unique instead of gdb::make_uniqueLancelot Six1-1/+1
gdb::make_unique is a wrapper around std::make_unique when compiled with C++17. Now that C++17 is required, use std::make_unique directly in the codebase, and remove gdb::make_unique. Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net
2023-10-10gdb: remove target_gdbarchSimon Marchi3-33/+43
This function is just a wrapper around the current inferior's gdbarch. I find that having that wrapper just obscures where the arch is coming from, and that it's often used as "I don't know which arch to use so I'll use this magical target_gdbarch function that gets me an arch" when the arch should in fact come from something in the context (a thread, objfile, symbol, etc). I think that removing it and inlining `current_inferior ()->arch ()` everywhere will make it a bit clearer where that arch comes from and will trigger people into reflecting whether this is the right place to get the arch or not. Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b Reviewed-By: John Baldwin <jhb@FreeBSD.org> Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-08-31gdb: remove TYPE_FIELD_BITSIZESimon Marchi3-3/+3
Replace with type::field + field::bitsize. Change-Id: I2a24755a33683e4a2775a6d2a7b7a9ae7362e43a Approved-By: Tom Tromey <tom@tromey.com>
2023-08-31gdb: remove TYPE_FIELD_ARTIFICIALSimon Marchi1-2/+2
Replace with type::field + field::is_artificial. Change-Id: Ie3bacae49d9bd02e83e504c1ce01470aba56a081 Approved-By: Tom Tromey <tom@tromey.com>
2023-08-23gdb: add gdb::make_unique functionAndrew Burgess1-1/+1
While GDB is still C++11, lets add a gdb::make_unique template function that can be used to create std::unique_ptr objects, just like the C++14 std::make_unique. If GDB is being compiled with a C++14 compiler then the new gdb::make_unique function will delegate to the std::make_unique. I checked with gcc, and at -O1 and above gdb::make_unique will be optimised away completely in this case. If C++14 (or later) becomes our minimum, then it will be easy enough to go through the code and replace gdb::make_unique with std::make_unique later on. I've make use of this function in all the places I think this can easily be used, though I'm sure I've probably missed some. Should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/compile] Fix typo in debug messageTom de Vries1-1/+1
In compile_object_load in gdb/compile/compile-object-load.c I came across: ... "Connectiong ELF symbol \"%s\" to the .toc section (%s)\n", ... Fix this typo by using "Connecting" instead. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-05-12Add dynamic_prop::is_constantTom Tromey2-2/+2
I noticed many spots checking whether a dynamic property's kind is PROP_CONST. Some spots, I think, are doing a slightly incorrect check -- checking for != PROP_UNDEFINED where == PROP_CONST is actually required, the key thing being that const_val may only be called for PROP_CONST properties. This patch adds dynamic::is_constant and then updates these checks to use it. Regression tested on x86-64 Fedora 36.
2023-05-01gdb: move struct ui and related things to ui.{c,h}Simon Marchi1-1/+1
I'd like to move some things so they become methods on struct ui. But first, I think that struct ui and the related things are big enough to deserve their own file, instead of being scattered through top.{c,h} and event-top.c. Change-Id: I15594269ace61fd76ef80a7b58f51ff3ab6979bc
2023-05-01Replace field_is_static with a methodTom Tromey2-2/+2
This changes field_is_static to be a method on struct field, and updates all the callers. Most of this patch was written by script. Regression tested on x86-64 Fedora 36.
2023-03-27Change symbol::line to unsigned intTom Tromey3-3/+3
A user here at AdaCore noticed that, when debugging a certain program, a stack frame reported line 34358, where it should have been line 99894. After debugging a bit, I discovered: (top) p (99894 & ~65536) $60 = 34358 That line, symbol::line is too narrow. This patch widens the member and changes all the uses that currently use the narrower type. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Rename objfile_type to builtin_typeTom Tromey2-10/+10
This renames objfile_type to be an overload of builtin_type, in preparation for their unification. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Use builtin type when appropriateTom Tromey2-13/+3
There are a few spots that check whether a type is objfile-owned, and then choose either the objfile- or arch-specific builtin type. I don't think there is a need to do this any more (if there ever was), because it is ok for an objfile-allocated type to refer to an arch-allocated type. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-19Convert explicit iterator uses to foreachTom Tromey1-6/+1
This converts most existing explicit uses of block_iterator to use foreach with the range iterator instead.
2023-02-19Convert block_static_block and block_global_block to methodsTom Tromey2-5/+5
This converts block_static_block and block_global_block to be methods. This was mostly written by script. It was simpler to convert them at the same time because they're often used near each other.
2023-02-19Convert block_linkage_function to methodTom Tromey1-1/+1
This converts block_linkage_function to be a method. This was mostly written by script.
2023-02-19Don't allow NULL as an argument to block_static_blockTom Tromey2-3/+9
block_static_block has special behavior when the block is NULL. Remove this and patch up the callers instead.
2023-02-13Remove deprecated_lval_hackTom Tromey3-3/+3
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 many optimized-out value functions into methodsTom Tromey1-2/+2
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 remaining value_contents functions into methodsTom Tromey1-1/+1
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_address and set_value_address functions into methodsTom Tromey3-3/+3
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-09Increase size of main_type::nfieldsTom Tromey1-1/+1
main_type::nfields is a 'short', and has been for many years. PR c++/29985 points out that 'short' is too narrow for an enum that contains more than 2^15 constants. This patch bumps the size of 'nfields'. To verify that the field isn't directly used, it is also renamed. Note that this does not affect the size of main_type on x86-64 Fedora 36. And, if it does have a negative effect somewhere, it's worth considering that types could be shrunk more drastically by using subclasses for the different codes. This is v2 of this patch, which has these changes: * I changed nfields to 'unsigned', per Simon's request. I looked at changing all the uses, but this quickly fans out into a very large patch. (One additional tweak was needed, though.) * I wrote a test case. I discovered that GCC cannot compile a large enough C test case, so I resorted to using the DWARF assembler. This test doesn't reproduce the crash, but it does fail without the patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-20gdb: move compile_instance to compile/compile.hSimon Marchi4-116/+118
struct compile_instance needs to be visible to users, since we use std::unique<compile_instance>. language.c and c-lang.c currently includes compile-internal.h for this reason, which kind of defeats the purpose of having an "internal" header file. Change-Id: Iedffe5f1173b3de7bdc1be533ee2a68e6f6c549f Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-20gdb: move type_map_instance to compile/compile.cSimon Marchi2-13/+13
It's only used in compile/compile.c, it doesn't need to be in a header. Change-Id: Ic5bec996b7b0cd7130055d1e8ff238b5ac4292a3 Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker17-17/+17
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-10-19internal_error: remove need to pass __FILE__/__LINE__Pedro Alves5-6/+5
Currently, every internal_error call must be passed __FILE__/__LINE__ explicitly, like: internal_error (__FILE__, __LINE__, "foo %d", var); The need to pass in explicit __FILE__/__LINE__ is there probably because the function predates widespread and portable variadic macros availability. We can use variadic macros nowadays, and in fact, we already use them in several places, including the related gdb_assert_not_reached. So this patch renames the internal_error function to something else, and then reimplements internal_error as a variadic macro that expands __FILE__/__LINE__ itself. The result is that we now should call internal_error like so: internal_error ("foo %d", var); Likewise for internal_warning. The patch adjusts all calls sites. 99% of the adjustments were done with a perl/sed script. The non-mechanical changes are in gdbsupport/errors.h, gdbsupport/gdb_assert.h, and gdb/gdbarch.py. Approved-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-18gdb, compile: unlink objfile stored in moduleMarkus Metzger1-12/+9
When cleaning up after a compile command, we iterate over all objfiles and unlink the first objfile with the same name as the one we compiled. Since we already store a pointer to that objfile in the module and use it to get the name we're comparing against, there's no reason to iterate, at all. We can simply use that objfile. This further avoids potential issues when an objfile with the same name is loaded into a different linker namespace.
2022-10-10Change GDB to use frame_info_ptrTom Tromey3-3/+3
This changes GDB to use frame_info_ptr instead of frame_info * The substitution was done with multiple sequential `sed` commands: sed 's/^struct frame_info;/class frame_info_ptr;/' sed 's/struct frame_info \*/frame_info_ptr /g' - which left some issues in a few files, that were manually fixed. sed 's/\<frame_info \*/frame_info_ptr /g' sed 's/frame_info_ptr $/frame_info_ptr/g' - used to remove whitespace problems. The changed files were then manually checked and some 'sed' changes undone, some constructors and some gets were added, according to what made sense, and what Tromey originally did Co-Authored-By: Bruno Larsen <blarsen@redhat.com> Approved-by: Tom Tomey <tom@tromey.com>
2022-09-21gdb: remove TYPE_LENGTHSimon Marchi4-23/+23
Remove the macro, replace all uses with calls to type::length. Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb
2022-09-21gdb: remove TYPE_TARGET_TYPESimon Marchi4-17/+17
Remove the macro, replace all uses by calls to type::target_type. Change-Id: Ie51d3e1e22f94130176d6abd723255282bb6d1ed
2022-08-03Use gdb_bfd_ref_ptr in objfileTom Tromey1-1/+1
This changes struct objfile to use a gdb_bfd_ref_ptr. In addition to removing some manual memory management, this fixes a use-after-free that was introduced by the registry rewrite series. The issue there was that, in some cases, registry shutdown could refer to memory that had already been freed. This help fix the bug by delaying the destruction of the BFD reference (and thus the per-bfd object) until after the registry has been shut down.
2022-07-28Change allocation of type-copying hash tableTom Tromey1-2/+2
When an objfile is destroyed, types that are still in use and allocated on that objfile are copied. A temporary hash map is created during this process, and it is allocated on the destroyed objfile's obstack -- which normally is fine, as that is going to be destroyed shortly anyway. However, this approach requires that the objfile be passed to registry destruction, and this won't be possible in the rewritten registry. This patch changes the copied type hash table to simply use the heap instead. It also removes the 'objfile' parameter from copy_type_recursive, to make this all more clear. This patch also fixes an apparent bug in copy_type_recursive. Previously it was copying the dynamic property list to the dying objfile's obstack: - = copy_dynamic_prop_list (&objfile->objfile_obstack, However I think this is incorrect -- that obstack is about to be destroyed.
2022-04-27gdb: remove BLOCKVECTOR_BLOCK and BLOCKVECTOR_NBLOCKS macrosSimon Marchi2-8/+7
Replace with calls to blockvector::blocks, and the appropriate method call on the returned array_view. Change-Id: I04d1f39603e4d4c21c96822421431d9a029d8ddd
2022-04-27gdb: remove BLOCK_ENTRY_PC macroSimon Marchi3-5/+5
Replace with equivalent method. Change-Id: I0e033095e7358799930775e61028b48246971a7d