Tom Tromey [Sat, 22 Apr 2023 00:53:48 +0000 (18:53 -0600)]
Allow pretty-print of static members
Python pretty-printers haven't applied to static members for quite
some time. I tracked this down to the call to cp_print_value_fields
in cp_print_static_field -- it doesn't let pretty-printers have a
chance to print the value. This patch fixes the problem.
The way that static members are handled is very weird to me. I tend
to think this should be done more globally, like in value_print.
However, I haven't made any big change.
Reviewed-by: Keith Seitz <keiths@redhat.com>
Tested-by: Keith Seitz <keiths@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30057
YunQiang Su [Fri, 5 May 2023 09:27:16 +0000 (17:27 +0800)]
gas: documents .gnu_attribute Tag_GNU_MIPS_ABI_MSA
It is added since 2016 by
Add support for .MIPS.abiflags and .gnu.attributes sections
b52717c0e104eb603e8189c3c0d3658ef5d903f5
But never documented.
GDB Administrator [Sat, 6 May 2023 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 6 Apr 2023 12:56:11 +0000 (06:56 -0600)]
Filter out types from DAP scopes request
The DAP scopes request examines the symbols in a block tree, but
neglects to omit types. This patch fixes the problem.
Tom Tromey [Thu, 27 Apr 2023 16:59:59 +0000 (10:59 -0600)]
Use discrete_position in ada-valprint.c
I found a couple of spots in ada-valprint.c that use an explicit loop,
but where discrete_position could be used instead.
Reviewed-by: Keith Seitz <keiths@redhat.com>
Andrew Burgess [Fri, 16 Sep 2022 15:08:17 +0000 (16:08 +0100)]
gdb/python: add mechanism to manage Python initialization functions
Currently, when we add a new python sub-system to GDB,
e.g. py-inferior.c, we end up having to create a new function like
gdbpy_initialize_inferior, which then has to be called from the
function do_start_initialization in python.c.
In some cases (py-micmd.c and py-tui.c), we have two functions
gdbpy_initialize_*, and gdbpy_finalize_*, with the second being called
from finalize_python which is also in python.c.
This commit proposes a mechanism to manage these initialization and
finalization calls, this means that adding a new Python subsystem will
no longer require changes to python.c or python-internal.h, instead,
the initialization and finalization functions will be registered
directly from the sub-system file, e.g. py-inferior.c, or py-micmd.c.
The initialization and finalization functions are managed through a
new class gdbpy_initialize_file in python-internal.h. This class
contains a single global vector of all the initialization and
finalization functions.
In each Python sub-system we create a new gdbpy_initialize_file
object, the object constructor takes care of registering the two
callback functions.
Now from python.c we can call static functions on the
gdbpy_initialize_file class which take care of walking the callback
list and invoking each callback in turn.
To slightly simplify the Python sub-system files I added a new macro
GDBPY_INITIALIZE_FILE, which hides the need to create an object. We
can now just do this:
GDBPY_INITIALIZE_FILE (gdbpy_initialize_registers);
One possible problem with this change is that there is now no
guaranteed ordering of how the various sub-systems are initialized (or
finalized). To try and avoid dependencies creeping in I have added a
use of the environment variable GDB_REVERSE_INIT_FUNCTIONS, this is
the same environment variable used in the generated init.c file.
Just like with init.c, when this environment variable is set we
reverse the list of Python initialization (and finalization)
functions. As there is already a test that starts GDB with the
environment variable set then this should offer some level of
protection against dependencies creeping in - though for full
protection I guess we'd need to run all gdb.python/*.exp tests with
the variable set.
I have tested this patch with the environment variable set, and saw no
regressions, so I think we are fine right now.
One other change of note was for gdbpy_initialize_gdb_readline, this
function previously returned void. In order to make this function
have the correct signature I've updated its return type to int, and we
now return 0 to indicate success.
All of the other initialize (and finalize) functions have been made
static within their respective sub-system files.
There should be no user visible changes after this commit.
Andrew Burgess [Tue, 2 May 2023 09:56:55 +0000 (10:56 +0100)]
gdb/testsuite: more newline pattern cleanup
After this commit:
commit
e2f620135d92f7cd670af4e524fffec7ac307666
Date: Thu Mar 30 13:26:25 2023 +0100
gdb/testsuite: change newline patterns used in gdb_test
It was pointed out in PR gdb/30403 that the same patterns can be found
in other lib/gdb.exp procs and that it would probably be a good idea
if these procs remained in sync with gdb_test. Actually, the bug
specifically calls out gdb_test_multiple when using with '-wrap', but
I found a couple of other locations in gdb_continue_to_breakpoint,
gdb_test_multiline, get_valueof, and get_local_valueof.
In all these locations one or both of the following issues are
addressed:
1. A leading pattern of '[\r\n]*' is pointless. If there is a
newline it will be matched, but if there is not then the testsuite
doesn't care. Also, as expect is happy to skip non-matched output
at the start of a pattern, if there is a newline expect is happy to
skip over it before matching the rest. As such, this leading
pattern is removed.
2. Using '\[\r\n\]*$gdb_prompt' means that we will swallow
unexpected blank lines at the end of a command's output, but also,
if the pattern from the test script ends with a '\r', '\n', or '.'
then these will partially match the trailing newline, with the
remainder of the newline matched by the pattern from gdb.exp. This
split matching doesn't add any value, it's just something that has
appeared as a consequence of how gdb.exp was originally written. In
this case the '\[\r\n\]*' is replaced with '\r\n'.
I've rerun the testsuite and fixed the regressions that I saw, these
were places where GDB emits a blank line at the end of the command
output, which we now need to explicitly match in the test script, this
was for:
gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
gdb.guile/guile.exp
gdb.python/python.exp
Or a location where the test script was matching part of the newline
sequence, while gdb.exp was previously matching the remainder of the
newline sequence. Now we rely on gdb.exp to match the complete
newline sequence, this was for:
gdb.base/commands.exp
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30403
Tom de Vries [Fri, 5 May 2023 16:57:06 +0000 (18:57 +0200)]
[gdb/testsuite] Generate long string in gdb.base/page.exp
I noticed in gdb.base/page.exp:
...
set fours [string repeat 4 40]
...
but then shortly afterwards:
...
[list 1\r\n 2\r\n 3\r\n
444444444444444444444444444444]
...
Summarize the long string in the same way using string repeat:
...
[list 1\r\n 2\r\n 3\r\n [string repeat 4 30]]
...
Tested on x86_64-linux.
Andrew Burgess [Fri, 5 May 2023 12:38:04 +0000 (13:38 +0100)]
gdb/testsuite: tighten patterns in build-id-no-debug-warning.exp
Tighten the expected output pattern in the test script:
gdb.debuginfod/build-id-no-debug-warning.exp
While working on some other patch I broke GDB such that this warning:
warning: "FILENAME": separate debug info file has no debug info
(which is generated in build-id.c) didn't actually include the
FILENAME any more -- yet this test script continued to pass. It turns
out that this script doesn't actually check for FILENAME.
This commit extends the test pattern to check for the full warning
string, including FILENAME, and also removes some uses of '.*' to make
the test stricter.
Tom Tromey [Fri, 7 Apr 2023 21:31:43 +0000 (15:31 -0600)]
Simplify decode_locdesc
While looking into another bug, I noticed that the DWARF cooked
indexer picks up an address for this symbol:
<1><82>: Abbrev Number: 2 (DW_TAG_variable)
<83> DW_AT_specification: <0x9f>
<87> DW_AT_location : 10 byte block: e 0 0 0 0 0 0 0 0 e0 (DW_OP_const8u: 0 0; DW_OP_GNU_push_tls_address or DW_OP_HP_unknown)
<92> DW_AT_linkage_name: (indirect string, offset: 0x156): _ZN9container8tlsvar_0E
This happens because decode_locdesc allows the use of
DW_OP_GNU_push_tls_address.
This didn't make sense to me. I looked into it a bit more, and I
think decode_locdesc is used in three ways:
1. Find a constant address of a symbol that happens to be encoded as a
location expression.
2. Find the offset of a function in a virtual table. (This one should
probably be replaced by code to just evaluate the expression in
gnu-v3-abi.c -- but there's no point yet because no compiler
actually seems to emit correct DWARF here, see the bug linked in
the patch.)
3. Find the offset of a field, if the offset is a constant.
None of these require TLS.
This patch simplifies decode_locdesc by removing any opcodes that
don't fit into the above. It also changes the API a little, to make
it less difficult to use.
Regression tested on x86-64 Fedora 36.
Tom Tromey [Tue, 4 Apr 2023 18:50:03 +0000 (12:50 -0600)]
Simplify auto_load_expand_dir_vars and remove substitute_path_component
This simplifies auto_load_expand_dir_vars to first split the string,
then do any needed substitutions. This was suggested by Simon, and is
much simpler than the current approach.
Then this patch also removes substitute_path_component, as it is no
longer called. This is nice because it helps with the long term goal
of removing utils.h.
Regression tested on x86-64 Fedora 36.
Tom de Vries [Fri, 5 May 2023 12:34:00 +0000 (14:34 +0200)]
[gdb/testsuite] Add gdb.base/wrap-line.exp
Add a test-case that tests prompt edit wrapping in CLI, both
for TERM=xterm and TERM=ansi, both with auto-detected and hard-coded width.
In the TERM=ansi case with auto-detected width we run into PR cli/30346, so
add a KFAIL for that failure mode.
Tested on x86_64-linux.
Tom de Vries [Fri, 5 May 2023 10:20:20 +0000 (12:20 +0200)]
[gdb/testsuite] Add gdb.tui/wrap-line.exp
Add a test-case that tests prompt edit wrapping behaviour in the tuiterm, both
for CLI and TUI, both with auto-detected and hard-coded width.
In the CLI case with auto-detected width we run into PR cli/30411, so add a
KFAIL for that failure mode.
Tested on x86_64-linux.
Nick Clifton [Fri, 5 May 2023 10:11:32 +0000 (11:11 +0100)]
Debug info is lost for functions only called from functions marked with cmse_nonsecure_entr
PR 30354
* elf32-arm.c (elf32_arm_gc_mark_extra_sections): If any debug sections are marked then rerun the extra marking in order to pick up any dependencies.
GDB Administrator [Fri, 5 May 2023 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Bruno Larsen [Thu, 4 May 2023 10:31:01 +0000 (12:31 +0200)]
Revert "gdb/testsuite: add KFAILs to gdb.reverse/step-reverse.exp"
This reverts commit
476410b3bca1389ee69e9c8fa18aaee16793a56d.
One of Simon's recent commits (
2a740b3ba4c9f39c86dd75e0914ee00942cab471)
changed the way recording a remote target works and fixed the underlying
issue of the bug, so the KFails can be removed from the test.
Approved-By: Tom Tromey <tom@tromey.com>
Gareth Rees [Sat, 11 Mar 2023 11:49:34 +0000 (11:49 +0000)]
Don't treat references to compound values as "simple".
SUMMARY
The '--simple-values' argument to '-stack-list-arguments' and similar
GDB/MI commands does not take reference types into account, so that
references to arbitrarily large structures are considered "simple" and
printed. This means that the '--simple-values' argument cannot be used
by IDEs when tracing the stack due to the time taken to print large
structures passed by reference.
DETAILS
Various GDB/MI commands ('-stack-list-arguments', '-stack-list-locals',
'-stack-list-variables' and so on) take a PRINT-VALUES argument which
may be '--no-values' (0), '--all-values' (1) or '--simple-values' (2).
In the '--simple-values' case, the command is supposed to print the
name, type, and value of variables with simple types, and print only the
name and type of variables with compound types.
The '--simple-values' argument ought to be suitable for IDEs that need
to update their user interface with the program's call stack every time
the program stops. However, it does not take C++ reference types into
account, and this makes the argument unsuitable for this purpose.
For example, consider the following C++ program:
struct s {
int v[10];
};
int
sum(const struct s &s)
{
int total = 0;
for (int i = 0; i < 10; ++i) total += s.v[i];
return total;
}
int
main(void)
{
struct s s = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } };
return sum(s);
}
If we start GDB in MI mode and continue to 'sum', the behaviour of
'-stack-list-arguments' is as follows:
(gdb)
-stack-list-arguments --simple-values
^done,stack-args=[frame={level="0",args=[{name="s",type="const s &",value="@0x7fffffffe310: {v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}"}]},frame={level="1",args=[]}]
Note that the value of the argument 's' was printed, even though 's' is
a reference to a structure, which is not a simple value.
See https://github.com/microsoft/MIEngine/pull/673 for a case where this
behaviour caused Microsoft to avoid the use of '--simple-values' in
their MIEngine debug adapter, because it caused Visual Studio Code to
take too long to refresh the call stack in the user interface.
SOLUTIONS
There are two ways we could fix this problem, depending on whether we
consider the current behaviour to be a bug.
1. If the current behaviour is a bug, then we can update the behaviour
of '--simple-values' so that it takes reference types into account:
that is, a value is simple if it is neither an array, struct, or
union, nor a reference to an array, struct or union.
In this case we must add a feature to the '-list-features' command so
that IDEs can detect that it is safe to use the '--simple-values'
argument when refreshing the call stack.
2. If the current behaviour is not a bug, then we can add a new option
for the PRINT-VALUES argument, for example, '--scalar-values' (3),
that would be suitable for use by IDEs.
In this case we must add a feature to the '-list-features' command
so that IDEs can detect that the '--scalar-values' argument is
available for use when refreshing the call stack.
PATCH
This patch implements solution (1) as I think the current behaviour of
not printing structures, but printing references to structures, is
contrary to reasonable expectation.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29554
Nick Clifton [Thu, 4 May 2023 13:24:16 +0000 (14:24 +0100)]
Stop the linker from loosing the entry point for COFF/PE code when compiling with LTO enabled.
PR 30300
* emultempl/pep.em (set_entry_point): Add an undefined reference to the entry point if it has been constructed heuristically.
* emultempl/pe.em (set_entry_point): Likewise.
Dimitar Dimitrov [Thu, 4 May 2023 11:41:55 +0000 (12:41 +0100)]
ld: pru: Place exception-handling sections correctly
* scripttempl/pru.sc (OUTPUT_SECTION_ALIGN): New helper variable to place at end of DMEM output sections.
(.data): Use the helper variable.
(.eh_frame): New output section.
(.gnu_extab): Ditto.
(.gcc_except_table): Ditto.
(.resource_table): Use the helper variable.
Jan Beulich [Thu, 4 May 2023 08:24:36 +0000 (10:24 +0200)]
RISC-V: tighten post-relocation-operator separator expectation
As per the spec merely a blank isn't okay as a separator, the operand
to the relocation function ought to be parenthesized. Enforcing this
then also eliminates an inconsistency in that
lui t0, %hi sym
lui t0, %hi 0x1000
were accepted, but
lui t0, %hi +sym
lui t0, %hi -0x1000
were not.
Ilya Leoshkevich [Thu, 4 May 2023 06:35:30 +0000 (08:35 +0200)]
gas: fix building tc-bpf.c on s390x
char is unsigned on s390x, so there are a lot of warnings like:
gas/config/tc-bpf.c: In function 'get_token':
gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits]
900 | if (ch == EOF || len > MAX_TOKEN_SZ)
| ^~
Change its type to int, like in the other similar code.
There is also:
gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized]
735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]);
| ~~~~~~~~~~~^~~~~~~~~~
-Wmaybe-uninitialized doesn't seem to understand the FSM; just
initialize bpf_endianness to silence it. Add an assertion to
build_bpf_endianness() in order to catch potential bugs.
YunQiang Su [Thu, 4 May 2023 01:45:22 +0000 (09:45 +0800)]
MIPS: revert "default r6 if vendor is img"
In commit:
9171de358f230b64646bbb525a74e5f8e3dbe0dc,
The default output is set to r6 if the vendor is img,
It is ugly and should not be in upstream.
Let's revert it.
GDB Administrator [Thu, 4 May 2023 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Wed, 3 May 2023 19:43:03 +0000 (21:43 +0200)]
[gdb/build] Fix frame_list position in frame.c
In commit
995a34b1772 ("Guard against frame.c destructors running before
frame-info.c's") the following problem was addressed.
The frame_info_ptr destructor:
...
~frame_info_ptr ()
{
frame_list.erase (frame_list.iterator_to (*this));
}
...
uses frame_list, which is a static member of class frame_info_ptr,
instantiated in frame-info.c:
...
intrusive_list<frame_info_ptr> frame_info_ptr::frame_list;
...
Then there's a static frame_info_pointer variable named selected_frame in
frame.c:
...
static frame_info_ptr selected_frame;
...
Because the destructor of selected_frame uses frame_list, its destructor needs
to be called before the destructor of frame_list.
But because they're in different compilation units, the initialization order and
consequently destruction order is not guarantueed.
The commit fixed this by handling the case that the destructor of frame_list
is called first, adding a check on is_linked ():
...
~frame_info_ptr ()
{
- frame_list.erase (frame_list.iterator_to (*this));
+ /* If this node has static storage, it may be deleted after
+ frame_list. Attempting to erase ourselves would then trigger
+ internal errors, so make sure we are still linked first. */
+ if (is_linked ())
+ frame_list.erase (frame_list.iterator_to (*this));
}
...
However, since then frame_list has been moved into frame.c, and
initialization/destruction order is guarantueed inside a compilation unit.
Revert aforementioned commit, and fix the destruction order problem by moving
frame_list before selected_frame.
Reverting the commit is another way of fixing the already fixed
Wdangling-pointer warning reported in PR build/30413, in a different way than
commit
9b0ccb1ebae ("Pass const frame_info_ptr reference for
skip_[language_]trampoline").
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tested on x86_64-linux.
PR build/30413
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413
Lancelot SIX [Wed, 3 May 2023 10:56:48 +0000 (11:56 +0100)]
gdb/show_args_command: print to the ui_file argument
The show_args_command uses gdb_printf without specifying the ui_file.
This means that it prints to gdb_stdout instead of the stream given as
an argument to the function.
This commit fixes this.
Reviewed-By: Tom Tromey <tom@tromey.com>
Oleg Tolmatcev [Wed, 3 May 2023 15:23:13 +0000 (16:23 +0100)]
Make ar faster
* archive.c (_bfd_write_archive_contents): Use a larger buffer in order to improve efficiency.
Mark Wielaard [Tue, 2 May 2023 18:23:32 +0000 (20:23 +0200)]
Pass const frame_info_ptr reference for skip_[language_]trampoline
g++ 13.1.1 produces a -Werror=dangling-pointer=
In file included from ../../binutils-gdb/gdb/frame.h:75,
from ../../binutils-gdb/gdb/symtab.h:40,
from ../../binutils-gdb/gdb/language.c:33:
In member function ‘void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’,
inlined from ‘void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’ at gdbsupport/intrusive_list.h:332:24,
inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at gdb/frame.h:241:26,
inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at gdb/language.c:530:49:
gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=]
415 | m_back = &elem;
| ~~~~~~~^~~~~~~
gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’:
gdb/language.c:530:49: note: ‘<anonymous>’ declared here
530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here
359 | static intrusive_list<frame_info_ptr> frame_list;
| ^~~~~~~~~~
Each new frame_info_ptr is being pushed on a static frame list and g++
cannot see why that is safe in case the frame_info_ptr is created and
destroyed immediately when passed as value.
It isn't clear why only in this one place g++ sees the issue (probably
because it can inline enough code in this specific case).
Since passing the frame_info_ptr as const reference is cheaper, use
that as workaround for this warning.
PR build/30413
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413
Tested-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-by: Tom Tromey <tom@tromey.com>
Oleg Tolmatcev [Wed, 3 May 2023 14:36:43 +0000 (15:36 +0100)]
Improve the speed of computing checksums for COFF binaries.
* coffcode.h (coff_read_word_from_buffer): New function.
* coffcode.h (COFF_CHECKSUM_BUFFER_SIZE): New constant.
* coffcode.h (coff_compute_checksum): Improve speed by reducing the number of seeks and reads used.
Alan Modra [Wed, 3 May 2023 06:23:29 +0000 (15:53 +0930)]
Remove unused args from bfd_make_debug_symbol
The ptr and size args are unused. Make the function look the same as
bfd_make_empty_symbol.
Alan Modra [Sun, 30 Apr 2023 11:12:30 +0000 (20:42 +0930)]
Generated docs and include files
bfd/doc/chew.c extracts documentation from source code comments
annotated with keywords, and generates much of bfd.h and libbfd.h from
those same comments. The docs have suffered from people (me too)
adding things like CODE_FRAGMENT to the source to put code into bfd.h
without realising that CODE_FRAGMENT also puts @example around said
code into the docs. So we have random senseless things in the docs.
This patch fixes that problem (well, the senseless things from
CODE_FRAGMENT), moves most of the code out of bfd-in.h, and improves a
few chew.c features. libbfd.h now automatically gets ATTRIBUTE_HIDDEN
prototypes, and indentation in bfd.h and libbfd.h is better.
Alan Modra [Wed, 3 May 2023 03:30:11 +0000 (13:00 +0930)]
Move bfd_alloc, bfd_zalloc and bfd_release to libbfd.c
These functions don't belong in opncls.c.
* libbfd-in.h (bfd_release): Delete prototype.
* opncls.c (bfd_alloc, bfd_zalloc, bfd_release): Move to..
* libbfd.c: ..here. Include objalloc.c and provide bfd_release
with a FUNCTION comment.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
Alan Modra [Wed, 3 May 2023 03:17:15 +0000 (12:47 +0930)]
Move bfd_elf_bfd_from_remote_memory to opncls.c
bfd_elf_bfd_from_remote_memory is just a wrapper, and the function
could be implemented for other formats. Move it to opncls.c because
it acts a little like some of the other bfd_open* routines. Also give
it the usual FUNCTION etc. comment so prototypes and docs are handled
automatically.
* elf.c (bfd_elf_bfd_from_remote_memory): Move to..
* opncls.c: ..here, add FUNCTION comment.
* bfd-in.h (bfd_elf_bfd_from_remote_memory): Delete prototype.
* bfd-in2.h: Regenerate.
Alan Modra [Tue, 2 May 2023 11:00:38 +0000 (20:30 +0930)]
hash.c: replace some unsigned long with unsigned int
* hash.c (higher_prime_number): Use uint32_t param, return value,
tables and variables.
(bfd_default_hash_table_size): Make it an unsigned int.
(bfd_hash_set_default_size): Use unsigned int param and return.
* bfd-in.h (bfd_hash_set_default_size): Update prototype.
* bfd-in2.h: Regenerate.
Alan Modra [Sat, 29 Apr 2023 03:30:46 +0000 (13:00 +0930)]
libbfc.c: Use stdint types for unsigned char and unsigned long
* libbfd.c (bfd_put_8): Use bfd_byte rather than unsigned char.
(bfd_get_8, bfd_get_signed_8): Likewise.
(_bfd_read_unsigned_leb128, _bfd_safe_read_leb128): Likewise.
(_bfd_read_signed_leb128): Likewise.
(bfd_getb24, bfd_getl24): Replace unsigned long with uint32_t.
(bfd_getb32, bfd_getl32): Likewise.
(bfd_getb_signed_32, bfd_getl_signed_32): Likewise.
Alan Modra [Sat, 29 Apr 2023 01:07:28 +0000 (10:37 +0930)]
Change signature of bfd crc functions
The crc calculated is 32 bits. Replace uses of unsigned long with
uint32_t. Also use bfd_byte* for buffers.
bfd/
* opncls.c (bfd_calc_gnu_debuglink_crc32): Use stdint types.
(bfd_get_debug_link_info_1, bfd_get_debug_link_info): Likewise.
(separate_debug_file_exists, bfd_follow_gnu_debuglink): Likewise.
(bfd_fill_in_gnu_debuglink_section): Likewise.
* bfd-in2.h: Regenerate.
gdb/
* auto-load.c (auto_load_objfile_script): Update type of
bfd_get_debug_link_info argument.
* symfile.c (find_separate_debug_file_by_debuglink): Likewise.
* gdb_bfd.c (get_file_crc): Update type of
bfd_calc_gnu_debuglink_crc32 argument.
Alan Modra [Sat, 29 Apr 2023 01:30:30 +0000 (11:00 +0930)]
_bfd_mips_elf_lo16_reloc vallo comment
This explains exactly why the high reloc adjustment is as it is,
replacing the rather nebulous existing comment. I've also changed the
expression from (lo+0x8000)&0xffff to (lo&0xffff)^0x8000 which better
matches part of the standard 16-bit sign extension (resulting in
exactly the same value), and hoisted the calculation out of the loop.
* elfxx-mips.c (_bfd_mips_elf_lo16_reloc): Expand vallo
comment. Hoist calculation out of loop.
Alexandra Hájková [Tue, 2 May 2023 20:33:49 +0000 (22:33 +0200)]
gdb.base/watchpoint-unaligned.exp: Always initialize wpoffset_to_wpnum
Initialize wpoffset_to_wpnumto avoid TCL error which happens in some aarch64 types.
ERROR: in testcase /root/build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
ERROR: can't read "wpoffset_to_wpnum(1)": no such element in array
ERROR: tcl error code TCL READ VARNAME
ERROR: tcl error info:
can't read "wpoffset_to_wpnum(1)": no such element in array
while executing
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30340
Reviewed-by: Luis Machado <luis.machado@arm.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Mark Wielaard [Sat, 29 Apr 2023 20:46:11 +0000 (22:46 +0200)]
xcoffread.c: Fix -Werror=dangling-pointer= issue with main_subfile.
GCC 13 points out that main_subfile has local function scope, but a
pointer to it is assigned to the global inclTable array subfile
element field:
In function ‘void process_linenos(CORE_ADDR, CORE_ADDR)’,
inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:727:19,
inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:720:1:
xcoffread.c:629:37: error: storing the address of local variable ‘main_subfile’ in ‘*inclTable.19_45 + _28._inclTable::subfile’ [-Werror=dangling-pointer=]
629 | inclTable[ii].subfile = &main_subfile;
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
xcoffread.c: In function ‘void aix_process_linenos(objfile*)’:
xcoffread.c:579:18: note: ‘main_subfile’ declared here
579 | struct subfile main_subfile;
| ^~~~~~~~~~~~
xcoffread.c:496:19: note: ‘inclTable’ declared here
496 | static InclTable *inclTable; /* global include table */
| ^~~~~~~~~
Fix this by making main_subfile file static. And allocate and
deallocated together with inclTable in allocate_include_entry and
xcoff_symfile_finish. Adjust the use of main_subfile in
process_linenos to take a pointer to the subfile.
Tom de Vries [Tue, 2 May 2023 15:37:58 +0000 (17:37 +0200)]
[gdb/testsuite] Use set in lmap in gdb.dwarf2/dw2-abs-hi-pc.exp
In gdb.dwarf2/dw2-abs-hi-pc.exp we do:
...
set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }]
...
The use of expr is not idiomatic. Fix this by using set instead:
...
set sources [lmap i $sources { set tmp $srcdir/$subdir/$i }]
...
Reported-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Andreas Schwab <schwab@suse.de>
Aditya Kamath [Tue, 2 May 2023 15:08:14 +0000 (10:08 -0500)]
Fix Assertion pid != 0 failure in AIX.
In AIX if there is a main and a thread created from it , then once the
program completed execution and goes to pd_disable () inferior_ptid
had pid 0 leading to an assertion failure while finding the thread's data
in aix-thread.c file.
This patch is a fix for the same.
Tom Tromey [Sun, 16 Apr 2023 18:40:33 +0000 (12:40 -0600)]
Remove error_stream
error_stream is trivial and only used in a couple of spots in
breakpoint.c. This patch removes it in favor of just writing it out
at the spots where it was used.
Nick Clifton [Tue, 2 May 2023 12:33:53 +0000 (13:33 +0100)]
Remove Dimity Diky as MSP430 maintainer.
Andrew Burgess [Tue, 2 May 2023 10:48:46 +0000 (11:48 +0100)]
gdb/testsuite: compile gdb.linespec/cp-completion-aliases.exp as C++
Noticed in passing that the prepare_for_testing call in
gdb.linespec/cp-completion-aliases.exp does not pass the 'c++' flag,
despite this being a C++ test.
I guess, as the source file has the '.cc' extension, all the compilers
are doing the right thing anyway -- the source file uses templates, so
is definitely being compiled as C++.
I noticed this when I tried to set CXX_FOR_TARGET (but not
CC_FOR_TARGET) and spotted that this script was still using the C
compiler.
Fixed in this commit by adding the 'c++' flag for prepare_for_testing.
GDB Administrator [Tue, 2 May 2023 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 14 Apr 2023 18:16:58 +0000 (12:16 -0600)]
Document DAP 'launch' parameter
The Debugger Adapter Protocol defines a "launch" request but leaves
the parameters up to the implementation:
Since launching is debugger/runtime specific, the arguments for
this request are not part of this specification.
This patch adds some documentation for the parameter GDB currently
defines. Note that I plan to add more parameters here, and perhaps
there will be other extensions in time as well.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Simon Marchi [Fri, 28 Apr 2023 18:27:13 +0000 (14:27 -0400)]
gdb: remove ui_interp_info
I don't think that having struct ui_interp_info separated from struct ui
is very useful. As of today, it looks like an unnecessary indirection
layer. Move the contents of ui_interp_info directly into struct ui, and
update all users.
Change-Id: I817ba6e047dbcc4ba15b666af184b40bfed7e521
Simon Marchi [Fri, 28 Apr 2023 18:27:12 +0000 (14:27 -0400)]
gdb: store interps in an intrusive_list
Use intrusive_list, instead of hand-made linked list.
Change-Id: Idc857b40dfa3e3c35671045898331cca2c928097
Simon Marchi [Fri, 28 Apr 2023 18:27:11 +0000 (14:27 -0400)]
gdb: move struct ui and related things to ui.{c,h}
I'd like to move some things so they become methods on struct ui. But
first, I think that struct ui and the related things are big enough to
deserve their own file, instead of being scattered through top.{c,h} and
event-top.c.
Change-Id: I15594269ace61fd76ef80a7b58f51ff3ab6979bc
Tom Tromey [Fri, 14 Apr 2023 19:18:05 +0000 (13:18 -0600)]
Turn set_inferior_args_vector into method of inferior
This patch turns set_inferior_args_vector into an overload of
inferior::set_args.
Regression tested on x86-64 Fedora 36.
Tom Tromey [Fri, 28 Apr 2023 13:26:44 +0000 (07:26 -0600)]
Remove evaluate_type
Like evaluate_expression, evaluate_type is also just a simple wrapper.
Removing it makes the code a little nicer.
Tom Tromey [Fri, 28 Apr 2023 13:24:59 +0000 (07:24 -0600)]
Remove evaluate_expression
evaluate_expression is just a little wrapper for a method on
expression. Removing it also removes a lot of ugly (IMO) calls to
get().
Tom Tromey [Fri, 28 Apr 2023 13:15:06 +0000 (07:15 -0600)]
Remove op_name
op_name is only needed in a single place, so remove it and inline it
there.
Tom Tromey [Mon, 1 May 2023 16:10:29 +0000 (10:10 -0600)]
Fix crash in Rust expression parser
A user found that an array expression with just a single value (like
"[23]") caused the Rust expression parser to crash.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30410
Tom Tromey [Sat, 22 Apr 2023 18:41:43 +0000 (12:41 -0600)]
Replace field_is_static with a method
This changes field_is_static to be a method on struct field, and
updates all the callers. Most of this patch was written by script.
Regression tested on x86-64 Fedora 36.
GDB Administrator [Mon, 1 May 2023 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sun, 30 Apr 2023 11:06:23 +0000 (13:06 +0200)]
[gdb/tui] Fix TUI resizing for TERM=ansi
With TERM=ansi, when resizing a TUI window from LINES/COLUMNS 31/118
(maximized) to 20/78 (de-maximized), I get a garbled screen (that ^L doesn't
fix) and a message:
...
@@ resize done 0, size = 77x20
...
with the resulting width being 77 instead of the expected 78.
[ The discrepancy also manifests in CLI, filed as PR30346. ]
The discrepancy comes from tui_resize_all, where we ask readline for the
screen size:
...
rl_get_screen_size (&screenheight, &screenwidth);
...
As it happens, when TERM is set to ansi, readline decides that the terminal
cannot auto-wrap lines, and reserves one column to deal with that, and as a
result reports back one less than the actual screen width:
...
$ echo $COLUMNS
78
$ TERM=xterm gdb -ex "show width" -ex q
Number of characters gdb thinks are in a line is 78.
$ TERM=ansi gdb -ex "show width" -ex q
Number of characters gdb thinks are in a line is 77.
...
In tui_resize_all, we need the actual screen width, and using a screenwidth of
one less than the actual value garbles the screen.
This is currently not causing trouble in testing because we have a workaround
in place in proc Term::resize. If we disable the workaround:
...
- stty columns [expr {$_cols + 1}] < $::gdb_tty_name
+ stty columns $_cols < $::gdb_tty_name
...
and dump the screen we get the same type of screen garbling:
...
0 +---------------------------------------+|
1 ||
2 ||
3 ||
...
Another way to reproduce the problem is using command "maint info screen".
After starting gdb with TERM=ansi, entering TUI, and issuing the command, we
get:
...
Number of characters curses thinks are in a line is 78.
...
and after maximizing and demaximizing the window we get:
...
Number of characters curses thinks are in a line is 77.
...
If we use TERM=xterm, we do get the expected 78.
Fix this by:
- detecting when readline will report back less than the actual screen width,
- accordingly setting a new variable readline_hidden_cols,
- using readline_hidden_cols in tui_resize_all to fix the resize problem, and
- removing the workaround in Term::resize.
The test-case gdb.tui/empty.exp serves as regression test.
I've applied the same fix in tui_async_resize_screen, the new test-case
gdb.tui/resize-2.exp serves as a regression test for that change. Without
that fix, we have:
...
FAIL: gdb.tui/resize-2.exp: again: gdb width 80
...
Tested on x86_64-linux.
PR tui/30337
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30337
GDB Administrator [Sun, 30 Apr 2023 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sat, 29 Apr 2023 08:47:46 +0000 (10:47 +0200)]
[gdb/testsuite] Fix gdb.base/readline.exp with stub-termcap
When doing a build which uses stub-termcap, we run into:
...
(gdb) set width 7
<b) FAIL: gdb.base/readline.exp: set width 7 (timeout)
...
Since readline can't detect very basic terminal support, it falls back on
horizontal scrolling.
Fix this by detecting the horizontal scrolling case, and skipping the
subsequent test.
Tested on x86_64-linux.
PR testsuite/30400
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30400
Manoj Gupta [Mon, 17 Apr 2023 20:33:15 +0000 (13:33 -0700)]
gdb: Fix building with latest libc++
Latest libc++[1] causes transitive include to <locale> when
<mutex> or <thread> header is included. This causes
gdb to not build[2] since <locale> defines isupper/islower etc.
functions that are explicitly macroed-out in safe-ctype.h to
prevent their use.
Use the suggestion from libc++ to include <locale> internally when
building in C++ mode to avoid build errors.
Use safe-gdb-ctype.h as the include instead of "safe-ctype.h"
to keep this isolated to gdb since rest of binutils
does not seem to use much C++.
[1]: https://reviews.llvm.org/
D144331
[2]: https://issuetracker.google.com/issues/
277967395
Tom de Vries [Sat, 29 Apr 2023 06:57:07 +0000 (08:57 +0200)]
[gdb/testsuite] Fix gdb.ada/excep_handle.exp for updated gdb_test
Test-case gdb.ada/excep_handle.exp fails since commit
e2f620135d9
("gdb/testsuite: change newline patterns used in gdb_test"):
...
(gdb) continue^M
Continuing.^M
^M
Catchpoint 2, exception at 0x00000000004020b6 in foo () at foo.adb:26^M
26 when Constraint_Error =>^M
(gdb) FAIL: gdb.ada/excep_handle.exp: continuing to first Constraint_Error \
exception handlers
...
The output is supposed to be matched by:
...
gdb_test "continue" \
"Continuing\.$eol$catchpoint_constraint_error_msg$eol.*" \
"continuing to first Constraint_Error exception handlers"
...
but the $eol bit no longer matches due to the stricter matching introduced
in aforementioned commit.
Fix this by dropping the "$eol.*" bit.
Tested on x86_64-linux.
PR testsuite/30399
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30399
Tom de Vries [Sat, 29 Apr 2023 05:04:27 +0000 (07:04 +0200)]
[gdb/build] Fix build without ncurses in maintenance_info_screen
With a build without ncurses we run into:
...
src/gdb/utils.c: In function ‘void maintenance_info_screen(const char*, int)’:
src/gdb/utils.c:1310:7: error: ‘COLS’ was not declared in this scope
COLS);
^~~~
src/gdb/utils.c:1331:8: error: ‘LINES’ was not declared in this scope
LINES);
^~~~~
...
Fix this by using HAVE_LIBCURSES.
Tested on x86_64-linux.
PR build/30391
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30391
Tom de Vries [Sat, 29 Apr 2023 05:00:34 +0000 (07:00 +0200)]
[gdb/testsuite] Fix gdb.tui/main.exp without TUI
With a build with --disable-tui, we get:
...
(gdb) PASS: gdb.tui/main.exp: set interactive-mode off
maint set tui-left-margin-verbose on^M
Undefined maintenance set command: "tui-left-margin-verbose on". \
Try "help maintenance set".^M
(gdb) FAIL: gdb.tui/main.exp: maint set tui-left-margin-verbose on
...
Fix this by adding the missing "require allow_tui_tests".
Tested on x86_64-linux.
GDB Administrator [Sat, 29 Apr 2023 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Fri, 3 Mar 2023 23:17:39 +0000 (23:17 +0000)]
gdb/mi: check thread exists when creating thread-specific b/p
I noticed the following behaviour:
$ gdb -q -i=mi /tmp/hello.x
=thread-group-added,id="i1"
=cmd-param-changed,param="print pretty",value="on"
~"Reading symbols from /tmp/hello.x...\n"
(gdb)
-break-insert -p 99 main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000401198",func="main",file="/tmp/hello.c",fullname="/tmp/hello.c",line="18",thread-groups=["i1"],thread="99",times="0",original-location="main"}
(gdb)
info breakpoints
&"info breakpoints\n"
~"Num Type Disp Enb Address What\n"
~"1 breakpoint keep y 0x0000000000401198 in main at /tmp/hello.c:18\n"
&"../../src/gdb/thread.c:1434: internal-error: print_thread_id: Assertion `thr != nullptr' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable."
&"\n"
&"----- Backtrace -----\n"
&"Backtrace unavailable\n"
&"---------------------\n"
&"\nThis is a bug, please report it."
&" For instructions, see:\n"
&"<https://www.gnu.org/software/gdb/bugs/>.\n\n"
Aborted (core dumped)
What we see here is that when using the MI a user can create
thread-specific breakpoints for non-existent threads. Then if we try
to use the CLI 'info breakpoints' command GDB throws an assertion.
The assert is a result of the print_thread_id call when trying to
build the 'stop only in thread xx.yy' line; print_thread_id requires a
valid thread_info pointer, which we can't have for a non-existent
thread.
In contrast, when using the CLI we see this behaviour:
$ gdb -q /tmp/hello.x
Reading symbols from /tmp/hello.x...
(gdb) break main thread 99
Unknown thread 99.
(gdb)
The CLI doesn't allow a breakpoint to be created for a non-existent
thread. So the 'info breakpoints' command is always fine.
Interestingly, the MI -break-info command doesn't crash, this is
because the MI uses global thread-ids, and so never calls
print_thread_id. However, GDB does support using CLI and MI in
parallel, so we need to solve this problem.
One option would be to change the CLI behaviour to allow printing
breakpoints for non-existent threads. This would preserve the current
MI behaviour.
The other option is to pull the MI into line with the CLI and prevent
breakpoints being created for non-existent threads. This is good for
consistency, but is a breaking change for the MI.
In the end I figured that it was probably better to retain the
consistent CLI behaviour, and just made the MI reject requests to
place a breakpoint on a non-existent thread. The only test we had
that depended on the old behaviour was
gdb.mi/mi-thread-specific-bp.exp, which was added by me in commit:
commit
2fd9a436c8d24eb0af85ccb3a2fbdf9a9c679a6c
Date: Fri Feb 17 10:48:06 2023 +0000
gdb: don't duplicate 'thread' field in MI breakpoint output
I certainly didn't intend for this test to rely on this feature of the
MI, so I propose to update this test to only create breakpoints for
threads that exist.
Actually, I've added a new test that checks the MI rejects creating a
breakpoint for a non-existent thread, and I've also extended the test
to run with the separate MI/CLI UIs, and then tested 'info
breakpoints' to ensure this command doesn't crash.
I've extended the documentation of the `-p` flag to explain the
constraints better.
I have also added a NEWS entry just in case someone runs into this
issue, at least then they'll know this change in behaviour was
intentional.
One thing that I did wonder about while writing this patch, is whether
we should treat requests like this, on both the MI and CLI, as another
form of pending breakpoint, something like:
(gdb) break foo thread 9
Thread 9 does not exist.
Make breakpoint pending on future thread creation? (y or [n]) y
Breakpoint 1 (foo thread 9) pending.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <PENDING> foo thread 9
Don't know if folk think that would be a useful idea or not? Either
way, I think that would be a separate patch from this one.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Andrew Burgess [Tue, 4 Apr 2023 09:10:44 +0000 (10:10 +0100)]
gdb: make deprecated_show_value_hack static
The deprecated_show_value_hack function is now only used inside
cli-setshow.c, so lets make the function static to discourage its use
anywhere else.
There should be no user visible changes after this commit
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Tue, 4 Apr 2023 11:11:50 +0000 (12:11 +0100)]
gdb: make set/show inferior-tty work with $_gdb_setting_str
Like the previous two commits, this commit fixes set/show inferior-tty
to work with $_gdb_setting_str.
Instead of using a scratch variable which is then pushed into the
current inferior from a set callback, move to the API that allows for
getters and setters, and store the value directly within the current
inferior.
Update an existing test to check the inferior-tty setting.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 28 Apr 2023 21:14:53 +0000 (22:14 +0100)]
gdb: make set/show cwd work with $_gdb_setting_str
The previous commit fixed set/show args when used with
$_gdb_setting_str, this commit fixes set/show cwd.
Instead of using a scratch variable which is then pushed into the
current inferior from a set callback, move to the API that allows for
getters and setters, and store the value directly within the current
inferior.
Update the existing test to check the cwd setting.
Andrew Burgess [Tue, 4 Apr 2023 08:56:00 +0000 (09:56 +0100)]
gdb: make set/show args work with $_gdb_setting_str
I noticed that $_gdb_setting_str was not working with 'args', e.g.:
$ gdb -q --args /tmp/hello.x arg1 arg2 arg3
Reading symbols from /tmp/hello.x...
(gdb) show args
Argument list to give program being debugged when it is started is "arg1 arg2 arg3".
(gdb) print $_gdb_setting_str("args")
$1 = ""
This is because the 'args' setting is implemented using a scratch
variable ('inferior_args_scratch') which is updated when the user does
'set args ...'. There is then a function 'set_args_command' which is
responsible for copying the scratch area into the current inferior.
However, when the user sets the arguments via the command line the
scratch variable is not updated, instead the arguments are pushed
straight into the current inferior.
There is a second problem, when the current inferior changes the
scratch area is not updated, which means that the value returned will
only ever reflect the last call to 'set args ...' regardless of which
inferior is currently selected.
Luckily, the fix is pretty easy, set/show variables have an
alternative API which requires we provide some getter and setter
functions. With this done the scratch variable can be removed and the
value returned will now always reflect the current inferior.
While working on set/show args I also rewrote show_args_command to
remove the use of deprecated_show_value_hack.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Tue, 4 Apr 2023 08:34:54 +0000 (09:34 +0100)]
gdb: cleanup command creation in infcmd.c
In infcmd.c, in order to add command completion to some of the 'set'
commands, we are currently creating the command, then looking up the
command by calling lookup_cmd.
This is no longer necessary, we already return the relevant
cmd_list_element object when the set/show command is created, and we
can use that to set the command completion callback.
I don't know if there's actually any tests for completion of these
commands, but I manually checked, and each command still appears to
offer the expected filename completion.
There should be no user visible changes after this commit.
Reviewed-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Thu, 27 Apr 2023 18:54:07 +0000 (14:54 -0400)]
gdb/record-full: disable range stepping when resuming threads
I see these failures, when running with the native-gdbserver of
native-extended-gdbserver boards:
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.reverse/finish-reverse-next.exp ...
FAIL: gdb.reverse/finish-reverse-next.exp: reverse next 1 LEP from function body
FAIL: gdb.reverse/finish-reverse-next.exp: reverse next 2 at b = 5, from function body
FAIL: gdb.reverse/finish-reverse-next.exp: reverse next 1 GEP call from function body
FAIL: gdb.reverse/finish-reverse-next.exp: reverse next 2 at b = 50 from function body
Let's use this simpler program to illustrate the problem:
int main()
{
int a = 362;
a = a * 17;
return a;
}
It compiles down to:
int a = 362;
401689: c7 45 fc 6a 01 00 00 movl $0x16a,-0x4(%rbp)
a = a * 17;
401690: 8b 55 fc mov -0x4(%rbp),%edx
401693: 89 d0 mov %edx,%eax
401695: c1 e0 04 shl $0x4,%eax
401698: 01 d0 add %edx,%eax
40169a: 89 45 fc mov %eax,-0x4(%rbp)
return a;
40169d: 8b 45 fc mov -0x4(%rbp),%eax
When single stepping these lines, debugging locally, while recording,
these are the recorded instructions (basically one for each instruction
shown above):
(gdb) maintenance print record-instruction 0
4 bytes of memory at address 0x00007fffffffdc5c changed from: 6a 01 00 00
Register rip changed: (void (*)()) 0x40169a <main+21>
(gdb) maintenance print record-instruction -1
Register rax changed: 5792
Register eflags changed: [ PF AF IF ]
Register rip changed: (void (*)()) 0x401698 <main+19>
(gdb) maintenance print record-instruction -2
Register rax changed: 362
Register eflags changed: [ PF ZF IF ]
Register rip changed: (void (*)()) 0x401695 <main+16>
(gdb) maintenance print record-instruction -3
Register rax changed:
4200069
Register rip changed: (void (*)()) 0x401693 <main+14>
(gdb) maintenance print record-instruction -4
Register rdx changed:
140737488346696
Register rip changed: (void (*)()) 0x401690 <main+11>
(gdb) maintenance print record-instruction -5
4 bytes of memory at address 0x00007fffffffdc5c changed from: 00 00 00 00
Register rip changed: (void (*)()) 0x401689 <main+4>
(gdb) maintenance print record-instruction -6
Not enough recorded history
But when debugging remotely:
(gdb) maintenance print record-instruction 0
Register rdx changed:
140737488346728
Register rip changed: (void (*)()) 0x401690 <main+11>
(gdb) maintenance print record-instruction -1
4 bytes of memory at address 0x00007fffffffdc7c changed from: 00 00 00 00
Register rip changed: (void (*)()) 0x401689 <main+4>
(gdb) maintenance print record-instruction -2
Not enough recorded history
In this list, we only have entries for the beginning of each line. This
is because of the remote target's support for range stepping. The
record-full layer can only record instructions when the underlying
process target reports a stop. With range stepping, the remote target
single-steps multiple instructions at a time, so the record-full target
doesn't get to see and record them all.
Fix this by making the record-full layer disable range-stepping
before handing the resume request to the beneath layer, forcing the
remote target to report stops for each instruction.
Change-Id: Ia95ea62720bbcd0b6536a904360ffbf839eb823d
Keith Seitz [Fri, 28 Apr 2023 17:43:20 +0000 (10:43 -0700)]
Allow strings with printf/eval
PR 13098 explains that if a user attempts to use a string with either
`printf' (or `eval'), gdb returns an error (inferior not running):
(gdb) printf "%s\n", "hello"
evaluation of this expression requires the target program to be active
However, the parser can certainly handle this case:
(gdb) p "hello"
$1 = "hello"
This discrepancy occurs because printf_c_string does not handle
this specific case. The passed-in value that we are attempting to print
as a string is TYPE_CODE_ARRAY but it's lval type is not_lval.
printf_c_string will only attempt to print a string from the value's
contents when !TYPE_CODE_PTR, lval is lval_internalvar, and the value's
type is considered a string type:
if (value->type ()->code () != TYPE_CODE_PTR
&& value->lval () == lval_internalvar
&& c_is_string_type_p (value->type ()))
{
...
}
Otherwise, it attempts to read the value of the string from the target's
memory (which is what actually generates the "evaluation of this ..."
error message).
Tom Tromey [Fri, 28 Apr 2023 12:49:16 +0000 (06:49 -0600)]
Move find_minimal_symbol_address to minsyms.c
I found find_minimal_symbol_address in parse.c, but it seems to me
that it belongs in minsyms.c.
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Tom Tromey [Thu, 27 Apr 2023 19:25:27 +0000 (13:25 -0600)]
Do not change type in get_discrete_low_bound
get_discrete_low_bound has this code:
/* Set unsigned indicator if warranted. */
if (low >= 0)
type->set_is_unsigned (true);
It's bad to modify a type in a getter like this, so this patch removes
this code. FWIW I looked and this code has been there since at least
1999 (it was in the initial sourceware import).
Types in general would benefit from const-ification, which would
probably reveal more code like this, but I haven't attempted that.
Regression tested on x86-64 Fedora 36.
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Tom Tromey [Thu, 6 Apr 2023 14:24:06 +0000 (08:24 -0600)]
Remove @var from @defun in Python documentation
Eli pointed out that @var isn't needed in @defun in Texinfo. This
patch removes the cases I found in python.texi. I also renamed some
variables in one spot, because "-" isn't valid in a Python variable
name.
Andrew Burgess [Fri, 28 Apr 2023 13:39:03 +0000 (14:39 +0100)]
gdb/testsuite: additional test fixes after gdb_test changes
After this commit:
commit
e2f620135d92f7cd670af4e524fffec7ac307666
Date: Thu Mar 30 13:26:25 2023 +0100
gdb/testsuite: change newline patterns used in gdb_test
There were some regressions in gdb.trace/*.exp tests when run with the
native-gdbserver board. This commit fixes these regressions.
All the problems are caused by unnecessary trailing newline characters
included in the patterns passed to gdb_test. After the above commit
the testsuite is stricter when matching trailing newlines, and so the
additional trailing newline characters are now causing the test to
fail. Fix by removing all the excess trailing newline characters.
In some cases this cleanup means we should use gdb_test_no_output,
I've done that where appropriate. In a couple of other places I've
made use of multi_line to better build the expected output pattern.
H.J. Lu [Mon, 16 Jan 2023 22:03:02 +0000 (14:03 -0800)]
ld: Use run_cc_link_tests for PR ld/26391 tests
Use run_cc_link_tests for PR ld/26391 tests to compile PR ld/26391 tests
in C.
PR ld/30002
* testsuite/ld-elf/elf.exp: Use run_cc_link_tests for PR ld/26391
tests.
Eli Zaretskii [Fri, 28 Apr 2023 15:36:30 +0000 (18:36 +0300)]
Fix a typo in gdb.texinfo.
Nelson Chu [Fri, 21 Apr 2023 08:28:39 +0000 (16:28 +0800)]
RISC-V: Enable x0 base relaxation for relax_pc even if --no-relax-gp.
Let --no-relax-gp only disable the gp relaxation for lui and pcrel
relaxations, since x0 base and gp relaxations are different optimizations
in fact, but just use the same function to handle.
bfd/
* elfnn-riscv.c (_bfd_riscv_relax_pc): Like _bfd_riscv_relax_lui,
set gp to zero when --no-relax-gp, then we should still keep the
x0 base relaxation.
(_bfd_riscv_relax_section): Enable _bfd_riscv_relax_pc when
--no-relax-gp, we will disable the gp relaxation in the
_bfd_riscv_relax_pc.
Nelson Chu [Fri, 21 Apr 2023 08:28:38 +0000 (16:28 +0800)]
RISC-V: Relax R_RISCV_[PCREL_]LO12_I/S to R_RISCV_GPREL_I/S for undefined weak.
bfd/
*elfnn-riscv.c (_bfd_riscv_relax_lui): For undefined weak symbol,
just relax the R_RISCV_LO12_I/S to R_RISCV_GPREL_I/S, and then don't
update the rs1 to zero until relocate_section.
(_bfd_riscv_relax_pc): Likewise, but for R_RISCV_PCREL_LO12_I/S.
Jan Beulich [Fri, 28 Apr 2023 06:24:41 +0000 (08:24 +0200)]
x86: limit data passed to i386_dis_printf()
The function doesn't use "ins" for other than retrieving "info". Remove
a thus pointless level of indirection.
Jan Beulich [Fri, 28 Apr 2023 06:24:11 +0000 (08:24 +0200)]
x86: limit data passed to prefix_name()
Make apparent that neither what "ins" points to nor, in particular, that
"ins->info->private_data" is actually used in the function.
Jan Beulich [Fri, 28 Apr 2023 06:20:15 +0000 (08:20 +0200)]
x86/Intel: reduce ELF/PE conditional scope in x86_cons()
All the Intel syntax related state adjustments apply independent of
target or object format.
Jan Beulich [Fri, 28 Apr 2023 06:19:53 +0000 (08:19 +0200)]
gas: move shift count check
... out of mainline code, grouping together the two case labels. This
then also make more obvious that the comment there applies to both forms
of shifts.
Jan Beulich [Fri, 28 Apr 2023 06:19:34 +0000 (08:19 +0200)]
x86: rework AMX control insn disassembly
Consistently do 64-bit first, VEX.L second, VEX.W third, ModR/M fourth,
and only then prefix, resulting in fewer table entries. Note that in the
course of the re-work
- TILEZERO has a previously missing decode step through rm_table[]
added,
- a wrong M_0 suffix for TILEZERO is also corrected to be M_1 (now an
infix).
Jan Beulich [Fri, 28 Apr 2023 06:19:19 +0000 (08:19 +0200)]
x86: rework AMX multiplication insn disassembly
Consistently do 64-bit first, ModR/M second, VEX.L third, VEX.W fourth,
and prefix last, resulting in fewer table entries. Note that in the
course of the re-work wrong M_0 suffixes are also corrected to be M_1
(partly infixes now).
Since it ended up confusing while testing the change, also adjust the
test name in x86-64-amx-bad.d (to be distinct from x86-64-amx.d's).
Alan Modra [Fri, 28 Apr 2023 01:41:09 +0000 (11:11 +0930)]
Re: Keeping track of rs6000-coff archive element pointers
Commit
de7b90610e9e left a hole in the element checking, explained by
the comment added to _bfd_xcoff_openr_next_archived_file. While
fixing this, tidy some types used to hold unsigned values so that
casts are not needed to avoid signed/unsigned comparison warnings.
Also tidy a few things in xcoff.h.
bfd/
* coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Check
that we aren't pointing back at the last element. Make
filestart a ufile_ptr. Update for xcoff_artdata change.
(_bfd_strntol, _bfd_strntoll): Return unsigned values.
(_bfd_xcoff_slurp_armap): Make off a ufile_ptr.
(add_ranges): Update for xcoff_artdata change.
* libbfd-in.h (struct artdata): Make first_file_filepos a
ufile_ptr.
* libbfd.h: Regenerate.
include/
* coff/xcoff.h (struct xcoff_artdata): Replace min_elt with
ar_hdr_size.
(xcoff_big_format_p): In the !SMALL_ARCHIVE case return true
for anything but a small archive.
Alan Modra [Wed, 26 Apr 2023 22:56:50 +0000 (08:26 +0930)]
Remove deprecated bfd_read
20+ years is long enough to warn.
* bfd-in.h (bfd_read, bfd_write): Don't define
(_bfd_warn_deprecated): Don't declare.
* bfd-in2.h: Regenerate.
* libbfd.c (_bfd_warn_deprecated): Delete.
Alan Modra [Wed, 26 Apr 2023 11:36:29 +0000 (21:06 +0930)]
Make bfd_byte an int8_t, flagword a uint32_t
* bfd-in.h (bfd_byte): Typedef as int8_t.
(flagword): Typedef as uint32_t.
(bfd_vma, bfd_signed_vma, bfd_size_type, symvalue): Use stdint
types in !BFD64 case.
* bfd-in2.h: Regenerate.
GDB Administrator [Fri, 28 Apr 2023 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Jose E. Marchesi [Thu, 27 Apr 2023 18:05:19 +0000 (20:05 +0200)]
gas: bpf: fix tests for pseudo-c syntax
This patch fixes the GAS BPF testsuite so the tests for pseudo-c
syntax are actually executed.
2023-04-27 Jose E. Marchesi <jose.marchesi@oracle.com>
* testsuite/gas/bpf/mem.dump: New file.
* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem.d: #dump mem.dump.
* testsuite/gas/bpf/lddw.dump: New file.
* testsuite/gas/bpf/lddw-pseudoc.d: Likewise.
* testsuite/gas/bpf/lddw.d: #dump lddw.dump.
* testsuite/gas/bpf/jump.dump: New file.
* testsuite/gas/bpf/jump-pseudoc.d: Likewise
* testsuite/gas/bpf/jump.d: #dump jump.dump.
* testsuite/gas/bpf/jump32.dump: New file.
* testsuite/gas/bpf/jump32-pseudoc.d: Likewise.
* testsuite/gas/bpf/jump32.d: #dump jump32.dump.
* testsuite/gas/bpf/lddw-be.dump: New file.
* testsuite/gas/bpf/lddw-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/lddw-be.d: #dump lddw-be.dump.
* testsuite/gas/bpf/indcall-1.dump: New file.
* testsuite/gas/bpf/indcall-1-pseudoc.d: Likewise.
* testsuite/gas/bpf/indcall-1.d: #dump indcall-1.dump.
* testsuite/gas/bpf/indcall-1-pseudoc.s (main): Fix lddw
instruction.
* testsuite/gas/bpf/atomic.dump: New file.
* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
* testsuite/gas/bpf/atomic.d: #dump atomic.dump.
* testsuite/gas/bpf/alu32.dump: New file.
* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32.d: #dump alu32.dump.
* testsuite/gas/bpf/alu.dump: New file.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu.d: #dump alu.dump.
* testsuite/gas/bpf/alu-be.dump: New file.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be.d: #dump alu-be.dump.
* testsuite/gas/bpf/alu32-be-pseudoc.d: New file.
* testsuite/gas/bpf/alu32-be-dump: Likewise.
* testsuite/gas/bpf/alu32-be.d: #dump alu32-be-dump.
* testsuite/gas/bpf/bpf.exp: Run *-pseudoc tests.
Tom Tromey [Thu, 27 Apr 2023 16:26:43 +0000 (10:26 -0600)]
Avoid some compiler warnings in gdb.ada
Running gdb.ada/verylong.exp shows a warning from the Ada compiler:
prog.adb:16:11: warning: file name does not match unit name, should be "main.adb" [enabled by default]
This patch fixes the problem, and another similar one in
unchecked_union.exp.
Michael Matz [Tue, 25 Apr 2023 15:10:05 +0000 (17:10 +0200)]
Fix PR30358, performance with --sort-section
since
af31506c we only use the binary tree when section sorting is
required. While its unbalanced and hence can degrade to a linear list
it should otherwise have been equivalent to the old code relying on
insertion sort. Unfortunately it was not. The old code directly used
lang_add_section to populate the sorted list, the new code first
populates the tree and only then does lang_add_section on the sorted
result.
In the testcase we have very many linkonce section groups, and hence
lang_add_section won't actually insert anything for most of them. That
limited the to-be-sorted list length previously. The tree-sorting code
OTOH first created a tree of all candidates sections, including those
that wouldn't be inserted by lang_add_section, hence increasing the size
of the sorting problem. In the testcase the chain length went from
about 1500 to 106000, and in the degenerated case (as in the testcase)
that goes in quadratically.
This splits out most of the early-out code from lang_add_section to its
own function and uses the latter to avoid inserting into the tree. This
refactoring slightly changes the order of early-out tests (the ones
based on section flags is now done last, and only in lang_add_section).
The new function is not a pure predicate: it can give warnings and it
might change output_section, like the old early-out code did. I have
also added a skip-warning case in the first discard case, whose
non-existence seemed to have been an oversight.
PR 30358
* ldlang.c (wont_add_section_p): Split out from ...
(lang_add_section): ... here.
(output_section_callback_sort): Use wont_add_section_p to not
always add sections to the sort tree.
Andrew Burgess [Mon, 24 Apr 2023 14:27:27 +0000 (15:27 +0100)]
gdb/doc: extend the documentation of the jump command
This commit addresses PR gdb/7946. While checking for bugs relating
to the jump command I noticed a long standing bug that points out a
deficiency with GDB's documentation of the jump command.
The bug points out that 'jump 0x...' is not always the same as 'set
$pc = 0x...' and then 'continue'. Writing directly to the $pc
register does not update any auxiliary state, e.g. $npc on SPARC,
while using 'jump' does.
It felt like this would be an easy issue to address by adding a
paragraph to the docs, so I took a stab at writing something suitable.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7946
Approved-By: Eli Zaretskii <eliz@gnu.org>
Andrew Burgess [Wed, 29 Mar 2023 09:41:07 +0000 (10:41 +0100)]
gdb/testsuite: special case '^' in gdb_test pattern
In this commit I propose that we add special handling for the '^' when
used at the start of a gdb_test pattern. Consider this usage:
gdb_test "some_command" "^command output pattern"
I think the intention here is pretty clear - run 'some_command', and
the output from the command should be exactly 'command output
pattern'.
After the previous commit which tightened up how gdb_test matches the
final newline and prompt we know that the only thing after the output
pattern will be a single newline and prompt, and the leading '^'
ensures that there's no output before 'command output pattern', so
this will do what I want, right?
... except it doesn't. The command itself will also needs to be
matched, so I should really write:
gdb_test "some_command" "^some_command\r\ncommand output pattern"
which will do what I want, right? Well, that's fine until I change
the command and include some regexp character, then I have to write:
gdb_test "some_command" \
"^[string_to_regexp some_command]\r\ncommand output pattern"
but this all gets a bit verbose, so in most cases I simply don't
bother anchoring the output with a '^', and a quick scan of the
testsuite would indicate that most other folk don't both either.
What I propose is this: the *only* thing that can appear immediately
after the '^' is the command converted into a regexp, so lets do that
automatically, moving the work into gdb_test. Thus, when I write:
gdb_test "some_command" "^command output pattern"
Inside gdb_test we will spot the leading '^' in the pattern, and
inject the regexp version of the command after the '^', followed by a
'\r\n'.
My hope is that given this new ability, folk will be more inclined to
anchor their output patterns when this makes sense to do so. This
should increase our ability to catch any unexpected output from GDB
that appears as a result of running a particular command.
There is one problem case we need to consider, sometime people do
this:
gdb_test "" "^expected output pattern"
In this case no command is sent to GDB, but we are still expecting
some output from GDB. This might be a result of some asynchronous
event for example. As there is no command sent to GDB (from the
gdb_test) there will be no command text to parse.
In this case my proposed new feature injects the command regexp, which
is the empty string (as the command itself is empty), but still
injects the '\r\n' after the command regexp, thus we end up with this
pattern:
^\r\nexpected output pattern
This extra '\r\n' is not what we should expected here, and so there is
a special case inside gdb_test -- if the command is empty then don't
add anything after the '^' character.
There are a bunch of tests that do already use '^' followed by the
command, and these can all be simplified in this commit.
I've tried to run all the tests that I can to check this commit, but I
am certain that there will be some tests that I manage to miss.
Apologies for any regressions this commit causes, hopefully fixing the
regressions will not be too hard.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 30 Mar 2023 12:26:25 +0000 (13:26 +0100)]
gdb/testsuite: change newline patterns used in gdb_test
This commit makes two changes to how we match newline characters in
the gdb_test proc.
First, for the newline pattern between the command output and the
prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'.
The old pattern would spot multiple newlines, and so there are a few
places where, as part of this commit, I've needed to add an extra
trailing '\r\n' to the pattern in the main test file, where GDB's
output actually includes a blank line.
But I think this is a good thing. If a command produces a blank line
then we should be checking for it, the current gdb_test doesn't do
that. But also, with the current gdb_test, if a blank line suddenly
appears in the output, this is going to be silently ignored, and I
think this is wrong, the test should fail in that case.
Additionally, the existing pattern will happily match a partial
newline. There are a strangely large number of tests that end with a
random '.' character. Not matching a literal period, but matching any
single character, this is then matching half of the trailing newline
sequence, while the \[\r\n\]+ in gdb_test is matching the other half
of the sequence. I can think of no reason why this would be
intentional, I suspect that the expected output at one time included a
period, which has since been remove, but I haven't bothered to check
on this. In this commit I've removed all these unneeded trailing '.'
characters.
The basic rule of gdb_test after this is that the expected pattern
needs to match everything up to, but not including the newline
sequence immediately before the GDB prompt. This is generally how the
proc is used anyway, so in almost all cases, this commit represents no
significant change.
Second, while I was cleaning up newline matching in gdb_test, I've
also removed the '[\r\n]*' that was added to the start of the pattern
passed to gdb_test_multiple.
The addition of this pattern adds no value. If the user pattern
matches at the start of a line then this would match against the
newline sequence. But, due to the '*', if the user pattern doesn't
match at the start of a line then this group doesn't care, it'll
happily match nothing.
As such, there's no value to it, it just adds more complexity for no
gain, so I'm removing it. No tests will need updating as a
consequence of this part of the patch.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 30 Mar 2023 12:26:13 +0000 (13:26 +0100)]
gdb/testsuite: use 'return' in gdb_test_no_output
A TCL proc will return the return value of the last command executed
within the proc's body if there is no explicit return call, so
gdb_test_no_output is already returning the return value of
gdb_test_multiple.
However, I'm not a fan of (relying on) this implicit return value
behaviour -- I prefer to be explicit about what we are doing. So in
this commit I have extended the comment on gdb_test_no_output to
document the possible return values (just as gdb_test does), and
explicitly call return.
This should make no different to our testing, but I think it's clearer
now what the gdb_test_no_output proc is expected to do.
The two tests gdb.base/auxv.exp and gdb.base/list.exp both rely on the
return value of gdb_test_no_output, and continue to pass after this
change.
I also spotted that gdb.base/watchpoint.exp could be updated to make
use of gdb_test_no_output, so I did that.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 30 Mar 2023 12:25:59 +0000 (13:25 +0100)]
gdb: remove some trailing newlines from warning messages
While working on a later patch in this series, which tightens up some
of our pattern matching when using gdb_test, I ran into some failures
caused by some warnings having a trailing newline character.
The warning function already adds a trailing newline, and it is my
understanding that we should not be adding a second by including a
newline at the end of any warning message.
The problem cases I found were in language.c and remote.c, in this
patch I fix the cases I hit, but I also checked all the other warning
calls in these two files and removed any additional trailing newlines
I found.
In remote.c the warning actually had a newline character in the middle
of the warning message (in addition to the trailing newline), which
I've removed. I don't think it's helpful to forcibly split a warning
as was done here -- in the middle of a sentence. Additionally, the
message isn't even that long (71 characters), so I think removing this
newline is an improvement.
None of the expected test result need updating with this commit,
currently the patterns in gdb_test will match one or more newline
sequences, so the tests are as happy with one newline (after this
commit) as they are with two newlines (before this commit). A later
commit will change gdb_test so that it is not so forgiving, and these
warnings would have caused some failures.
Reviewed-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 31 Mar 2023 15:41:27 +0000 (16:41 +0100)]
gdb/testsuite: fix occasional failure in gdb.base/clear_non_user_bp.exp
I noticed that the gdb.base/clear_non_user_bp.exp test would sometimes
fail when run from a particular directory.
The test tries to find the number of the first internal breakpoint
using this proc:
proc get_first_maint_bp_num { } {
gdb_test_multiple "maint info break" "find first internal bp num" {
-re -wrap "(-\[0-9\]).*" {
return $expect_out(1,string)
}
}
return ""
}
The problem is, at the time we issue 'maint info break' there are both
internal breakpoint and non-internal (user created) breakpoints in
place. The user created breakpoints include the path to the source
file.
Sometimes, I'll be working from a directory that includes a number,
like '/tmp/blah-1/gdb/etc', in which case the pattern above actually
matches the '-1' from 'blah-1'. In this case there's no significant
problem as it turns out that -1 is the number of the first internal
breakpoint.
Sometimes my directory name might be '/tmp/blah-4/gdb/etc', in which
case the above pattern patches '-4' from 'blah-4'. It turns out this
is also not a problem -- the test doesn't actually need the first
internal breakpoint number, it just needs the number of any internal
breakpoint.
But sometimes my directory name might be '/tmp/blah-0/gdb/etc', in
which case the pattern above matches '-0' from 'blah-0', and in this
case the test fails - there is no internal breakpoint '-0'.
Fix this by spotting that the internal breakpoint numbers always
occurs after a '\r\n', and that they never start with a 0. Our
pattern becomes:
-re -wrap "\r\n(-\[1-9\]\[0-9\]*).*" {
return $expect_out(1,string)
}
After this I'm no longer seeing any failures.
Reviewed-By: Tom Tromey <tom@tromey.com>
Tankut Baris Aktemur [Thu, 27 Apr 2023 11:36:08 +0000 (13:36 +0200)]
gdb, doc: add index entry for the $_inferior_thread_count convenience var
Add a marker in the documentation for indexing the $_inferior_thread_count
variable.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Nick Clifton [Thu, 27 Apr 2023 12:02:00 +0000 (13:02 +0100)]
Add support for %x and %lx formats to the linker's vinfo() function.