In https://github.com/rust-lang/rust/pull/46457, "m4b" pointed out
that the Rust support in gdb doesn't properly handle the lookup of
qualified names.
In particular, as shown in the test case in this patch, something like
"::NAME" should be found in the global scope, but is not.
This turns out to happen because rust_lookup_symbol_nonlocal does not
search the global scope unless the name in question is unqualified.
However, lookup_symbol_aux does not search the global scope, and
appears to search the static scope only as a fallback (I wonder if
this is needed?).
This patch fixes the problem by changing rust_lookup_symbol_nonlocal
to search the static and global blocks in more cases.
Regression tested against various versions of the rust compiler on
Fedora 26 x86-64. (Note that there are unrelated failures with newer
versions of rustc; I will be addressing those separately.)
2018-01-19 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_lookup_symbol_nonlocal): Look up qualified
symbols in the static and global blocks.
2018-01-19 Tom Tromey <tom@tromey.com>
* gdb.rust/modules.rs (TWENTY_THREE): New global.
* gdb.rust/modules.exp: Add ::-qualified lookup test.
GDB used to assume that functions without debug info return int. It
accepted an expression containing such a function call and silently
interpreted the function's return value as int. But nowadays GDB yields
an error message instead, see
https://sourceware.org/ml/gdb-patches/2017-07/msg00139.html
This affects the s390-vregs test case, because it contains calls to
setrlimit64 and chdir. When no glibc debug info is installed, these lead
to unnecessary FAILs. Fix this by adding appropriate casts to the
inferior function calls.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-vregs.exp: Explicitly cast the return values of
setrlimit and chdir to int.
On ia64, gdb_wait.h eventually includes siginfo-consts-arch.h, which
contains an enum with TRAP_HWBKPT, along with a #define. Thus we cannot
define TRAP_HWBKPT to 4 beforehand, and so gdb_wait.h must be included
earlier; include it from linux-ptrace.h so it can never come afterwards.
gdb/ChangeLog:
* nat/linux-ptrace.c: Remove unnecessary reinclusion of
gdb_ptrace.h, and move including gdb_wait.h ...
* nat/linux-ptrace.h: ... to here.
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
The to_detach target_ops method implementations are currently expected
to work on current_inferior/inferior_ptid. In order to make things more
explicit, and remove some "shadow" parameter passing through globals,
this patch adds an "inferior" parameter to to_detach. Implementations
will be expected to use this instead of relying on the global. However,
to keep things simple, this patch only does the minimum that is
necessary to add the parameter. The following patch gives an example of
how one such implementation would be adapted. If the approach is deemed
good, we can then look into adapting more implementations. Until then,
they'll continue to work as they do currently.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Add inferior
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Pass inferior down.
(target_detach): Pass inferior down. Assert that it is equal to
the current inferior.
* aix-thread.c (aix_thread_detach): Pass inferior down.
* corefile.c (core_file_command): Pass current_inferior() down.
* corelow.c (core_detach): Add inferior parameter.
* darwin-nat.c (darwin_detach): Likewise.
* gnu-nat.c (gnu_detach): Likewise.
* inf-ptrace.c (inf_ptrace_detach): Likewise.
* infcmd.c (detach_command): Pass current_inferior() down to
target_detach.
* infrun.c (follow_fork_inferior): Pass parent_inf to
target_detach.
(handle_vfork_child_exec_or_exit): Pass inf->vfork_parent to
target_detach.
* linux-nat.c (linux_nat_detach): Add inferior parameter.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
* record.c (record_detach): Likewise.
* record.h (struct inferior): Forward-declare.
(record_detach): Add inferior parameter.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-debug.h (target_debug_print_inferior_p): New macro.
* target-delegates.c: Re-generate.
* top.c (kill_or_detach): Pass inferior down to target_detach.
* windows-nat.c (windows_detach): Add inferior parameter.
I was looking into adding a parameter to target_detach, and was
wondering what the args parameter was. It seems like in the distant
past, it was possible to specify a signal number when detaching. That
signal was injected in the process before it was detached. There is an
example of code handling this in linux_nat_detach. With today's GDB, I
can't get this to work. Doing "detach 15" (15 == SIGTERM) doesn't work,
because detach is a prefix command and doesn't recognize the sub-command
15. Doing "detach inferiors 15" doesn't work because it expects a list
of inferior id to detach. Therefore, I don't think there's a way of
invoking detach_command with a non-NULL args. I also didn't find any
documentation related to this feature.
I assume that this feature stopped working when detach was made a prefix
command, which is in f73adfeb8b (sorry,
there's no commit title) from 2006. Given that this feature was broken
for such a long time and we haven't heard anything (AFAIK, I did not
find any related bug), I think it's safe to remove it, as well as the
args parameter to target_detach. If someone wants to re-introduce it, I
would suggest rethinking the user interface, and in particular would
suggest using signal name instead of numbers.
I tried to fix all the impacted code, but I might have forgotten some
spots. It shouldn't be hard to fix if that's the case. I also couldn't
build-test everything I changed, especially the nto and solaris stuff.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Remove args
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Adjust.
(target_detach): Remove args parameter, adjust.
* aix-thread.c (aix_thread_detach): Adjust.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_detach): Adjust.
* darwin-nat.c (darwin_detach): Adjust.
* gnu-nat.c (gnu_detach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
* infcmd.c (detach_command): Adjust
* infrun.c (follow_fork_inferior): Adjust.
(handle_vfork_child_exec_or_exit): Adjust.
* linux-fork.c (linux_fork_detach): Remove args parameter.
* linux-fork.h (linux_fork_detach): Likewise.
* linux-nat.c (linux_nat_detach): Likewise, and adjust.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
(do_detach): Remove signo parameter.
* record.c (record_detach): Remove args parameter.
* record.h (record_detach): Likewise.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-delegates.c: Re-generate.
* top.c (struct qt_args) <args>: Remove field.
(kill_or_detach): Don't pass args.
(quit_force): Don't set args.
* windows-nat.c (windows_detach): Remove args parameter.
Remove spurious comments after the definition of ToC and ToU.
2018-01-19 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (ToC macro): Remove spurious comment.
(ToU macro): Likewise.
This adds more explanation as to why the test case must be compiled with
the -msoft-float option. It also documents the my_tbegin and my_tend
functions.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-tdbregs.c (my_tbegin): Add comment documenting the
function.
(my_tend): Likewise.
* gdb.arch/s390-tdbregs.exp: Enhance comment; explain the
rationale of avoiding FP- and vector instructions.
When I run gdb.compile/ tests on arm-linux, I get the following fails,
(gdb) compile code -- ;^M
arm-none-linux-gnueabihf-gcc: error: unrecognized command line option '-m32'; did you mean '-mbe32'?^M
Compilation failed.^M
(gdb) compile code (void) param^M
arm-none-linux-gnueabihf-gcc: error: unrecognized command line option '-m32'; did you mean '-mbe32'?^M
Compilation failed.^M
(gdb) FAIL: gdb.compile/compile-ops.exp: compile code (void) param
This patch fixes it by implementing gcc_target_options gdbarch method
for arm-linux to override option "-m32".
gdb:
2018-01-19 Yao Qi <yao.qi@linaro.org>
* arm-linux-tdep.c (arm_linux_gcc_target_options): New function.
(arm_linux_init_abi): Install it.
GCC for arm-linux has different names on different distros. It is
arm-linux-gnu-gcc on fedora. Debian/Ubuntu has arm-linux-gnueabihf-gcc
and arm-linux-gnueabi-gcc. So when I run gdb.compile/ tests on arm-linux,
I get,
(gdb) compile code -- ;
Could not find a compiler matching "^arm(-[^-]*)?-linux(-gnu)?-gcc$"
This patch extend the regexp to match both arm-linux-gnu-gcc and
arm-linux-gnueabihf-gcc.
gdb:
2018-01-19 Yao Qi <yao.qi@linaro.org>
* osabi.c (gdb_osabi_names): Extend the regexp for
arm-linux-gnueabihf and arm-linux-gnueabi.
This will allow to format output of "info reg" command as we wish,
without breaking the tests. In particular, it'll let us correctly align
raw and natural values of the registers using spaces instead of current
badly-working approach with tabs.
This change is forwards- and backwards-compatible, so that the amended
tests will work in the same way before and after reformatting patches
(unless the tests check formatting, of course, but I've not come across
any such tests).
Some tests already used this expected pattern, so they didn't
even have to be modified. Others are changed by this patch.
I've checked this on a i386 system, with no noticeable differences in
test results, so at least on i386 nothing seems to be broken by this.
gdb/testsuite/ChangeLog:
* gdb.arch/powerpc-d128-regs.exp: Replace expected "\[\t\]*" from
"info reg" with "\[ \t\]*".
* gdb.arch/altivec-regs.exp: Replace expected "\t" from "info reg" with
"\[ \t\]+".
* gdb.arch/s390-multiarch.exp: Ditto.
* gdb.base/pc-fp.exp: Ditto.
* gdb.reverse/i386-precsave.exp: Ditto.
* gdb.reverse/i386-reverse.exp: Ditto.
* gdb.reverse/i387-env-reverse.exp: Ditto.
* gdb.reverse/i387-stack-reverse.exp: Ditto.
Also xfail ld-elf/group1.d for Solaris since _GLOBAL_OFFSET_TABLE_ is
always generated for Solaris as a global symbol after
.*: 0+1000 +0 +(NOTYPE|OBJECT) +WEAK +DEFAULT +. foo
instead of appending "#..." which will weaken the test.
* testsuite/ld-elf/group1.d: Also xfail Solaris.
Update ld-elf/linkinfo1[ab].d to accommodate slightly different PLT/GOT
order/layout for Solaris/x86 targets.
* testsuite/ld-elf/linkinfo1a.d: Updated for slightly different
PLT/GOT order/layout for Solaris/x86 targets.
* testsuite/ld-elf/linkinfo1b.d: Likewise.
Since all ELF linkers call check_relocs after opening all inputs, we
can fold after_allocation into before_allocation so that local dynamic
symbols will be placed before global dynamic symbols in .dynsym section.
This fixed:
FAIL: Common symbol override test (auxiliary shared object build)
FAIL: ld-elf/pr19617a
FAIL: ld-elf/pr19698
for i386-solaris2.12 and x86_64-solaris2.12 targets.
PR ld/22728
* emultempl/solaris2.em (elf_solaris2_after_allocation): Fold
into ...
(elf_solaris2_before_allocation): This.
(LDEMUL_AFTER_ALLOCATION): Removed.
In August 2017 the GDB test suite was changed to always add the compile
option "-fdiagnostics-color=never", see:
https://sourceware.org/ml/gdb-patches/2017-08/msg00150.html
Since this option is not understood by rustc, a commit from 09/2017
dropped its use in that case:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=5eb5f850
("Don't use -fdiagnostics-color=never for rustc")
But that change goes overboard and stops using the option for other
languages as well. Thus compiler diagnostics written into gdb.log may
contain colored output again. This is fixed.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Re-enable use of
universal_compile_options for languages other than Rust.
The GDB test case s390-tdbregs.exp verifies GDB's handling of the
"transaction diagnostic block". For simplicity, the test case uses the
"transaction begin" (TBEGIN) instruction with the "allow floating-point
operation" flag set to zero. But some GCC versions may indeed emit
floating point or vector instructions for this test case. If this happens
in the transaction, it aborts, and an endless loop results.
This change tells the compiler to produce a soft-float binary, so no
floating-point or vector registers are touched.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-tdbregs.exp: Add the compile option -msoft-float.
abbrev_table::abbrevs is only access within abbrev_table's methods, so
it can be private. Add "m_" prefix.
gdb:
2018-01-18 Yao Qi <yao.qi@linaro.org>
* dwarf2read.c (abbrev_table) <abbrevs>: Rename it to
m_abbrevs.
(abbrev_table::add_abbrev): Update.
(abbrev_table::lookup_abbrev): Update.
The code in ppu2spu_prev_register is in fact regcache_cooked_read,
because spu doesn't have gdbarch method pseudo_register_read_value.
gdb:
2018-01-18 Yao Qi <yao.qi@linaro.org>
* ppc-linux-tdep.c (ppu2spu_prev_register): Call cooked_read.
Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries
didn't quite work. For ld.bfd they were spaced 32 bytes apart, but
only started on a 16 byte boundary. ld.gold also didn't get it right.
Finding that bug made me check over the ppc64 plt stub alignment,
where I found that negative values for alignment (meaning align to
minimize boundary crossing) were not accepted. Since no one has
complained about that, I guess I could have removed the feature from
ld.bfd documentation, but I've opted instead to correct the code.
I've also added an optional alignment paramenter for ppc32
--plt-align, for some consistency with gold and ppc64 ld.bfd.
bfd/
* elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink.
* elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align.
(ppc64_elf_build_stubs): Likewise.
gold/
* powerpc.cc (param_plt_align): New function supplying default
--plt-align values. Use it..
(Stub_table::plt_call_align): ..here, and..
(Output_data_glink::global_entry_align): ..here.
(Stub_table::stub_align): Correct 32-bit minimum alignment.
ld/
* emultempl/ppc32elf.em: Support optional --plt-align arg.
* emultempl/ppc64elf.em: Support negative --plt-align arg.
This fixes a GCC warning that happens when compiling
gdb/compile/compile.c on some GCC versions (e.g., "gcc (GCC) 7.2.1
20180104 (Red Hat 7.2.1-6)"):
../../gdb/compile/compile.c: In function 'void eval_compile_command(command_line*, const char*, compile_i_scope_types, void*)':
../../gdb/compile/compile.c:548:19: warning: 'triplet_rx' may be used uninitialized in this function [-Wmaybe-uninitialized]
error_message = compiler->fe->ops->set_arguments_v0 (compiler->fe, triplet_rx,
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
argc, argv);
~~~~~~~~~~~
../../gdb/compile/compile.c:466:9: note: 'triplet_rx' was declared here
char *triplet_rx;
^~~~~~~~~~
It's a simple patch that converts "triplet_rx" from "char *" to
"std::string", thus guaranteeing that it will be always initialized.
I've regtested this patch and did not find any regressions. OK to
apply on both master and 8.1 (after creating a bug for it)?
gdb/ChangeLog:
2018-01-17 Sergio Durigan Junior <sergiodj@redhat.com>
* compile/compile.c (compile_to_object): Convert "triplet_rx"
to "std::string".
This removes the symbolp typedef from dwarf2read.c. It is no longer
used.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (symbolp): Remove typedef. Don't instantiate VEC.
The objfile argument to add_dyn_prop is redundant, so this patch
removes it.
2018-01-17 Tom Tromey <tom@tromey.com>
* gdbtypes.h (add_dyn_prop): Remove objfile parameter.
* gdbtypes.c (add_dyn_prop): Remove objfile parameter.
(create_array_type_with_stride): Update.
* dwarf2read.c (set_die_type): Update.
This changes the type of dwarf2_cu::method_info and fixes up the uses.
In order to remove cleanups from process_full_comp_unit and
process_full_type_unit, psymtab_include_file_name also had to be
changed to avoid leaving dangling cleanups.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (delayed_method_info): Remove typedef.
(dwarf2_cu::method_info): Now a std::vector.
(add_to_method_list): Update.
(free_delayed_list): Remove.
(compute_delayed_physnames): Update.
(process_full_comp_unit, process_full_type_unit): Clear the method
list. Remove cleanups.
(psymtab_include_file_name): Add name_holder parameter. Use
unique_xmalloc_ptr.
(dwarf_decode_lines): Update.
This changes dwarf2_cu to be allocated with new, and fixes up the
users.
2018-01-17 Tom Tromey <tom@tromey.com>
Simon Marchi <simon.marchi@ericsson.com>
* dwarf2read.c (struct dwarf2_cu): Add constructor, destructor.
(dwarf2_per_objfile::free_cached_comp_units)
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow): Update.
(dwarf2_cu::dwarf2_cu): Rename from init_one_comp_unit.
(dwarf2_cu::~dwarf2_cu): New.
(free_heap_comp_unit, free_stack_comp_unit): Remove.
(age_cached_comp_units, free_one_cached_comp_unit): Update.
This changes dwarf2read.c to allocate abbrev tables using "new", and
then updates the users.
This version of the patch incorporates the changes that Simon
implemented. These changes simplify the ownership rules for abbrev
tables.
2018-01-17 Tom Tromey <tom@tromey.com>
Simon Marchi <simon.marchi@ericsson.com>
* dwarf2read.c (struct dwarf2_cu) <abbrev_table>: Remove.
(struct die_reader_specs) <abbrev_table>: New member.
(struct abbrev_table): Add constructor.
<alloc_abbrev, add_abbrev, lookup_abbrev>: Declare.
<abbrev_obstack>: Now an auto_obstack.
(abbrev_table_up): New typedef.
(init_cu_die_reader): Add abbrev_table parameter.
(read_cutu_die_from_dwo): Remove abbrev_table_provided parameter.
Add result_dwo_abbrev_table.
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow, build_type_psymtabs_1):
Update.
(peek_die_abbrev): Take die_reader_specs, not dwarf_cu as
parameter.
(skip_children): Update.
(abbrev_table::alloc_abbrev): Rename from
abbrev_table_alloc_abbrev.
(abbrev_table::add_abbrev): Rename from abbrev_table_add_abbrev.
(abbrev_table::lookup_abbrev): Rename from
abbrev_table_lookup_abbrev.
(abbrev_table_read_table): Return abbrev_table_up.
(abbrev_table_free, abbrev_table_free_cleanup)
(dwarf2_read_abbrevs, dwarf2_free_abbrev_table): Remove.
(load_partial_dies): Update.
This patch unifies new_symbol with new_symbol_full, replacing a
wrapper function with a default parameter.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_compute_name): Update comment.
(read_func_scope, read_variable): Update.
(new_symbol): Remove.
(new_symbol_full): Rename to new_symbol.
This fixes PR 16577.
This patch changes gdb_bfd_map_section to issue a warning rather than an error
if it is unable to read the object file, and sets the size of the section/frame
that it attempted to read to 0 on error.
The description of gdb_bfd_map_section states that it will try to read or map
the contents of the section SECT, and if successful, the section data is
returned and *SIZE is set to the size of the section data. This function was
throwing an error and leaving *SIZE as-is. Setting the section size to 0
indicates to dwarf2_build_frame_info that there is no data to read, otherwise
it will try to read from an invalid frame pointer.
Changing the error to a warning allows this to be handled gracefully.
Additionally, the error was clobbering the breakpoint output indicating the
current frame (function name, arguments, source file, and line number). E.g.
Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-1013829440/jna2973250704389291330.tmp: No such file or directory
BFD: reopening /tmp/jna-1013829440/jna2973250704389291330.tmp: No such file or directory
(gdb)
While the "BFD: reopening ..." messages will still appear interspersed in the
breakpoint output, the current frame info is now displayed:
Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-1013829440/jna1875755897659885075.tmp: No such file or directory
BFD: reopening /tmp/jna-1013829440/jna1875755897659885075.tmp: No such file or directory
warning: Can't read data for section '.eh_frame' in file '/tmp/jna-1013829440/jna1875755897659885075.tmp'
do_something () at file.cpp:80
80 {
(gdb)
This patch makes linux_ptrace_attach_fail_reason and
linux_ptrace_attach_fail_reason_string return std::string. It also
replaces usages of struct buffer with std::string. This allows getting
rid of a cleanup in in linux_ptrace_attach_fail_reason_string and
simplifies the code in general.
Something that looks odd to me is that in
linux_ptrace_attach_fail_reason, if the two messages are appended, there
is no separating space or \n, so the result won't be very nice. I left
it as-is for now though.
gdb/ChangeLog:
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Return
std::string.
(linux_ptrace_attach_fail_reason_string): Likewise.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason):
Likewise.
(linux_ptrace_attach_fail_reason_string): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Adjust.
gdb/gdbserver/ChangeLog:
* linux-low.c (attach_proc_task_lwp_callback): Adjust to
linux_ptrace_attach_fail_reason_string now returning an
std::string.
(linux_attach): Likewise.
* thread-db.c (attach_thread): Likewise.
I think this xstrdup is not useful. We can pass ex.message directly to
throw_error instead.
gdb/ChangeLog:
* linux-nat.c (linux_nat_attach): Remove xstrdup.
Make <sys/types.h> be included prior to including <sys/user.h>.
glibc versions older than 2.14 use __uintNN_t types within certain
structures defined in <sys/user.h> probably assuming these types are
defined prior to including the header. This results in the following
`configure` feature test compilation error that makes it think that
`struct user_regs_struct` doesn't have `fs_base`/`gs_base` fields,
althouh it does.
configure:13617: checking for struct user_regs_struct.fs_base
configure:13617: gcc -c -g -O2 -I/linux/include conftest.c >&5
In file included from conftest.c:158:0:
/usr/include/sys/user.h:32:3: error: unknown type name '__uint16_t'
__uint16_t cwd;
^
/usr/include/sys/user.h:33:3: error: unknown type name '__uint16_t'
__uint16_t swd;
^
/usr/include/sys/user.h:34:3: error: unknown type name '__uint16_t'
__uint16_t ftw;
^
/usr/include/sys/user.h:35:3: error: unknown type name '__uint16_t'
__uint16_t fop;
^
/usr/include/sys/user.h:36:3: error: unknown type name '__uint64_t'
__uint64_t rip;
^
/usr/include/sys/user.h:37:3: error: unknown type name '__uint64_t'
__uint64_t rdp;
^
/usr/include/sys/user.h:38:3: error: unknown type name '__uint32_t'
__uint32_t mxcsr;
^
/usr/include/sys/user.h:39:3: error: unknown type name '__uint32_t'
__uint32_t mxcr_mask;
^
/usr/include/sys/user.h:40:3: error: unknown type name '__uint32_t'
__uint32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
^
/usr/include/sys/user.h:41:3: error: unknown type name '__uint32_t'
__uint32_t xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
^
/usr/include/sys/user.h:42:3: error: unknown type name '__uint32_t'
__uint32_t padding[24];
^
configure:13617: $? = 1
configure: failed program was:
| /* confdefs.h */
...
| /* end confdefs.h. */
| #include <sys/user.h>
|
| int
| main ()
| {
| static struct user_regs_struct ac_aggr;
| if (ac_aggr.fs_base)
| return 0;
| ;
| return 0;
| }
Recent glibc versions don't use typedef'ed int types in <sys/user.h>,
thus allowing it to be included as is
(glibc commit d79a9c949c84e7f0ba33e87447c47af833e9f11a).
However there're still some distros alive that use older glibc,
for instance, RHEL/CentOS 6 package glibc 2.12.
Also affects PR gdb/21559:
../../gdb/regcache.c:1087: internal-error: void regcache_raw_supply(regcache, int, const void): Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
As noted by Andrew Paprocki, who submitted the PR
(https://sourceware.org/bugzilla/show_bug.cgi?id=21559#c3):
> It should be noted that modifying `configure` to force on
> `HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE` and
> `HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE` fixes this issue. For some
> reason the `configure` tests for `fs_base` and `gs_base` fail
> even though `sys/user.h` on RHEL5 has the fields defined in
> `user_regs_struct`.
Note that this patch does NOT fix the root cause of PR gdb/21559,
although now that `configure` properly detects the presence of the
fields and sets HAVE_XXX accordingly, the execution takes another
path, which doesn't lead to the assertion failure in question.
gdb/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
Nowadays, if we use "compile" on aarch64-linux, we'll get the following
error,
(gdb) compile code -- ;
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-m64'
because the default gcc_target_options returns "-m64" and
"-mcmodel=large", neither is useful to aarch64-linux.
gdb:
2018-01-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): New
function.
(aarch64_linux_init_abi): Install it to gdbarch hook
gcc_target_options.
One test in gdb.compile/compile.exp passes on one fedora builder,
bt
#0 0x00007ffff7ff43f6 in _gdb_expr (__regs=0x7ffff7ff2000) at gdb
command line:1^M
#1 <function called from gdb>^M
#2 main () at /home/gdb-buildbot/fedora-x86-64-1/fedora-x86-64/build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.compile/compile.c:106^M
(gdb) PASS: gdb.compile/compile.exp: bt
but fails on my machine with gcc trunk,
bt^M
#0 _gdb_expr (__regs=0x7ffff7ff3000) at gdb command line:1^M
#1 <function called from gdb>^M
#2 main () at gdb/testsuite/gdb.compile/compile.c:106^M
(gdb) FAIL: gdb.compile/compile.exp: bt
The test should be tweaked to match both cases (pc in the start of line
vs pc in the middle of line). Note that I am not clear that why libcc1
emits debug info this way so that the address is in the middle of line.
gdb/testsuite:
2018-01-17 Yao Qi <yao.qi@linaro.org>
* gdb.compile/compile.exp: Match the address printed for
frame in the output of command "bt".
This is in preparation for the next patch adding Spectre variant 2
mitigation for PowerPC and PowerPC64. Besides tidying code involved
in stub output (to reduce the number of places where bctr is output),
the patch adds some user visible features:
1) PowerPC64 ELFv2 global entry stubs now are aligned under the
control of --plt-align, with a default alignment of 32 bytes.
2) PowerPC64 __glink_PLTresolve is no longer padded out with nops.
3) PowerPC32 PLT stubs are aligned under the control of --plt-align,
with the default alignment being 16 bytes as before.
4) The PowerPC32 branch/nop table emitted before __glink_PLTresolve
is now smaller in many cases. It was sized incorrectly when the
__tls_get_addr_opt stub was used, and unnecessarily included space
for local ifuncs.
bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle
__tls_get_addr_opt, and alignment sizing.
(TLS_GET_ADDR_GLINK_SIZE): Delete.
(is_nonpic_glink_stub): Don't use GLINK_ENTRY_SIZE.
(ppc_elf_get_synthetic_symtab): Recognize stubs spaced at 4, 6,
or 8 insns.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(allocate_dynrelocs): Use new GLINK_ENTRY_SIZE.
(ppc_elf_size_dynamic_sections): Likewise. Size branch table
by PLT reloc count.
(write_glink_stub): Handle __tls_get_addr_opt stub.
Pad out to size given by GLINK_ENTRY_SIZE.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Write PLTresolve without using
insn array since so many need rewriting.
* elf32-ppc.h (struct ppc_elf_params): Add plt_stub_align.
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Rename from
GLINK_CALL_STUB_SIZE. Add htab param and evaluate to size without
nops. Adjust all uses.
(ppc64_elf_get_synthetic_symtab): Don't use GLINK_CALL_STUB_SIZE
in glink_vma calculation.
(struct ppc_link_hash_table): Add global_entry section pointer.
(create_linkage_sections): Create separate section for global
entry stubs.
(PPC_LO, PPC_HI, PPC_HA): Move earlier.
(size_global_entry_stubs): Handle sizing for aligned stubs.
(ppc64_elf_size_dynamic_sections): Handle global_entry alloc,
and don't stash end of glink branch table in rawsize.
(ppc_build_one_stub): Rewrite stub size calculations.
(build_global_entry_stubs): Use new section.
(ppc64_elf_build_stubs): Don't pad __glink_PLTresolve with nops.
Build lazy link stubs out to end of section. Build global entry
stubs in new section.
gold/
* options.h (plt_align): Support for PowerPC32 too.
* powerpc.cc (Stub_table::stub_align): Heed --plt-align for 32-bit.
(Stub_table::plt_call_size, branch_stub_size): Tidy.
(Stub_table::plt_call_align): Implement using stub_align.
(Output_data_glink::global_entry_align): New function.
(Output_data_glink::global_entry_off): New function.
(Output_data_glink::global_entry_address): Use global_entry_off.
(Output_data_glink::pltresolve_size): New function, replacing
pltresolve_size_ constant. Update all uses.
(Output_data_glink::add_global_entry): Align offset.
(Output_data_glink::set_final_data_size): Use global_entry_align.
(Stub_table::do_write): Don't pad __glink_PLTrelsolve with nops.
Tidy stub output. Use global_entry_off.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(enum ppc32_opt): New enum to define OPTION_* values. Add
OPTION_PLT_ALIGN and OPTION_NO_PLT_ALIGN.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise. Break up help output.
* emultempl/ppc64elf.em (ppc_add_stub_section): Init alignment
correctly for negative --plt-stub-align.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/relbrlt.s,
* testsuite/ld-powerpc/tlsexe.d,
* testsuite/ld-powerpc/tlsexe.r,
* testsuite/ld-powerpc/tlsexe32.d,
* testsuite/ld-powerpc/tlsexe32.g,
* testsuite/ld-powerpc/tlsexe32.r,
* testsuite/ld-powerpc/tlsexetoc.d,
* testsuite/ld-powerpc/tlsexetoc.r,
* testsuite/ld-powerpc/tlsopt5_32.d,
* testsuite/ld-powerpc/tlsso.d,
* testsuite/ld-powerpc/tlstocso.d: Update for changed stub order.
As described in PR 18749, GDB/GDBserver may get an error on accessing
memory or register because the thread may disappear. However, some
path doesn't expect the error. This patch fixes this problem by
marking the register unavailable when PTRACE_PEEKUSER fails instead
of throwing error.
gdb/gdbserver:
2018-01-16 Yao Qi <yao.qi@linaro.org>
PR gdb/18749
* linux-low.c (fetch_register): Call supply_register instead of
error.