To be consistent with all_threads and the others, following the previous
patch.
Change-Id: I4ee4ff32b005fc5554a9d637725f10fca70cee14
Approved-By: Tom Tromey <tom@tromey.com>
When adding reference_to_pointer_iterator, I saw it as a temporary
thing, to not have to do a codebase-wide change right away. Remove it
from inf_threads_iterator and adjust all the users.
It's very possible that I forgot to update some spots in the files I
can't compile, but it will be very easy to fix if that happens.
Change-Id: Iddc462fecfaafb6a9861d185b217bc714e7dc651
Approved-By: Tom Tromey <tom@tromey.com>
With the recent addition of the gdb.Style Python API, this commit goes
through the gdb.Command sub-classes which we ship with GDB and adds
some styling support.
This adds 'title' style in a couple of places where we layout tables.
And uses 'filename' style where we are printing filenames.
While I was making these changes I've made a couple of related fixes.
In 'info frame-filter', 'info missing-objfile-handlers', 'info
pretty-printer', and 'info xmethod', we would sometimes print the
gdb.Progspace.filename unconditionally, even though this field can
sometimes be None. To better handle this case, I now check for None,
and print '<no-file>' instead. We already printed that same string
for the program space name in at least one other case, so this change
makes things a little more consistent.
I don't format the '<no-file>' string with the filename style, only if
we have an actual filename does the string get formatted.
The other fix I made was in 'maint info python-disassemblers'. Here
I've added an extra space between the two columns in the output
table. The two columns are 'Architecture' and 'Disassembler Name'.
Given that one column contains a white space, it was rather confusing
having a single space between columns. Luckily the tests don't depend
on a single space, so nothing needs updating for this change.
Additionally, in 'info frame-filter' I've updated the exception
handling to use the gdb.warning function, rather than just printing a
line of output. This means that should this case occur we get the
neat little emoji. We have no tests that trigger this warning, and I
couldn't figure out how to write one. In this end, I just hacked the
Python code to raise an exception and checked the output looked
reasonable. I suspect this warning might be a hard one to trigger!
Approved-By: Tom Tromey <tom@tromey.com>
A user found an unusual Ada situation that DWARF does not readily
support. Consider this type:
type Discrete_Typ is tagged null record;
type Int_Typ (Is_Static : Boolean) is new Discrete_Typ with null record;
type Signed_Int_Typ (Is_Static : Boolean) is
new Int_Typ (Is_Static => Is_Static)
with record
case Is_Static is
when True =>
Field : Integer;
when others =>
null;
end case;
end record;
Here, Signed_Int_Typ has a variant part where the discriminant is
stored in a superclass.
Anyway, this code caused gnat-llvm to crash. While fixing the crash,
I decided to fix this by emitting an anonymous field in Signed_Int_Typ
that represents the discriminant. This would allow member DIEs to
refer to it -- which I suppose is possibly why DWARF specified that
the discriminant should be a member of the variant (though I don't
really know; this decision always seemed very strange to me).
Making the field anonymous lead to the strange error:
Type ... is not a structure or union type.
... which comes from lookup_struct_elt, which fails when an anonymous
member of a structure has a non-composite type. This patch includes a
fix for this issue.
After fixing that, though I decided it would be better if the
artificial discriminant were still given a name. So, this patch
includes a change to ada_is_ignored_field to ignore artificial fields.
Approved-By: Andrew Burgess <aburgess@redhat.com>
The DAP breakpoint code has some helper functions that don't really
provide much value any more. This patch removes them.
Approved-By: Andrew Burgess <aburgess@redhat.com>
The recent change to change the parsing of location expressions in the
test suite broke compile-ops.exp. I neglected to update that patch.
This patch fixes the oversight.
When running test-case gdb.tui/tui-missing-src.exp with target board
gold-gdb-index (and likewise fission and fission-dwp) on aarch64-linux, I run
into:
...
FAIL: gdb.tui/tui-missing-src.exp: checking if inside f2 ()
...
Looking at the gold-gdb-index case, the problem is caused by the address table
of the .gdb_index section:
...
Address table:
000000000040066c 0000000000400694 0
000000000040053f 0000000000400563 1
...
The address range for f2 is [0x400694, 0x4006b8), but the address table says
it's [0x40053f, 0x400563).
The address 0x40053f is not even in a section:
...
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
...
[12] .plt PROGBITS 00000000004004b8 0004b8 000050 10 AX 0 0 8
[13] .text PROGBITS 0000000000400540 000540 000178 00 AX 0 0 64
...
but part of the hole [0x400508, 0x400540) in between .plt and .text.
Detect this in the invalid range check in create_addrmap_from_gdb_index.
Tested on aarch64-linux.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Correct the rightshift amount for the R_MIPS_HIGHER, R_MIPS_HIGHEST and
R_MIPS_CALL_HI16 RELA relocation howtos, missed with commit f38e992147
("MIPS HI16 and LO16 reloc howtos").
On VxWorks calls can refer directly to a .got.plt entry, in which case
they won't have an entry in the regular GOT. It was missed with commit
6c42ddb92b ("MIPS GOT: Remove TLS GOT info from the symbol table"),
<https://inbox.sourceware.org/binutils/878v6uyaw3.fsf@talisman.default/>,
which revamped GOT entry bookkeeping, and consequently space for regular
GOT entries is needlessly reserved and then not used, with extraneous
null dynamic relocations attached, e.g.:
Relocation section '.rela.dyn' at offset 0x1400 contains 11 entries:
Offset Info Type Sym.Value Sym. Name + Addend
00080c0c 00000405 R_MIPS_HI16 00000000 __GOTT_BASE__ + 0
00080c10 00000406 R_MIPS_LO16 00000000 __GOTT_BASE__ + 0
00080c14 00000601 R_MIPS_16 00000000 __GOTT_INDEX__ + 0
0008141c 00000002 R_MIPS_32 80c5c
00081800 00000002 R_MIPS_32 80c5c
00081804 00000002 R_MIPS_32 81800
00081808 00000502 R_MIPS_32 00081808 dglobal + 0
0008180c 00000202 R_MIPS_32 00000000 dexternal + 0
00081428 00000a02 R_MIPS_32 00081c00 x + 0
00000000 00000000 R_MIPS_NONE 0
00000000 00000000 R_MIPS_NONE 0
Adjust regular GOT entry counting then to take .got.plt entries into
account, removing a regression from the commit referred:
mips-vxworks -FAIL: VxWorks shared library test 1
mipsel-vxworks -FAIL: VxWorks shared library test 1
Adjust segment addresses in the program header dump to account for the
inclusion of the program headers in the segment, removing a regression
from commit 1a9ccd70f9 ("Fix the linker so that it will not silently
generate ELF binaries with invalid program headers. Fix readelf to
report such invalid binaries."):
mips-vxworks -FAIL: VxWorks executable test 2 (dynamic)
mipsel-vxworks -FAIL: VxWorks executable test 2 (dynamic)
Work around a compilation error:
.../gas/config/tc-tic6x.c: In function 'tic6x_start_unwind_section':
.../gas/config/tc-tic6x.c:4632:17: error: offset '16' outside bounds of constant string [-Werror=array-bounds]
4632 | text_name += strlen (".gnu.linkonce.t.");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
observed with GCC 10.
Work around compilation errors:
.../gas/config/tc-ia64.c: In function 'declare_register_set':
.../gas/config/tc-ia64.c:5375:41: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Werror=format-truncation=]
5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
| ^~
.../gas/config/tc-ia64.c:5375:38: note: directive argument in the range [0, 4294967294]
5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
| ^~~~~~
.../gas/config/tc-ia64.c:5375:7: note: 'snprintf' output 2 or more bytes (assuming 11) into a destination of size 8
5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
observed with GCC 10. Pick 16 for a round 64-bit stack frame size.
This patch adds support for hypervisor control registers on AArch64,
available via the Generic Interrupt Controller v5 feature, and enabled
via the +gcie flag.
- ich_apr_el2
- ich_contextr_el2
- ich_hfgitr_el2
- ich_hfgrtr_el2
- ich_hfgwtr_el2
- ich_hppir_el2 (RO)
- ich_ppi_activer[0,1]_el2
- ich_ppi_dvir[0,1]_el2
- ich_ppi_enabler[0,1]_el2
- ich_ppi_pendr[0,1]_el2
- ich_ppi_priorityr[0,15]_el2
- ich_vctlr_el2
- ich_vmcr_el2
This patch adds support for PPI registers on AArch64, available via the
Generic Interrupt Controller v5 feature, and enabled via the +gcie flag.
- icc_ppi_cactiver[0,1]_el1
- icc_ppi_cpendr[0,1]_el1
- icc_ppi_enabler[0,1]_el1
- icc_ppi_hmr[0,1]_el1 (RO)
- icc_ppi_priorityr[0,15]_el1
- icc_ppi_sactiver[0,1]_el1
- icc_ppi_spendr[0,1]_el1
Also, the new system register 'icc_ppi_priorityr8_el1' clashed with the
encoding of 's3_0_c12_c15_0' used in a test for the generic syntax of
system registers using mrs and msr.
This patch replaces 's3_0_c12_c15_0' in the test by an unused encoding:
s3_7_c0_c15_0.
This patch adds support for 13 new AArch64 system registers for the CPU
interface, which are enabled on using Generic Interrupt Controller v5
(+gcie flag) feature:
- 7 R/W registers: ICC_APR_EL1, ICC_APR_EL3, ICC_CR0_EL1, ICC_CR0_EL3
ICC_ICSR_EL1, ICC_PCR_EL1, ICC_PCR_EL3.
- 6 RO registers: ICC_DOMHPPIR_EL3, ICC_HAPR_EL1, ICC_HPPIR_EL1,
ICC_HPPIR_EL3, ICC_IAFFIDR_EL1, ICC_IDR0_EL1.
Note: the already-existing ID_AA64PFR2_EL1 register is required by the
GICv5 feature.
Add new instructions from the Generic Interrupt Controller, GICv5,
extension. These instructions are aliases to system instructions and are
the following:
* gic <operation>, <reg>
* gicr <reg>, <operation>
* gsb <operation>
Generic Interrupt Controller v5, GICv5, adds new system registers
and system instructions. These are enabled with the +gcie flag, where
gcie stands for GICv5 (Generic Interrupt Controller) CPU Interrupt
Extension.
Previous commit 4dc07bf6 missed making some of the testnames in encode-1
unique.
libsframe/testsuite/
PR libsframe/33437
* libsframe.encode/encode-1.c: Update test name to ensure they
are unique.
Add a new Corefile.mapped_files method which returns a list of
gdb.CorefileMappedFile objects.
Each gdb.CorefileMappedFile object represents a file that was mapped
into the process when the core file was created.
A gdb.CorefileMappedFile has attributes:
+ filename -- A string, the name of the mapped file.
+ build_id -- A string or None, the build-id of the mapped file if
GDB could find it (None if not).
+ is_main_executable -- A boolean, True if this mapping is the main
executable.
+ regions -- A list containing the regions of this file that were
mapped into the process.
The 'regions' list is a list of gdb.CorefileMappedFileRegion objects,
each of these objects has the following attributes:
+ start -- the start address within the inferior.
+ end -- the end address within the inferior.
+ file_offset -- the offset within the mapped file for this mapping.
There are docs and tests.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32844
Approved-By: Tom Tromey <tom@tromey.com>
In corelow.c, within core_target::build_file_mappings, we have code
that wraps around a call to gdbarch_read_core_file_mappings and
provides more structure to the results.
Specifically, gdbarch_read_core_file_mappings calls a callback once
for every region of every mapped file. The wrapper code groups all of
the mappings for one file into an instance of 'struct mapped_file',
this allows all of the mapped regions to be associated with the
build-id and filename of a file.
In the next commit I plan to make this information available via the
Python API, and so I need to allow access to this structured wrapping
outside of corelow.c.
This commit renames 'struct mapped_file' to 'struct core_mapped_file'
and moves the struct into gdbcore.h. Then a new global function
gdb_read_core_file_mappings is created into which I move the code to
build the structured data.
Then corelow.c is updated to call gdb_read_core_file_mappings.
This commit does not extend the Python API, that is for the next
commit.
There should be no user visible changes after this commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32844
Approved-By: Tom Tromey <tom@tromey.com>
This commit starts adding some core file related features to the
Python API.
In this initial commit I've tried to keep the changes as small as
possible for easy review.
There's a new Python class gdb.Corefile, which represents a loaded
core file. This API doesn't allow the user to create their own
gdb.Corefile objects, a core file must be loaded using the 'core-file'
command, then a gdb.Corefile object can be obtained by querying the
inferior in which the core file was loaded.
There's a new attribute gdb.Inferior.corefile, this is None when no
core file is loaded, or contains a gdb.Corefile object if a core file
has been loaded.
Currently, the gdb.Corefile object has one attribute, and one method,
these are:
gdb.Corefile.filename -- the file name of the loaded core file.
gdb.Corefile.is_valid() -- indicates if a gdb.Corefile object is
valid or not. See notes below.
A gdb.Corefile object is only valid while the corresponding core file
is loaded into an inferior. Unloading the core file, or loading a
different one will cause a gdb.Corefile object to become invalid. For
example:
(gdb) core-file /tmp/core.54313
... snip ...
(gdb) python core=gdb.selected_inferior().corefile
(gdb) python print(core)
<gdb.Corefile inferior=1 filename='/tmp/core.54313'>
(gdb) python print(core.is_valid())
True
(gdb) core-file
No core file now.
(gdb) python print(core)
<gdb.Corefile (invalid)>
(gdb) python print(core.is_valid())
False
(gdb)
In order to track changes to the core file, there is a new observable
'core_file_changed', which accounts for the changes in corelow.c,
observable,c, and observable.h. Currently, this observable is not
visible as a Python event.
I chose to access the core file via the inferior even though the core
file BFD object is actually stored within the program_space. As such,
it might seem that the natural choice would be to add the attribute as
gdb.Progspace.corefile.
For background reading on my choice, please see:
https://inbox.sourceware.org/gdb-patches/577f2c47793acb501c2611c0e6c7ea379f774830.1668789658.git.aburgess@redhat.com
This patch was never merged, it is still on my backlog, but the
observation in that work is that some targets are not really
shareable. For example, the core_target (corelow.c) stores
information about the loaded core file within the target instance. As
such, each target instance represents a single loaded core file.
Except that the BFD part of the core file is stored in the
program_space, which is a little weird.
During review, Tom made the observation, that maybe we should
investigate moving the core file BFD into the core_target. I'm
inclined to agree with this as a direction of travel.
All this leaves us with two observations:
1. Currently, loading a core file into an inferior, then using
'add-inferior' will try to share the core_target between
inferiors. This is broken, and can trigger GDB crashes. The
obvious fix, without reworking core_target, is just to prevent
this sharing, making core_target per-inferior.
2. Having the core file information split between the core_target
instance, and the BFD stored in the program_space is a little
weird, and is really just historical. Planning for a future
where the BFD is also stored in the core_target might be wise.
So, if we imagine that the BFD is (one day) moved into the
core_target, and that the core_target really becomes non-shareable,
then it is, I think, clearer that the corefile attribute should live
on the gdb.Inferior object, not the gdb.Progspace object.
There's testing for all the functionality added in this commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32844
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Currently the DWARF assembler implements manual parsing for location
expressions. With a recent refactoring, this lead to the use of
[subst] in a number of places.
Following the same logic as the DW_AT_* change, this patch changes
location expressions to simply be nested Tcl code. This avoids the
need for subst and also allows more complex logic, should that ever be
needed.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33402
This changes the DWARF assembler to store the desired "uplevel" frame
in Dwarf::assemble. This frame is then used in the relevant "uplevel"
invocations in the assembler.
This is primarily useful for the next patch, but it also seems
somewhat cleaner in general to me, as the implementation can now be
refactored without worrying too much about introducing new stack
frames.
I found some more spots in gdb.ada where a "return" has a value but
does not need one. This patch cleans these up.
Most of these would be eliminated by the old "critical" idea, if I
ever got around to finishing that...
Approved-by: Kevin Buettner <kevinb@redhat.com>
I noticed that the length of line in gdb/configure.tgt was more than
80 lines, so I straightened it out. Also, in gdb/Makefile.in newly added
file riscv-linux-canonicalize-syscall-gen.c was missed in ALLDEPFILES,
so I added it there. And the last change: one more file
riscv-linux-canonicalize-syscall-gen.o was not in alphabetical order.
If we run out of file before decompression finishes, the archive is
broken. Don't allow the buffer to be returned with uninitialised data.
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Return an
error if the full element size can't be decompressed.
image_offset takes values from section vma then increments when
filling out section data. Avoid signed integer overflow.
* vms-alpha.c (struct vms_private_data_struct): Make image_offset
unsigned.
In commit 6c3458a8b7 I claimed that u.kenum is always non-NULL,
which is true for debug_make_enum_type, but not for enums made by
debug_make_undefined_tagged_type. Fix that oversight
PR 32829
* debug.c (debug_write_type): Handle NULL u.kenum.
(debug_type_samep): Likewise.
A fuzzed object file hit this sanitizer error.
readelf.c:16764:9: runtime error: pointer index expression with base
0x6dd4491e1590 overflowed to 0xe7af96d4491e17a1
The same could occur in any of the IN_RANGE reloc checks, where the
reloc address is calculated as "start + r_offset" then compared
against "start" and "end". So don't do that. Compare r_offset
against the memory size, first.
* readelf.c (IN_RANGE): Delete.
(in_range): New inline funcion.
(target_specific_reloc_handling): Replace "end" param with
"size". Update uses. Replace IN_RANGE with in_range.
(apply_relocations): Delete "end" variable. Update
target_specific_reloc_handling calls and replace IN_RANGE.
Avoid pointer overflow.
This avoids a gcc-14.2 bug reporting an "error: null destination
pointer" on an sprintf buffer that is not NULL. Don't ask me why this
happens to work.
* msp430-dis.c (msp430_singleoperand): Don't overprint op or
comm for extended_dst.
Another patch I am working on induced some failures in CTF tests.
Looking into this, I found that ctfread.c seems to largely work by
accident. In particular, it often chooses the wrong domain for a
symbol.
In CTF, I believe there are 4 kinds of symbols: types, variables,
functions, and "data objects" (which IIUC may be either a variable or
a function).
ctfread.c was examining the type-kind of a variable and sometimes
treating one as a type. add_stt_entries and
ctf_psymtab_add_stt_entries only ever used VAR_DOMAIN (but are called
for functions, which should be in FUNCTION_DOMAIN). And
ctf_psymtab_type_cb sometimes used VAR_DOMAIN, but is only called for
types, and so should only ever use TYPE_DOMAIN or STRUCT_DOMAIN.
This patch cleans all this up, based on my understanding of the
situation. This passes the existing tests, and also works with my
aforementioned yet-to-be-submitted patch as well.
Finally, I renamed new_symbol because it is only used for type
symbols.
Acked-By: Simon Marchi <simon.marchi@efficios.com>
I noticed that ctfread.c could create a symbol with the name "". This
happens because a couple of spots check that a name is not NULL -- but
libctf never returns such names. Instead check the string contents.
I left the NULL checks in for robustness.
Note that other spots in ctfread.c already do check the contents of
the name. I changed these to avoid strlen and instead check the first
character.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
ctfread.c creates two per-objfile registry keys. However, one is
sufficient. This patch combines the two.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
ctfread.c uses raw "new" and "delete", but for an object that could
just as easily be stack allocated.
Approved-By: Simon Marchi <simon.marchi@efficios.com>