Before this change, "help" was not showing the TUI class.
With this change:
(gdb) help
...
support -- Support facilities.
text-user-interface -- TUI is the GDB text based interface.
tracepoints -- Tracing of program execution without stopping the program.
...
(gdb) help text-user-interface
TUI is the GDB text based interface.
In TUI mode, GDB can display several text windows showing
the source file, the processor registers, the program disassembly, ...
List of commands:
+ -- Scroll window forward.
...
Note that we cannot use "tui" for the fake class command name, as "tui"
is a command.
gdb/ChangeLog
2020-05-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* command.h: Add comment giving the name of class_tui.
* cli/cli-cmds.c (_initialize_cli_cmds): If TUI defined,
create the fake command for the help for class_tui.
In Ada, like C, an enum can assign values to the constants. However,
unlike C (or any other language supported by gdb), the enum type can
also be used as the range of an array.
In this case, the user's code references the enum constants, but the
compiler translates these to the position of the constant in the enum.
So for example one might write:
type Enum_With_Gaps is
(
LIT0,
LIT1,
LIT2,
LIT3,
LIT4
);
for Enum_With_Gaps use
(
LIT0 => 3,
LIT1 => 5,
LIT2 => 8,
LIT3 => 13,
LIT4 => 21
);
Then index an array like "array(LIT3)" -- but this will be the 4th
element in an array of 5 elements, not the 13th element in an array of
19 (assuming I did the math right) elements.
gdb supports this to some degree, with the only missing piece being
indexing into such an array. This patch implements this missing
feature, and also fixes an existing bug, which is that in some
situations I believe gdb would mis-compute the resulting array's
length.
The approach taken here is to try to integrate this feature into the
core of gdb. My view is that much of the Ada support should be better
integrated with gdb, rather than being "on the side". This, I think,
would help avoid code duplication at least. So, I try to take steps
toward this goal when possible.
Because other languages generally don't allow the user to specify the
index type of an array, I simply made the core of gdb unconditionally
apply discrete_position when computing the range of such an array.
This is a no-op for ordinary types, but applies the enum
value-to-position transformation for TYPE_CODE_ENUM.
gdb/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_print_array_index): Change type. Call val_atr.
(ada_value_ptr_subscript): Don't call pos_atr on the lower bound.
(val_atr): New function.
(value_val_atr): Use it.
* ada-valprint.c (print_optional_low_bound): Change low bound
handling for enums.
(val_print_packed_array_elements): Don't call discrete_position.
* gdbtypes.c (get_discrete_bounds) <TYPE_CODE_RANGE>: Call
discrete_position for enum types.
* language.c (default_print_array_index): Change type.
* language.h (struct language_defn) <la_print_array_index>: Add
index_type parameter, change type of index_value.
(LA_PRINT_ARRAY_INDEX): Add index_type parameter.
(default_print_array_index): Update.
* valprint.c (maybe_print_array_index): Don't call
value_from_longest. Update.
(value_print_array_elements): Don't call discrete_position.
gdb/testsuite/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/arr_acc_idx_w_gap.exp: Add tests.
In Ada, the 'val and 'pos attributes can be used to map from an
enumeration constant to its position in the enum and vice versa.
These operators did not work properly when the type in question was a
subrange of an enum type with "holes".
gdb/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE.
* gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE.
gdb/testsuite/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New
type.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New
variable.
Reported by sobukus on IRC.
gdb/testsuite/ChangeLog:
2020-05-26 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Use = instead of == for the test command
for portability.
Change-Id: I431ccfa5e5ba15f9af082ffd6aa8cd7046456cd2
Accept vector alignment hints on z13 although they are ignored there.
The advantage is that any binary compiled for architecture level z13 may
run on z14 or later and benefit from vector alignment hints.
gas/ChangeLog:
2020-05-18 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* testsuite/gas/s390/zarch-z13.d: Add regexp checks for vector
load/store instruction variants with alignment hints.
* testsuite/gas/s390/zarch-z13.s: Emit new vector load/store
instruction variants with alignment hints.
opcodes/ChangeLog:
2020-05-18 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* s390-opc.txt: Relocate vector load/store instructions with
additional alignment parameter and change architecture level
constraint from z14 to z13.
opcode/crx.h has
typedef enum
{
...
MAX_REG
}
reg;
typedef enum
{
c0 = MAX_REG,
}
copreg;
tc-crx.c has
static int
getreg_image (reg r)
{
...
/* Check whether the register is in registers table. */
if (r < MAX_REG)
rreg = &crx_regtab[r];
/* Check whether the register is in coprocessor registers table. */
else if (r < (int) MAX_COPREG)
rreg = &crx_copregtab[r-MAX_REG];
}
Change getreg_image's argument type to int and replace fragP->fr_literal
with &fragP->fr_literal[0] to silence GCC 10 warning.
PR gas/26044
* config/tc-crx.c (getreg_image): Change argument type to int.
(md_convert_frag): Replace fragP->fr_literal with
&fragP->fr_literal[0].
There's a PR binutils/15646 - "gold-generated .gdb_index has duplicated
symbols that gdb-generated index doesn't", and gdb contains a workaround,
added in commit 8943b87476 "Work around gold/15646".
Add a test-case testing this workaround.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-26 Tom de Vries <tdevries@suse.de>
* gdb.base/gold-gdb-index-2.c: New test.
* gdb.base/gold-gdb-index.c: New test.
* gdb.base/gold-gdb-index.exp: New file.
* gdb.base/gold-gdb-index.h: New test.
Add new target board that uses gold to add a .gdb_index section, enabled by
-ggnu-pubnames.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* boards/gold-gdb-index.exp: New file.
The AVR architecture is a Harvard one, meaning it has different memory
spaces for code and data. In GDB, this is dealt with by having the data
(SRAM) addresses start at 0x00800000. When interpreting an integer as
an address (converting to a CORE_ADDR), we currently always generate a
data address. This doesn't work for some cases described below, where
the integer is meant to represent a code address.
This patch changes avr_integer_to_address so that it generates the
correct type of address (code or data) based on the passed type.
Using the simavr.exp board, I didn't see any regressions when running
the gdb.base/*.exp tests. A few tests go from fail to pass, but none
from pass to fail. There are a few new fails and unresolved, but it's
just because some tests manage to make more progress before failing in a
different way.
In practice, it fixes disassembling by address, as described in the PR:
- (gdb) disassemble 0x12a,0x12b
- Dump of assembler code from 0x12a to 0x12b:
- 0x0000012a <main+0>: push r28
- End of assembler dump.
+ (gdb) disassemble 0x12a,0x12b
+ Dump of assembler code from 0x80012a to 0x80012b:
+ 0x0080012a: nop
+ End of assembler dump.
And also, setting a breakpoint by address:
- (gdb) p &main
- $1 = (int (*)(void)) 0x12a <main>
- (gdb) b *0x12a
- Breakpoint 1 at 0x80012a
+ (gdb) p &main
+ $1 = (int (*)(void)) 0x12a <main>
+ (gdb) b *0x12a
+ Breakpoint 1 at 0x12a: file test-avr.c, line 3.
+ Note: automatically using hardware breakpoints for read-only addresses.
gdb/ChangeLog:
PR gdb/13519
* avr-tdep.c (avr_integer_to_address): Return data or code
address accordingly to the second 'type' argument of the
function.
Change-Id: Iaea1587d053e86f4ab8aebdcabec8d31a6d262cd
This patch adds a board file for against a simavr target (so, for the
AVR architecture).
simavr, when started with option -g, runs a GDB stub on port 1234. In
the current latest release (1.6), the port is hardcoded to 1234. But in
master, there is the option to choose another port. So while the board
file hardcodes the port today, in the future it should be possible to
let the user choose a port, or automatically select a free port.
It is easy enough to run, make sure you have avr-gcc/avr-g++ and simavr
installed, and as usual just run:
make check RUNTESTFLAGS="--target_board=simavr"
The following environment variables influence the behavior of the board
file:
- SIMAVR_MCU: type of chip to simulate
- SIMAVR_PATH: path to simavr binary (useful if you build your own
simavr or for some reason it is not simply called `simavr`.
As expected, there are a lot of failures. Many tests use some features
not supported by such a target, and I suppose there are real GDB bugs
too. But a lot also passes (including tests that actually run stuff),
so this board file should still help to validate changes to the AVR
architecture support.
These are the results I got of running tests gdb.base/*.exp:
# of expected passes 20926
# of unexpected failures 2257
# of expected failures 14
# of unknown successes 1
# of known failures 13
# of unresolved testcases 592
# of untested testcases 156
# of unsupported tests 30
# of paths in test names 3
# of duplicate test names 56
gdb/testsuite/ChangeLog:
* boards/simavr.exp: New file.
Change-Id: Ib7fa8c4e2e90b08b104bb9b552df37779de3bc21
Add a test for verifying different methods of passing arguments to the
inferior: the start, starti and run commands, as well as `set args`.
All these methods work naturally when using the unix or
native-extended-gdbserver target boards. Since those are non-stub
boards, GDB runs new inferiors and therefore pass arguments to them.
With target boards where GDB connects to a stub, for example with
native-gdbserver, they don't really make sense. The inferior process is
already started when GDB connects.
However, the "run" method is still tested with stub targets, because the
gdb_run_cmd procedure is adapted for stub targets. Instead of issuing
the `run` command, it spawns whatever program is supposed to bring up
the stub (gdbserver, for example) using gdb_reload and makes GDB connect
to it. So this allows us to exercise argument passing through the
gdbserver command line, when testing with the native-gdbserver board.
Note that there is already a gdb.base/args.exp, but this tests
specifically the --args switch of GDB. Perhaps it could be integrated
in this new test, as a new "method".
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_run_cmd): Return success or failure.
* gdb.base/inferior-args.exp: New file.
* gdb.base/inferior-args.c: New file.
Change-Id: Ib61ea6220a47f9f67aed2960dcacd240cb57af70
This patch makes it possible to run tests requiring passing arguments to
the inferior with the native-gdbserver board. The end goal is to write
a test that verifies passing arguments to the inferior works, and to
have that test exercise inferior arguments passed on the gdbserver
command line, when using the native-gdbserver target board (in addition
to the other boards). This is done in the next patch.
With the native-gdbserver target board, gdbserver is started in
gdb_reload (implemented in config/gdbserver.exp), called in gdb_run_cmd.
gdb_run_cmd already supposedly accepts inferior arguments (although that
feature does not seem to be used anywhere), which it passes to the `run`
command, for non-stub target boards. I've changed gdb_run_cmd so that
it forwards these arguments to gdb_reload as well. gdb_reload passes
them to gdbserver_run, and they eventually make their way to the
gdbserver command line.
gdb_run_cmd currently accepts `args` (the varargs of tcl), which means
it receives inferior arguments as a list. This won't work with
arguments with spaces, because they will end up being formatted with
curly braces like this:
% set args [list hello "with spaces" world]
hello {with spaces} world
% puts "run $args"
run hello {with spaces} world
I've changed it to accept a single string that is passed to `run` and
gdb_reload. I've done the same change in gdb_start_cmd and
gdb_starti_cmd, although these two are not used with native-gdbserver.
I've changed all gdb_reload implementations in the tree to accept a new
inferior_args argument, although most of them don't do anything with it
(and don't need to). People maintaining target boards out of tree will
need to do the same.
I found two tests to adjust to avoid adding new failures or errors.
These tests needed new [use_gdb_stub] checks, because they rely on
having GDB run new processes. These are guarded by a [target_info
exists noargs], which made them get skipped on native-gdbserver. But
now that the native-gdbserver board supports args, this is no longer
enough.
Note that with this change, noargs and use_gdb_stub are orthogonal. It
took me a moment to grasp this, so I thought I would spell out the
different possible situations:
- !noargs and !use_gdb_stub: inferior process started by gdb, can pass
args
- noargs and !use_gdb_stub: inferior process started by gdb (perhaps
through extended-remote protocol, the simulator, some other target),
but that target doesn't support inferior arguments
- noargs and use_gdb_stub: inferior process started by some other
program to which GDB connects using the remote protocol, that program
does not support passing args to the inferior process
- !noargs and use_gdb_stub: inferior process started by some other
program to which GDB connects u sing the remote protocol, that program
supports passing args to the inferior process
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_run_cmd): Change argument from args to
inferior_args. Pass it to gdb_reload.
(gdb_start_cmd, gdb_starti_cmd): Change argument from args to
inferior_args.
(gdb_reload): Add inferior_args argument.
* config/gdbserver.exp (gdb_reload): Add inferior_args argument,
pass it to gdbserver_run.
* boards/native-gdbserver.exp: Do not set noargs.
* boards/native-extended-gdbserver.exp (gdb_reload): Add
inferior_args argument.
* boards/stdio-gdbserver-base.exp (gdb_reload): Likewise.
* gdb.base/a2-run.exp: Check for use_gdb_stub.
* gdb.base/args.exp: Likewise.
Change-Id: Ibda027c71867157852f34700342ab31edf39e4d8
The function did not properly escape special characters
and all uses have been replaced in previous commits, so
drop the now unused function.
gdbsupport/ChangeLog:
* common-utils.cc, common-utils.h (stringify_argv): Drop
now unused function stringify_argv
Change-Id: Id5f861f44eae1f0fbde3476a5eac23a842ed04fc
Use the construct_inferior_arguments function instead of
stringify_argv to construct a string from the program
arguments in those places where that one is then passed
to fork_inferior (linux-low, lyn-low), since
construct_inferior_arguments properly takes care of
special characters, while stringify_argv does not.
Using construct_inferior_arguments seems "natural", since its
documentation also mentions that it "does the
same shell processing as fork_inferior".
Since construct_inferior_args has been extended to do
proper quoting for Windows shells in commit
5d60742e2d
("Fix quoting of special characters for the MinGW build.",
2012-06-12), use it for the Windows case as well.
(I could not test that case myself, though.)
Adapt handling of empty args in function 'handle_v_run'
in gdbserver/server.cc to just insert an empty string
for an empty arg, since that one is now properly handled
in 'construct_inferior_arguments' already (and inserting
a "''" string in 'handle_v_run' would otherwise
cause that one to be treated as a string literally
containing two quote characters, which
'construct_inferior_args' would preserve by adding
extra escaping).
This makes gdbserver properly handle program args containing special
characters (like spaces), e.g. (example from PR25893)
$ gdbserver localhost:50505 myprogram "hello world"
now properly handles "hello world" as a single arg, not two separate
ones ("hello", "world").
gdbserver/ChangeLog:
PR gdbserver/25893
* linux-low.cc (linux_process_target::create_inferior),
lynx-low.cc (lynx_process_target::create_inferior),
win32-low.cc (win32_process_target::create_inferior): Use
construct_inferior_arguments instead of stringify_argv
to get string representation which properly escapes
special characters.
* server.cc (handle_v_run): Just pass empty program arg
as such, since any further processing is now handled via
construct_inferior_arguments.
Change-Id: Ibf963fcd51415c948840fb463289516b3479b0c3
According to [1], the fifth parameter
to the 'spawnp' function is 'char * const argv[]',
so just pass the args contained in the vector as
an array right away, rather than converting that
to a C string first and passing that one.
With commit 2090129c36
("Share fork_inferior et al with gdbserver",
2016-12-22) the type had changed from 'char **'
to 'char *', but I can't see an apparent reason for
that, and 'nto_procfs_target::create_inferior'
(in gdb/nto-procfs.c) also passes a 'char **' to
'spawnp' instead.
I do not know much about that target and cannot actually
test this, however.
The main motivation to look at this was identifying
and replacing the remaining uses of the 'stringify_argv'
function which does not properly do escaping.
[1] http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.lib_ref/topic/s/spawnp.html
gdbserver/ChangeLog:
* nto-low.cc (nto_process_target::create_inferior): Pass
argv to spawnp function as char **.
Change-Id: Ic46fe745c2aa1118114240d149d4156032f84344
The vector holding the program args is passed as a parameter
to target_create_inferior, which then passes it to
stringify_argv for all platforms, where any NULL entry in
the vector is ignored, so there seems to be no reason
to actually add one after all.
(Since the intention is to replace uses of stringify_argv with
construct_inferior_arguments in a follow-up commit and that
function doesn't currently handle such NULL arguments, it
would otherwise have to be extended.)
gdbserver/ChangeLog:
* server.cc (captured_main), (handle_v_run): No longer
insert extra NULL element to args vector.
Change-Id: Ia2ef6d36814a6b11ce8b0d6e3b33248a7945e825
Adapt the construct_inferior_arguments function to
take a gdb::array_view<char * const> parameter instead
of a char * array and an int indicating the length
and adapt the only call site.
This will allow calling it more simply in a follow-up
patch introducing more uses of the function.
gdbsupport/ChangeLog:
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to take a gdb::array_view<char * const> parameter.
Adapt call site.
Change-Id: I1c6496c8c0b0eb3ef3fda96e9e3bd64c5e6cac3c
Allow construct_inferior_arguments to handle zero args
and have it return a std::string, similar to how
stringify_argv in gdbsupport/common-utils does.
Also, add a const qualifier for the second parameter,
since it is only read, not written to.
The intention is to replace existing uses of
stringify_argv by construct_inferior_arguments
in a subsequent step, since construct_inferior_arguments
properly handles special characters, while stringify_argv
doesn't.
gdbsupport/ChangeLog:
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to handle zero args and return a std::string.
Adapt call site.
Change-Id: I126c4390a1018c7527b0b8fd545252ab8a5a7adc
This moves the function construct_inferior_arguments from
gdb/inferior.h and gdb/infcmd.c to gdbsupport/common-inferior.{h,cc}.
While at it, also move the function's comment to the header file
to align with current standards.
The intention is to use it from gdbserver in a follow-up commit.
gdb/ChangeLog:
* infcmd.c, inferior.h: (construct_inferior_arguments):
Moved function from here to gdbsupport/common-inferior.{h,cc}
gdbsupport/ChangeLog:
* common-inferior.h, common-inferior.cc: (construct_inferior_arguments):
Move function here from gdb/infcmd.c, gdb/inferior.h
Change-Id: Ib9290464ce8c0872f605d8829f88352d064c30d6
Add comment to exec_is_pie explaining why readelf -d output is not used.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (exec_is_pie): Add comment.
In commit 1b59ca1cf1 "[gdb/testsuite] Fix tcl error in jit-elf-helpers.exp", I
introduced a variable f in compile_and_download_n_jit_so, to be used in the
untested message, but actually variable binfile was used instead:
...
+ set f [file tail $binfile]
+ untested "failed to compile shared library $binfile"
...
Fix this by using $f in the untested message.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* lib/jit-elf-helpers.exp (compile_and_download_n_jit_so): Use $f
instead of $binfile in the untested message.
When running test-case gdb.base/break-interp.exp with target board gold, we
run into:
...
gdb compile failed, pie failed to generate PIE executable
...
The problem is that the proc exec_is_pie uses the PIE flag in the readelf -d
output, which doesn't seem to be set by the gold linker.
Instead, use the "Type" field in the readelf -h output.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
PR testsuite/26031
* lib/gdb.exp (exec_is_pie): Test readelf -h output.
Add a target board that uses the gold linker.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* boards/gold.exp: New file.
The frag code makes a distinction between inserting frags before the frag
chains are chained together and afterward. After chaining, we need to set
now_seg before creating the frag. tc-xtensa.c has a function called
fix_new_exp_in_seg that handles this right, but switches segments twice each
time it is called. In this case, we can inline it and pull the save and
restore out of the loop to get better code.
gas/
PR 26025
* config/tc-riscv.c (riscv_pre_output_hook): Change s type from const
asection to segT. New locals seg and subseg. Call subseg_set before
fix_new_exp. Call subseg_set after loop to restore original values.
It was suggested in this thread [1] that gdbarch.sh should write to
gdbarch.h and gdbarch.c directly. This patch implements that.
When running gdbarch.sh, we currently need to move new-gdbarch.c over
gdbarch.c and new-gdbarch.h over gdbarch.h. It might have been useful
at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
but with git it's really unnecessary. Any changes to gdbarch.sh can be
inspected using `git diff`.
A next step would be to have the Makefile automatically run gdbarch.sh
if it sees that gdbarch.c and gdbarch.h are out of date. Or maybe even
remove gdbarch.c and gdbarch.h from the tree and generate them in the
build directory when building. But that requires more thinking and
discussions, and I think that this change is already useful in itself.
[1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html
gdb/ChangeLog;
* gdbarch.sh: Write to gdbarch.c/gdbarch.h directly. Don't
compare old and new versions.
(compare_new): Remove.
Change-Id: I7970a9e8af0afc0145cb5a28e73d94fbaa1e25b9
completion_list_add_symbol currently tries to remove C++ function
aliases from the completions match list even if the symbol passed down
wasn't successfully added to the completion list because it didn't
match. I.e., we call cp_canonicalize_string_no_typedefs for each and
every C++ function in the program, which is useful work. This patch
skips that useless work.
gdb/ChangeLog:
2020-05-24 Pedro Alves <palves@redhat.com>
* symtab.c (completion_list_add_name): Return boolean indication
of whether the symbol matched.
(completion_list_add_symbol): Don't try to remove C++ aliases if
the symbol didn't match in the first place.
* symtab.h (completion_list_add_name): Return bool.
--dynamic-list* should work both before and after -Bsymbolic and
-Bsymbolic-functions.
PR ld/26018
* lexsup.c (parse_args): Simplify.
* testsuite/ld-elf/dl4e.out: New.
* testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
Replace all uses of it by type::field.
Note that since type::field returns a reference to the field, some spots
are used to assign the whole field structure. See ctfread.c, function
attach_fields_to_type, for example. This is the same as was happening
with the macro, so I don't think it's a problem, but if anybody sees a
really nicer way to do this, now could be a good time to implement it.
gdb/ChangeLog:
* gdbtypes.h (TYPE_FIELD): Remove. Replace all uses with
type::field.