Age | Commit message (Collapse) | Author | Files | Lines |
|
This patch rewrites the .gdb_index reader to create the same data
structures that are created by the cooked indexer and the .debug_names
reader.
This is done in support of this series; but also because, from what I
can tell, the "templates.exp" change didn't really work properly with
this reader.
In addition to fixing that problem, this patch removes a lot of code.
Implementing this required a couple of hacks, as .gdb_index does not
contain all the information that's used by the cooked index
implementation.
* The index-searching code likes to differentiate between the various
DWARF tags when matching, but .gdb_index lumps many things into a
single "other" category. To handle this, we introduce a phony tag
that's used so that the match method can match on multiple domains.
* Similarly, .gdb_index doesn't distinguish between the type and
struct domains, so another phony tag is used for this.
* The reader must attempt to guess the language of various symbols.
This is somewhat finicky. "Plain" (unqualified) symbols are marked
as language_unknown and then a couple of hacks are used to handle
these -- one in expand_symtabs_matching and another when recognizing
"main".
For what it's worth, I consider .gdb_index to be near the end of its
life. While .debug_names is not perfect -- we found a number of bugs
in the standard while implementing it -- it is better than .gdb_index
and also better documented.
After this patch, we could conceivably remove dwarf_scanner_base.
However, I have not done this.
Finally, this patch also changes this reader to dump the content of
the index, as the other DWARF readers do. This can be handy when
debugging gdb.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33316
|
|
Currently, gdb will search the already-expanded symtabs in one loop,
and then also expand matching symtabs in another loop. However, this
is somewhat inefficient -- when searching the already-expanded
symtabs, all such symtabs are examined. However, the various "quick"
implementations already know which subset of symtabs might have a
match.
This changes the contract of expand_symtabs_matching to also call the
callback for an already-expanded symtab. With this change, and some
subsequent enabling changes, the number of searched symtabs should
sometimes be reduced. This also cuts down on the amount of redundant
code.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30736
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This removes dwarf2_per_cu_data::mark, replacing it with a
locally-allocated boolean vector. It also inverts the sense of the
flag -- now, the flag is true when a CU should be skipped, and false
when the CU should be further examined. Also, the validity of the
flag is no longer dependent on 'file_matcher != NULL'.
This patch makes the subsequent patch to searching a bit simpler, so
I've separated it out.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
g++ will sometimes use a typedef to give a name to an otherwise
anonymous type for linkage purposes. gdb tries to handle this odd
scenario, which is enforced by anon-struct.exp.
It's difficult to detect this problem in the current tree, but the
cooked index does not include an entry for these DIEs.
This patch changes gdb to add these to the index. This is needed by
subsequent changes in this series.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32519
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
When I rewrote the .debug_names writer (commit 91a42a61), I changed
the writer to not import .debug_str into the debug_str_lookup object.
However, a later patch in this series needed this again. The issue
here was that if a name occurs in the DWARF, and is also allocated,
then there is a race, where the created index depends on which DIE is
read first. This can cause index-file.exp failures.
This patch restores the old approach, avoiding this problem. I also
applied a couple of small cleanups to the class. And, I removed the
old complaint from the "ingestion" function, as this was not
necessary.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
The new approach to searching (solely via the quick API) is more
sensitive to discrepancies between the partial and full readers. In
CTF, there is some disagreement about which scope to use. CTF doesn't
seem to really distinguish between the file and global scope, so this
patch takes the simple approach of putting all CTF symbols into the
global scope.
This changes one test as well. It seems to me that the behavior here
is arbitrary and the test is making unwarranted assumptions.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
Currently the full symbol reader puts DW_TAG_imported_declaration in
TYPE_DOMAIN, in the global scope. This patch changes the cooked
indexer to follow.
Without this patch, a later patch in the series would cause
nsalias.exp to regress.
This also updates read-gdb-index.c to do something similar.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
The cooked index does not currently contain entries for Ada import
functions. This means that whether or not these are visible to
"break" depends on which CUs were previously expanded -- clearly a
bug.
This patch fixes the issue. I think the comments in the patch explain
the fix reasonably well.
Perhaps one to-do item here is to change GNAT to use
DW_TAG_imported_declaration for these imports. This may eventually
let us remove some of the current hacks.
This version includes a fix from Simon to initialize the new member.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32511
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
If you run struct-decl.exp with the .gdb_index board, you will see
that "the_type" is not emitted in the index. This would cause a
failure in this series. The fix is to ensure that certain necessary
type declarations are emitted.
However, a naive fix here will regress stub-array-size.exp, where a
type declaration and a type definition are both seen -- but the
declaration is seen first and causes a failure. This is handled by
adding some code (including a mild hack) to filter out type
declarations when a corresponding type definition is seen.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This patch is needed to avoid regressions later in the series.
The issue here is that ada_decode, when called with wide=false, would
act as though the input needed verbatim quoting. That would happen
because the 'W' character would be passed through; and then a later
loop would reject the result due to that character.
Similarly, with operators=false the upper-case-checking loop would be
skipped, but then some names that did need verbatim quoting would pass
through.
Furthermore I noticed that there isn't a need to distinguish between
the "wide" and "operators" cases -- all callers pass identical values
to both.
This patch cleans up the above, consolidating the parameters and
changing how upper-case detection is handled, so that both the
operator and wide cases pass-through without issue. I've added new
unit tests for this.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This patch adds another minor hack to cooked_index_entry::full_name.
In particular, if GNAT emits non-hierarchical names (still the default
as the hierarchical series is blocked on one tricky problem), then a
request to compute the "linkage-style" name will now just return the
'name' field.
Without this tweak, this series would regress ada-cold-name.exp,
because the search would look for "name.cold" but the index would
return "name[cold]" as the "linkage" name (which would be wrong).
This area is a bit difficult to unravel. The best plan here, IMO, is
to change Ada to work like the other languages in gdb: store the
natural name and do searches with that name. I think this is
achievable, but I didn't want to try it here.
I've updated the relevant bug (tagged below) to reflect this.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32766
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This series pointed out a few tests that check that a particular index
is in use. It seems to me that this does not really make sense when
the "readnow" board is in use, as this actually skips index creation.
The tests do pass today, but by accident. This patch adds the
appropriate "require" line to the tests in question.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This patch removes support for .gdb_index versions less than 7. See
the patch that rewrites the reader to understand why this is needed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Acked-By: Simon Marchi <simon.marchi@efficios.com>
|
|
Currently, gas warns and skips generating SFrame FDE when it sees:
.cfi_escape 0x2e,XX
From the documentation of DW_CFA_GNU_args_size:
"The DW_CFA_GNU_args_size instruction takes an unsigned LEB128 operand
representing an argument size. This instruction specifies the total of
the size of the arguments which have been pushed onto the stack."
With origins seemingly for VAX architecture, the usage of
DW_CFA_GNU_args_size seems to have evolved. The purpose of
DW_CFA_GNU_args_size is to adjust SP when performing stack unwinding for
exception handling.
For the purpose of stack tracing using SFrame, DW_CFA_GNU_args_size is
safe to skip, especially when the CFA restoration is known to be FP
based. A previous summary of the reasoning and intent was indicated
here [1].
[1] https://sourceware.org/pipermail/binutils/2025-August/143829.html
This fixes PR gas/33414 - sframe: handle DW_CFA_GNU_args_size in gas better
gas/
PR gas/33414
* gen-sframe.c (sframe_xlate_do_escape_gnu_args_size): New
definition.
(sframe_xlate_do_cfi_escape): Handle DW_CFA_GNU_args_size.
gas/testsuite/
PR gas/33414
* gas/cfi-sframe/cfi-sframe.exp: New test.
* gas/cfi-sframe/cfi-sframe-common-12.d: New test.
* gas/cfi-sframe/cfi-sframe-common-12.s: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-3.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-3.s: New test.
|
|
This patch fixes var_arr_typedef.exp to preserve a local variable a
bit better, protecting it from a gnat-llvm optimization.
|
|
R_X86_64_TPOFF32 relocation of local-exec TLS model can only be used in
executable, not in a shared library, even if the source code is compiled
with -fPIC. Change the linker error message from
relocation R_X86_64_TPOFF32 against symbol `foo' can not be used when making a shared object; recompile with -fPIC
to
relocation R_X86_64_TPOFF32 against symbol `foo' can not be used when making a shared object; replace local-exec with initial-exec TLS model
bfd/
PR ld/33408
* elf64-x86-64.c (elf_x86_64_need_pic): Suggest "replace
local-exec with initial-exec TLS model" for R_X86_64_TPOFF32.
(elf_x86_64_scan_relocs): Drop ABI_64_P check for
R_X86_64_TPOFF32.
ld/
PR ld/33408
* testsuite/ld-x86-64/tls-le-pic-1-x32.d: New file.
* testsuite/ld-x86-64/tls-le-pic-1.d: Likewise.
* testsuite/ld-x86-64/tls-le-pic-1.s: Likewise.
* testsuite/ld-x86-64/tls-le-pic-2-x32.d: Likewise.
* testsuite/ld-x86-64/tls-le-pic-2.d: Likewise.
* testsuite/ld-x86-64/tls-le-pic-2.s: Likewise.
* testsuite/ld-x86-64/tls-le-pic-3-x32.d: Likewise.
* testsuite/ld-x86-64/tls-le-pic-3.d: Likewise.
* testsuite/ld-x86-64/tls-le-pic-3.s: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
ld previously crashed with a segmentation fault if the specified linker
script could not be found. The issue seems to have been introduced
recently by d048eee2910 [1].
This patch adds a check to ensure that a filename was found after
searching the possible prefixes. If no filename was found, the function
returns NULL, and ldfile_open_command_file_1() emits a proper fatal
error message.
This change prevents the crash and provides a clear diagnostic.
A new generic test was also added to cover this error case.
[1]: https://inbox.sourceware.org/binutils/20250812143757.3565482-1-hjl
.tools@gmail.com/
|
|
This reverts commit 897d8d7bba581e4c1614af5712b730b006f03407.
|
|
Since
commit eeb2f20a764bee3a6a1edb9872467d044aaad848
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Sep 1 13:03:40 2017 -0700
x86: Add _bfd_x86_elf_adjust_dynamic_symbol
replaced elf_i386_adjust_dynamic_symbol with
_bfd_x86_elf_copy_indirect_symbol, correct the comments.
* elfxx-x86.c (_bfd_x86_elf_copy_indirect_symbol): Replace
elf_i386_adjust_dynamic_symbol with
_bfd_x86_elf_copy_indirect_symbol in comments.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
* gdb/NEWS : Add MicroBlaze gdbserver target
Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
Approved-by: Michael J. Eager <eager@eagercon.com>
|
|
This patch updates breakpoint instruction machine code to be inline
with the specification in MicroBlaze ISA [1]
* gdb/microblaze-tdep.h : Update MICROBLAZE_BREAKPOINT
[1] https://docs.amd.com/r/en-US/ug984-vivado-microblaze-ref/brki
Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
|
|
This changes type_stack::insert to take a gdbarch rather than an
expr_builder. This is simpler and means that type_stack doesn't have
to know anything about expression building; the parser-defs.h include
can be removed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes type_stack so that an element that has an argument can't
be popped in isolation. The idea is to make type stack use a little
safer, making it so that the stack can't end up in an invalid state.
This also fixes up a few related comments.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes type_stack to make pushing elements a bit safer: if an
element requires an argument, these are now always pushed at the same
time, rather than separately.
This patch also adds a few comments to help document a bit better.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
|
|
A comment in display_relocations said "RELRS has been freed by
dump_relr_relocations". Except that hadn't happened on all return
paths. Tidy that by freeing relrs allocated in dump_relr_relocations
in that function, and relrs allocated in display_relocation in that
function.
* readelf.c (dump_relr_relocations): Only free relrs allocated
in this function.
(display_relocations): Free relrs here, on error return paths
too.
|
|
gdb currently crashes if you try to get the dynamic_type from a
gdb.Value of a POD struct:
(gdb) py print(gdb.parse_and_eval('pod').dynamic_type)
Fatal signal: Segmentation fault
It happens because value_rtti_type() returns NULL for them, and this is
not handled correctly.
Fixed by using val->type() as a fallback in this case.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
PR ada/33217 points out that gdb incorrectly calls the <ctype.h>
functions. In particular, gdb feels free to pass a 'char' like:
char *str = ...;
... isdigit (*str)
This is incorrect as isdigit only accepts EOF and values that can be
represented as 'unsigned char' -- that is, a cast is needed here to
avoid undefined behavior when 'char' is signed and a character in the
string might be sign-extended. (As an aside, I think this API seems
obviously bad, but unfortunately this is what the standard says, and
some systems check this.)
Rather than adding casts everywhere, this changes all the code in gdb
that uses any <ctype.h> API to instead call the corresponding c-ctype
function.
Now, c-ctype has some limitations compared to <ctype.h>. It works as
if the C locale is in effect, so in theory some non-ASCII characters
may be misclassified. This would only affect a subset of character
sets, though, and in most places I think ASCII is sufficient -- for
example the many places in gdb that check for whitespace.
Furthermore, in practice most users are using UTF-8-based locales,
where these functions aren't really informative for non-ASCII
characters anyway; see the existing workarounds in gdb/c-support.h.
Note that safe-ctype.h cannot be used because it causes conflicts with
readline.h. And, we canot poison the <ctype.h> identifiers as this
provokes errors from some libstdc++ headers.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33217
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes gdb and related programs to use the gnulib c-ctype code
rather than safe-ctype.h. The gdb-safe-ctype.h header is removed.
This changes common-defs.h to include the c-ctype header, making it
available everywhere in gdb.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33217
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This arranges to import the c-ctype module from gnulib. c-ctype is
similar ot safe-ctype, but doesn't poison the <ctype.h> APIs.
This patch should not result in any functional changes, as nothing
includes the new header yet.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33217
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
The upstream build of GDB can fail on fedora rawhide, since the self
check in regcache.c uses an unitialized variable to be compared, which
now generates the following warning:
binutils-gdb/gdb/regcache.c:1847:42: error: variable
'buf' is uninitialized when passed as a const pointer argument here
[-Werror,-Wuninitialized-const-pointer]
1847 | SELF_CHECK (regcache->raw_compare (0, &buf, register_size (inf.arch (), 0)));
This commit fixes that by initializing the variable to 0.
Since the comment above that line would be changed, it was also
reformatted so that it doesn't go beyond 80 columns.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
ada_binop_in_bounds can be merged with its sole caller.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
ada_ternop_slice can be merged with its sole caller.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
ada_equal_binop can be merged with its sole caller.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
ada_unop_in_range can be merged with its sole caller. This change
points out that one of the arguments was not needed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
commit a16f37e8 changed finish-var-size.exp to use have_fvar_tracking.
However, in Ada tests, ada_fvar_tracking must be used instead.
|
|
..., like PR33360 does for strings.
Signed-off-by: Andrew C Aitchison <github@aitchison.me.uk>
|
|
If an ifunc symbol is processed in print_symbol(), a 'type' field of a
'syminfo' structure is set to any character specified by a user with an
'--ifunc-chars' option. But afterwards the 'type' field is used to
check whether a symbol is a stab in print_symbol_info_{bsd,sysv}()
functions in order to print additional stab related data. If the 'type'
field equals '-', a symbol is treated as a stab. If '--ifunc-chars=--'
is given, all ifunc symbols will be treated as stab symbols and
uninitialized stab related fields of the 'syminfo' structure will be
printed which can lead to segmentation fault.
To fix this, check if a symbol is a stab before override the 'type'
field. Also, add a test case for this fix.
PR binutils/32556
* nm.c (extended_symbol_info): Add is_stab.
(print_symbol): Check if a symbol is a stab.
(print_symbol_info_bsd): Use info->is_stab.
(print_symbol_info_sysv): Use info->is_stab.
* testsuite/binutils-all/nm.exp: Test nm --ifunc-chars=--.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32556
Fixes: e6f6aa8d184 ("Add option to nm to change the characters displayed for ifunc symbols")
Signed-off-by: Dmitry Klochkov <dmitry.klochkov@bell-sw.com>
|
|
Trying to dump .sframe in a PE file results in a segfault accessing
elf_section_data.
* objdump (dump_sframe_section, dump_dwarf_section): Don't access
elf_section_type without first checking the file is ELF.
|
|
an error message that references the target string, not the file being copied
|
|
* objdump.c (remove_useless_symbols): Deal with gcc_compiled
and gcc2_compiled here..
(compare_symbols): ..rather than here..
(disassemble_section): ..and here.
|
|
PR 33389
This reverts commit 6b27a220321ecead5435b170f1db02f1876cee08.
|
|
This changes dwarf_record_line_1 to be a method of lnp_state_machine,
simplifying it a bit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes dwarf_finish_line to be a method of lnp_state_machine,
simplifying it a bit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
I noticed that several spots in lnp_state_machine fetch the CU's
builder. Since this can't change over the lifetime of the object, it
seemed nicer to simply cache it.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes dwarf_record_line_p to be a method of lnp_state_machine.
This simplifies it, as it can refer to members of the object.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This changes some code in line-program.c to use bool rather than int.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
I noticed that the compute_include_file_name intro comment was
slightly wrong, and while looking at this, I also noticed that it has
a single caller. This patch hoists it slightly so that a forward
declaration isn't needed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This patch moves lnp_state_machine and some supporting code to a new
file, dwarf2/line-program.c. The main benefit of this is shrinking
dwarf2/read.c a bit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
|