aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-10-20[gdb/symtab] Fix more style issues in v9 .gdb_index section supportTom de Vries5-9/+9
I noticed a few more style issues in commit 8b9c08eddac ("[gdb/symtab] Add name_of_main and language_of_main to the DWARF index"), after checking it with gcc's check_GNU_style.{sh,py}. Fix these. Build on x86_64-linux.
2023-10-19opcodes: microblaze: Fix bit masking bugNeal Frager3-8/+11
There is currently a bug in the bit masking for the barrel shift instructions because the bit mask is not including all of the register bits which must be zero. With this patch, the disassembler can be sure that the 32-bit value is indeed a barrel shift instruction and not a data value in memory. This fix can be verified by assembling and disassembling the following: .text .long 0x65005f5f With this patch, the bug is fixed, and the objdump will know that 0x65005f5f is not a barrel shift instruction. Signed-off-by: Neal Frager <neal.frager@amd.com> Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-10-20Automatic date update in version.inGDB Administrator1-1/+1
2023-10-19Fix race in DWARF readerTom Tromey3-25/+41
The recent change to record the DWARF language in the per-CU data yielded a race warning in my testing: ThreadSanitizer: data race ../../binutils-gdb/gdb/dwarf2/read.c:21779 in prepare_one_comp_unit This patch fixes the bug by applying the same style of fix that was done for the ordinary (gdb) language. I wonder if this code could be improved. Requiring an atomic for the language in particular seems unfortunate, as it is often consulted during index finalization. However, I haven't investigated this. Regression tested on x86-64 Fedora 38. Reviewed-by: Tom de Vries <tdevries@suse.de>
2023-10-20PR30984, assertion fail elf.c:8485Alan Modra1-0/+1
PR 30984 * ldelf.c (ldelf_place_orphan): Don't allow bfd_abs_section as a potential output section.
2023-10-19gdb: fix no-expat build of solib-target.cSimon Marchi1-2/+2
Fixes: CXX solib-target.o /home/smarchi/src/binutils-gdb/gdb/solib-target.c:57:8: error: ‘lm_info_vector’ does not name a type 57 | static lm_info_vector | ^~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/solib-target.c: In function ‘intrusive_list<shobj> solib_target_current_sos()’: /home/smarchi/src/binutils-gdb/gdb/solib-target.c:244:7: error: ‘solib_target_parse_libraries’ was not declared in this scope 244 | = solib_target_parse_libraries (library_document->data ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: Ib477d3343b401017d79729118242143bc95f24b2
2023-10-19ld: fix typo in ld.texi metdata->metadataJose E. Marchesi2-1/+5
2023-10-19gdb: rename struct so_list to shobjSimon Marchi25-128/+126
Now that so_list lists are implemented using intrusive_list, it doesn't really make sense for the element type to be named "_list". Rename to just `struct shobj` (`struct so` was deemed to be not greppable enough). Change-Id: I1063061901298bb40fee73bf0cce44cd12154c0e Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: remove free_so functionSimon Marchi3-35/+5
Remove this function, replace it with deleting the so_list in callers. Change-Id: Idbd0cb84674ade1d8e17af471550dbd388264f60 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: don't call so_list::clear in free_soSimon Marchi1-1/+0
I think this `so.clear ()` call is not useful. - so_list::clear deletes some things that now get automatically deleted when the so_list gets deleted right after in free_so. - so_list::clear resets some scalar fields of so_list, which we don't really care about since the so_list gets deleted right after. - so_list::clear calls target_so_ops::clear_so, of which there is a single implementation, svr4_clear_so. That implementation just resets a field in lm_info_svr4, which we don't care about, as it will get deleted when the so_list gets deleted right after. Change-Id: Ie4d72f2a04a4129e55c460bb5c69bc0af0d12b32 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: link so_list using intrusive_listSimon Marchi12-252/+178
Replace the hand-made linked list implementation with intrusive_list, simplying management of list items. Change-Id: I7f55fd88325bb197cc655c9be5a2ec966d8cc48d Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make so_list::{so_original_name,so_name} std::stringsSimon Marchi13-80/+68
Change these two fields, simplifying memory management and copying. Change-Id: If2559284c515721e71e1ef56ada8b64667eebe55 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make so_list::abfd a gdb_bfd_ref_ptrSimon Marchi5-14/+11
Change the field from a `bfd *` to a gdb_bfd_ref_ptr to automatically manage the reference. Change-Id: I3ace18bea985bc194c5e67bb559eec567e258950 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make so_list::sections not a pointerSimon Marchi2-13/+7
Make the field a vector directly, instead of a pointer to a vector. This was needed when so_list had to be a trivial type, which is not the case anymore. Change-Id: I79a8378ce0d0d1e2206ca08a273ebf332cb3ba14 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: remove target_section_table typedefSimon Marchi17-51/+47
Remove this typedef. I think that hiding the real type (std::vector) behind a typedef just hinders readability. Change-Id: I80949da3392f60a2826c56c268e0ec6f503ad79f Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make clear_so a method of struct so_listSimon Marchi2-21/+24
... just because it seems to make sense to do so. Change-Id: Ie283c92d9b90c54e3deee96a43c6a942d8b5910b Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make so_list::lm_info a unique_ptrSimon Marchi10-31/+40
Make it a unique_ptr, so it gets automatically deleted when the so_list is deleted. Change-Id: Ib62d60ae2a80656239860b80e4359121c93da13d Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: remove lm_info_vector typedefSimon Marchi1-9/+9
I think this typedef hinders readability. First, it's not well named (it's not clear it contains lm_info_target objects). And hiding the fact that it contains unique pointers is not very useful either. I was looking at the code in solib_target_current_sos where the unique pointers get moved from the vector, and it wasn't obvious at all what the source of the move was. Change-Id: I4a5cda7c90554f018b7c466b1535b41d69cbcbe7 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make solib-rocm not use so_list internallySimon Marchi1-50/+42
Same rationale as the previous patch, but for solib-rocm. - Introduce rocm_so, which is a name a unique_name (see comment in rocm_update_solib_list for that) and a unique_ptr to the lm_info_svr4. - Change the internal lists from so_list lists to vectors of rocm_so. - Remove rocm_free_solib_list, as everything is automatic now. - Replace rocm_solib_copy_list with so_list_from_rocm_sos. Change-Id: I71e06e3ea22d6420c9e4e500501c06e9a13398a8 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make solib-svr4 not use so_list internallySimon Marchi2-177/+100
A subsequent patch makes use of non-trivial types in struct so_list. This trips on the fact that svr4_copy_library_list uses memcpy to copy so_list objects: so_list *newobj = new so_list; memcpy (newobj, src, sizeof (struct so_list)); solib-svr4 maintains lists of so_list objects in its own internal data structures. When requested to return a list of so_list objects (through target_so_ops::current_sos), it duplicates the internal so_list lists, using memcpy. When changing so_list to make it non-trivial, we would need to replace this use of memcpy somehow. That would mean making so_list copyable, with all the complexity that entails, just to satisfy this internal usage of solib-svr4 (and solib-rocm, which does the same). Change solib-svr4 to use its own data type for its internal lists. The use of so_list is a bit overkill anyway, as most fields of so_list are irrelevant for this internal use. - Introduce svr4_so, which contains just an std::string for the name and a unique_ptr for the lm_info. - Change the internal so_list lists to be std::vector<svr4_so>. Vector seems like a good choice for this, we don't need to insert/remove elements in the middle of these internal lists. - Remove svr4_free_library_list, free_solib_lists and ~svr4_info, as everything is managed automatically now. - Replace svr4_copy_library_list (which duplicated internal lists in order to return them to the core) with so_list_from_svr4_sos, which creates an so_list list from a vector of svr4_so. - Generalize svr4_same a bit, because find_debug_base_for_solib now needs to compare an so_list and an svr4_so to see if they are the same. Change-Id: I6012e48e07aace2a8172b74b389f9547ce777877 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: use gdb::checked_static_cast when casting lm_infoSimon Marchi8-19/+19
Now that the lm_info class hierarchy has a virtual destructor and therefore a vtable, use checked_static_cast instead of C-style cases to ensure (when building in dev mode) that we're casting to the right kind of lm_info. Change-Id: I9a99b7d6aa9a44edbe76377d57a7008cfb75a744 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: remove target_so_ops::free_soSimon Marchi9-77/+13
target_so_ops::free_so is responsible for freeing the specific lm_info object. All implementations basically just call delete. Remove that method, make the destructor of lm_info virtual, and call delete directly from the free_so function. Make the sub-classes final, just because it's good practice. Change-Id: Iee1fd4861c75034a9e41a656add8ed8dfd8964ee Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: rename lm_info_base to lm_infoSimon Marchi7-8/+8
The base class doesn't need to have "_base" in its name, all the sub-classes have a specific suffix. Change-Id: I87652105cfedd87898770a81f0eda343ff7f2bdb Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: allocate so_list with new, deallocate with deleteSimon Marchi9-34/+26
Initialize all fields in the class declaration, change allocations to use "new", change deallocations to use "delete". This is needed by a subsequent patches that use C++ stuff in so_list. Change-Id: I4b140d9f1ec9ff809554a056f76e3eb2b9e23222 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make get_cbfd_soname_build_id staticSimon Marchi2-9/+4
It is only used in solib.c. Change-Id: I43461d13d84d65c4f6913d4033678d8983b9910b Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdbsupport: use "reference" and "pointer" type aliases in intrusive_listSimon Marchi1-14/+14
It seems to me like the code should used the defined type aliases, for consistency. Change-Id: Ib52493ff18ad29464405275bc10a0c6704ed39e9 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: replace some so_list parameters to use referencesSimon Marchi23-191/+183
A subsequent patch changes so_list to be linked using intrusive_list. Iterating an intrusive_list yields some references to the list elements. Convert some functions accepting so_list objects to take references, to make things easier and more natural. Add const where possible and convenient. Change-Id: Id5ab5339c3eb6432e809ad14782952d6a45806f3 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: make interps_notify work with referencesSimon Marchi1-3/+3
A subsequent patch changes the interp::on_solib_loaded and interp::on_solib_unloaded methods to take references. This highlighted that interps_notify did not work with reference parameters. Fix that by changing interps_notify's `args` arg to be a universal reference (&&). Change the type of the method to be auto-deduced as an additional template parameter, otherwise the signature of the callback function would never match: CXX interps.o /home/simark/src/binutils-gdb/gdb/interps.c: In function ‘void interps_notify_signal_received(gdb_signal)’: /home/simark/src/binutils-gdb/gdb/interps.c:378:18: error: no matching function for call to ‘interps_notify(void (interp::*)(gdb_signal), gdb_signal&)’ 378 | interps_notify (&interp::on_signal_received, sig); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/gdb/interps.c:363:1: note: candidate: ‘template<class ... Args> void interps_notify(void (interp::*)(Args ...), Args&& ...)’ 363 | interps_notify (void (interp::*method) (Args...), Args&&... args) | ^~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/gdb/interps.c:363:1: note: template argument deduction/substitution failed: /home/simark/src/binutils-gdb/gdb/interps.c:378:18: note: inconsistent parameter pack deduction with ‘gdb_signal’ and ‘gdb_signal&’ 378 | interps_notify (&interp::on_signal_received, sig); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I0cd9378e24ef039f30f8e14f054f8d7fb539c838 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: add program_space parameter to target_so_ops::clear_solibSimon Marchi6-42/+33
The clear_solib is implicitly meant to clear the resources associated to the current program space (that's what the solib implementations that actually support multi-program-space / multi-inferior do). Make that explicit by adding a program_space parameter and pass down current_program_space in call sites. The implementation of the clear_solib callbacks is fairly simple, I don't think any of them rely on global state other than accessing current_program_space. Change-Id: I8d0cc4db7b4f8db8d7452879c0c62db03269bf46 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19gdb: remove empty clear_solib functionsSimon Marchi3-18/+6
Make the target_so_ops::clear_solib method optional, remove two empty implementations. Change-Id: Ifda297d50c74327d337091c58cdb5b3b60382591 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-19RISC-V: Don't do undefweak relaxations for the linker_def symbols.Nelson Chu1-0/+6
I get the following truncated errors recently when running riscv-gnu-toolchain regressions, /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/libc.a(libc-start.o): in function `elf_irela': /scratch/riscv-gnu-toolchain/glibc/csu/../sysdeps/riscv/dl-irel.h:47:(.text+0x88): relocation truncated to fit: R_RISCV_GPREL_I against symbol `__ehdr_start' defined in .note.ABI-tag section in /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/elf/sln The linker_def symbols like __ehdr_start that may be undefweak in early stages of linking, including relax stage, but are guaranteed to be defined later. Therefore, it seems like we shouldn't do the undefweak relaxations for these kinds of symbols since they may be defined after relaxations. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_section): Don't do undefweak relaxations for the linker_def symbols.
2023-10-19RISC-V: Remove semicolons from DECLARE_INSNTsukasa OI1-15/+15
This is for consistency and to prevent possible unnecessary errors due to this inconsistency. include/ChangeLog: * opcode/riscv-opc.h (DECLARE_INSN): Remove semicolons from the end of each entry.
2023-10-19Automatic date update in version.inGDB Administrator1-1/+1
2023-10-18gdb/testsuite/gdb.rocm: Fix incorrect use of continue N in ↵Lancelot Six1-1/+1
multi-inferior-gpu.exp The gdb.rocm/multi-inferior-gpu.exp testcase uses a "continue $thread" command, but this is incorrect. If "continue" is given an argument, it sets the ignore count of the breakpoint the thread stopped at. For this testcase it does not really matter since the breakpoint is not meant to be hit anymore, so whatever the ignore count is won't influence the outcome of the test. It is worth fixing nevertheless. Change-Id: I0eb674d5529cdeb9e808b74870a29b6077265737 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-18sim/riscv: fix JALR instruction simulationJaydeep Patil3-4/+32
Fix 32bit 'jalr rd,ra,imm' integer instruction, where RD was written before using it to calculate destination address. This commit also improves testutils.inc for riscv; make use of pushsection and popsection when adding things to .data, and setup the %gp global pointer register within the 'start' macro. Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-10-18libctf: check for problems with error returnsNick Alcock2-0/+75
We do this as a writable test because the only known-affected platforms (with ssize_t longer than unsigned long) use PE, and we do not have support for CTF linkage in the PE linker yet. PR libctf/30836 * libctf/testsuite/libctf-writable/libctf-errors.*: New test.
2023-10-18gdb/testsuite/gdb.rocm: Check value returned by hipDeviceSynchronizeLancelot Six6-6/+52
Functions of the hip runtime returning a hipError_t can be marked nodiscard depending on the configuration[1] (when compiled with C++17). This patch makes sure that we always check the value returned by hipDeviceSynchronize and friends, and print an error message when appropriate. This avoid a wall of warnings when running the testsuite if the compiler defaults to using C++17. It is always a good practice to check the return values anyway. [1] https://github.com/ROCm-Developer-Tools/HIP/blob/docs/5.7.1/include/hip/hip_runtime_api.h#L203-L218 Change-Id: I2a819a8ac45f4bcf814efe9a2ff12c6a7ad22f97 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-18libctf: Return CTF_ERR in ctf_type_resolve_unsliced PR 30836Torbjörn SVENSSON1-1/+1
In commit 998a4f589d68503f79695f180fdf1742eeb0a39d, all but one return statement was updated to return the error proper value. This commit rectifies that missed return statement. libctf/ ctf-types.c (ctf_type_resolve_unsliced): Return CTF_ERR on error. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2023-10-18[gdb/testsuite] Fix gdb.base/jit-bfd-name.expTom de Vries1-1/+1
When running test-case gdb.base/jit-bfd-name.exp, I run into: ... ERROR: tcl error sourcing gdb/testsuite/gdb.base/jit-bfd-name.exp. ERROR: can't read "start": no such variable ... The problem is that commit c96ceed9dce ("gdb: include the end address in in-memory bfd filenames") introduced a use of variable start, but not a definition. Fix this by adding the missing definition. Tested on x86_64-linux.
2023-10-18[gdb/symtab] Fix two style issues in gdb/dwarf2/index-write.cTom de Vries1-3/+3
While reviewing gdb/dwarf2/index-write.c I noticed two style issues. Fix these. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2023-10-18[gdb/symtab] Fix style issues in v9 .gdb_index section supportTom de Vries4-15/+15
Post-commit review pointed out a few style issues in commit 8b9c08eddac ("[gdb/symtab] Add name_of_main and language_of_main to the DWARF index"). Fix these. Tested on x86_64-linux. Reported-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com>
2023-10-18RISC-V: Make sure rv32q conflict won't affect the zfa gas testcases.Nelson Chu2-2/+2
According to the commit 51498ab9abc6, the q extension was no longer allowed for rv32 since version 2.2. Therefore, make sure the version of q is larger than 2.2, in case the new extension conflict breaks the toolchain regressions, which built with the old -misa-spec. gas/ * testsuite/gas/riscv/zfa-zvfh.d: Set q to v2.2. * testsuite/gas/riscv/zfa.d: Likewise.
2023-10-18LoongArch: Correct comments.caiyinyu1-1/+1
2023-10-18Automatic date update in version.inGDB Administrator1-1/+1
2023-10-17gas: testsuite: microblaze: Add new bit-field testsNeal Frager2-1/+14
This patch adds new gas tests for the microblaze bsefi and bsifi instructions. Signed-off-by: Neal Frager <neal.frager@amd.com> Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-10-17gdb: include the end address in in-memory bfd filenamesMarkus Metzger2-6/+14
Commit 66984afd29e gdb: include the base address in in-memory bfd filenames added the base address to in-memory bfd filenames. Also add the end address to allow dumping the in-memory bfd using the 'dump memory' command.
2023-10-17libctf: Sanitize error types for PR 30836Torbjörn SVENSSON8-134/+114
Made sure there is no implicit conversion between signed and unsigned return value for functions setting the ctf_errno value. An example of the problem is that in ctf_member_next, the "offset" value is either 0L or (ctf_id_t)-1L, but it should have been 0L or -1L. The issue was discovered while building a 64 bit ld binary to be executed on the Windows platform. Example object file that demonstrates the issue is attached in the PR. libctf/ Affected functions adjusted. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
2023-10-17Update the documentation of the LINKER_VERSIOn script command to actually ↵Nick Clifton1-4/+4
mention the name of the command.
2023-10-17[gdb/cli] Keep track of styling failures in source_cacheTom de Vries2-2/+26
In source_cache::ensure, keep track of which files failed to be styled, and don't attempt to style them again in case the file dropped out of the cache. Tested on x86_64-linux. Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-17[gdb/cli] Factor out try_source_highlightTom de Vries1-36/+55
Function source_cache::ensure contains some code using the GNU source-highlight library. The code is a sizable part of the function, and contains conditional compilation in a slightly convoluted way: ... if (!already_styled) #endif /* HAVE_SOURCE_HIGHLIGHT */ { ... Fix this by factoring out the code into new function try_source_highlight, such that: - source_cache::ensure is easier to read, and - the conditional compilation is at the level of the function body. Tested on x86_64-linux. Reviewed-By: Lancelot Six <lancelot.six@amd.com>