aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-05-06Use OBSTACK_ZALLOC when allocating batonsTom Tromey1-6/+9
I found some places in dwarf2/read.c that allocate a location baton, but fail to initialize one of the fields. It seems safer to me to use OBSTACK_ZALLOC here, so this patch makes this change. This will be useful in a subsequent patch as well, where a new field is added to one of the batons.
2025-05-06Clean up handle_member_locationTom Tromey1-3/+2
This removes a redundant check from handle_member_location, and also changes the complaint -- currently it will issue the "complex location" complaint, but really what is happening here is an unrecognized form.
2025-05-06Handle dynamic field propertiesTom Tromey9-91/+237
I found a situation where gdb could not properly decode an Ada type. In this first scenario, the discriminant of a type is a bit-field. PROP_ADDR_OFFSET does not handle this situation, because it only allows an offset -- not a bit-size. My original approach to this just added a bit size as well, but after some discussion with Eric Botcazou, we found another failing case: a tagged type can have a second discriminant that appears at a variable offset. So, this patch changes this code to accept a general 'struct field' instead of trying to replicate the field-finding machinery by itself. This is handled at property-evaluation time by simply using a 'field' and resolving its dynamic properties. Then the usual field-extraction function is called to get the value. Because the baton now just holds a field, I renamed PROP_ADDR_OFFSET to PROP_FIELD. The DWARF reader now defers filling in the property baton until the fields have been attached to the type. Finally, I noticed that if the discriminant field has a biased representation, then unpack_field_as_long would not handle this either. This bug is also fixed here, and the test case checks this. Regression tested on x86-64 Fedora 41.
2025-05-06Add new unpack_field_as_long overloadTom Tromey2-6/+22
This introduces a new unpack_field_as_long that takes the field object directly, rather than a type and an index. This will be used in the next patch.
2025-05-06Add resolve_dynamic_fieldTom Tromey2-42/+62
The final patch in this series will change one dynamic property approach to use a struct field rather than an offset and a field type. This is convenient because the reference in DWARF is indeed to a field -- and this approach lets us reuse the field-extraction logic that already exists in gdb. However, the field in question may have dynamic properties which must be resolved before it can be used. This patch prepares for this by introducing a separate resolve_dynamic_field function. This patch should cause no visible changes to behavior.
2025-05-06Constify property_addr_infoTom Tromey2-14/+14
This changes most places to use a const property_addr_info. This seems more correct to me because normally the user of a property_addr_info should not modify it. Furthermore, some functions already take a const object, and for a subsequent patch it is convenient if other functions do as well.
2025-05-06gdb/testsuite: Add require allow_hipcc_tests in gdb.rocm/mi-attach.expLancelot SIX1-1/+2
The gdb.rocm/mi-attach.exp test is missing a proper `require` check to ensure that the current configuration can run ROCm tests. This issue has been reported by Baris. This patch adds the missing `allow_hipcc_tests` requirement, and also adds `load_lib rocm.exp` to enable this test. Change-Id: Ie136adfc2d0854268b92af5c4df2dd0334dce259 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Approved-By: Tom Tromey <tom@tromey.com>
2025-05-06gdb: support zero inode in generate-core-file commandAndrew Burgess1-1/+1
It is possible, when creating a shared memory segment (i.e. with shmget), that the id of the segment will be zero. When looking at the segment in /proc/PID/smaps, the inode field of the entry holds the shared memory segment id. And so, it can be the case that an entry (in the smaps file) will have an inode of zero. When GDB generates a core file, with the generate-core-file (or its gcore alias) command, the shared memory segment should be written into the core file. Fedora GDB has, since 2008, carried a patch that tests this case. There is no fix for GDB associated with the test, and unfortunately, the motivation for the test has been lost to the mists of time. This likely means that a fix was merged upstream without a suitable test, but I've not been able to find and relevant commit. The test seems to be checking that the shared memory segment with id zero, is being written to the core file. While looking at this test and trying to work out if it should be posted upstream, I saw that GDB does appear to write the shared memory segment into the core file (as expected), which is good. However, GDB still isn't getting this case exactly right. In gcore_memory_sections (gcore.c) we call back into linux-tdep.c (via the gdbarch_find_memory_regions call) to correctly write the shared memory segment into the core file, however, in linux_make_mappings_corefile_notes, when we use linux_find_memory_regions_full to create the NT_FILE note, we call back into linux_make_mappings_callback for each mapping, and in here we reject any mapping with a zero inode. The result of this, is that, for a shared memory segment with a non-zero id, after loading the core file, the shared memory segment will appear in the 'proc info mappings' output. But, for a shared memory segment with a zero id, the segment will not appear in the 'proc info mappings' output. I propose fixing this by not checking the inode in linux_make_mappings_callback. The inode check was in place since the code was originally added in commit 451b7c33cb3c9ec6272c36870 (in 2012). The test for this bug, based on the original Fedora patch, can be found on the mailing list here: https://inbox.sourceware.org/gdb-patches/0d389b435cbb0924335adbc9eba6cf30b4a2c4ee.1741776651.git.aburgess@redhat.com I have not committed this test into the tree though because the test was just too unreliable. User space doesn't have any control over the shared memory id, so all we can do is spam out requests for new shared memory segments and hope that we eventually get the zero id. Obviously, this can fail; the zero id might already be in use by some long running process, or the kernel, for whatever reason, might choose to never allocate the zero id. The test I posted (see above thread) did work more than 50% of the time, but it was far closer to a 50% success rate than 100%, and I really don't like introducing unreliable tests.
2025-05-06gdb/testsuite: add gcore_cmd_available predicate procAndrew Burgess7-4/+25
Add a new gcore_cmd_available predicate proc that can be used in a 'requires' line, and make use of it in a few tests. All of the tests I have modified call gdb_gcore_cmd as one of their first actions and exit if the gcore command is not available, so it makes sense (I think) to move the gcore command check into a requires call. There should be no change in what is actually run after this commit.
2025-05-06gdb/python/guile: check if styling is disabled in Color.escape_sequenceAndrew Burgess6-7/+41
I noticed that the gdb.Color.escape_sequence() method would produce an escape sequence even when styling is disabled. I think this is the wrong choice. Ideally, when styling is disabled (e.g. with 'set style enabled off'), GDB should not be producing styled output. If a GDB extension is using gdb.Color to apply styling to the output, then currently, the extension should be checking 'show style enabled' any time Color.escape_sequence() is used. This means lots of code duplication, and the possibility that some locations will be missed, which means disabling styling no longer does what it says. I propose that Color.escape_sequence() should return the empty string if styling is disabled. A Python extension can then do: python c_none = gdb.Color('none') c_red = gdb.Color('red') print(c_red.escape_sequence(True) + "Text in red." + c_none.escape_sequence(True)) end If styling is enable this will print some red text. And if styling is disabled, then it will print text in the terminal's default color. I have applied the same fix to the guile API. I have extended the tests to cover this case. Approved-By: Tom Tromey <tom@tromey.com>
2025-05-06gas: input_scrub buffersAlan Modra1-8/+19
This tidies freeing of input_scrub buffers on failure paths, making input_scrub_end iterate over any input_scrub_push'd files or string buffers to clean up memory. * input-scrub.c (input_scrub_free): New function. (input_scrub_pop): Call it rather than input_scrub_end. (input_scrub_end): Iterate over next_saved_file freeing buffers. (input_scrub_next_buffer): Move sb_kill to input_scrub_free.
2025-05-06windres_get_* functionsAlan Modra6-252/+254
windres_get_32 and similar have a length parameter that in most cases is just the required length, so it is redundant. The few cases where a variable length is passed are all in resrc.c. So, get rid of the length parameter and introduce wrappers in resrc.c to check the length.
2025-05-06Automatic date update in version.inGDB Administrator1-1/+1
2025-05-05Fix sign of Ada rational constantsTom Tromey3-6/+18
My earlier patch commit 0c03db90 ("Use correct sign in get_mpz") was (very) incorrect. It changed get_mpz to check for a strict sign when examining part of an Ada rational constant. However, in Ada the "delta" for a fixed-point type must be positive, and so the components of the rational representation will be positive. This patch corrects the error. It also renames the get_mpz function, in case anyone is tempted to reuse this code for another purpose. Finally, this pulls over the test from the internal AdaCore test suite that found this issue.
2025-05-05gprofng: remove unused functions, duplicate macrosVladimir Mezentsev11-187/+47
class Reloc is not used after commit 13f614be23a gprofng: Refactor readSymSec for using BFD's asymbol struct Many common macros were defined in different sources. Sometimes a macro was used, sometimes a macros value was used. Removed unused macros and include files. gprofng/ChangeLog 2025-05-03 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> * common/gp-experiment.h: Define variables that are passed to libcollector. Remove unused macros. * libcollector/collector.c: Cleanup macros. * libcollector/descendants.h: Likewise. * libcollector/envmgmt.c: Likewise. * libcollector/linetrace.c: Likewise. * src/collect.h: Likewise. * src/envsets.cc: Likewise. * src/gp-collect-app.cc: Likewise. * src/Stabs.cc: Remove class Reloc. * src/Stabs.h: Likewise. * src/ipcio.cc: Remove unused include files.
2025-05-04gprofng: fix 32892 source line level information not available with "-g -O2"Vladimir Mezentsev11-153/+563
gprofng ignored DW_AT_specification. As a result, gprofng skiped Dwarf for all functions declared as: < 2>:<0x0000f725> DW_TAG_subprogram(46) DW_AT_linkage_name(110) "func_name" DW_AT_declaration*(60) 0x1 (1) < 1>:<0x00015acc> DW_TAG_subprogram(46) DW_AT_specification(71) 0xf725 (63269) Another problem was that gprofng ignored DW_AT_ranges. As a result, many functions are mapped to the <Unknown> module. gprofng/ChangeLog 2025-05-01 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR 32892 * src/Dwarf.cc: Handle DW_AT_specification and DW_AT_ranges. * src/DwarfLib.cc: Likewise. * src/DwarfLib.h: Likewise. * src/Dwarf.h (get_ranges): New function. * src/Stabs.h (get_symbols): New function. * src/Stabs.cc: Move Symbol class to src/Symbol.cc. * src/Symbol.cc: New file. * src/Symbol.h: New file. * src/Makefile.am: Add Symbol.cc in build. * src/Makefile.in: Rebuild. * src/LoadObject.cc (dump_functions): Improve output for -dfunc option.
2025-05-05Automatic date update in version.inGDB Administrator1-1/+1
2025-05-04Automatic date update in version.inGDB Administrator1-1/+1
2025-05-03Automatic date update in version.inGDB Administrator1-1/+1
2025-05-02[gdb/testsuite] Simplify gdb.tui/tui-layout-asm.expTom de Vries1-37/+69
On x86_64-cygwin, with test-case gdb.tui/tui-layout-asm.exp I run into: ... WARNING: The following failure is probably due to the TUI window width. See the comments in the test script for more details. FAIL: $exp: scroll to end of assembler (scroll failed) ... The problem is as follows. On the TUI screen, we have: 1 | 0x1004010ff <__gdb_set_unbuffered_output+95> nop | 2 | 0x100401100 <__cxa_atexit> jmp *0x6fc2(%rip) # 0x10040 | ... We send the down key, which should have the effect of scrolling up. So, we expect that the second line moves to the first line. That seems to be the case indeed: ... 1 | 0x100401100 <__cxa_atexit> jmp *0x6fc2(%rip) # 0x1004080c8 <__imp___cxa_ | ... but the line has changed somewhat, so the matching fails. We could increase the width of the screen, as suggested in the test-case, but I think that approach is fragile. Instead, fix this by relaxing the matching: just check that the line before scrolling is fully contained in the line after scrolling, or the other way around. Doing so gets us the next failure: ... FAIL: $exp: scroll to end of assembler (too much assembler) ... The test-case states: ... if { $down_count > 250 } { # Maybe we should accept this as a pass in case a target # really does have loads of assembler to scroll through. fail "$testname (too much assembler)" ... and I agree, so fix this by issuing a pass. This results in the test-case taking ~20 seconds, so reduce the maximum number of scrolls from 250 to 25, bringing that down to ~10 seconds. Tested on x86_64-cygwin and x86_64-linux. PR testsuite/32898 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32898
2025-05-02[gdb/symtab] Throw DWARF error on out-of-bounds DW_FORM_strxTom de Vries2-3/+45
With the test-case contained in the patch, and gdb build with -fsanitize=address we get: ... ==23678==ERROR: AddressSanitizer: heap-buffer-overflow ...^M READ of size 1 at 0x6020000c30dc thread T3^[[1m^[[0m^M ptype global_var^M #0 0x2c6a40b in bfd_getl32 bfd/libbfd.c:846^M #1 0x168f96c in read_str_index gdb/dwarf2/read.c:15349^M ... The executable contains an out-of-bounds DW_FORM_strx attribute: ... $ readelf -wi $exec <2eb> DW_AT_name :readelf: Warning: string index of 1 converts to \ an offset of 0xc which is too big for section .debug_str (indexed string: 0x1): <string index too big> ... and read_str_index doesn't check for this: ... info_ptr = (str_offsets_section->buffer + str_offsets_base + str_index * offset_size); if (offset_size == 4) str_offset = bfd_get_32 (abfd, info_ptr); ... and consequently reads out-of-bounds. Fix this in read_str_index by checking for the out-of-bounds condition and throwing a DWARF error: ... (gdb) ptype global_var DWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing \ outside of .debug_str_offsets section in CU at offset 0x2d7 \ [in module dw-form-strx-out-of-bounds] No symbol "global_var" in current context. (gdb) ... Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2025-05-02[gdb/testsuite] Add gdb.dwarf2/dw-form-strx.expTom de Vries3-0/+125
Add a test-case using DW_FORM_strx. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2025-05-02[gdbsupport] Reimplement phex and phex_nz as templatesTom de Vries16-48/+68
Gdbsupport functions phex and phex_nz have a parameter sizeof_l: ... extern const char *phex (ULONGEST l, int sizeof_l); extern const char *phex_nz (ULONGEST l, int sizeof_l); ... and a lot of calls use: ... phex (l, sizeof (l)) ... Make this easier by reimplementing the functions as a template, allowing us to simply write: ... phex (l) ... Simplify existing code using: ... $ find gdb* -type f \ | xargs sed -i 's/phex (\([^,]*\), sizeof (\1))/phex (\1)/' $ find gdb* -type f \ | xargs sed -i 's/phex_nz (\([^,]*\), sizeof (\1))/phex_nz (\1)/' ... and manually review: ... $ find gdb* -type f | xargs grep "phex (.*, sizeof.*)" $ find gdb* -type f | xargs grep "phex_nz (.*, sizeof.*)" ... Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2025-05-02Use emoji to indicate errors and warningsTom Tromey10-17/+207
This patch adds, at long last, some emoji output to gdb. In particular, warnings are indicated with the U+26A0 (WARNING SIGN), and errors with U+274C (CROSS MARK). There is a new setting to control whether emoji output can be used. It defaults to "auto", which means emoji will be used if the host charset is UTF-8. Note that disabling styling will also disable emoji, handy for traditionalists. I've refactored mingw console output a little, so that emoji will not be printed to the console. Note the previous code here was a bit strange in that it assumed that the first use of gdb_console_fputs would be to stdout. This version lets the user control the prefixes directly, so different emoji can be chosen if desired. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Keith Seitz <keiths@redhat.com> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-05-02readline/tcap.h: Update definitions for C23Chris Packham1-6/+6
C23 changes how function definitions like int `int tputs ()` are interpreted. In older standards this meant that the function arguments are unknown. In C23 this is interpreted as `int tputs (void)` so now when we compile with GCC15 (which defaults to -std=gnu23) we get an error such as readline/display.c:2839:17: error: too many arguments to function 'tputs'; expected 0, have 3 Add the function arguments for tgetent(), tgetflag(), tgetnum(), tgetstr(), tputs() and tgoto(). Signed-off-by: Chris Packham <judge.packham@gmail.com> Approved-By: Tom Tromey <tom@tromey.com>
2025-05-02[gdb/testsuite] Fix gdb.reverse/time-reverse.exp timeoutTom de Vries1-1/+25
After building gdb with "-O0 -g -fsanitize=thread" on aarch64-linux, with test-case gdb.reverse/time-reverse.exp I run into: ... (gdb) continue^M Continuing.^M FAIL: $exp: mode=c: continue to breakpoint: marker2 (timeout) ... The problem is that instruction stepping gets stuck in a loop with this call stack: time -> __GI___clock_gettime -> __kernel_clock_gettime -> __cvdso_clock_gettime. This is not specific to fsanitize=thread, it just makes gdb slow, which makes instruction stepping slow, which results in the application getting stuck. I ran into this as well with a regular gdb build on a 32-bit i686 laptop with 1GB of memory, an inherently slow setup. In that instance, I was able to observe that the loop we're stuck in is the outer loop in do_coarse in linux kernel source lib/vdso/gettimeofday.c. Fix this by setting "record full insn-number-max" to 2000, and handling running into the limit. Initially I tried the approach of using "stepi 2000" instead of continue, but that made the issue more likely to show up (for instance, I observed it after building gdb with -O0 on aarch64-linux). Tested on aarch64-linux. Approved-By: Guinevere Larsen <guinevere@redhat.com> PR testsuite/32678 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32678
2025-05-02[gdb/testsuite] Make gdb.reverse/time-reverse.exp more robustTom de Vries1-8/+11
I noticed that test-case gdb.reverse/time-reverse.exp contains: ... if [supports_process_record] { # Activate process record/replay gdb_test_no_output "record" "turn on process record" ... So I tried out forcing supports_process_record to 0, and got: ... FAIL: gdb.reverse/time-reverse.exp: mode=syscall: info record FAIL: gdb.reverse/time-reverse.exp: mode=syscall: reverse to marker1 FAIL: gdb.reverse/time-reverse.exp: mode=syscall: check time record FAIL: gdb.reverse/time-reverse.exp: mode=c: info record FAIL: gdb.reverse/time-reverse.exp: mode=c: reverse to marker1 FAIL: gdb.reverse/time-reverse.exp: mode=c: check time record ... Fix this by requiring supports_process_record alongside supports_reverse. I also noticed when running make-check-all.sh that there were a lot of failures with target board dwarf5-fission-debug-types. Fix this by not ignoring the result of "runto marker1". Then I noticed that $srcfile is used as a regexp. Fix this by applying string_to_regexp. Tested on x86_64-linux. Approved-By: Guinevere Larsen <guinevere@redhat.com>
2025-05-02Minor changes to Ada tests for gnat-llvmTom Tromey6-4/+56
I found a few more spots where a minor modification to a test lets it pass with gnat-llvm: * For array_subcript_addr, gnat-llvm was not putting the array into memory. Making the array larger works around this. * For bp_inlined_func, it is normal for gnat-llvm to sometimes emit a call to an out-of-line copy of the function, so accept this. * For null_overload and type-tick-size, I've applied the usual fix for keeping an unused local variable alive.
2025-05-02[gdb/testsuite] Make gdb.threads/inf-thr-count.exp more readableTom de Vries1-21/+34
While investigating a timeout in gdb.threads/inf-thr-count.exp I noticed that it uses quite some escaping, resulting in hard-to-parse regexps like "\\\$$::decimal". Fix this by reducing the escaping using: - quoting strings using {} instead of "", and - string_to_regexp. Also use multi_line to split up long multi-line regexps. Tested on x86_64-linux.
2025-05-02[gdb/testsuite] Fix timeout in gdb.threads/inf-thr-count.expTom de Vries1-1/+1
With test-case gdb.threads/inf-thr-count.exp, check-readmore and READMORE_SLEEP=1000 I run into: ... (gdb) set variable spin = 0^M (gdb) ^M Thread 1 "inf-thr-count" hit Breakpoint 2, breakpt () at /data/vries/gdb/src/gdb/testsuite/gdb.threads/inf-thr-count.c:49^M 49 }^M FAIL: gdb.threads/inf-thr-count.exp: set 'spin' flag to allow main thread to exit (timeout) PASS: gdb.threads/inf-thr-count.exp: wait for main thread to stop ... Fix this by using -no-prompt-anchor. Tested on x86_64-linux.
2025-05-02aarch64: drop stray newlinesJan Beulich1-3/+3
as_bad() already emits a newline; having extra ones leads to somewhat distorted diagnostics.
2025-05-02arm: drop stray newlinesJan Beulich1-11/+11
Both as_bad() and as_warn() already emit a newline; having extra ones leads to somewhat distorted diagnostics.
2025-05-02COFF: correct function auxiliary symbol data clearingJan Beulich1-2/+2
It's unclear why the array part of the union was used there, when we're dealing with a function. Originally, when 32-bit hosts and targets were prevailing, the memset() in question ended up clearing the entire x_fcn, while for 64-bit hosts/targets only x_lnnoptr would have been cleared. Then a2c7ca15a560 ("Use stdint types in coff internal_auxent") made things consistent, but imo in the wrong direction (and likely unintentionally). Go back to what apparently was meant originally, using the correct part of the union now.
2025-05-02COFF: function auxiliary symbolsJan Beulich12-17/+216
For one at least x86 gcc emits .def/.endef for functions, but no 2nd pair to designate their ends (sizes). While we can't recover the sizes, we can at least properly establish the chain of function symbols, which of course requires to emit auxiliary symbols for every function symbol even when there's no C_EFCN: We simply shouldn't be making their insertion conditional upon there not being a function processing of which is "in progress". In fact it was wrong to assign dual purpose to {,next_}set_end: Functions don't have "ends" set, but links to the next one. The same symbol table entry can serve both as an end marker and be a part of the chain of (defined) functions; this can't be expressed by a single static variable. Use what (again) becomes last_functionP for this purpose, along with tracking what symbol C_EFCN should apply to. This then allows to undo exposing of the respective (supposedly static) tracking variable, which PPC's XCOFF handling had introduced. Also rename it back to what it was before its exposure. For now the new testcases are XFAIL for Arm64 since there, unlike for Arm32, mapping symbols are emitted for COFF, too.
2025-05-02gas: add new COFF-specific subdir in testsuiteJan Beulich4-17/+34
... and move the cofftag testcase there (from all/). Just like we have one for ELF.
2025-05-02Arm/COFF: accept .def outside of CCS modeJan Beulich4-3/+7
There's no reason to reject this common COFF directive when it doesn't have any other meaning.
2025-05-02Automatic date update in version.inGDB Administrator1-1/+1
2025-05-01asan: null pointer as arg 2 of memcpyAlan Modra1-12/+2
Replace xmalloc+memcpy+free with xrealloc, avoiding the asan warning on the initial allocation where we had memcpy(p,0,0). * cg_arcs.c (arc_add): Use xrealloc.
2025-05-01dwarf: Properly check holes in .debug_ranges/debug_rnglistsH.J. Lu5-12/+52394
Don't warn if the offset of the first entry in .debug_rnglists starts right after the header. Warn holes in .debug_ranges and debug_rnglists sections only if the last end pointer isn't the same as the current start pointer. PR binutils/32927 * dwarf.c (display_debug_ranges_list): Return the pointer to the end. (display_debug_ranges): Don't warn if the offset of the first entry in .debug_rnglists starts right after the header. Warn a hole only if the last end pointer is the same as the next pointer. * testsuite/binutils-all/x86-64/dwarf4.s: New file. * testsuite/binutils-all/x86-64/dwarf5.s: Likewise. * testsuite/binutils-all/x86-64/pr32927-1.d: Likewise. * testsuite/binutils-all/x86-64/pr32927-2.d: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-By: Alan Modra <amodra@gmail.com>
2025-05-01Automatic date update in version.inGDB Administrator1-1/+1
2025-04-30gdb/progspace: fix formatting issueGuinevere Larsen1-1/+1
The previous commit had a small styling issue that I forgot to fix before pushing. This commit fixes the styling issue.
2025-04-30gdb: Stop exec_close looking like a UAF weaknessGuinevere Larsen1-3/+5
A recent static analyzer run flagged that program_space::exec_close could be using a pointer after it has been freed. This is not true, as the pointer is never dereferenced, the address is used for comparisons. However, to avoid false positives from static analyzers (or bogus security bugs), this commit makes the code stop looking like a UAF by moving the unique_ptr into a local unique_ptr, so that there is no way someone would think memory could be used after being freed. Approved-By: Tom Tromey <tom@tromey.com>
2025-04-30[gdb/testsuite] Don't compile read1.so with -fsanitizeTom de Vries1-2/+3
After building gdb with: ... CFLAGS= -O0 -g -fstack-protector-all -fsanitize=thread -fno-exceptions CXXFLAGS= -O0 -g -fstack-protector-all -fsanitize=thread ... when doing: ... $ cd build/gdb $ make check-read1 RUNTESTFLAGS=gdb.threads/clone-attach-detach.exp ... I run into: ... Running /data/vries/gdb/src/gdb/testsuite/gdb.threads/clone-attach-detach.exp ... ThreadSanitizer:DEADLYSIGNAL ==4799==ERROR: ThreadSanitizer: SEGV on unknown address 0x000000000000 \ (pc 0x7f636029a947 bp 0x7f635dfbf090 sp 0x7f635dfbf028 T4824) ==4799==The signal is caused by a READ memory access. ==4799==Hint: address points to the zero page. ThreadSanitizer:DEADLYSIGNAL ThreadSanitizer: nested bug in the same thread, aborting. ... This doesn't happen when doing the same from build/gdb/testsuite, because CFLAGS doesn't get propagated from build/gdb. I'm not sure what is the root cause here, but when building with -fsanitize, I'm interested in running the sanitizer on gdb, not on testsuite utility libraries that are used with expect. Fix this by skipping -fsanitize when compiling read1.so and readmore.so. Tested on x86_64-linux, by rebuilding read1.so and running the test-case. Approved-By: Tom Tromey <tom@tromey.com>
2025-04-30[gdb/testsuite] Handle asm frame in gdb.python/py-missing-objfile.expTom de Vries1-0/+10
On arm-linux, with test-case gdb.python/py-missing-objfile.exp I get: ... (gdb) whatis global_exec_var^M type = volatile exec_type^M (gdb) FAIL: $exp: initial sanity check: whatis global_exec_var ... instead of the expected "type = volatile struct exec_type". The problem is that the current language is ASM instead of C, because the inner frame at the point of the core dump has language ASM: ... #0 __libc_do_syscall () at libc-do-syscall.S:47 #1 0xf7882920 in __pthread_kill_implementation () at pthread_kill.c:43 #2 0xf784df22 in __GI_raise (sig=sig@entry=6) at raise.c:26 #3 0xf783f03e in __GI_abort () at abort.c:73 #4 0x009b0538 in dump_core () at py-missing-objfile.c:34 #5 0x009b0598 in main () at py-missing-objfile.c:46 ... Fix this by manually setting the language to C. Tested on arm-linux and x86_64-linux. PR testsuite/32445 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32445
2025-04-30[gdb/build] Fix Wformat errors in gdb/riscv-tdep.cTom de Vries1-6/+7
When building gdb with --enable-targets=all on arm-linux, I run into: ... gdb/riscv-tdep.c: In function ‘bool try_read(regcache*, int, ULONGEST&)’: gdb/riscv-tdep.c:4887:18: error: format ‘%lx’ expects argument of type \ ‘long unsigned int’, but argument 2 has type ‘ULONGEST’ \ {aka ‘long long unsigned int’} [-Werror=format=] 4887 | warning (_("Can not read at address %lx"), addr); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... and a few more Wformat errors, due to commit b9c7eed0c24 ("This commit adds record full support for rv64gc instruction set"). Fix these by using hex_string. Tested by completing a build on arm-linux.
2025-04-30RISC-V: Mark fgt.*/fge.* as instruction aliasKito Cheng1-8/+8
They are instruction alias, but not mark correctly, and seems like we don't have a good way to verify that since the disassembler doesn't disassemble instruction into alias. [1] https://github.com/riscv-non-isa/riscv-asm-manual/pull/124
2025-04-30PR 32896 testcaseAlan Modra2-7/+11
Modify it a little to run on more targets.
2025-04-30kvxelf.em: translate error messagesAlan Modra1-7/+7
gettext calls were missing. Fix that, and change a couple of einfo calls to fatal.
2025-04-29gdb/dwarf: change a bunch of functions to be methods of ↵Simon Marchi1-59/+52
cooked_index_worker_debug_info Move a few functions exclusively used to process units to become methods of cooked_index_worker_debug_info. Rename them to a more consistent name scheme, which gets rid of outdated naming. The comments were also quite outdated. Change-Id: I2e7dcc2e4ff372007dcb4f6c3d34187c9cc2da05 Approved-By: Tom Tromey <tom@tromey.com>
2025-04-29gdb/dwarf: move cooked_index_worker_debug_info upSimon Marchi1-75/+73
The next patch moves some functions to be methods of cooked_index_worker_debug_info. Move cooked_index_worker_debug_info above those functions, to make that easier (methods can't be defined before the class declaration). Change-Id: I7723cb42efadb2cc86f2227b3c2fb275e2d620f9 Approved-By: Tom Tromey <tom@tromey.com>