We get this error when doing a build with a single amd64 target (the
default when doing just ./configure on x86-64 GNU/Linux):
/home/simark/src/binutils-gdb/gdb/i386-tdep.c:4431: error: undefined reference to 'x86_in_indirect_branch_thunk(unsigned long, char const**, int, int)'
/home/simark/src/binutils-gdb/gdb/amd64-tdep.c:3045: error: undefined reference to 'x86_in_indirect_branch_thunk(unsigned long, char const**, int, int)'
The problem is that commit
1d509aa625 ("infrun: step through indirect branch thunks")
missed adding x86-tdep.o to the list of object file included in an amd64
or i386 build. The problem is not seen with --enable-targets=all
because that file is included in ALL_TARGET_OBS.
Built-tested using:
* --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
* --host=armv7-rpi2-linux-gnueabihf --target=x86_64-pc-linux-gnu
gdb/ChangeLog:
* configure.tgt (x86_tobjs): New variable.
(amd64_tobjs, i386_tobjs): Use it.
Since only the first 32 bits of input operand are used for tpause and
umwait, the REX.W bit is skipped. Both 32-bit registers and 64-bit
registers are allowed.
gas/
* testsuite/gas/i386/x86-64-waitpkg.s: Add 32-bit registers
tests for tpause and umwait.
* testsuite/gas/i386/x86-64-waitpkg-intel.d: Updated.
* testsuite/gas/i386/x86-64-waitpkg.d: Likewise.
opcodes/
* i386-dis.c (prefix_table): Replace Em with Edq on tpause and
umwait.
* i386-opc.tbl: Allow 32-bit registers for tpause and umwait in
64-bit mode.
* i386-tbl.h: Regenerated.
When checking a R_ARM_TARGET[12] relocation, we need a valid target
pointer, but the garbage collection code was passing a NULL instead.
gold/
PR gold/23046
* gc.h (gc_process_relocs): Pass target to
scan.global_reloc_may_be_function_pointer.
max-page-size only matters for demand paged executables or shared
libraries, and the ideal size is the largest value used by your
operating system. Values larger than necessary just waste file space
and memory. common-page-size also affects file and memory size,
trading a possible small increase in file size for a decrease in
memory size when the operating system is using a common-page-size
page. With a powerpc max-page-size of 64k and common-page-size of 4k
many executables will use no more memory pages when the system page
size is 4k than an executable linked with -z max-page-size=0x1000,
yet will still run on a system using 64k pages. However, when running
on a system using 64k pages relro protection will not be completely
effective.
Due to the relro problem, powerpc binutils has been using a default
common-page-size of 64k since 2014-12-18 (git commit 04c6a44c7),
leading to complaints about increased file and memory sizes. People
not using relro do have a valid reason to complain..
So this patch introduces an extra back-end value to use as the default
for common-page-size when generating relro executables, and enables
the support for powerpc. Non relro executables will now be generated
with a default common-page-size of 4k.
bfd/
* elf-bfd.h (struct elf_backend_data): Add relropagesize.
* elfxx-target.h (ELF_RELROPAGESIZE): Provide default and
sanity test.
(elfNN_bed): Init relropagesize.
* bfd.c (bfd_emul_get_commonpagesize): Add boolean param to
select relropagesize.
* elf32-ppc.c (ELF_COMMONPAGESIZE): Define as 0x1000.
(ELF_RELROPAGESIZE): Define as ELF_MAXPAGESIZE.
(ELF_MINPAGESIZE): Don't define.
* elf64-ppc.c (ELF_COMMONPAGESIZE): Define as 0x1000.
(ELF_RELROPAGESIZE): Define as ELF_MAXPAGESIZE.
* bfd-in2.h: Regenerate.
ld/
* ldmain.c (main): Move config.maxpagesize and
config.commonpagesize initialization to..
* ldemul.c (after_parse_default): ..here.
* testsuite/ld-powerpc/ppc476-shared.d: Pass -z common-page-size.
* testsuite/ld-powerpc/ppc476-shared2.d: Likewise.
The default max-page-size on ppc32 has been 64k since 1995-02-15 (git
commit bcbe2c71). There was a change committed 2003-07-12 to chose a
4k page if __QNXTARGET__ is defined, but that particular commit was
from an earlier posted patch
https://sourceware.org/ml/binutils/2003-07/msg00211.html that only
made the change effective for arm, rather than the later one
https://sourceware.org/ml/binutils/2003-07/msg00220.html that also
changed powerpc and sh..
Since the __QNXTARGET__ #ifdef in elf32-ppc.c is ineffective unless
the user defines it in his or her CFLAGS, I'm removing that code.
* elf32-ppc.c (ELF_MAXPAGESIZE, ELF_COMMONPAGESIZE): Don't depend
on __QNXTARGET__ define.
Enabling shared lib tests showed the powerpc-lynxos target is broken,
and has been for a long time. The breakage happened in a 2005-05-07
patch of mine, git commit 3b36f7e62, I think. There have been no bug
reports I recall so it seems the target is dead. powerpc-windiss is
similarly broken.
This patch fixes the breakage, and puts the targets on the obsolete
list.
bfd/
* config.bfd: Add powerpc-*-lynxos* and powerpc-*-windiss*
to obsolete list.
ld/
* emulparams/elf32ppcwindiss.sh: Rewrite to use elf32ppc.sh.
* emulparams/ppclynx.sh: Likewise.
The GDB commands "info variables", "info functions", and "info types" show
the appropriate list of definitions matching the given pattern. They also
group them by source files. But no line numbers within these source files
are shown.
The line number information is particularly useful to the user when a
simple "grep" doesn't readily point to a definition. This is often the
case when the definition involves a macro, occurs within a namespace, or
when the identifier appears very frequently in the source file.
This patch enriches the printout of these commands by the line numbers and
adjusts affected test cases to the changed output where necessary. The
new output looks like this:
(gdb) i variables
All defined variables:
File foo.c:
3: const char * const foo;
1: int x;
The line number is followed by a colon and a tab character, which is then
followed by the symbol definition. If no line number is available, the
tab is printed out anyhow, so definitions line up.
gdb/ChangeLog:
* symtab.c (print_symbol_info): Precede the symbol definition by
the line number when available.
* NEWS: Advertise this enhancement.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Mention the fact that "info
variables/functions/types" show source files and line numbers.
gdb/testsuite/ChangeLog:
* gdb.ada/info_types.exp: Adjust expected output to the line
numbers now printed by "info var/func/type".
* gdb.base/completion.exp: Likewise.
* gdb.base/included.exp: Likewise.
* gdb.cp/cp-relocate.exp: Likewise.
* gdb.cp/cplusfuncs.exp: Likewise.
* gdb.cp/namespace.exp: Likewise.
* gdb.dwarf2/dw2-case-insensitive.exp: Likewise.
Add new set/show commands to set the processor that is used for enabling
errata workarounds when decoding branch trace.
The general format is "<vendor>:<identifier>" but we also allow two
special values "auto" and "none".
The default is "auto", which is the current behaviour of having GDB
determine the processor on which the trace was recorded.
If that cpu is not known to the trace decoder, e.g. when using an old
decoder on a new system, decode may fail with "unknown cpu". In most
cases it should suffice to 'downgrade' decode to assume an older cpu.
Unfortunately, we can't do this automatically.
The other special value, "none", disables errata workarounds.
gdb/
* NEWS (New options): announce set/show record btrace cpu.
* btrace.c: Include record-btrace.h.
(btrace_compute_ftrace_pt): Skip enabling errata workarounds if
the vendor is unknown.
(btrace_compute_ftrace_1): Add cpu parameter. Update callers.
Maybe overwrite the btrace configuration's cpu.
(btrace_compute_ftrace): Add cpu parameter. Update callers.
(btrace_fetch): Add cpu parameter. Update callers.
(btrace_maint_update_pt_packets): Call record_btrace_get_cpu.
Maybe overwrite the btrace configuration's cpu. Skip enabling
errata workarounds if the vendor is unknown.
* python/py-record-btrace.c: Include record-btrace.h.
(recpy_bt_begin, recpy_bt_end, recpy_bt_instruction_history)
(recpy_bt_function_call_history): Call record_btrace_get_cpu.
* record-btrace.c (record_btrace_cpu_state_kind): New.
(record_btrace_cpu): New.
(set_record_btrace_cpu_cmdlist): New.
(record_btrace_get_cpu): New.
(require_btrace_thread, record_btrace_info)
(record_btrace_resume_thread): Call record_btrace_get_cpu.
(cmd_set_record_btrace_cpu_none): New.
(cmd_set_record_btrace_cpu_auto): New.
(cmd_set_record_btrace_cpu): New.
(cmd_show_record_btrace_cpu): New.
(_initialize_record_btrace): Initialize set/show record btrace cpu
commands.
* record-btrace.h (record_btrace_get_cpu): New.
testsuite/
* gdb.btrace/cpu.exp: New.
doc/
* gdb.texinfo: Document set/show record btrace cpu.
Alan Hayward pointed out a typo in the output of "set record btrace" that
I took from "set record". Fix the original.
gdb/
* record.c (set_record_command): Fix typo in message.
Instead of giving a message that "set record btrace" needs a sub-command,
GDB crashed. Fix it. A regression test comes with the next patch.
gdb/
* record-btrace.c (cmd_set_record_btrace): Print sub-commands.
With version 7.3 GCC supports new options
-mindirect-branch=<choice>
-mfunction-return=<choice>
The choices are:
keep behaves as before
thunk jumps through a thunk
thunk-external jumps through an external thunk
thunk-inline jumps through an inlined thunk
For thunk and thunk-external, GDB would, on a call to the thunk, step into
the thunk and then resume to its caller assuming that this is an
undebuggable function. On a return thunk, GDB would stop inside the
thunk.
Make GDB step through such thunks instead.
Before:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
30 }
After:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
inc (x=41) at gdb.base/step-indirect-call-thunk.c:23
23 return x + 1;
This is independent of the step-mode. In order to step into the thunk,
you would need to use stepi.
When stepping over an indirect call thunk, GDB would first step through
the thunk, then recognize that it stepped into a sub-routine and resume to
the caller (of the thunk). Not sure whether this is worth optimizing.
Thunk detection is implemented via gdbarch. I implemented the methods for
IA. Other architectures may run into unexpected fails.
The tests assume a fixed number of instruction steps to reach a thunk.
This depends on the compiler as well as the architecture. They may need
adjustments when we add support for more architectures. Or we can simply
drop those tests that cover being able to step into thunks using
instruction stepping.
When using an older GCC, the tests will fail to build and will be reported
as untested:
Running .../gdb.base/step-indirect-call-thunk.exp ...
gdb compile failed, \
gcc: error: unrecognized command line option '-mindirect-branch=thunk'
gcc: error: unrecognized command line option '-mfunction-return=thunk'
=== gdb Summary ===
# of untested testcases 1
gdb/
* infrun.c (process_event_stop_test): Call
gdbarch_in_indirect_branch_thunk.
* gdbarch.sh (in_indirect_branch_thunk): New.
* gdbarch.c: Regenerated.
* gdbarch.h: Regenerated.
* x86-tdep.h: New.
* x86-tdep.c: New.
* Makefile.in (ALL_TARGET_OBS): Add x86-tdep.o.
(HFILES_NO_SRCDIR): Add x86-tdep.h.
(ALLDEPFILES): Add x86-tdep.c.
* arch-utils.h (default_in_indirect_branch_thunk): New.
* arch-utils.c (default_in_indirect_branch_thunk): New.
* i386-tdep: Include x86-tdep.h.
(i386_in_indirect_branch_thunk): New.
(i386_elf_init_abi): Set in_indirect_branch_thunk gdbarch
function.
* amd64-tdep: Include x86-tdep.h.
(amd64_in_indirect_branch_thunk): New.
(amd64_init_abi): Set in_indirect_branch_thunk gdbarch function.
testsuite/
* gdb.base/step-indirect-call-thunk.exp: New.
* gdb.base/step-indirect-call-thunk.c: New.
* gdb.reverse/step-indirect-call-thunk.exp: New.
* gdb.reverse/step-indirect-call-thunk.c: New.
Since moving Rust enum handling into dwarf2read.c, some old code for
handling univariant enums in rust-lang.c has been obsolete. This
patch removes this code.
Tested on x86-64 Fedora 26, using rustc 1.23 (1.24 emits incorrect
DWARF for enums and so can't be used for this test).
2018-04-12 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_print_struct_def): Remove univariant code.
(rust_evaluate_subexp): Likewise.
This commit fixes a bit of rot in procfs.c caused by recent changes.
Specifically, the target_ops::to_detach change to pass down 'inferior
*' missed updating a forward declation, and the change to use
scoped_fd in more places missed removing one do_cleanups call.
src/gdb/procfs.c: In function ‘target_ops* procfs_target()’:
src/gdb/procfs.c:167:16: error: invalid conversion from ‘void (*)(target_ops*, const char*, int)’ to ‘void (*)(target_ops*, inferior*, int)’ [-fpermissive]
t->to_detach = procfs_detach;
^
src/gdb/procfs.c: In function ‘ssd* proc_get_LDT_entry(procinfo*, int)’:
src/gdb/procfs.c:1624:17: error: ‘old_chain’ was not declared in this scope
do_cleanups (old_chain);
^
src/gdb/procfs.c: At global scope:
src/gdb/procfs.c:90:13: error: ‘void procfs_detach(target_ops*, const char*, int)’ declared ‘static’ but never defined [-Werror=unused-function]
static void procfs_detach (struct target_ops *, const char *, int);
^
src/gdb/procfs.c:1923:1: error: ‘void procfs_detach(target_ops*, inferior*, int)’ defined but not used [-Werror=unused-function]
procfs_detach (struct target_ops *ops, inferior *inf, int from_tty)
^
gdb/ChangeLog:
2018-04-12 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_detach): Make forward declaration's prototype
match definition's protototype.
(proc_get_LDT_entry): Remove stale do_cleanups call.
Commit
b2e586e ("Defer breakpoint reset when cloning progspace for fork
child")
fixed following fork childs when the executable is position-independent.
This patch adds a little test for it.
gdb/testsuite/ChangeLog:
* gdb.base/pie-fork.c: New file.
* gdb.base/pie-fork.exp: New file.
Building with --coverage pointed out that there was no Rust test for
initializing a structure using the ".." initializer. This patch adds
such a test.
Regression tested on x86-64 Fedora 26.
2018-04-11 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Add test for ".." struct initializer.
These targets use the ELF format according to `bfd/config.bfd'.
binutils/
* testsuite/lib/binutils-common.exp (is_elf_format): Also return
1 for `*-*-lynxos*' and `*-*-symbianelf*' targets.
A future patch will propose making the remote target's target_ops be
heap-allocated (to make it possible to have multiple instances of
remote targets, for multiple simultaneous connections), and will
delete/destroy the remote target at target_close time.
That change trips on a latent problem, though. File I/O handles
remain open even after the target is gone, with a dangling pointer to
a target that no longer exists. This results in GDB crashing when it
calls the target_ops backend associated with the file handle:
(gdb) Disconnect
Ending remote debugging.
* GDB crashes deferencing a dangling pointer
Backtrace:
#0 0x00007f79338570a0 in main_arena () at /lib64/libc.so.6
#1 0x0000000000858bfe in target_fileio_close(int, int*) (fd=1, target_errno=0x7ffe0499a4c8)
at src/gdb/target.c:2980
#2 0x00000000007088bd in gdb_bfd_iovec_fileio_close(bfd*, void*) (abfd=0x1a631b0, stream=0x223c9d0)
at src/gdb/gdb_bfd.c:353
#3 0x0000000000930906 in opncls_bclose (abfd=0x1a631b0) at src/bfd/opncls.c:528
#4 0x0000000000930cf9 in bfd_close_all_done (abfd=0x1a631b0) at src/bfd/opncls.c:768
#5 0x0000000000930cb3 in bfd_close (abfd=0x1a631b0) at src/bfd/opncls.c:735
#6 0x0000000000708dc5 in gdb_bfd_close_or_warn(bfd*) (abfd=0x1a631b0) at src/gdb/gdb_bfd.c:511
#7 0x00000000007091a2 in gdb_bfd_unref(bfd*) (abfd=0x1a631b0) at src/gdb/gdb_bfd.c:615
#8 0x000000000079ed8e in objfile::~objfile() (this=0x2154730, __in_chrg=<optimized out>)
at src/gdb/objfiles.c:682
#9 0x000000000079fd1a in objfile_purge_solibs() () at src/gdb/objfiles.c:1065
#10 0x00000000008162ca in no_shared_libraries(char const*, int) (ignored=0x0, from_tty=1)
at src/gdb/solib.c:1251
#11 0x000000000073b89b in disconnect_command(char const*, int) (args=0x0, from_tty=1)
at src/gdb/infcmd.c:3035
This goes unnoticed in current master, because the current remote
target's target_ops is never destroyed nowadays, so we end up calling:
remote_hostio_close -> remote_hostio_send_command
which gracefully fails with FILEIO_ENOSYS if remote_desc is NULL
(because the target is closed).
Fix this by invalidating a target's file I/O handles when the target
is closed.
With this change, remote_hostio_send_command no longer needs to handle the
case of being called with a closed remote target, originally added here:
<https://sourceware.org/ml/gdb-patches/2008-08/msg00359.html>.
gdb/ChangeLog:
2018-04-11 Pedro Alves <palves@redhat.com>
* target.c (fileio_fh_t::t): Add comment.
(target_fileio_pwrite, target_fileio_pread, target_fileio_fstat)
(target_fileio_close): Handle a NULL target.
(invalidate_fileio_fh): New.
(target_close): Call it.
* remote.c (remote_hostio_send_command): No longer check whether
remote_desc is open.
Preparation for the next patch.
- Replace VEC with std::vector.
- Rewrite a couple macros as methods/functions.
- While at it, rename fileio_fh_t::fd as fileio_fh_t::target_fd to
avoid confusion between target and host file descriptors.
gdb/ChangeLog:
2018-04-11 Pedro Alves <palves@redhat.com>
* target.c (fileio_fh_t): Make it a named struct instead of a
typedef.
(fileio_fh_t::is_closed): New method.
(DEF_VEC_O (fileio_fh_t)): Remove.
(fileio_fhandles): Now a std::vector.
(is_closed_fileio_fh): Delete.
(acquire_fileio_fd): Adjust. Rename parameters.
(release_fileio_fd): Adjust.
(fileio_fd_to_fh): Reimplement as a function instead of a macro.
(target_fileio_pwrite, target_fileio_pread, target_fileio_fstat)
(target_fileio_close): Adjust.
As reported by Jan, we get this error when building with -D_GLIBCXX_DEBUG:
/usr/include/c++/7/debug/safe_iterator.h:297:
Error: attempt to increment a singular iterator.
Objects involved in the operation:
iterator "this" @ 0x0x7fffffffd140 {
type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::unique_ptr<char, gdb::xfree_deleter<char> >*, std::__cxx1998::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > >, std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > > (mutable iterator);
state = singular;
references sequence with type 'std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > >' @ 0x0x265db40
}
The bug was introduced by commit
commit e80aaf6183
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Fri Mar 2 23:22:06 2018 -0500
Make delim_string_to_char_ptr_vec return an std::vector
The problem is that we iterate using a range-based for on a vector to
which we push in the loop. Pushing to the vector invalidates the
iterator used in the loop. Instead, change the code to iterate by index
as was done in the previous code.
gdb/ChangeLog:
* auto-load.c (auto_load_safe_path_vec_update): Iterate by
index.
On my multi-target branch I was occasionaly seeing a FAIL like this:
(gdb) PASS: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill parent
[Inferior 2 (process 32672) exited normally]
kill inferior 2
warning: Inferior ID 2 is not running.
(gdb) FAIL: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill child (the program exited)
... other similar fails ...
Turns out to be a testcase bug/race. A tweak like this increases the
changes of hitting the race substancially:
--- a/gdb/testsuite/gdb.base/fork-running-state.c
+++ b/gdb/testsuite/gdb.base/fork-running-state.c
@@ -29,7 +29,7 @@ fork_child (void)
{
while (1)
{
- sleep (1);
+ usleep (100);
The testcase has two processes, parent and child fork. The problem is
that the child exits itself if it notices the parent is gone, but the
testcase .exp does not expect that.
I first wrote a patch that handled the different combinations of
non-stop/detach-on-fork/follow-fork/schedule-multiple, making the .exp
file know when to expect the child to exit itself vs when to kill it
explicitly, but the result was that the code to kill the parent and
child was getting about as large as the test code that is the actual
point of the testcase, above the kills.
So I scratched that approach and came up with a simpler patch --
simply make the child not exit itself when the parent exits.
The .exp file is going to kill both parent and child explicitly, and,
main() already calls alarm() as a safeguard. I don't think we lose
anything.
gdb/testsuite/ChangeLog:
2018-04-10 Pedro Alves <palves@redhat.com>
* gdb.base/fork-running-state.c (fork_child): Don't exit if parent
exits. Instead loop running forever.
(fork_parent): Run forever too.
Fixes these fails:
nds32le-linux +FAIL: binutils-all/strip-14
nds32le-linux +FAIL: binutils-all/strip-15
pru-elf +FAIL: binutils-all/strip-14
pru-elf +FAIL: binutils-all/strip-15
strip-13 fails on nds32 due to an assertion failure and out of bounds
access to nds32_elf_howto_table.
* testsuite/binutils-all/objcopy.exp (strip-14, strip-15): Choose
reloc=11 for pru and reloc=50 for nds32.
* testsuite/binutils-all/strip-15.d: Accept 0xb reloc number.
Add some selftests for these two functions. To to make it easier to
compare sequences of ranges, add operator== and operator!= to compare
two gdb::array_view, and add operator== in struct range.
gdb/ChangeLog:
* value.c: Include "selftest.h" and "common/array-view.h".
(struct range) <operator ==>: New.
(test_ranges_contain): New.
(check_ranges_vector): New.
(test_insert_into_bit_range_vector): New.
(_initialize_values): Register selftests.
* common/array-view.h (operator==, operator!=): New.
This patch replaces VEC(inline_state) with std::vector<inline_state> and
adjusts the code that uses it.
gdb/ChangeLog:
* common/gdb_vecs.h (unordered_remove): Add overload that takes
an iterator.
* inline-frame.c: Include <algorithm>.
(struct inline_state): Add constructor.
(inline_state_s): Remove.
(DEF_VEC_O(inline_state_s)): Remove.
(inline_states): Change type to std::vector.
(find_inline_frame_state): Adjust to std::vector.
(allocate_inline_frame_state): Remove.
(clear_inline_frame_state): Adjust to std::vector.
(skip_inline_frames): Adjust to std::vector.
This patch removes VEC(tsv_s), using an std::vector instead. I C++ified
trace_state_variable a bit in the process, using std::string for the
name. I also thought it would be nicer to pass a const reference to
target_download_trace_state_variable, since we know it will never be
NULL. This highlighted that the make-target-delegates script didn't
handle references well, so I adjusted this as well. It will surely be
useful in the future.
gdb/ChangeLog:
* tracepoint.h (struct trace_state_variable): Add constructor.
<name>: Change type to std::string.
* tracepoint.c (tsv_s): Remove.
(DEF_VEC_O(tsv_s)): Remove.
(tvariables): Change to std::vector.
(create_trace_state_variable): Adjust to std::vector.
(find_trace_state_variable): Likewise.
(find_trace_state_variable_by_number): Likewise.
(delete_trace_state_variable): Likewise.
(trace_variable_command): Adjust to std::string.
(delete_trace_variable_command): Likewise.
(tvariables_info_1): Adjust to std::vector.
(save_trace_state_variables): Likewise.
(start_tracing): Likewise.
(merge_uploaded_trace_state_variables): Adjust to std::vector
and std::string.
* target.h (struct target_ops)
<to_download_trace_state_variable>: Pass reference to
trace_state_variable.
* target-debug.h (target_debug_print_const_trace_state_variable_r): New.
* target-delegates.c: Re-generate.
* mi/mi-interp.c (mi_tsv_created): Adjust to std::string.
(mi_tsv_deleted): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise.
* remote.c (remote_download_trace_state_variable): Change
pointer to reference and adjust.
* make-target-delegates (parse_argtypes): Handle references.
(write_function_header): Likewise.
(munge_type): Likewise.
The previous patch copied the string_view tests from libstdc++. This
patch adjusts them in a similar way that the libstdc++ optional tests
are integrated in our unit test suite.
Not all tests are used, some of them require language features not
present in c++11. For example, we can't use a string_view constructor
where the length is not explicit in a constexpr, because
std::char_traits::length is not a constexpr itself (it is in c++17
though). Nevertheless, a good number of tests are integrated, which
covers pretty well the string_view features.
gdb/ChangeLog:
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
string_view-selftests.c.
* unittests/basic_string_view/capacity/1.cc: Adapt to GDB
testsuite.
* unittests/basic_string_view/cons/char/1.cc: Likewise.
* unittests/basic_string_view/cons/char/2.cc: Likewise.
* unittests/basic_string_view/cons/char/3.cc: Likewise.
* unittests/basic_string_view/element_access/char/1.cc:
Likewise.
* unittests/basic_string_view/element_access/char/empty.cc:
Likewise.
* unittests/basic_string_view/element_access/char/front_back.cc:
Likewise.
* unittests/basic_string_view/inserters/char/2.cc: Likewise.
* unittests/basic_string_view/modifiers/remove_prefix/char/1.cc:
Likewise.
* unittests/basic_string_view/modifiers/remove_suffix/char/1.cc:
Likewise.
* unittests/basic_string_view/modifiers/swap/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/compare/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/compare/char/13650.cc:
Likewise.
* unittests/basic_string_view/operations/copy/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/data/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/find/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/find/char/2.cc:
Likewise.
* unittests/basic_string_view/operations/find/char/3.cc:
Likewise.
* unittests/basic_string_view/operations/find/char/4.cc:
Likewise.
* unittests/basic_string_view/operations/rfind/char/1.cc:
Likewise.
* unittests/basic_string_view/operations/rfind/char/2.cc:
Likewise.
* unittests/basic_string_view/operations/rfind/char/3.cc:
Likewise.
* unittests/basic_string_view/operations/substr/char/1.cc:
Likewise.
* unittests/basic_string_view/operators/char/2.cc: Likewise.
* unittests/string_view-selftests.c: New file.
This patch copies the string_view tests from the gcc repository (commit
02a4441f002c).
${gcc}/libstdc++-v3/testsuite/21_strings/basic_string_view ->
${binutils-gdb}/gdb/unittests/basic_string_view
The local modifications are done in the following patch, so that it's
easier to review them.
gdb/ChangeLog:
* unittests/basic_string_view/capacity/1.cc: New file.
* unittests/basic_string_view/capacity/empty_neg.cc: New file.
* unittests/basic_string_view/cons/char/1.cc: New file.
* unittests/basic_string_view/cons/char/2.cc: New file.
* unittests/basic_string_view/cons/char/3.cc: New file.
* unittests/basic_string_view/cons/wchar_t/1.cc: New file.
* unittests/basic_string_view/cons/wchar_t/2.cc: New file.
* unittests/basic_string_view/cons/wchar_t/3.cc: New file.
* unittests/basic_string_view/element_access/char/1.cc: New file.
* unittests/basic_string_view/element_access/char/2.cc: New file.
* unittests/basic_string_view/element_access/char/empty.cc: New file.
* unittests/basic_string_view/element_access/char/front_back.cc: New file.
* unittests/basic_string_view/element_access/wchar_t/1.cc: New file.
* unittests/basic_string_view/element_access/wchar_t/2.cc: New file.
* unittests/basic_string_view/element_access/wchar_t/empty.cc: New file.
* unittests/basic_string_view/element_access/wchar_t/front_back.cc: New file.
* unittests/basic_string_view/include.cc: New file.
* unittests/basic_string_view/inserters/char/1.cc: New file.
* unittests/basic_string_view/inserters/char/2.cc: New file.
* unittests/basic_string_view/inserters/char/3.cc: New file.
* unittests/basic_string_view/inserters/pod/10081-out.cc: New file.
* unittests/basic_string_view/inserters/wchar_t/1.cc: New file.
* unittests/basic_string_view/inserters/wchar_t/2.cc: New file.
* unittests/basic_string_view/inserters/wchar_t/3.cc: New file.
* unittests/basic_string_view/literals/types.cc: New file.
* unittests/basic_string_view/literals/values.cc: New file.
* unittests/basic_string_view/modifiers/remove_prefix/char/1.cc: New file.
* unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc: New file.
* unittests/basic_string_view/modifiers/remove_suffix/char/1.cc: New file.
* unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc: New file.
* unittests/basic_string_view/modifiers/swap/char/1.cc: New file.
* unittests/basic_string_view/modifiers/swap/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/compare/char/1.cc: New file.
* unittests/basic_string_view/operations/compare/char/13650.cc: New file.
* unittests/basic_string_view/operations/compare/char/2.cc: New file.
* unittests/basic_string_view/operations/compare/char/70483.cc: New file.
* unittests/basic_string_view/operations/compare/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/compare/wchar_t/13650.cc: New file.
* unittests/basic_string_view/operations/compare/wchar_t/2.cc: New file.
* unittests/basic_string_view/operations/copy/char/1.cc: New file.
* unittests/basic_string_view/operations/copy/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/data/char/1.cc: New file.
* unittests/basic_string_view/operations/data/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/find/char/1.cc: New file.
* unittests/basic_string_view/operations/find/char/2.cc: New file.
* unittests/basic_string_view/operations/find/char/3.cc: New file.
* unittests/basic_string_view/operations/find/char/4.cc: New file.
* unittests/basic_string_view/operations/find/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/find/wchar_t/2.cc: New file.
* unittests/basic_string_view/operations/find/wchar_t/3.cc: New file.
* unittests/basic_string_view/operations/find/wchar_t/4.cc: New file.
* unittests/basic_string_view/operations/rfind/char/1.cc: New file.
* unittests/basic_string_view/operations/rfind/char/2.cc: New file.
* unittests/basic_string_view/operations/rfind/char/3.cc: New file.
* unittests/basic_string_view/operations/rfind/wchar_t/1.cc: New file.
* unittests/basic_string_view/operations/rfind/wchar_t/2.cc: New file.
* unittests/basic_string_view/operations/rfind/wchar_t/3.cc: New file.
* unittests/basic_string_view/operations/string_conversion/1.cc: New file.
* unittests/basic_string_view/operations/substr/char/1.cc: New file.
* unittests/basic_string_view/operations/substr/wchar_t/1.cc: New file.
* unittests/basic_string_view/operators/char/2.cc: New file.
* unittests/basic_string_view/operators/wchar_t/2.cc: New file.
* unittests/basic_string_view/range_access/char/1.cc: New file.
* unittests/basic_string_view/range_access/wchar_t/1.cc: New file.
* unittests/basic_string_view/requirements/explicit_instantiation/1.cc: New file.
* unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc: New file.
* unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc: New file.
* unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc: New file.
* unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc: New file.
* unittests/basic_string_view/requirements/typedefs.cc: New file.
* unittests/basic_string_view/typedefs.cc: New file.
* unittests/basic_string_view/types/1.cc: New file.
We had a few times the need for a data structure that does essentially
what C++17's std::string_view does, which is to give an std::string-like
interface (only the read-only operations) to an arbitrary character
buffer.
This patch adapts the files copied from libstdc++ by the previous patch
to integrate them with GDB. Here's a summary of the changes:
* Remove things related to wstring_view, u16string_view and
u32string_view (I don't think we need them, but we can always add them
later).
* Remove usages of _GLIBCXX_BEGIN_NAMESPACE_VERSION and
_GLIBCXX_END_NAMESPACE_VERSION.
* Put the code in the gdb namespace. I had to add a few "std::" in
front of std type usages.
* Change __throw_out_of_range_fmt() for error().
* Make gdb::string_view an alias of std::string_view when building
with >= c++17.
* Remove a bunch of constexpr, because they are not valid in c++11
(e.g. they are not a single return line).
* Use std::common_type<_Tp>::type instead of std::common_type_t<_Tp>,
because c++11 doesn't have the later.
* Remove the #pragma GCC system_header, since that silences some
warnings that we might want to have if we're doing something not
correctly.
* Remove operator ""sv. It would need a lot of work to make all
supported compilers happy, and we can easily live without it.
* Remove operator<<. It is implemented using __ostream_insert (a
libstdc++ internal). Bringing it in might be possible, but I don't
think that would be worth the effort, since we don't really use
streams at the moment.
* Replace internal libstdc++ asserts ( __glibcxx_assert and
__glibcxx_requires_string_len) with gdb_assert.
* Remove hash helpers, because they use libstdc++ internal functions.
If we need them we always import them later.
The string_view class in cli/cli-script.c is removed and its usage
replaced with the new gdb::string_view.
gdb/ChangeLog:
* common/gdb_string_view.h: Remove libstdc++ implementation
details, adjust to gdb reality.
* common/gdb_string_view.tcc: Likewise.
* cli/cli-script.c (struct string_view): Remove.
(user_args) <m_args>: Change element type to gdb::string_view.
(user_args::insert_args): Adjust.
This patch copies the following files from libstdc++ (commit
02a4441f002c):
${gcc}/libstdc++-v3/include/experimental/string_view
-> ${binutils-gdb}/gdb/common/gdb_string_view.h
${gcc}/libstdc++-v3/include/experimental/bits/string_view.tcc
-> ${binutils-gdb}/gdb/common/gdb_string_view.tcc
The local modifications are done in the following patch in order to make
it easier to review them.
gdb/ChangeLog:
* common/gdb_string_view.h: New file.
* common/gdb_string_view.tcc: New file.
This file provides the AX_CXX_COMPILE_STDCXX macro. In the context of
the following patch, I wanted to build and test GDB in c++17 mode. The
version of the macro we have in the repo does not support detecting
c++17 compilers, but the upstream version has been updated to do so.
Since we have local modifications to the file, I had to reconcile our
modifications and the updated upstream version (which was relatively
straightforward).
gdb/ChangeLog:
* ax_cxx_compile_stdcxx.m4: Sync with upstream.
* configure: Re-generate.
The gold change is to pick up HJ's PR22318 AC_PLUGINS update. The
ld change is to correct a file I generated from a modified tree.
gold/
* configure: Regenerate.
ld/
* po/BLD-POTFILES.in: Regenerate.