aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-08-04PR30697, ppc32 mix of local-dynamic and global-dynamic TLSAlan Modra4-9/+37
This fixes miscounting of dynamic relocations on GOT entries when a) there are both local-dynamic and global-dynamic tls accesss for a given symbol, and b) the symbol is global with non-default visibility, and c) the __tls_get_addr calls aren't optimised away. PR 30697 bfd/ * elf32-ppc.c (allocate_dynrelocs): Correct local-dynamic reloc count. ld/ * testsuite/ld-powerpc/tls32ldgd.d, * testsuite/ld-powerpc/tls32ldgd.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
2023-08-04gdb/testsuite: Disable gdb.compile when testing with clangBruno Larsen16-4/+32
Attempting to test the gdb.compile with clang as the compiler results in over 300 unexpected errors, due to a segmentation fault and several handshake failures. Since the whole feature is designed around a gcc plugin, and even the gcc testing is shaky at best, this commit restricts those tests to only running under gcc. If that gets fixed, this commit can be reverted. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-04Automatic date update in version.inGDB Administrator1-1/+1
2023-08-03[gdb/symtab] Remove superfluous handling of Ada main in write_cooked_indexTom de Vries1-21/+6
I filed PR29179 about the following FAIL in test-case gdb.ada/O2_float_param.exp with target board cc-with-gdb-index: ... (gdb) break increment^M Function "increment" not defined.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.ada/O2_float_param.exp: scenario=all: gdb_breakpoint: \ set breakpoint at increment ... The FAIL was a regression since commit 2cf349be0e3 ("Do not put linkage names into .gdb_index"). Before that commit we had: ... $ readelf -w foo > READELF $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... but after only: ... $ grep callee.*increment READELF [3115] callee.increment: 5 [global, function] ... The regression was fixed by commit 67e83a0deef ("Fix regression in c-linkage-name.exp with gdb index"), which got us again: ... $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... The commit however did not claim that particular PR. A subsequent commit, commit 5fea9794325 ("Improve Ada support in .gdb_index") did claim to fix it, together with commit dd05fc7071a ("Change .gdb_index de-duplication implementation"). The commit 5fea9794325 contained the following addition in write_cooked_index: ... + if (entry->per_cu->lang () == language_ada) + { + /* We want to ensure that the Ada main function's name + appears verbatim in the index. However, this name will + be of the form "_ada_mumble", and will be rewritten by + ada_decode. So, recognize it specially here and add it + to the index by hand. */ + if (entry->tag == DW_TAG_subprogram + && strcmp (main_for_ada, name) == 0) + { + /* Leave it alone. */ + } + else + { + /* In order for the index to work when read back into + gdb, it has to use the encoded name, with any + suffixes stripped. */ + std::string encoded = ada_encode (name, false); + name = obstack_strdup (&symtab->m_string_obstack, + encoded.c_str ()); + } + } ... The code contains some special handling related to the Ada main function, so let's look at that one: foo. Before commit 67e83a0deef we have: ... $ grep foo.*function READELF [3733] foo: 7 [global, function] ... and after: ... $ grep foo.*function READELF [2738] _ada_foo: 7 [global, function] [3733] foo: 7 [global, function] ... so that looks identical to the callee.increment case. At commit 5fea9794325, we have slightly different index numbers: ... $ grep foo.*function READELF [1658] foo: 7 [global, function] [2738] _ada_foo: 7 [global, function] ... but otherwise the same result. If we disable the special handling of the Ada main function like so: ... - if (entry->tag == DW_TAG_subprogram + if (false && entry->tag == DW_TAG_subprogram ... we still have the exact same result because: ... (gdb) p main_for_ada $1 = 0x352e6a0 "_ada_foo" ... and ada_encode ("_ada_foo", false) == "_ada_foo". The comment seems to be copied from debug_names::insert, which does indeed use ada_decode, while the code in write_cooked_index uses ada_encode instead. Remove the superfluous special handling of Ada main in write_cooked_index. Tested on x86_64-linux, with target boards unix and cc-with-gdb-index. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-03Remove f-string from DAPTom Tromey1-1/+1
One more f-string snuck into the DAP code, in breakpoint.py. Most of them were removed here: https://sourceware.org/pipermail/gdb-patches/2023-June/200023.html but I think this one landed after that patch. While DAP only supports Python 3.5 and later, f-strings were added in 3.6, so remove this. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708
2023-08-03Use frame.name() in FrameDecoratorTom Tromey2-12/+12
A co-worker pointed out that gdb's DAP implementation might return an integer for the name of a stack frame, like: {"id": 1, "name": 93824992310799, ...} This can be seen currently in the logs of the bt-nodebug.exp test case. What is happening is that FrameDecorator falls back on returning the PC when the frame's function symbol cannot be found, relying on the gdb core to look up the minsym and print its name. This can actually yield the wrong answer sometimes, because it falls into the get_frame_pc / get_frame_address_in_block problem -- if the frame is at a call to a noreturn function, the PC in this case might appear to be in the next function in memory. For more on this, see: https://sourceware.org/bugzilla/show_bug.cgi?id=8416 and related bugs. However, there's a different approach we can take: the code here can simply use Frame.name. This handles the PC problem correctly, and gets us the information we need.
2023-08-03gdb: avoid double stop after failed breakpoint condition checkAndrew Burgess5-23/+152
This commit replaces this earlier commit: commit 2e411b8c68eb2b035b31d5b00d940d4be1a0928b Date: Fri Oct 14 14:53:15 2022 +0100 gdb: don't always print breakpoint location after failed condition check and is a result of feedback received here[1]. The original commit addressed a problem where, if a breakpoint condition included an inferior function call, and if the inferior function call failed, then GDB would announce the stop twice. Here's an example of GDB's output before the above commit that shows the problem being addressed: (gdb) break foo if (some_func ()) Breakpoint 1 at 0x40111e: file bpcond.c, line 11. (gdb) r Starting program: /tmp/bpcond Program received signal SIGSEGV, Segmentation fault. 0x0000000000401116 in some_func () at bpcond.c:5 5 return *p; Error in testing condition for breakpoint 1: The program being debugged stopped while in a function called from GDB. Evaluation of the expression containing the function (some_func) will be abandoned. When the function is done executing, GDB will silently stop. Breakpoint 1, 0x0000000000401116 in some_func () at bpcond.c:5 5 return *p; (gdb) The original commit addressed this issue in breakpoint.c, by spotting that the $pc had changed while evaluating the breakpoint condition, and inferring from this that GDB must have stopped elsewhere. However, the way in which the original commit suppressed the second stop announcement was to set bpstat::print to true -- this tells GDB not to print the frame during the stop announcement, and for the CLI this is fine, however, it was pointed out that for the MI this still isn't really enough. Below is an example from an MI session after the above commit was applied, this shows the problem with the above commit: -break-insert -c "cond_fail()" foo ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000040111e",func="foo",file="/tmp/mi-condbreak-fail.c",line="30",thread-groups=["i1"],cond="cond_fail()",times="0",original-location="foo"} (gdb) -exec-run =thread-group-started,id="i1",pid="2636270" =thread-created,id="1",group-id="i1" =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7fd3110",to="0x00007ffff7ff2bb4"}] ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/libm.so.6",target-name="/lib64/libm.so.6",host-name="/lib64/libm.so.6",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7e59390",to="0x00007ffff7ef4f98"}] =library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7ca66b0",to="0x00007ffff7df3c5f"}] ~"\nProgram" ~" received signal SIGSEGV, Segmentation fault.\n" ~"0x0000000000401116 in cond_fail () at /tmp/mi-condbreak-fail.c:24\n" ~"24\t return *p;\t\t\t/* Crash here. */\n" *stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",frame={addr="0x0000000000401116",func="cond_fail",args=[],file="/tmp/mi-condbreak-fail.c",fullname="/tmp/mi-condbreak-fail.c",line="24",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="9" &"Error in testing condition for breakpoint 1:\n" &"The program being debugged was signaled while in a function called from GDB.\n" &"GDB remains in the frame where the signal was received.\n" &"To change this behavior use \"set unwindonsignal on\".\n" &"Evaluation of the expression containing the function\n" &"(cond_fail) will be abandoned.\n" &"When the function is done executing, GDB will silently stop.\n" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000040111e",func="foo",file="/tmp/mi-condbreak-fail.c",fullname="/tmp/mi-condbreak-fail.c",line="30",thread-groups=["i1"],cond="cond_fail()",times="1",original-location="foo"} *stopped (gdb) Notice that we still see two '*stopped' lines, the first includes the full frame information, while the second has no frame information, this is a result of bpstat::print having been set. Ideally, the second '*stopped' line should not be present. By setting bpstat::print I was addressing the problem too late, this flag really only changes how interp::on_normal_stop prints the stop event, and interp::on_normal_stop is called (indirectly) from the normal_stop function in infrun.c. A better solution is to avoid calling normal_stop at all for the stops which should not be reported to the user, and this is what I do in this commit. This commit has 3 parts: 1. In breakpoint.c, revert the above commit, 2. In fetch_inferior_event (infrun.c), capture the stop-id before calling handle_inferior_event. If, after calling handle_inferior_event, the stop-id has changed, then this indicates that somewhere within handle_inferior_event, a stop was announced to the user. If this is the case then GDB should not call normal_stop, and we should rely on whoever announced the stop to ensure that we are in a PROMPT_NEEDED state, which means the prompt will be displayed once fetch_inferior_event returns. And, 3. In infcall.c, do two things: (a) In run_inferior_call, after making the inferior call, ensure that either async_disable_stdin or async_enable_stdin is called to put the prompt state, and stdin handling into the correct state based on whether the inferior call completed successfully or not, and (b) In call_thread_fsm::should_stop, call async_enable_stdin rather than changing the prompt state directly. This isn't strictly necessary, but helped me understand this code more. This async_enable_stdin call is only reached if normal_stop is not going to be called, and replaces the async_enable_stdin call that exists in normal_stop. Though we could just adjust the prompt state if felt (to me) much easier to understand when I could see this call and the corresponding call in normal_stop. With these changes in place now, when the inferior call (from the breakpoint condition) fails, infcall.c leaves the prompt state as PROMPT_NEEDED, and leaves stdin registered with the event loop. Back in fetch_inferior_event GDB notices that the stop-id has changed and so avoids calling normal_stop. And on return from fetch_inferior_event GDB will display the prompt and handle input from stdin. As normal_stop is not called the MI problem is solved, and the test added in the earlier mentioned commit still passes just fine, so the CLI has not regressed. [1] https://inbox.sourceware.org/gdb-patches/6fd4aa13-6003-2563-5841-e80d5a55d59e@palves.net/
2023-08-03Remove PEI_HEADERS defineTom Tromey14-27/+36
I noticed a few files double-included libcoff.h, and digging deeper I found that the PEI_HEADERS define is a sort of external include guard. This patch adds include guards to the few files in include/coff that were missing one, and then removes the PEI_HEADERS workaround and the redundant includes. I didn't see anything in these files that indicated that double-inclusion would be useful, so it seems to me that this approach is ok. Tested by rebuilding with --enable-targets=all. 2023-08-02 Tom Tromey <tromey@adacore.com> * pei-x86_64.c (PEI_HEADERS): Do not define. * pei-loongarch64.c (PEI_HEADERS): Do not define. * pei-aarch64.c (PEI_HEADERS): Do not define. * pe-x86_64.c (PEI_HEADERS): Do not define. * pe-aarch64.c (PEI_HEADERS): Do not define. * libpei.h (_LIBPEI_H): Add include guard. * coff-x86_64.c (PEI_HEADERS): Do not check. * coff-loongarch64.c (PEI_HEADERS): Do not check. * coff-aarch64.c (PEI_HEADERS): Do not check. include/ChangeLog 2023-08-02 Tom Tromey <tromey@adacore.com> * coff/x86_64.h (COFF_X86_64_H): Add include guard. * coff/loongarch64.h (COFF_LOONGARCH64_H): Add include guard. * coff/aarch64.h (COFF_AARCH64_H): Add include guard.
2023-08-03readelf sprintf optimisationAlan Modra1-721/+1050
This replaces sprintf and strcat calls with stpcpy, and makes use of sprintf return value rather than using strlen, for get_machine_flags. decode_NDS32_machine_flags made use of snprintf, which is arguably the "correct" way to do things if there can be a buffer overflow. In this case I don't think there can be, the buffer is 1k in size which is at least 5 times more than needed. What's more, snprintf returns the count of chars that would be output given no buffer limit, which means code like r += snprintf (buf + r, size - r, ...); r += snprintf (buf + r, size - r, ...); is just wrong. There needs to be a check on the return value in order to prevent buf + r being out of bounds for the second snprintf call. BTW, if you look closely you'll see the return value of the decode functions is unused. I admit to getting a little carried away with writing "out = stpcpy (out, ...):" in each of the decode functions and didn't notice that until get_machine_flags was trimmed down to a much smaller size. When I did notice, I decided it's not such a bad thing. * readelf.c (decode_ARC_machine_flags, decode_ARM_machine_flags), (decode_AVR_machine_flags, decode_NDS32_machine_flags), (decode_AMDGPU_machine_flags): Use stpcpy and sprintf return value. Return end of string. (decode_BLACKFIN_machine_flags, decode_FRV_machine_flags), (decode_IA64_machine_flags, decode_LOONGARCH_machine_flags), (decode_M68K_machine_flags, decode_MeP_machine_flags), (decode_MIPS_machine_flags, decode_MSP430_machine_flags), (decode_PARISC_machine_flags, decode_RISCV_machine_flags), (decode_RL78_machine_flags, decode_RX_machine_flags), (decode_SH_machine_flags, decode_SPARC_machine_flags), (decode_V800_machine_flags, decode_V850_machine_flags), (decode_Z80_machine_flags): New functions, split out from.. (get_machine_flags): ..here. Similarly use stpcpy.
2023-08-03binutils sprintf optimisationAlan Modra7-70/+68
Avoid the use of sprintf with a "%s" format string, replacing with strcpy or stpcpy. Use sprintf return value rather than a later strlen. Don't use strcat where we can keep track of the end of a string output buffer. * dlltool.c (look_for_prog): memcpy prefix and strcpy prog_name. * dllwrap.c (look_for_prog): Likewise. * resrc.c (look_for_default): Likewise. Add quotes with memmove rather than allocating another buffer. * size.c (size_number): Use sprintf return value. * stabs.c (parse_stab_argtypes): Likewise. * windmc.c (write_bin): Likewes, and use stpcpy. * wrstabs.c: Similarly throughout.
2023-08-03cris: sprintf optimisationAlan Modra1-19/+10
Since I was poking at cris-dis.c to avoid the sanitizer warning, I figure I might as well make use of stpcpy and sprintf return value in other places in this file. * cris-dis.c (format_hex): Use sprintf return value. (format_reg): Use stpcpy and sprintf return, avoiding strlen. (format_sup_reg): Likewise.
2023-08-03arm: sanitizer stringop-overflowAlan Modra1-2/+8
In function 'memset', inlined from 'create_unwind_entry' at /home/alan/src/binutils-gdb/gas/config/tc-arm.c:27881:3: /usr/include/bits/string_fortified.h:59:10: error: '__builtin_memset' specified size between 2147483652 and 4294967295 exceeds maximum object size 2147483647 [-Werror=stringop-overflow=] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | __glibc_objsize0 (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ * config/tc-arm.c (create_unwind_entry): Return after bad size, and bad opcode count.
2023-08-03xtensa: sprintf sanitizer null destination pointerAlan Modra1-7/+4
* config/tc-xtensa.c (xtensa_add_config_info): Use auto buffer rather than malloc. Use sprintf return value.
2023-08-03ld: sprintf sanitizer null destination pointerAlan Modra9-25/+42
* configure.ac (stpcpy): AC_CHECK_DECLS. * sysdep.h (stpcpy): Add fallback declaraion. * config.in: Regenerate. * configure: Regenerate. * emultempl/pe.em (open_dynamic_archive): Use stpcpy rather than sprintf plus strlen. * emultempl/pep.em (open_dynamic_archive): Likewise. * emultempl/xtensaelf.em (elf_xtensa_before_allocation): Use auto rather than malloc'd buffer. Use sprintf count. * ldelf.c (ldelf_search_needed): Use memcpy in place of sprintf. * pe-dll.c (pe_process_import_defs): Use string already formed for alias match rather than recreating.
2023-08-03gprof: sprintf sanitizer null destination pointerAlan Modra1-8/+4
* basic_blocks.c (annotate_with_count): Use output of sprintf rather than strlen.
2023-08-03resrc: sprintf sanitizer null destination pointerAlan Modra1-15/+9
* resrc.c (read_rc_file): Use stpcpy rather than sprintf followed by strlen. Tidy.
2023-08-03dlltool: sprintf sanitizer null destination pointerAlan Modra1-3/+5
* dlltool.c (gen_lib_file): Avoid bogus sanitizer error.
2023-08-03wrstabs: sprintf sanitizer null destination pointerAlan Modra1-5/+9
gcc-2.12 seems to be ignoring __attribute__((__returns_nonnull__)) on xmalloc. * wrstabs.c (stab_method_type): Use stpcpy rather than sprintf or strcat.
2023-08-03cris: sprintf sanitizer null destination pointerAlan Modra1-6/+1
Simplify the sprintf calls, and use sprintf return value. Older code in binutils avoided using the sprintf return count of chars printed, because with some older C libraries it wasn't reliable. Nowadays it should be OK to use (and we already use the return value elsewhere). sprintf can't return an error status of -1 here. * cris-dis.c (format_dec): Avoid sanitizer warning. Use sprintf return value rather than calling strlen.
2023-08-03objdump, nm: sprintf sanitizer null destination pointerAlan Modra2-22/+32
Seen on Ubuntu 23.04 x86_64-linux using gcc-12.2 and gcc-12.3 with CFLAGS="-m32 -g -O2 -fsanitize=address,undefined". CC objdump.o In file included from /usr/include/stdio.h:906, from /home/alan/src/binutils-gdb/binutils/sysdep.h:24, from /home/alan/src/binutils-gdb/binutils/objdump.c:51: In function 'sprintf', inlined from 'display_utf8' at /home/alan/src/binutils-gdb/binutils/objdump.c:621:14, inlined from 'sanitize_string.part.0' at /home/alan/src/binutils-gdb/binutils/objdump.c:742:11: /usr/include/bits/stdio2.h:30:10: error: null destination pointer [-Werror=format-overflow=] 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors The warning is bogus of course. xmalloc is guaranteed to return non-NULL, but apparently this isn't seen in display_utf6. The same doesn't happen with -m64, maybe due to inlining differences, I haven't investigated fully. Easily avoided as we hardly need to use sprintf for a single char, or a two char string. * objdump.c (display_utf8): Avoid bogus sprintf sanitizer warning. Use hex ESC to switch back to default colour. (sanitize_string): Comment. Bump buffer size by one. Fix overlong line. * nm.c (display_utf8, sanitize_string): As above.
2023-08-03gdb: fix possible nullptr dereference in a remote_debug_printf callAndrew Burgess1-2/+2
While working on another patch I triggered a segfault from within the function remote_target::discard_pending_stop_replies. Turns out this was caused by a cut&paste error introduced in this commit: commit df5ad102009c41ab4dfadbb8cfb8c8b2a02a4f78 Date: Wed Dec 1 09:40:03 2021 -0500 gdb, gdbserver: detach fork child when detaching from fork parent This commit adds a remote_debug_printf call that was copied from earlier in the function, however, the new call wasn't updated to use the appropriate local variable. The local variable that it is using might be nullptr, in which case we trigger undefined behaviour, and could crash, which is what I was seeing. Fixed by updating to use the correct local variable.
2023-08-03 Fix Wlto-type-mismatch in opcodes/ft32-dis.cTom de Vries1-1/+1
2023-08-03RISC-V: Add support for 'Zvfh' and 'Zvfhmin'Tsukasa OI1-0/+5
This commit adds support for recently ratified vector FP16 extensions: 'Zvfh' and 'Zvfhmin'. This is based on: <https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#zvfhmin-vector-extension-for-minimal-half-precision-floating-point> <https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#zvfh-vector-extension-for-half-precision-floating-point> Despite not having any new instructions, it will be necessary since those extensions are already implemented in GCC. Note that however, in this commit, following dependencies are implemented. 1. 'Zvfhmin' -> 'Zve32f' 2. 'Zvfh' -> 'Zvfhmin' (not 'Zvfh' -> 'Zve32f' as in the documentation) 3. 'Zvfh' -> 'Zfhmin' This is because the instructions and configurations supported by the 'Zvfh' extension is a strict superset of the 'Zvfhmin' extension and 'Zvfh' -> 'Zve32f' dependency is indirectly derived from that fact. bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets): Add implications related to 'Zvfh' and 'Zvfhmin' extensions. (riscv_supported_std_z_ext) Add 'Zvfh' and 'Zvfhmin' to the list.
2023-08-03RISC-V: Imply 'Zicsr' from 'Zve32x'Tsukasa OI1-0/+1
Further clarification is made so that 'Zve32x' implies 'Zicsr' (the same implication is already implemented in LLVM). See related issue (the author raised) on the vector specification: <https://github.com/riscv/riscv-v-spec/issues/908> and its resolution: <https://github.com/riscv/riscv-v-spec/issues/909> bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets): Add 'Zve32x' -> 'Zicsr'.
2023-08-03Automatic date update in version.inGDB Administrator1-1/+1
2023-08-02[gdb] Initialize main_thread_id earlierTom de Vries2-1/+25
I wrote a patch using is_main_thread (), and found it returning false in the main thread due to main_thread_id not being initialized yet. Initialization currently takes place in _initialize_run_on_main_thread, but that's too late for earlier uses. Fix this by initializing, either: - when entering main, or - on an earlier first use. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-02[gdb/dap] Disable DAP for python <= 3.5Tom de Vries2-0/+28
DAP requires python module typing, which is supported starting python 3.5. Make this formal by: - disabling the dap interpreter for python version < 3.5 - returning 0 in allow_dap_tests for python version < 3.5 Approved-By: Tom Tromey <tom@tromey.com> PR dap/30708 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708
2023-08-02Avoid failures in fixed_points.exp with older GCCTom Tromey1-2/+5
Tom de Vries pointed out that my recent change to fixed_points.exp failed with older versions of GCC. This patch fixes the problem by skipping the new test in this situation.
2023-08-02Revert "2.41 Release sources"Sam James288-159122/+20767
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d. See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton288-20767/+159122
2023-08-01gprofng: Fix build with 64bit file offset on 32bit machinesKhem Raj1-3/+6
gprofng/ChangeLog 2023-07-31 Khem Raj <raj.khem@gmail.com> * libcollector/iotrace.c: Define open64, fgetpos64, and fsetpos64 only when __USE_LARGEFILE64 and __USE_FILE_OFFSET64 are not defined.
2023-08-02Automatic date update in version.inGDB Administrator1-1/+1
2023-08-02Don't declare xmalloc and others in ldmisc.hAlan Modra7-7/+10
* ldmisc.h (xmalloc, xrealloc, xexit, yyerror): Don't declare. * emultempl/pdp11.em: Include libiberty.h. * emultempl/ticoff.em: Likewise. * emultempl/vms.em: Likewise. * ldctor.c: Likewise. * ldelfgen.c: Likewise. * ldgram.y: Likewise. (yyerror): Prototype and make static.
2023-08-02Don't declare xmalloc or xrealloc in bucomm.hAlan Modra3-6/+2
It's better to include the proper header, which has declarations with various attributes. Commit 096aefc040 in 1994 introduced this wart. * bucomm.h (xmalloc, xrealloc): Delete declaration. * od-macho.c: Include libiberty.h. * od-xcoff.c: Include libiberty.h.
2023-08-02Regen ld/configureAlan Modra1-1/+1
For commit 3d05c80b5dc4.
2023-08-01Implement DAP "source" requestTom Tromey4-4/+97
This implements the DAP "source" request. I renamed the "loadedSources" function from "sources" to "loaded_sources" to avoid any confusion. I also moved the loadedSources test to the new sources.exp. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30691
2023-08-01Handle Source in DAP breakpointLocationsTom Tromey2-8/+20
This changes the DAP breakpointLocations request to accept a Source and to decode it properly.
2023-08-01Introduce sourceReference handling in DAPTom Tromey3-20/+41
This changes the gdb DAP implementation to emit a real sourceReference, rather than emitting 0. Sources are tracked in some maps in sources.py, and a new helper function is introduced to compute the "Source" object that can be sent to the client.
2023-08-01Don't supply DAP 'path' for non-file shared librariesTom Tromey1-2/+4
The DAP 'module' event may include a 'path' component. I noticed that this is supplied even when the module in question does not come from a file. This patch only emits this field when the objfile corresponds to a real file. No test case, because I wasn't sure how to write a portable one. However, it's clear from gdb.log on Linux: {"type": "event", "event": "module", "body": {"reason": "new", "module": {"id": "system-supplied DSO at 0x7ffff7fc4000", "name": "system-supplied DSO at 0x7ffff7fc4000"}}, "seq": 21} Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30676
2023-08-01Implement ValueFormat for DAPTom Tromey4-78/+124
This patch implements ValueFormat for DAP. Currently this only means supporting "hex". Note that StackFrameFormat is defined to have many more options, but none are currently recognized. It isn't entirely clear how these should be handled. I'll file a new gdb bug for this, and perhaps an upstream DAP bug as well. New in v2: - I realized that the "hover" context was broken, and furthermore that we only had tests for "hover" failing, not for it succeeding. This version fixes the oversight and adds a test. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30469
2023-08-01Respect supportsMemoryReferences in DAPTom Tromey5-12/+13
I noticed that the support for memoryReference in the "variables" output is gated on the client "supportsMemoryReferences" capability. This patch implements this and makes some other changes to the DAP memory reference code: * Remove the memoryReference special case from _SetResult. Upstream DAP fixed this oversight in response to https://github.com/microsoft/debug-adapter-protocol/issues/414 * Don't use the address of a variable as its memoryReference -- only emit this for pointer types. There's no spec support for the previous approach. * Use strip_typedefs to handle typedefs of pointers.
2023-08-01Add DAP support for C++ exceptionsTom Tromey3-4/+119
This adds DAP support for the various C++ exception-catching operations. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30682
2023-08-01Implement DAP 'terminated' eventTom Tromey3-1/+41
This implements the DAP 'terminated' event. Vladimir Makaev noticed that VSCode will not report the debug session as over unless this is sent. It's not completely clear when exactly this event ought to be sent. Here I've done it when the inferior exits. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30681
2023-08-01Do not send "new breakpoint" event when breakpoint is setTom Tromey2-13/+34
When the DAP client sets a breakpoint, gdb currently sends a "new breakpoint" event. However, Vladimir Makaev discovered that this causes VSCode to think there are two breakpoints. This patch changes gdb to suppress the event in this case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30678
2023-08-01Move DAP breakpoint event code to breakpoint.pyTom Tromey2-39/+40
A subsequent patch will add the ability to suppress breakpoint events to DAP. My first attempt at this ended up with recurse imports, causing Python failures. So, this patch moves all the DAP breakpoint event code to breakpoint.py in preparation for the change. I've renamed breakpoint_descriptor here as well, because it can now be private to breakpoint.py.
2023-08-01Full paths in DAP stackTrace responsesTom Tromey2-51/+82
Vladimir Makaev noticed that, in some cases, a DAP stackTrace response would include a relative path name for the "path" component. This patch changes the frame decorator code to add a new DAP-specific decorator, and changes the DAP entry point to frame filters to use it. This decorator prefers the symtab's full name, and does not fall back to the solib's name. I'm not entirely happy with this patch, because if a user frame filter uses FrameDecorator, it may still do the wrong thing. It would be better to have frame filters return symtab-like objects instead, or to have a separate method to return the full path to the source file. I also tend to think that the solib fallback behavior of FrameDecorator is a mistake. If this is ever needed, it seems to me that it should be a separate method. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30665
2023-08-01Add "cwd" parameter to DAP launch requestTom Tromey4-17/+70
This adds the "cwd" parameter to the DAP launch request. This came up here: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/issues/90 ... and seemed like a good idea. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-08-01Refactor dap_launchTom Tromey3-28/+43
This patch refactors dap_launch to make it more extensible and also easier to use.
2023-08-01Rename private member of FrameDecoratorTom Tromey1-4/+4
In Python, a member name starting with "__" is specially handled to make it "more private" to the class -- it isn't truly private, but it is renamed to make it less likely to be reused by mistake. This patch ensures that this is done for the private method of FrameDecorator.
2023-08-01Add thread exited eventSimon Farre1-7/+18
Reports a thread exit according to the DAP spec: https://microsoft.github.io/debug-adapter-protocol/specification#Events_Thread This patch requires the ThreadExitedEvent to be checked in, in order to work. That patch is found here https://sourceware.org/pipermail/gdb-patches/2023-June/200071.html Formatted correctly using black Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30474 Approved-By: Tom Tromey <tom@tromey.com>