A heap-allocated multidictionary should be freed by calling
mdict_free. However, while this function does free the contents of
the dictionary, it neglects to free the dictionary itself.
There's also a second bug, which is that if a multidictionary is
created with no dictionaries, gdb will crash on the first line of
mdict_free:
enum dict_type type = mdict->dictionaries[0]->vector->type;
So, this patch also adds the type to struct multidictionary, avoiding
this problem. Note that this does not increase the structure size on
x86-64, because the new member fits into the padding.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
The GCC plugin that implements the Python API checker does not appear
to really be maintained. And, as far as I know, it never really
worked for C++ code anyway. Considering those factors, and that no
one has tried to run it in years, I think it's time to remove the
macros from the gdb source.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
According to 'git annotate', the Py_TPFLAGS_CHECKTYPES was added to
python-internal.h way back when gdb was first ported to Python 3. It
was a compatibility fix for Python 2.
This is not needed any more, because Python 2 is no longer supported.
This patch removes the vestiges.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit updates mdebugread.c to use common blockvector ordering
predicate. It also changes the code to use std::stable_sort as in
buildsym.c. This is probably not necessary but should not hurt and makes
block sorting code more consistent.
Approved-By: Tom Tromey <tom@tromey.com>
This commit adds blockvector::block_less_than() predicate that defines
required ordering of blocks within blockvector.
It orders blocks so that blocks with lower start address come before
blocks with higher start address. If two blocks start at the same
address, enclosing (larger) block should come before nested (smaller)
block.
This ordering is depended upon in find_block_in_blockvector(). Although
its comment did not say so, find_block_in_blockvector() is called from
blockvector_for_pc_sect() which is explicit about it. While at it, I
changed the comment of find_block_in_blockvector() to say so explicitly
too.
As Andrew pointed out, buildsym.c sorts block slightly differently,
taking only the start address into account. The comment there says
blocks with same start address should not be reordered as they are in
correct order already and that order is needed. It is unclear to me
if buildsym.c arranges blocks starting at the same address in required
order before sorting them or this happens "by chance". I did modify
buildsym_compunit::make_blockvector() to assert blocks are properly
ordered and running testsuite did not show any regressions.
Approved-By: Tom Tromey <tom@tromey.com>
This patch changes blockvector to be allocated on the heap (using 'new')
and changes internal implementation to use std::vector<> rather than
flexible array to add blocks to existing blockvector. This is needed for
lazy CU expansion and for Python API to build objfiles, compunits and
symtabs dynamically (similarly to JIT reader API).
The downside is higher memory consumption. The size of std::vector is
24 bytes (GCC 14) compared to 8 bytes used currently to store the number
of blocks (m_num_blocks). Stopping gdb at its main(), followed by
"maint expand-symtabs" results in 4593 compunit symtabs so in this case
the overhead is 16*4593 = 73488 bytes which I hope is acceptable.
While at it, add blockvector::append_block() to add more block at the
end of block vector. This is currently used only in mdebugread.c.
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-22 John David Anglin <danglin@gcc.gnu.org>
bfd/ChangeLog:
* elf64-hppa.c (elf_hppa_final_link_relocate): Change
bfd_put_32 and bfd_put_64 bfd argument from input_bfd
to output_bfd.
libinproctrace.so doesn't link against gnulib, and some versions of
clang won't inline the c-ctype.h functions. This causes link
failures.
This patch works around the problem by reverting to <ctype.h> in this
case.
Tested-By: Guinevere Larsen <guinevere@redhat.com>
I measured that removing saving mem chunks and regs to std::vector before
calling API functions speeds up stepping up to 15%, so I added this
optimization (as Guinevere Larsen <guinevere@redhat.com> recommended in
initial support). It turns out that after this, the m_record_type and
m_error_occured no longer needed, so I removed them too.
Approved-By: Guinevere Larsen <guinevere@redhat.com>
Simplify test-case gdb.cp/local-static.exp in the following way.
First rewrite this uplevel into a more usual form:
...
-set print_quoted_re [uplevel 1 "subst_vars \"$print_quoted_re\""]
+set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]]
...
This requires us to use "subst -nocommands" instead of subst_vars, to allow
backslash substitution, which previously was happening implicitly because of
the way uplevel was used.
Then, declare globals hex and syntax_re, such that we no longer have to use
uplevel:
...
-set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]]
+set print_quoted_re [subst -nocommands $print_quoted_re]
...
Finally, stop applying backslash substitution, simplifying cxx_scopes_list and
c_scopes_list:
...
-set print_quoted_re [subst -nocommands $print_quoted_re]
+set print_quoted_re [subst_vars $print_quoted_re]
...
While we're at it, simplify some regexps using string_to_regexp in a few places.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
The function `gdb_bfd_get_full_section_contents` doesn't implement
decompressing debug sections. This regresses loading `.debug_gdb_scripts`-section
from ELFs that were built with `-ggdb -Wa,--compress-debug-sections`
giving the following warnings on load:
warning: BFD: /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo: unable to get decompressed section .debug_gdb_scripts
warning: Couldn't read .debug_gdb_scripts section of /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo
The problem can be reproduced with a `test.cc` like this:
__asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
".ascii \"\\4gdb.inlined-script.BOOST_OUTCOME_INLINE_GDB_PRETTY_PRINTER_H\\n\"\n"
".ascii \"import gdb.printing\\n\"\n"
".ascii \"import os\\n\"\n"
/* a sufficiently long script such that it gets actually
compressed */
".byte 0\n"
".popsection\n");
#include <iostream>
int main(void) {
std::cout << "hello world\n";
return 0;
}
I compiled the file with
`g++ test.cc -o test-program -ggdb -Wa,--compress-debug-sections` (GCC
version 14.3.0).
As suggested, this refactors gdb_bfd_get_full_section_contents to use
bfd_get_full_section_contents which implements decompression.
Approved-By: Tom Tromey <tom@tromey.com>
Now that gdb/testsuite/gdb.stabs has been removed, drop the corresponding
exclude from gdb/tclint.toml.
Tested by running "pre-commit run --all-files".
Add proc subst_vars, an alias of subst -nobackslashes -nocommands.
I've used tailcall to implement this:
...
proc subst_vars { str } {
tailcall subst -nobackslashes -nocommands $str
}
...
but I found that this also works:
...
proc subst_vars { str } {
return [uplevel 1 [list subst -nobackslashes -nocommands $str]]
}
...
I've found other uses of subst that don't add "-nobackslashes -nocommands",
but really only use subst to do variable substitution. Also use subst_vars in
those cases.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
I ran gdb/contrib/dwarf-to-dwarf-assembler.py on a hello world compiled with
gcc 15, and ran into:
...
Traceback (most recent call last):
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 642, in <module>
main(sys.argv)
~~~~^^^^^^^^^^
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 638, in main
generator.generate()
~~~~~~~~~~~~~~~~~~^^
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 610, in generate
self.generate_die(die, indent_count)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 589, in generate_die
die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count)
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 279, in format
return "\n".join(self.format_lines(offset_die_lookup, indent_count))
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 376, in format_lines
inner_lines = super().format_lines(offset_die_lookup, indent_count + 1)
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 251, in format_lines
attr_line = attr.format(
offset_die_lookup, indent_count=indent_count + 1
)
File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 199, in format
s += self.name + " "
~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'str'
...
because of trying to print DWARF v6 attributes DW_AT_language_name (0x90) and
DW_AT_language_version (0x91).
Fix this by printing the number if the name is not known:
...
{DW_AT_0x90 3 DW_FORM_data1}
{DW_AT_0x91 202311 DW_FORM_data4}
...
When running dwarf-to-dwarf-assembler.py without arguments, I run into:
...
$ ./gdb/contrib/dwarf-to-dwarf-assembler.py
Usage:
python ./asm_to_dwarf_assembler.py <path/to/elf/file>
Traceback (most recent call last):
File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 621, in main
filename = argv[1]
~~~~^^^
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 642, in <module>
main(sys.argv)
~~~~^^^^^^^^^^
File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 625, in main
sys.exit(errno.EOPNOTSUP)
^^^^^^^^^^^^^^^
AttributeError: module 'errno' has no attribute 'EOPNOTSUP'. Did you mean: 'EOPNOTSUPP'?
...
Fix this by using errno.EOPNOTSUPP.
If zstd is not available or was intentionally disabled by the user
don't add it to the list of the available options to compress debug
sections when showing usage.
binutils/
* objcopy.c (copy_usage): Only output
--compress-debug-sections=zstd if HAVE_ZSTD.
Peter Maydell and Vacha Bhavsar pointed out that we have an incorrect
description of the SME za register in the documentation. It is currently
described as a vector of SVL x SVL bytes, but that is incorrect.
What we really have is a 2-dimensional array of bytes, with each dimension
having size SVL.
Change the documentation to reflect that.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Verify that archives are rejected in the link, regular and thin, that
have no symbol map included. Exclude XCOFF targets from verification
which have handling for such archives implemented and therefore accept
them. These targets will be handled with a follow-up change.
Add basic verification for archives to work, regular and thin, in the
link. Refer to PR binutils/33484 and PR binutils/33485 for targets that
fail these basic checks, where `ar' fails to add subsequent members to
the archive or fails to add symbols from subsequent members to the map
respectively, for thin archives.
NB symbol names chosen such as to avoid a clash with Z80 CPU registers.
With the removal of stabs support, reading a dbx inferior has become a
no-op and GDB is unable to perform sybmolic debugging in such inferiors.
As such, this commit removes the files that work on it with spotty
support.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
This commit is the last in the series removing GDB's support for stabs.
It removes the stabsread.{c|h} files, and removes the last usage of
stabsread stuff in buildsym. Notably, the header file gdb-stabs.h
remains in the tree as it is misnamed at this point - it is used for
reading dbx objfiles. It (and dbxread) will be removed in a future
commit.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
This commit is the second to last in the series fully removing support
for stabs in GDB, removing it from XCOFF inferiors. According to IBM's
AIX documentation[1], xcoff binaries can only have stabs or DWARF debug
info, meaning removing stabs seems pretty trivial, as anything that
isn't related to setting base information on the objfile or reading
dwarf can be removed.
The unfortunate part of this removal is that XCOFF minimal symbols are
encoded in stabs, so if an inferior has not been compiled with dwarf
debuginfo, GDB will only be able to do assembly-level debugging. Due to
this, the xcoff reader now emits a warning if no dwarf is read, saying:
"No usable debug information found". This change would also add a lot of
regressions to to AIX, so the gdb_compile proc has been changed to not
work when a test tries to compile a test with nodebug.
As a sidenote, gdb-stabs.h can just be removed from rs6000-aix-nat, as
none of the structs or macros defined in the header are used in the nat
file, so that is an unnecessary include.
This commit introduces some known regressions when testing GDB in AIX
systems. The main ones are:
* inferior function calls now crash with a corrupted stack. This seems
to be some fault of dwarf in explaining how to correctly set the frame
for a function.
* fortran tests can't runto_main: the fortran compiler does not add any
symbol for MAIN__ in the dwarf information, only in stabs, so the
fortran_runto_main proc can't set the breakpoint correctly.
* When dealing with c++ class methods, there are cases when we fail to
properly recognize a method call as a new function.
* When dealing with c++ virtual inheritance, GDB has issues finding a
derived class's members when it has been downcast to a base class.
[1] https://www.ibm.com/docs/en/aix/7.3?topic=formats-xcoff-object-file-format
Approved-By: Tom Tromey <tom@tromey.com>
This commit continues the removal of stabs by removing support from coff
inferiors. This is trivial for the most part, just a removal of code
setting things only relevant for stabs, with one exception.
The global variables symnum and within_function were introduced to
coffread.c (and within_function was converted to boolean). I looked into
making them parameters to the relevant function, but this would require
changes to several otherwise untouched functions, so I kept them as globals
instead.
Approved-By: Tom Tromey <tom@tromey.com>
This commit makes it so reading dbx inferiors will not read stabs
debuginfo from the inferiors.
This has the side effect of making reading DBX inferiors a noop. It
will be removed in a future commit, however, the present series of
commit is focused on just removing stabs.
Approved-By: Tom Tromey <tom@tromey.com>
This commit makes it so that GDB won't read stabs information from ELF
files. If stabs is detected in an ELF file, the reader now warns the user
that stabs is not supported.
This test would cause two new failures in the test gdb.stabs/weird.exp
(that surprisingly didn't happen in the mips commit). Rather than fixing
the test that'll be removed soon, I just removed the test instead.
Approved-By: Tom Tromey <tom@tromey.com>
Ostensibly, the mdebugread.c is about reading debug information in the
ecoff format, but it also supports stabs-in-ecoff according to comments
in there, and also relied in some stabs facilities for ecoff reading
itself. This commit takes the first step in removing stabs support by
removing those dependencies from mdebug. And in order to support
stabs-in-ecoff, mipsread would also call stabsread_new_init.
Removing stabs-in-ecoff is trivial, as the code was well demarcated with
comments mentioning where stabs was read. Plus the call to
stabsread_new_init in mipsread can be trivially removed.
Another simple removal was the dependence on stabs_end_psymtabs: because
the local variables dependencies_used and includes_used were only touched
by stabs-reading code, they are always 0 in the new version, which means
we can find the exact code path that'd be followed in stabs_end_psymtab
and move the relevant lines to mdebug instead.
After all those, the last remaining dependency is when reading a fortran
common block from an inferior compiled by SGI fortran compilers (and
maybe more). The block could have no address, meaning it'd need to be
fixed after all the minimal symbols have been read. This was done by
adding the symbol to the stabs global_sym_chain, then calling
scan_file_globals to fix them up. This commit copies all the necessary
code for handling the fortran symbols onto mdebug, technically making
some code duplication, but since stabsread will be removed soon, this
shouldn't be too concerning.
This change was tested in the compile farm's mips64 machine (number
230), where it actually seems to have solved some 50 failures in the
testsuite, not including changes in tests from gdb.threads, as those are
often very racy. I'm not sure if these were true fixes or racy cases,
but since the new version has no newly introduced fails, only fewer of
them, I'm inclined to think this change is at least harmless.
Acked-By: Tom Tromey <tom@tromey.com>
The gdb/stabsread.h and .c files define 2 things that, while originally
intended only for stabs reading, actually end up being used for coff,
ecoff and maybe more debuginfo formats. That is the function "hashname",
and the macro HASHSIZE. Both are used for small hashtables when reading
some symbols with incomplete information.
With the upcoming removal of stabs code, this code should be moved
somewhere, and the location that looked most reasonable was
gdb/buildsym-legacy. No change in behavior is expected after this
commit.
Approved-By: Tom Tromey <tom@tromey.com>
Since commit dad36cf919 ("gdb/dwarf: use dynamic partitioning for
DWARF CU indexing"), we get the intermittent failures:
python print (gdb.lookup_static_symbol ('rr').line)
18
(gdb) FAIL: gdb.python/py-symbol.exp: print line number of rr
python print (gdb.lookup_static_symbol ('rr').value ())
99
(gdb) FAIL: gdb.python/py-symbol.exp: print value of rr
The situation is:
- The program isn't running.
- Two compilation units define a static symbol named `rr`.
- The test does:
gdb.lookup_static_symbol ('rr')
The test expects this to return one specific (out of the two) `rr`
static symbols. Since dad36cf919, the call sometimes returns the
wrong symbol.
The documentation for gdb.lookup_static_symbol says this:
There can be multiple global symbols with static linkage with the
same name. This function will only return the first matching symbol
that it finds. Which symbol is found depends on where GDB is
currently stopped, as GDB will first search for matching symbols in
the current object file, and then search all other object files. If
the application is not yet running then GDB will search all object
files in the order they appear in the debug information.
cooked_index_functions::search searches index shards linearly and
returns the first matching symbol. Before dad36cf919, the work was
split statically among threads, so symbols would end up in shards
deterministically. Since the first part of the debug info ends up in
the first shard, it happens to work as described in the doc.
Since dad36cf919, symbols end up in random shards, based on which
thread happened to pop their CU from the work queue.
I don't think that specifying which of the multiple matching static
symbols is returned is really useful, as it unnecessarily restricts the
implementation. If multiple static symbols match the criteria, I think
it makes sense that you'll get an unspecified one. Code that needs to
deal with the possibility of multiple static symbols of the same name
should use gdb.lookup_static_symbols.
I propose to remove this guarantee from gdb.lookup_static_symbol. I
understand that this is a breaking change, but I think it's easy enough
to deal with it.
Update the test to accept either symbol.
Update the doc to say that an unspecified symbol will be returned if the
program is not running and there are multiple matching symbols. The
previous text also seemed a bit wrong about its use of the term "object
file". GDB searches a static symbol for the current compilation unit
first. It then falls back to searching all symbols.
Change-Id: I22f81c186b1483a488ea7614fb81fd102db3c7f1
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33518
Approved-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
PR testsuite/32261 requests a script that could convert old .S-based
tests (that were made before dwarf.exp existed) into the new
Dwarf::assemble calls in Tcl. This commit is an initial implementation
of such a script. Python was chosen for convenience, and only relies on
a single external library.
Usage: the script operates not on .S files, but on ELF files with DWARF
information. To convert an old test, one must run said test via
`make check-gdb TESTS=testname` in their build directory. This will
produce, as a side effect, an ELF file the test used as an inferior, at
gdb/testsuite/outputs/testname/testname. This ELF file is this script's
input.
Reliability: not counting the limitations listed below, the script seems
functional enough to be worthy of discussion in the mailing list. I have
been testing it with different tests that already use Dwarf::assemble,
to see if the script can produce a similar call to it. Indeed, in most
cases that I've tested (including some more complex ones, marked with an
asterisk below) it is able to produce comparable output to the original
exp file. Of course, it can't reproduce the complex code *before* the
Dwarf::assemble call. Values calculated then are simply inlined.
The following .exp files have been tried in this way and their outputs
highly resemble the original:
- gdb.dwarf2/dynarr-ptr
- gdb.dwarf2/void-type
- gdb.dwarf2/ada-thick-pointer
- gdb.dwarf2/atomic-type
- gdb.dwarf2/dw2-entry-points (*)
- gdb.dwarf2/main-subprogram
The following .exp files work, with caveats addressed in the limitations
section below.
- gdb.dwarf2/cpp-linkage-name
- Works correctly except for one attribute of the form SPECIAL_expr.
- gdb.dwarf2/dw2-unusual-field-names
- Same as above, with two instances of SPECIAL_expr.
- gdb.dwarf2/implptr-optimized-out
- Same as above, with two instances of SPECIAL_expr.
- gdb.dwarf2/negative-data-member-location
- Same as above, with one instance of SPECIAL_expr.
The following .exp files FAIL, but that is expected:
- gdb.dwarf2/staticvirtual.exp
- high_pc and low_pc of subprogram "~S" are hardcoded in the original
.exp file, but they get replaced with a get_func_info call. Since
the function S::~S is not present in the original, get_func_info
will fail.
The following .exp files DO NOT WORK with this script:
- gdb.dwarf2/cu-no-addrs
- `aranges` not supported.
- Compile unit high_pc and low_pc hardcoded, prone to user error
due to forgetting to replace with variables.
- gdb.dwarf2/dw2-inline-stepping
- Same as above.
- gdb.dwarf2/fission-relative-dwo
- `fission` not supported.
- gdb.dwarf2/dw2-prologue-end and gdb.dwarf2/dw2-prologue-end-2
- Line tables not supported.
Currently the script has the following known limitations:
- It does not support line tables.
- It does not use $srcfile and other variables in the call to
Dwarf::assemble (since it can't know where it is safe to substitute).
- It does not support "fission" type DWARFs (in fact I still have no
clue what those are).
- It does not support cu {label LABEL} {} CUs, mostly because I couldn't
find the information using pyelftools.
- It sometimes outputs empty CUs at the start and end of the call. This
might be a problem with my machine, but I've checked with DWARF dumps
and they are indeed in the input ELF files generated by
`make check-gdb`.
- It does not support attributes with the forms DW_FORM_block* and
DW_FORM_exprloc. This is mostly not a concern of the difficulty of
the implementation, but of it being an incomplete feature and, thus,
more susceptible to users forgetting to correct its mistakes or
unfinished values (please see discussion started by Guinevere at
comment 23 https://sourceware.org/bugzilla/show_bug.cgi?id=32261#c23).
The incompleteness of this feature is easy to demonstrate: any call to
gdb_target_symbol, a common tool used in these attributes, needs a
symbol name that is erased after compilation. There is no way to guess
where that address being referenced in a DW_OP_addr comes from, and it
can't be hard coded since it can change depending on the machine
compiling it.
Please bring up any further shortcomings this script may have with your
expectations.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32261
Approved-By: Tom Tromey <tom@tromey.com>
This function was added in commit 2f0c68f23b as part of the compact
EH support. By the comments it looks like to code was copied from
bfd_elf_reloc_symbol_deleted_p without sufficient editing, and would
only work for local syms due to the discarded_section test left in
place for global syms. Fix that, and remove the discard param.
* elf-bfd.h (_bfd_elf_section_for_symbol): Update prototype.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame_entry): Adjust.
* elflink.c (_bfd_elf_section_for_symbol): Remove "discard".
Don't test for discarded_section.
In an earlier discussion, I noted that most compunit_symtabs do not
have a call-site hash table, so inlining the object into
compunit_symtab did not make sense.
It turns out that this is not entirely true -- while most
compunit_symtabs do not have any data in this object, the object
itself is always created. This in turn is a regression introduced by
commit de2b4ab5 ("Convert dwarf2_cu::call_site_htab to new hash
table").
This patch fixes the issue by arranging to only store a call-site hash
table when it is non-empty.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
I noticed my IDE (VSCode) starting to automatically trim trailing
whitespaces on save, despite the setting for it being disabled. I
realized that this is because the .editorconfig file now has
trim_trailing_whitespace = true
for many file types. If we have this EditorConfig setting forcing
editors to trim trailing whitespaces, I think it would make sense to
clean up trailing whitespaces from our files. Otherwise, people will
always get spurious whitespace changes when editing these files.
I did a mass cleanup using this command:
$ find gdb gdbserver gdbsupport -type f \( \
-name "*.c" -o \
-name "*.h" -o \
-name "*.cc" -o \
-name "*.texi" -o \
-name "*.exp" -o \
-name "*.tcl" -o \
-name "*.py" -o \
-name "*.s" -o \
-name "*.S" -o \
-name "*.asm" -o \
-name "*.awk" -o \
-name "*.ac" -o \
-name "Makefile*" -o \
-name "*.sh" -o \
-name "*.adb" -o \
-name "*.ads" -o \
-name "*.d" -o \
-name "*.go" -o \
-name "*.F90" -o \
-name "*.f90" \
\) -exec sed -ri 's/[ \t]+$//' {} +
I then did an autotools regen, because we don't actually want to change
the Makefile and Makefile.in files that are generated.
Change-Id: I6f91b83e3b8c4dc7d5d51a2ebf60706120efe691
Use the suffix "maybe_inline" to differentiate it from
find_symbol_for_pc_sect. find_symbol_for_pc_sect_maybe_inline can
return symbols for inline functions, while find_symbol_for_pc_sect
doesn't.
Change-Id: I6c4ef961383429ee26c8fcc0cc5df2e4e1e24959
Approved-by: Kevin Buettner <kevinb@redhat.com>
My commit 6474c699a5 ("gdb/dwarf: sort dwarf2_per_bfd::all_units by
(section, offset)") introduced a pretty bad performance regression in
the "skeletonless type units" step. I have a pretty big executable
(Blender) compiled with -gsplit-dwarf (to generate .dwo files) and
-fdebug-types-section (to generate type units). Before the offending
commit:
Time for "DWARF skeletonless type units": wall 29.126, user 28.507, sys 0.497, user+sys 29.004, 99.6 % CPU
... and after:
Time for "DWARF skeletonless type units": wall 120.768, user 119.543, sys 0.651, user+sys 120.194, 99.5 % CPU
The reason for the slowdown is that add_type_unit now inserts type units
at the right place in the all_units vector to keep it sorted. These
repeated insertions in the middle of the vector require shifting a lot
of elements and end up taking a lot of time.
This patch fixes it by doing just one sort at the end of
process_skeletonless_type_units. The responsibility of keeping the
all_units sorted is delegated to the callers of add_type_unit. The
other two callers call finalize_all_units right after calling
add_type_unit.
One drawback that is probably not a real one: in
process_skeletonless_type_unit, we call process_type_unit. If something
in there needs to look up another type unit by (section, offset), it
wouldn't find it. I don't think that's a real issue though, as type
units are typically self contained. If a type unit needs to refer to a
type defined in another type unit, it would do so by signature, with
DW_FORM_ref_sig8. And during the indexing phase, I don't think we even
look at the DW_AT_type of things anyway.
With this patch applied, I am back to:
Time for "DWARF skeletonless type units": wall 29.277, user 28.632, sys 0.521, user+sys 29.153, 99.6 % CPU
I would like to cherry pick this patch to GDB 17, to avoid shipping GDB
17 with the performance regression.
Change-Id: I2a5b89ebca9e1a4e6248032e144520c9a579f47a
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33526
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Convert the remaining uses of gcc_major_version in gdb.ada.
Tested on x86_64-linux with gcc 7, gcc 13 and gcc 15.
Approved-By: Tom Tromey <tom@tromey.com>
Results of evaluating 'test "no" == yes' in non-Bash shells range from
unfortunate (dash: "test: no: unexpected operator") to comically wrong
(AdaCore's gsh: returns 0).