aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-01-06Tidy pe flag in coff_dataAlan Modra11-15/+14
Make it a bool, use obj_pe accessor everywhere.
2023-01-06Make coff backend data read-onlyAlan Modra7-53/+72
The bfd_coff_backend_data struct should be read-only, the only thing preventing this is that objcopy writes to one of the fields, _bfd_coff_long_section_names. This patch creates a copy of the field in bfd coff_obj_tdata, which makes more sense anyway. When enabling long section names the intent is to do so for a particular bfd, not for all bfds that might happen to be using the target xvec. bfd/ * coffcode.h: Update coff long section name comment. (bfd_coff_set_long_section_names_allowed): Use macro accessor to set flag. (bfd_coff_set_long_section_names_disallowed): Tidy. (coff_backend_info): Return a const pointer. (bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table), (bigobj_swap_table): Make const. (bfd_coff_long_section_names): Use tdata copy. (coff_mkobject): Set long_section_names from coff_backend_info. * coff-go32.c (_bfd_go32_mkobject): Likewise. * peicode.h (pe_mkobject): Likewise. * coff-sh.c (bfd_coff_small_swap_table): Make const. * libcoff-in.h (struct coff_tdata): Add long_section_names, reorder fields. * libcoff.h: Regenerate. binutils/ * objcopy.c (set_long_section_mode): Move earlier in file. (copy_object): Call set_long_section_mode here, after setting output format. (copy_file): Don't call set_long_section_mode.
2023-01-06gdb/c++: Detect ambiguous variables in imported namespacesBruno Larsen2-27/+83
When running gdb.cp/nsusing.cc and stopping at line 17, we can ask GDB to print x and get a compiler-dependent answer. Using gcc 12.2.1, GDB will print M::x, and using clang 16.0.0 prints N::x. Not only is this behavior confusing to users, it is also not consistent with compiler behaviors, which would warn that using x is ambiguous at this point. This commit makes GDB behavior consistent with compilers. it achieves this by making it so instead of exiting early when finding any symbol with the correct name, GDB continues searching through all include directives, storing all matching symbols in a relational map betwen the mangled name and the found symbols. If the resulting map has more than one entry, GDB says that the reference is ambiguous and lists all possibilities. Otherwise it returns the block_symbol structure for the desired symbol, or an empty struct if nothing was found. The commit also changes gdb.cp/nsusing.exp to test the ambiguous detection.
2023-01-06gdb/mi: add no-history stop reasonBruno Larsen6-2/+14
When executing in reverse and runs out of recorded history, GDB prints a warning to the user, but does not add a reason in the stopped record, for example: *stopped,frame={addr="0x000000000040113e",func="main",args=[],file="/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",fullname="/home/blarsen/Documents/binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",line="27",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="1" This problem was reported as record/29260. This commit adds the reason no-history to the record, making it easier for interfaces using the mi interpreter to report the result. It also changes the test gdb.mi/mi-reverse.exp to test that the reason shows up correctly. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29260
2023-01-06gdb/testsuite: Fix FAILs in gdb.linespec/cpcompletion.exp when using clangBruno Larsen1-15/+18
When using clang 16.0.0 to test gdb.linespec/cpcompletion.exp, I get 99 unexpected failures. They all fail to produce a complete list of completion options for a function, either overload2_function, overload3_function or anon_ns_function. This happens because clang is optimizing them away, since they are never used. Fix this by adding __attribute__((used)) to all declarations to the aforementioned functions.
2023-01-06configure: remove dependencies on gmp and mpfr when gdb is disabledClément Chigot2-2/+6
Since 991180627851801f1999d1ebbc0e569a17e47c74, the configure checks about GMP and MPFR for gdb builds have been moved to the toplevel configure. However, it doesn't take into account the --disable-gdb option. Meaning that a build without gdb will require these libraries even if not needed. ChangeLog: * configure.ac: Skip GMP and MPFR when --disable-gdb is provided. * configure: Regenerate.
2023-01-06Automatic date update in version.inGDB Administrator1-1/+1
2023-01-05gdbsupport: fix scoped_debug_start_end's move constructorSimon Marchi1-1/+20
I spotted a problem with scoped_debug_start_end's move constructor. When constructing a scoped_debug_start_end through it, it doesn't disable the moved-from object, meaning there are now two objects that will do the side-effects of decrementing the debug_print_depth global and printing the "end" message. Decrementing the debug_print_depth global twice is actually problematic, because the increments and decrements get out of sync, meaning we should hit this assertion, in theory: gdb_assert (debug_print_depth > 0); However, in practice, we don't see that. This is because despite the move constructor being required for this to compile: template<typename PT> static inline scoped_debug_start_end<PT &> ATTRIBUTE_NULL_PRINTF (6, 7) make_scoped_debug_start_end (PT &&pred, const char *module, const char *func, const char *start_prefix, const char *end_prefix, const char *fmt, ...) { va_list args; va_start (args, fmt); auto res = scoped_debug_start_end<PT &> (pred, module, func, start_prefix, end_prefix, fmt, args); va_end (args); return res; } ... it is never actually called, because compilers elide the move constructors all the way (the scoped_debug_start_end gets constructed directly in the instance of the top-level caller). To confirm this, I built GDB with -fno-elide-constructors, and now I see it: /home/simark/src/binutils-gdb/gdb/../gdbsupport/common-debug.h:147: internal-error: ~scoped_debug_start_end: Assertion `debug_print_depth > 0' failed. #9 0x00005614ba5f17c3 in internal_error_loc (file=0x5614b8749960 "/home/simark/src/binutils-gdb/gdb/../gdbsupport/common-debug.h", line=147, fmt=0x5614b8733fa0 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:58 #10 0x00005614b8e1b2e5 in scoped_debug_start_end<bool&>::~scoped_debug_start_end (this=0x7ffc6c5e7b40, __in_chrg=<optimized out>) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/common-debug.h:147 #11 0x00005614b96dbe34 in make_scoped_debug_start_end<bool&> (pred=@0x5614baad7200: true, module=0x5614b891d840 "infrun", func=0x5614b891d800 "infrun_debug_show_threads", start_prefix=0x5614b891d7c0 "enter", end_prefix=0x5614b891d780 "exit", fmt=0x0) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/common-debug.h:235 Fix this by adding an m_disabled field to scoped_debug_start_end, and setting it in the move constructor. Change-Id: Ie5213269c584837f751d2d11de831f45ae4a899f
2023-01-05gdbsupport: add gdb::string_view_hashSimon Marchi2-1/+18
Add the string_view_hash type, which will be useful to be able to use gdb::string_view as std::unordered_map keys. Use it in gdb/symtab.c, to exercise it. Change-Id: Id69a466ab19a9f6620b5df8a2dd29b5cddd94c00 Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-01-05gdbsupport: move fast_hash to gdbsupport/common-utils.hSimon Marchi2-19/+21
The following patch adds a hash type for gdb::string_view in gdbsupport, which will use the fast_hash function. Move the latter to gdbsupport. Change-Id: Id74510e17801e775bd5ffa5f443713d79adf14ad Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-01-05gdbsupport: move libxxhash configure check to gdbsupportSimon Marchi8-537/+1575
The following patch moves the fast_hash function, which uses libxxhash, to gdbsupport. Move the libxxhash configure check to gdbsupport (and transitively to gdbserver). Change-Id: I242499e50c8cd6fe9f51e6e92dc53a1b3daaa96e Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-01-05gdb: make gdbarch_alloc take ownership of the tdepSimon Marchi46-149/+148
It's currently not clear how the ownership of gdbarch_tdep objects works. In fact, nothing ever takes ownership of it. This is mostly fine because we never free gdbarch objects, and thus we never free gdbarch_tdep objects. There is an exception to that however: when initialization fails, we do free the gdbarch object that is not going to be used, and we free the tdep too. Currently, i386 and s390 do it. To make things clearer, change gdbarch_alloc so that it takes ownership of the tdep. The tdep is thus automatically freed if the gdbarch is freed. Change all gdbarch initialization functions to pass a new gdbarch_tdep object to gdbarch_alloc and then retrieve a non-owning reference from the gdbarch object. Before this patch, the xtensa architecture had a single global instance of xtensa_gdbarch_tdep. Since we need to pass a dynamically allocated gdbarch_tdep_base instance to gdbarch_alloc, remove this global instance, and dynamically allocate one as needed, like we do for all other architectures. Make the `rmap` array externally visible and rename it to the less collision-prone `xtensa_rmap` name. Change-Id: Id3d70493ef80ce4bdff701c57636f4c79ed8aea2 Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-01-05gdb/testsuite: add back needed -re clause in gdb_breakpointSimon Marchi1-0/+6
Commit 4b9728be ("gdb: use gdb_test_multiple in gdb_breakpoint") caused, amongst others: (gdb) break 1^M No line 1 in the current file.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.dwarf2/dw2-main-no-line-number.exp: gdb_breakpoint: set breakpoint at 1 FAIL: gdb.dwarf2/dw2-main-no-line-number.exp: !$breakpoint_at_missing_lineno_set This is because it removed one empty -re clause (matching just the prompt) that is necessary after replying "n" to the pending breakpoint question. Add this clause back. Change-Id: Ibfaa059d58bbea660bc29f0547e2f75c323fcbc6 Approved-By: Tom de Vries <tdevries@suse.de>
2023-01-05[gdb/python] Avoid queue.SimpleQueue for python 3.6Tom de Vries2-2/+10
On openSUSE Leap 15.4 with python 3.6, the gdb.dap/basic-dap.exp test-case fails as follows: ... ERROR: eof reading json header while executing "error "eof reading json header"" invoked from within "expect { -i exp19 -timeout 10 -re "^Content-Length: (\[0-9\]+)\r\n" { set length $expect_out(1,string) exp_continue } -re "^(\[^\r\n\]+)..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE eof reading json header UNRESOLVED: gdb.dap/basic-dap.exp: startup - initialize ... Investigation using a "catch throw" shows that: ... (gdb) at gdb/python/py-utils.c:396 396 error (_("Error occurred in Python: %s"), msg.get ()); (gdb) p msg.get () $1 = 0x2b91d10 "module 'queue' has no attribute 'SimpleQueue'" ... The python class queue.SimpleQueue was introduced in python 3.7. Fix this by falling back to queue.Queue for python <= 3.6. Tested on x86_64-linux, by successfully running the test-case: ... # of expected passes 47 ...
2023-01-05Add type to expression dump of symbolTom Tromey1-0/+1
I recently had cause to dump some expressions from gdb. I got output like this: Operation: BINOP_GTR Operation: OP_VAR_VALUE Block symbol: Symbol: small_value Block: 0x39b4c20 Operation: OP_LONG Operation: OP_LONG Type: int Constant: 0x0000000000000014 This is ok, but it would have been handy to see the type of the symbol. This patch adds this information. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-05Remove Stephen Casner as the PDP11 maintainer.Nick Clifton2-1/+4
2023-01-05Add an extra emulation called arm64pe to the aarch64pe emulation.Nick Clifton8-141/+175
2023-01-05Un xfail the PR19719 test for the AArch64 architectureAndreas K. Huettel2-1/+6
2023-01-05Updated Bulgarian and Russian translations for the gprof subdirectoryNick Clifton3-229/+205
2023-01-05PR29963, PDP11 link produces spurious relocation truncated messagesPaul Koning1-3/+3
PDP11 is a 16-bit processor with 16-bit logical addresses. Therefore wrapping should be allowed on the 16-bit relocs, and may as well be allowed for the 32-bit reloc too. PR 29963 * pdp11.c (howto_table_pdp11): Use complain_overflow_dont.
2023-01-04sim: mips: add multi source to built sourcesMike Frysinger2-1/+6
The multirun generation mode is a bit of a mess as generated run files depend on generate igen files, all with unknown names ahead of time. In the multirun mode, be lazy and declare all of these generated source files as built sources so they'll be created early on.
2023-01-05sim: Move getopt checking inside SIM_AC_PLATFORMTsukasa OI3-42/+46
This commit moves getopt declaration checker originally in sim/ configure.ac; added in commit 340aa4f6872c ("sim: Check known getopt definition existence") to sim/m4/sim_ac_platform.m4 (inside the SIM_AC_PLATFORM macro). It also regenerates configuration files using the maintainer mode.
2023-01-04sim: bpf: fix testsuite due to linker warnings [PR sim/29954]Guillermo E. Martinez1-4/+1
On a bpf-*-* testsuite fails: ./ld/ld-new: warning: test has a LOAD segment with RWX permissions Adjusting `--memory-size=10Mb' to the simulator bpf testsuite passes. Tested on bpf-*-*: Bug: https://sourceware.org/PR29954 sim/testsuite: * bpf/allinsn.exp (SIMFLAGS_FOR_TARGET): Adjust sim flags.
2023-01-05Automatic date update in version.inGDB Administrator1-1/+1
2023-01-04MAINTAINERS: add myself as maintainer of libsframeIndu Bhagat1-0/+1
binutils/ * MAINTAINERS: Add myself as maintainer of libsframe.
2023-01-04x86: Remove duplicated I386_PCREL_TYPE_P/X86_64_PCREL_TYPE_PH.J. Lu1-7/+0
I386_PCREL_TYPE_P and X86_64_PCREL_TYPE_P are defined twice. Remove the duplications. * elfxx-x86.h (I386_PCREL_TYPE_P): Remove duplication. (X86_64_PCREL_TYPE_P): Likewise.
2023-01-04gdb: ensure test_name is initialized in gdb_breakpointLancelot SIX1-1/+2
A refactoring in 4b9728bec15 (gdb: use gdb_test_multiple in gdb_breakpoint) left the $test_name variable undefined. This patch fixes this. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-01-04Use first_opcode in another spotTom Tromey1-1/+1
I found one place that could use expression::first_opcode. Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-01-04Convert exp_uses_objfile to a method of expressionTom Tromey6-17/+16
This changes the exp_uses_objfile function to be a method of 'expression'. Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-01-04gdb: use gdb_test_multiple in gdb_breakpointSimon Marchi1-34/+2
When running the testsuite in a non-optimized build on a slow machine, I sometimes get: UNTESTED: gdb.gdb/selftest.exp: Cannot set breakpoint at captured_main, skipping testcase. do_self_tests, in lib/selftest-support.exp, uses `with_timeout_factor 10`, to account for the fact that reading the debug info of the gdb binary (especially in a non-optimized GDB) can take time. But then it ends up calling gdb_breakpoint, which uses gdb_expect with a hard-coded timeout of 30 seconds. Fix this by making gdb_breakpoint use gdb_test_multiple, which is a desired change anyway for this kind of simple command / expected output case. Change-Id: I9b06ce991cc584810d8cc231b2b4893980b8be75 Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-01-04Re: Avoid unaligned pointer reads in PEP .idata sectionAlan Modra3-50/+50
Fix testsuite fallout. * testsuite/ld-pe/cfi.d: Adjust for changed .idata padding. * testsuite/ld-pe/secidx_64.d: Likewise. * testsuite/ld-pe/secrel_64.d: Likewise.
2023-01-04objcopy fuzzed pe out of memoryAlan Modra1-0/+4
This occurs when attempting to read back a section from the output file in _bfd_XX_bfd_copy_private_bfd_data_common. The copy of the section failed size sanity checking, thus it won't be written. * objcopy.c (copy_object): Return false if copy_section or copy_relocations_in_section fails.
2023-01-04fuzzed file timeoutAlan Modra1-1/+2
objcopy of archive, element containing an object with a fuzzed section size far exceeding the element size. copy_section detects this, but the temp file is laid out for the large section. It can take a long time to write terabytes of sparse file, a waste of time when it will be deleted. * objcopy.c (copy_archive): Don't write element contents after bad status result from copy_object.
2023-01-04asan: segv in parse_moduleAlan Modra1-2/+5
* vms-alpha.c (parse_module): Ignore DST__K_SRC_SETFILE data if out of range.
2023-01-04addr2line out of memory on fuzzed fileAlan Modra1-0/+8
Another case of fuzzers finding the section size sanity checks are avoided with SHT_NOBITS sections. * dwarf2.c (read_section): Check that the DWARF section being read has contents.
2023-01-04gdb: fix some #ifdef logic in bt-utils.hAndrew Burgess1-1/+1
In passing I spotted some incorrect #ifdef logic in bt-utils.h. The logic in question has existed since the file was originally added in commit: commit abbbd4a3e0ca51132e7fb31a43f896d29894dae0 Date: Wed Aug 11 13:24:33 2021 +0100 gdb: use libbacktrace to create a better backtrace for fatal signals The code is trying to select between using libbacktrace or using the execinfo supplied backtrace API. First we check to see if we can use libbacktrace. If we can then we include some header files, and then set some defines to indicate that libbacktrace is being used. Then we check if execinfo is available, if it is then we include <execinfo.h> and set some alternative defines. In theory the second block of logic should not trigger if the first block (that uses libbacktrace) has also triggered, but we incorrectly check the define 'PRINT_BACKTRACE_ON_FATAL_SIGNAL' instead of checking for 'GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE', so the second block triggers more than it should. The 'PRINT_BACKTRACE_ON_FATAL_SIGNAL' define is not defined anywhere, this was a mistake in the original commit. In reality this is harmless, we include <execinfo.h> when we don't need too, but in by-utils.c the libbacktrace define is always checked for before the execinfo define, so we never actually end up using the execinfo path (when libbacktrace is available). But I figure its still worth cleaning this up. I've tested GDB in a "default" build where libbacktrace is used, and when configuring with --disable-libbacktrace which causes the execinfo backtrace API to be used instead, both still appear to work fine. There should be no user visible changes after this commit.
2023-01-04gdb: add 'maintenance print record-instruction' commandBruno Larsen5-0/+211
While chasing some reverse debugging bugs, I found myself wondering what was recorded by GDB to undo and redo a certain instruction. This commit implements a simple way of printing that information. If there isn't enough history to print the desired instruction (such as when the user hasn't started recording yet or when they request 2 instructions back but only 1 was recorded), GDB warns the user like so: (gdb) maint print record-instruction Not enough recorded history If there is enough, GDB prints the instruction like so: (gdb) maint print record-instruction 4 bytes of memory at address 0x00007fffffffd5dc changed from: 01 00 00 00 Register eflags changed: [ IF ] Register rip changed: (void (*)()) 0x401115 <main+15> Approved-by: Eli Zaretskii <eliz@gnu.org> Reviewed-by: Alexandra Hajkova <ahajkova@redhat.com> Reviewed-by: Lancelot Six <lsix@lancelotsix.com> Approved-by: Tom Tromey <tom@tromey.com>
2023-01-04Fix AArch64 linker testsuite failures trigeered by differences in build ↵Andreas K. Huettel3-5/+12
environments. PR 29843 * testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow for differences in build environments. * testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.
2023-01-04Avoid unaligned pointer reads in PEP .idata sectionMark Harmstone1-0/+1
This is something I discovered when working on aarch64, though it's relevant to x86_64 too. The PE32+ imports are located in the .idata section, which starts off with a 20-byte structure for each DLL, containing offsets into the rest of the section. This is the Import Directory Table in https://learn.microsoft.com/en-us/windows/win32/debug/pe-format, which is a concatenation of the .idata$2 sections. This is then followed by an 20 zero bytes generated by the linker script, which calls this .idata$3. After this comes the .idata$4 entries for each function, which the loader overwrites with the function pointers. Because there's no padding between .idata$3 and .idata$4, this means that if there's an even number of DLLs, the function pointers won't be aligned on an 8-byte boundary. Misaligned reads are slower on x86_64, but this is more important on aarch64, as the e.g. `ldr x0, [x0, :lo12:__imp__func]` the compiler might generate requires __imp__func (the .idata$4 entry) to be aligned to 8 bytes. Without this you get IMAGE_REL_ARM64_PAGEOFFSET_12L overflow errors.
2023-01-04Merge config/picflag.m4 from gccAlan Modra2-0/+6
and regen libiberty/configure
2023-01-04sim: Regenerate using the maintainer modeTsukasa OI1-1/+1
Those files have changed by regenerating using the maintainer mode. The first line of sim/ppc/pk.h have changed by an effect of the commit 319e41e83a40 ("sim: ppc: inline the sim-packages option").
2023-01-04Automatic date update in version.inGDB Administrator1-1/+1
2023-01-03opcodes: xtensa: fix jump visualization for FLIXMax Filippov1-3/+20
opcodes/ * xtensa-dis.c (print_insn_xtensa): Add local variables insn_type, target and imm_pcrel to track control flow across multiple slots.
2023-01-03opcodes: xtensa: implement styled disassemblyMax Filippov1-11/+22
opcodes/ * xtensa-dis.c (print_xtensa_operand) (print_insn_xtensa): Replace fprintf_func with fprintf_styled_func.
2023-01-03Add test case for "finish" with variably-sized typesTom Tromey5-2/+123
This adds a test case for "finish" with variably-sized types, and for inferior calls as well. This also extends the "runto" proc to handle temporary breakpoints.
2023-01-03Use value_at_non_lval in get_call_return_valueTom Tromey1-6/+1
get_call_return_value can handle RETURN_VALUE_STRUCT_CONVENTION, because the call is completely managed by gdb. However, it does not handle variably-sized types correctly. The simplest way to fix this is to use value_at_non_lval, which does type resolution.
2023-01-03Fix inferior calls with variably-sized return typeTom Tromey7-89/+91
This patch updates the gdbarch_return_value_as_value implementations to work correctly with variably-sized return types.
2023-01-03Convert selected architectures to gdbarch_return_value_as_valueTom Tromey9-20/+81
This converts a few selected architectures to use gdbarch_return_value_as_value rather than gdbarch_return_value. The architectures are just the ones that I am able to test. This patch should not introduce any behavior changes.
2023-01-03Don't let property evaluation affect the current languageTom Tromey1-0/+5
On PPC, we saw that calling an inferior function could sometimes change the current language, because gdb would select the call dummy frame -- associated with _start. This patch changes gdb so that the current language is never affected by DWARF property evaluation.
2023-01-03Introduce value_at_non_lvalTom Tromey2-0/+14
In some cases, while a value might be read from memory, gdb should not record the value as being equivalent to that memory. In Ada, the inferior call code will call ada_convert_actual -- and here, if the argument is already in memory, that address will simply be reused. However, for a call like "f(g())", the result of "g" might be on the stack and thus overwritten by the call to "f". This patch introduces a new function that is like value_at but that ensures that the result is non-lvalue.