Additionally, change FEAT_XS tlbi variants to be gated on "+xs" instead of
"+d128". This is an incremental improvement; there are still some FEAT_XS tlbi
variants that are gated incorrectly or missing entirely.
This commit updates the Python example code in the gdb.Progspace and
gdb.Objfile sections of the docs. Changes made:
1. Use @value{GDBP} for the GDB prompt rather than
hard-coding (gdB),
2. Use @group...@end group to split the example code into
unbreakable chunks, and
3. Add parenthesis to the Python print() calls in the examples. In
Python 2 it was OK to drop the parenthesis, but now GDB is Python 3
only, example code should include the parenthesis.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
In previous commits I've added Object.__dict__ support to gdb.Inferior
and gdb.InferiorThread, this is similar to the existing support for
gdb.Objfile and gdb.Progspace.
This commit extends the documentation to offer the user some guidance
on selecting good names for their custom attributes so they
can (hopefully) avoid conflicting with any future attributes that GDB
might add.
The rules I've proposed are:
1. Don't start user attributes with a lower case letter, all the
current GDB attributes start with a lower case letter, and I suspect
all future attributes would also start with a lower case letter, and
2. Don't start user attributes with a double underscore, this risks
conflicting with Python built in attributes (e.g. __dict__) - though
clearly the user would need to start and end with a double
underscore, but it seemed easier just to say no double underscores.
I'm doing this as a separate commit as I've updated the docs for the
existing gdb.Objfile and gdb.Progspace so they all reference a single
paragraph on selecting attribute names.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
The gdb.Objfile, gdb.Progspace, gdb.Type, and gdb.Inferior Python
types already have a __dict__ attribute, which allows users to create
user defined attributes within the objects. This is useful if the
user wants to cache information within an object.
This commit adds the same functionality to the gdb.InferiorThread
type.
After this commit there is a new gdb.InferiorThread.__dict__
attribute, which is a dictionary. A user can, for example, do this:
(gdb) pi
>>> t = gdb.selected_thread()
>>> t._user_attribute = 123
>>> t._user_attribute
123
>>>
There's a new test included.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
The gdb.Objfile, gdb.Progspace, and gdb.Type Python types already have
a __dict__ attribute, which allows users to create user defined
attributes within the objects. This is useful if the user wants to
cache information within an object.
This commit adds the same functionality to the gdb.Inferior type.
After this commit there is a new gdb.Inferior.__dict__ attribute,
which is a dictionary. A user can, for example, do this:
(gdb) pi
>>> i = gdb.selected_inferior()
>>> i._user_attribute = 123
>>> i._user_attribute
123
>>>
There's a new test included.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
I noticed that it is possible for the user to create a new
gdb.Progspace object, like this:
(gdb) pi
>>> p = gdb.Progspace()
>>> p
<gdb.Progspace object at 0x7ffad4219c10>
>>> p.is_valid()
False
As the new gdb.Progspace object is not associated with an actual C++
program_space object within GDB core, then the new gdb.Progspace is
created invalid, and there is no way in which the new object can ever
become valid.
Nor do I believe there's anywhere in the Python API where it makes
sense to consume an invalid gdb.Progspace created in this way, for
example, the gdb.Progspace could be passed as the locus to
register_type_printer, but all that would happen is that the
registered printer would never be used.
In this commit I propose to remove the ability to create new
gdb.Progspace objects. Attempting to do so now gives an error, like
this:
(gdb) pi
>>> gdb.Progspace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 'gdb.Progspace' instances
Of course, there is a small risk here that some existing user code
might break ... but if that happens I don't believe the user code can
have been doing anything useful, so I see this as a small risk.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Add a gdb.Frame.__repr__() method. Before this patch we would see
output like this:
(gdb) pi
>>> gdb.selected_frame()
<gdb.Frame object at 0x7fa8cc2df270>
After this patch, we now see:
(gdb) pi
>>> gdb.selected_frame()
<gdb.Frame level=0 frame-id={stack=0x7ffff7da0ed0,code=0x000000000040115d,!special}>
More verbose, but, I hope, more useful.
If the gdb.Frame becomes invalid, then we will see:
(gdb) pi
>>> invalid_frame_variable
<gdb.Frame (invalid)>
which is inline with how other invalid objects are displayed.
Approved-By: Tom Tromey <tom@tromey.com>
Add a gdb.InferiorThread.__repr__() method. Before this patch we
would see output like this:
(gdb) pi
>>> gdb.selected_thread()
<gdb.InferiorThread object at 0x7f4dcc49b970>
After this patch, we now see:
(gdb) pi
>>> gdb.selected_thread()
<gdb.InferiorThread id=1.2 target-id="Thread 0x7ffff7da1700 (LWP 458134)">
More verbose, but, I hope, more useful.
If the gdb.InferiorThread becomes invalid, then we will see:
(gdb) pi
>>> invalid_thread_variable
<gdb.InferiorThread (invalid)>
Which is inline with how other invalid objects are displayed.
Approved-By: Tom Tromey <tom@tromey.com>
Many object types now have a __repr__() function implementation. A
common pattern is that, if an object is invalid, we print its
representation as: <TYPENAME (invalid)>.
I thought it might be a good idea to move the formatting of this
specific representation into a utility function, and then update all
of our existing code to call the new function.
The only place where I haven't made use of the new function is in
unwind_infopy_repr, where we currently return a different string.
This case is a little different as the UnwindInfo is invalid because
it references a frame, and it is the frame itself which is invalid.
That said, I think it would be fine to switch to using the standard
format; if the UnwindInfo references an invalid frame, then the
UnwindInfo is itself invalid. But changing this would be an actual
change in behaviour, while all the other changes in this commit are
just refactoring.
Approved-By: Tom Tromey <tom@tromey.com>
This patch contains work pulled from this previously proposed patch:
https://inbox.sourceware.org/gdb-patches/20210213220752.32581-2-lsix@lancelotsix.com/
But has been modified by me. Credit for the original idea and
implementation goes to Lancelot, any bugs in this new iteration belong
to me.
Consider the executable `/tmp/foo/my_exec', and if we assume `/tmp' is
empty other than the `foo' sub-directory, then currently within GDB,
if I type:
(gdb) file /tmp/f
and then hit TAB, GDB completes this to:
(gdb) file /tmp/foo/
notice that not only did GDB fill in the whole of `foo', but GDB also
added a trailing '/' character. This is done within readline when the
path that was just completed is a directory. However, if I instead
do:
(gdb) complete file /tmp/f
file /tmp/foo
I now see the completed directory name, but the trailing '/' is
missing. The reason is that, in this case, the completions are not
offered via readline, but are handled entirely within GDB, and so
readline never gets the chance to add the trailing '/' character.
The above patch added filename option support to GDB, which included
completion of the filename options. This initially suffered from the
same problem that I've outlined above, but the above patch proposed a
solution to this problem, but this solution only applied to filename
options (which have still not been added to GDB), and was mixed in
with the complete filename options support.
This patch pulls out just the fix for the trailing "/" problem, and
applies it to GDB's general filename completion. This patch does not
add filename options to GDB, that can always be done later, but I
think this small part is itself a useful fix.
One of the biggest changes I made in this version is that I got rid of
the set_from_readline member function, instead, I now pass the value
of m_from_readline into the completion_tracker constructor.
I then moved the addition of the trailing '/' into filename_completer
so that it is applied in the general filename completion case. I also
added a call to gdb_tilde_expand which was missing from the original
patch, I haven't tested, but I suspect that this meant that the
original patch would not add the trailing '/' if the user entered a
path starting with a tilde character.
When writing the test for this patch I ran into two problems.
The first was that the procedures in lib/completion-support.exp relied
on the command being completed for the test name. This is fine for
many commands, but not when completing a filename, if we use the
command in this case the test name will (potentially) include the name
of the directory in which the test is being run, which means we can't
compare results between two runs of GDB from different directories.
So in this commit I've gone through completion-support.exp and added a
new (optional) testname argument to many of the procedures, this
allows me to give a unique test name, that doesn't include the path
for my new tests.
The second issue was in the procedure make_tab_completion_list_re,
this builds the completion list which is displayed after a double tab
when there are multiple possible completions.
The procedure added the regexp ' +' after each completion, and then
added another ' +' at the very end of the expected output. So, if we
expected to match the name of two functions 'f1' and 'f2' the
generated regexp would be: 'f1 +f2 + +'. This would match just fine,
the actual output would be: 'f1 f2 ', notice that we get two spaces
after each function name.
However, if we complete two directory names 'd1' and 'd2' then the
output will be 'd1/ d2/ '. Notice that now we only have a single
space between each match, however, we do get the '/' added instead.
What happens is that when presenting the matches, readline always adds
the appropriate trailing character; if we performed tab completion of
'break f1' then, as 'f1' is a unique match, we'd get 'break f1 ' with
a trailing space added. However, if we complete 'file d1' then we get
'file d1/'. Then readline is adding a single space after each
possible match, including the last one, which accounts for the
trailing space character.
To resolve this I've simply remove the addition o the second ' +'
within make_tab_completion_list_re, for the function completion
example I gave above the expected pattern is now 'f1 +f2 +', which for
the directory case we expect 'd1/ +d2/ +', both of which work just
fine.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16265
Co-Authored-By: Lancelot SIX <lsix@lancelotsix.com>
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
This commit adds a new InferiorThread.ptid_string attribute. This
read-only attribute contains the string returned by target_pid_to_str,
which actually converts a ptid (not pid) to a string.
This is the string that appears (at least in part) in the output of
'info threads' in the 'Target Id' column, but also in the thread
exited message that GDB prints.
Having access to this string from Python is useful for allowing
extensions identify threads in a similar way to how GDB core would
identify the thread.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
In test-case gdb.dwarf2/assign-variable-value-to-register.exp a return is
missing here after the unsupported:
...
if { ![is_x86_64_m64_target] } {
unsupported "unsupported architecture"
}
...
and consequently on aarch64-linux I ran into an UNSUPPORTED followed by 3
FAILs.
Fix this by simply using require:
...
require is_x86_64_m64_target
...
Tested on x86_64-linux and aarch64-linux.
Fix PR gas/31213.
gas/
PR gas/31213
* gen-sframe.c (sframe_do_cfi_insn): Add new warning.
gas/testsuite/
* gas/cfi-sframe/common-empty-1.d: Test the new warning as well.
* gas/cfi-sframe/common-empty-2.d: Likewise.
When deleting NOP instructions addend by .align at second pass, this may cause
the PC decrease but the symbol address to remain unchanged due to section
alignment.
To solve this question, we subtract a maximux alignment of all sections like
RISC-V.
Commit 78f2fd84e8 ("gdb: remove VALUE_REGNUM, add value::regnum")
introduced an unexpected change in value_assign. It replaced
`get_prev_frame_always (next_frame)` with `next_frame`in the call to
gdbarch_value_to_register.
This is the result of a merge error, since I previously had a patch to
change gdbarch_value_to_register to take the next frame, and later
decided to drop it. Revert that change.
Add a test based on the DWARF assembler to expose the problem and test
the fix. I also tested on ppc64le to make sure the problem reported in
PR 31231 was fixed.
Change-Id: Ib8b851287ac27a4b2e386f7b680cf65865e6aee6
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31231
On ppc64le-linux, I run into:
...
(gdb) bt^M
#0 0x00000000100006dc in foobar (J=2)^M
#1 0x000000001000070c in prog ()^M
(gdb) FAIL: gdb.dwarf2/dw2-entry-points.exp: bt foo
...
The test-case attemps to emulate additional entry points of a function, with
function bar having entry points foo and foobar:
...
(gdb) p bar
$1 = {void (int, int)} 0x1000064c <bar>
(gdb) p foo
$2 = {void (int, int)} 0x10000698 <foo>
(gdb) p foobar
$3 = {void (int)} 0x100006d0 <foobar>
...
However, when setting a breakpoint on the entry point foo:
...
(gdb) b foo
Breakpoint 1 at 0x100006dc
...
it ends up in foobar instead of in foo, due to prologue skipping, and
consequently the backtrace show foobar instead foo.
The problem is that the test-case does not emulate an actual prologue at each
entry point.
Fix this by disabling the prologue skipping when setting a breakpoint, using
"break *foo".
Tested on ppc64le-linux and x86_64-linux.
Tested-By: Guinevere Larsen <blarsen@redhat.com>
Approved-By: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
PR testsuite/31232
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31232
I ran into the following FAIL:
...
(gdb) python kill_and_detach()^M
Traceback (most recent call last):^M
File "<string>", line 1, in <module>^M
File "<string>", line 7, in kill_and_detach^M
gdb.error: Selected thread is running.^M
Error while executing Python code.^M
(gdb) FAIL: gdb.base/kill-during-detach.exp: exit_p=true: checkpoint_p=true: \
python kill_and_detach()
...
The FAIL happens as follows:
- gdb is debugging a process A
- a checkpoint is created, in other words, fork is called in the inferior,
after which we have:
- checkpoint 0 (the fork parent, process A), and
- checkpoint 1 (the fork child, process B).
- during checkpoint creation, lseek is called in the inferior (process A) for
all file descriptors, and it returns != -1 for at least one file descriptor.
- the process A continues in the background
- gdb detaches, from process A
- gdb switches to process B, in other words, it restarts checkpoint 1
- while restarting checkpoint 1, gdb tries to call lseek in the inferior
(process B), but this fails because gdb incorrectly thinks that inferior B
is running.
This happens because linux_nat_switch_fork patches the pid of process B into
the current inferior and current thread which where originally representing
process A. So, because process A was running in the background, the
thread_info fields executing and resumed are set accordingly, but they are not
correct for process B.
There's a line in fork_load_infrun_state that fixes up the thread_info field
stop_pc, so fix this by adding similar fixups for the executing and resumed
fields alongside.
The FAIL did not always reproduce, so extend the test-case to reliably
trigger this scenario.
Tested on x86_64-linux.
Approved-By: Kevin Buettner <kevinb@redhat.com>
PR gdb/31203
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31203
Due to the formatted output of objdump, some instructions
that do not require output operands (such as nop/ret) will
have extra spaces added after them.
Determine whether to output operands through the format
of opcodes. When opc->format is an empty string, no extra
spaces are output.
The m32r trap code was written for a 32-bit Linux host (and really, one
whose Linux ABI matched pretty exactly). This has lead to conversions
between integers and pointers which breaks down hard on 64-bit hosts.
Clean up some of the functions where possible to avoid unnecessary
conversions, use uintptr_t to cast 32-bit target pointers to host
pointers in some places, and just stub out a few functions that can't
easily be salvaged currently when sizeof(void*) is not 32-bits. This
is a bit ugly, but lets us enable warnings for the whole file.
The ftime() function has been deprecated since POSIX-1-2004, and
removed in POSIX.1-2008. It's also been deprecated/removed in glibc
since 2.33. POSIX has always said the function is not portable, and
its return value, timezone, and dstflag fields are unspecified. Even
if Linux/glibc & m32r had defined behavior, those aren't the host for
the sim runtime.
So let's stop using the function and switch to clock_gettime. gnulib
already has detection support for it, and it's been around since at
least POSIX-1-2004.
While gcc propagates the printf attribute via the typedef, clang
doesn't seem to, so add it to the prototypes themselves too. We
still keep it on the prototype for cases where it's used as a
variable.
The HAVE_DECL_xxx defines are always defined to 0 or 1. The current
defines.h logic assumes every HAVE_xxx symbol is only defined iff it's
defined to 1 which causes this to break. Tweak the sed logic to only
match defines of 1.
This is used by gdb, gdbsupport, and gdbserver. We want to use it
in the sim tree too. Move it to gdbsupport which is meant as the
common sharing space for these projects.
Approved-By: Tom Tromey <tom@tromey.com>
This directory contains example programs for the user to experiment with.
Initially there is one application written in C. The plan is to include
more examples, also in other langauges, over time.
In addition to the sources and a make file, a sample script how to make
a profile is included. There is also a README.md file.
gprofng/ChangeLog
2024-01-08 Ruud van der Pas <ruud.vanderpas@oracle.com>
* examples: Top level directory.
* examples/mxv-pthreads: Example program written in C.
Our hardware counter profiling is based on perf_event_open().
Our HWC tables are absent for new machines.
I have added HWC tables for the following events: PERF_TYPE_HARDWARE,
PERF_TYPE_SOFTWARE, PERF_TYPE_HW_CACHE. Other events require additional fixes.
Did a little cleaning: marked the symbols as static, used Stringbuilder,
created a function to read /proc/cpuinfo.
gprofng/ChangeLog
2024-01-08 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/31123
* common/core_pcbe.c: Mark the symbols as static. Add events_generic[].
* common/hwc_cpus.h: Declare a new function read_cpuinfo.
* common/hwcdrv.c: Add a new parameter in init_perf_event().
* common/hwcentry.h: Add use_perf_event_type in Hwcentry.
* common/hwcfuncs.c (process_data_descriptor): Read use_perf_event_type,
type, config.
* common/hwctable.c: Add a new HWC table generic_list[].
* common/opteron_pcbe.c (opt_pcbe_init): Accept AMD machines.
* src/collctrl.cc: Use StringBuilder in Coll_Ctrl::build_data_desc().
Add a new function read_cpuinfo.
In AIX we were missing some hooks needed to catch a fork () event
in rs6000-aix-nat.c. Due to their absence we were returning 1 while we
insert the breakpoint/catchpoint location. This patch is a fix to the same.
This update brings in the following commits from the gcc mainline:
commit b7e5a29602143b53267efcd9c8d5ecc78cd5a62f
Author: Tom Tromey <tom@tromey.com>
Date: Tue Jan 9 06:25:26 2024 -0700
Pass GUILE down to subdirectories
When I enable cgen rebuilding in the binutils-gdb tree, the default is
to run cgen using 'guile'. However, on my host, guile is guile 2.2,
which doesn't work for me -- I have to use guile3.0.
This patch arranges to pass "GUILE" down to subdirectories, so I can
use 'make GUILE=guile3.0'.
commit 725fb3595622a4ad8cd078a42fab1c395cbf90cb
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Wed Oct 25 13:06:48 2023 +0200
build: Add libgrust as compilation modules
Define the libgrust directory as a host compilation module as well as
for targets. Disable target libgrust if we're not building target
libstdc++.
commit 56ca59a03150cf44cea340f58967c990ed6bf43c
Author: Lewis Hyatt <lhyatt@gmail.com>
Date: Thu Nov 16 11:18:37 2023 -0500
Makefile.tpl: Avoid race condition in generating site.exp from the top level
A command like "make -j 2 check-gcc-c check-gcc-c++" run in the top level of
a fresh build directory does not work reliably. That will spawn two
independent make processes inside the "gcc" directory, and each of those
will attempt to create site.exp if it doesn't exist and will interfere with
each other, producing often a corrupted or empty site.exp. Resolve that by
making these targets depend on a new phony target which makes sure site.exp
is created first before starting the recursive makes.
commit 6a6d3817afa02bbcd2388c8e005da6faf88932f1
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun Mar 28 14:48:17 2021 +0100
Config,Darwin: Allow for configuring Darwin to use embedded runpath.
Recent Darwin versions place contraints on the use of run paths
specified in environment variables. This breaks some assumptions
in the GCC build.
This change allows the user to configure a Darwin build to use
'@rpath/libraryname.dylib' in library names and then to add an
embedded runpath to executables (and libraries with dependents).
The embedded runpath is added by default unless the user adds
'-nodefaultrpaths' to the link line.
For an installed compiler, it means that any executable built with
that compiler will reference the runtimes installed with the
compiler (equivalent to hard-coding the library path into the name
of the library).
During build-time configurations any "-B" entries will be added to
the runpath thus the newly-built libraries will be found by exes.
Since the install name is set in libtool, that decision needs to be
available here (but might also cause dependent ones in Makefiles,
so we need to export a conditional).
This facility is not available for Darwin 8 or earlier, however the
existing environment variable runpath does work there.
We default this on for systems where the external DYLD_LIBRARY_PATH
does not work and off for Darwin 8 or earlier. For systems that can
use either method, if the value is unset, we use the default (which
is currently DYLD_LIBRARY_PATH).
commit 2551e10038a70901f30b2168e6e3af4536748f3c
Author: Sergei Trofimovich <siarheit@google.com>
Date: Mon Oct 2 12:08:17 2023 +0100
Makefile.tpl: disable -Werror for feedback stage [PR111663]
Without the change profiled bootstrap fails for various warnings on
master branch as:
$ ../gcc/configure
$ make profiledbootstrap
...
gcc/genmodes.cc: In function ‘int main(int, char**)’:
gcc/genmodes.cc:2152:1: error: ‘gcc/build/genmodes.gcda’ profile count data file not found [-Werror=missing-profile]
...
gcc/gengtype-parse.cc: In function ‘void parse_error(const char*, ...)’:
gcc/gengtype-parse.cc:142:21: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
The change removes -Werror just like autofeedback does today.
commit d1bff1ba4d470f6723be83c0e3c4d5083e51877a
Author: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu Jun 1 23:07:37 2023 +0200
Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries [PR109951]
..., where we need to use it (separate commits) for build-tree testing, similar
to 'gcc/Makefile.in:site.exp':
# TEST_ALWAYS_FLAGS are flags that should be passed to every compilation.
# They are passed first to allow individual tests to override them.
@echo "set TEST_ALWAYS_FLAGS \"$(SYSROOT_CFLAGS_FOR_TARGET)\"" >> ./site.tmp
PR testsuite/109951
* Makefile.tpl (BASE_TARGET_EXPORTS): Add
'SYSROOT_CFLAGS_FOR_TARGET'.
* Makefile.in: Regenerate.
This patch adds support for the new AArch64 system registers that are part of the following extensions:
* FEAT_DEBUGv8p9
* FEAT_PMUv3p9
* FEAT_PMUv3_SS
* FEAT_PMUv3_ICNTR
* FEAT_SEBEP
When doing "checkpoint delete 0" we run into an assertion failure:
...
+delete checkpoint 0
inferior.c:406: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
...
Fix this by handling the "pptid == null_ptid" case in
delete_checkpoint_command.
Tested on x86_64-linux.
Approved-By: Kevin Buettner <kevinb@redhat.com>
PR gdb/31209
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31209