Use XSHAL_ABI value provided by xtensa-config.h to correctly initialize
xtensa_tdep.call_abi
This fixes calls to functions from GDB that otherwise fail with the
following assertion in call0 configuration:
gdb/regcache.c:602: internal-error: regcache_raw_read: Assertion
`regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
2015-08-31 Max Filippov <jcmvbkbc@gmail.com>
gdb/
* xtensa-tdep.h (XTENSA_GDBARCH_TDEP_INSTANTIATE): Initialize
call_abi using XSHAL_ABI macro.
These int vars are really unsigned, so make them so.
* section.c (struct bfd_section): Make "id" and "index" unsigned.
* coff-rs6000.c (_bfd_xcoff_sizeof_headers): Adjust local var to suit.
* elf.c (elf_map_symbols): Likewise.
* elf64-ppc.c (sym_exists_at): Make "id" param unsigned.
(struct ppc_link_hash_table): Make "top_id" and "top_index" unsigned.
(ppc64_elf_setup_section_lists): Ditto for local vars.
* elf32-arm.c: Similarly to elf64-ppc.c.
* elf32-avr.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-nios2.c: Likewise.
* elfnn-aarch64.c: Likewise.
* simple.c (struct saved_offsets): Make "section_count" unsigned.
* bfd-in2.h: Regenerate.
Since the type whose name is being set is now being allocated on the
gdbarch obstack, we should allocate its TYPE_NAME on the obstack too.
This reduces the number of individual valgrind warnings for the command
"gdb gdb" from ~300 to ~150.
Tested on x86_64-unknown-linux-gnu.
gdb/ChangeLog:
* gdbarch.h (gdbarch_obstack_strdup): Declare.
* gdbarch.c (gdbarch_obstack_strdup): Define.
* gdbtypes.c (arch_type): Use it.
For the command "gdb gdb" valgrind currently reports 100s of individual
memory leaks, 500 of which originate solely out of the function
alloc_type_arch. This function allocates a "struct type" associated
with the given gdbarch using malloc but apparently the types allocated
by this function are never freed.
This patch fixes these leaks by making the function alloc_type_arch
allocate these gdbarch-associated types on the gdbarch obstack instead
of on the general heap. Since, from what I can tell, the types
allocated by this function are all fundamental "wired-in" types, such
types would not benefit from more granular memory management anyway.
They would likely live as long as the gdbarch is alive so allocating
them on the gdbarch obstack makes sense.
With this patch, the number of individual vargrind warnings emitted for
the command "gdb gdb" drops from ~800 to ~300.
Tested on x86_64-unknown-linux-gnu.
gdb/ChangeLog:
* gdbtypes.c (alloc_type_arch): Allocate the type on the given
gdbarch obstack instead of on the heap. Update commentary
accordingly.
solib_ops are installed as a property of the inferior gdbarch,
so they need to be systematically looked up via that architecture,
not some objfile architecture.
ChangeLog:
Revert:
2014-11-06 Doug Evans <xdje42@gmail.com>
* solib.c (solib_global_lookup): Fetch arch from objfile,
not target_gdbarch.
When debugging Cell/B.E. code, the cross-architecture frame unwinding
works by accessing data structures refered to by a thread-local variable
in the inferior. While accessing this variable via minimal symbol,
code would use BMSYMBOL_VALUE_ADDRESS to determine the offset of the
variable in the thread-local storage block.
This is incorrect, since it adds any relocation offset of the shared
library defining the TLS variable. That offset would be OK when
accessing the initial copy present in the .tbss section, but it must
not be applied to the offset of the variable in the TLS block at
runtime. Depending on whether or not the libspe2.so library was
prelinked, access to the variable would fail due to the incorrectly
relocated offset.
ChangeLog:
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Do not
attempt to relocate a TLS variable offset.
With recent changes to inferior handling, parse_spufs_run needs to be
more careful in assumptions it makes. In particular, this patch:
- Bails out early if the current inferior has not yet been registered
(e.g. during fork procession) to avoid assertion failures in register
cache code.
- Sets inferior_ptid to the current ptid while calling target_read_memory
to make sure the correct process is accessed if parse_spufs_run is
called early when inferior_ptid has not yet been switched by the caller.
ChangeLog:
* spu-multiarch.c (parse_spufs_run): Bail out if inferior is not
registered yet. Set inferior_ptid while calling target_read_memory.
The Linux target and gdbserver now check the siginfo si_code
reported on a SIGTRAP to detect whether the trap indicates
a software breakpoint was hit.
Unfortunately, on Cell/B.E., the kernel uses an si_code value
of TRAP_BRKPT when a SW breakpoint was hit in PowerPC code,
but a si_code value of SI_KERNEL when a SW breakpoint was
hit in SPU code.
This patch updates Linux target and gdbserver to accept both
si_code values to indicate SW breakpoint on PowerPC.
ChangeLog:
* nat/linux-ptrace.h (GDB_ARCH_TRAP_BRKPT): Replace by ...
(GDB_ARCH_IS_TRAP_BRKPT): ... this. Add __powerpc__ case.
* linux-nat.c (check_stopped_by_breakpoint): Use
GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
gdbserver/ChangeLog:
* linux-low.c (check_stopped_by_breakpoint): Use
GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
Since we are no longer using thread events by default in linux-thread-db,
the find_new_threads_once routine contains an assertion that it should
never be called on a live inferior unless using thread events:
gdb_assert (!target_has_execution || thread_db_use_events ());
However, there is a code path from thread_db_get_thread_local_address
that will in fact call find_new_threads_once in some scenarios. In
particular, this is currently always triggered when starting up any
Cell/B.E. combined exeuctable.
To fix this, this patch removes the call to thread_db_find_new_threads_1
when the current thread was not yet detected. In its place, we now just
call thread_from_lwp to detect this one thread if necessary.
ChangeLog:
* linux-thread-db.c (thread_db_get_thread_local_address): If the
thread was not yet discovered, use thread_from_lwp instead of
calling thread_db_find_new_threads_1.
The gdb.cell testcases use the predicate skip_cell_tests defined in
lib/cell.exp to determine whether Cell/B.E. test cases ought to be
run. This tests verifies that we have a toolchain that supports
generating combined Cell/B.E. binaries, and that the target machine
actually is a Cell/B.E.
In order to do so, a small test program is built and run (under the
debugger). Any failure is taken as a sign that we don't have a
Cell/B.E. machine and the tests are to be skipped.
This has the unfortunate effect that a serious bug in GDB that causes
internal compiler errors even on the trivial test program does not
lead to any failures in the testsuite, since now all gdb.cell test
are simply skipped.
This patch changes skip_cell_tests to at least report UNRESOLVED
in cases where execution of the test program fails in unexpected
ways.
testsuite/ChangeLog:
* lib/cell.exp (skip_cell_tests): Report UNRESOLVED on unexpected
failures to run the test program under GDB.
Some of the TC_START_LABEL implementations need to adjust the end of
the symbol, when a colon doesn't mean a label definition. That means
they need access to nul_char both the restore the NUL location (it may
be a quote rather than a colon) and to store the new nul_char. Others
need adjusting to step over a potential trailing quote.
PR gas/18581
* config/tc-aarch64.h (TC_START_LABEL): Redefine.
* config/tc-arm.c (tc_start_label_without_colon): Delete params.
Use input_line_pointer directly.
* config/tc-arm.h (TC_START_LABEL): Redefine.
(TC_START_LABEL_WITHOUT_COLON): Redefine.
(tc_start_label_without_colon): Update prototype.
* config/tc-bfin.c (bfin_start_label): Delete ptr param. Check
for NUL instead.
* config/tc-bfin.h (bfin_start_label): Update prototype.
(TC_START_LABEL): Redefine.
* config/tc-d30v.h (TC_START_LABEL): Redefine.
* config/tc-fr30.c (restore_colon): Rewrite.
(fr30_is_colon_insn): Add nul_char param. Return int. Bump
i_l_p over quote. Update restore_colon calls.
* config/tc-fr30.h (TC_START_LABEL): Redefine.
(fr30_is_colon_insn): Update prototype.
* config/tc-m32c.c (restore_colon, m32c_is_colon_insn): As above.
* config/tc-m32c.h (TC_START_LABEL): Redefine.
(m32c_is_colon_insn): Update prototype.
* config/tc-m32r.h (TC_START_LABEL): Redefine.
* config/tc-mep.h (TC_START_LABEL): Redefine.
* config/tc-nds32.h (TC_START_LABEL): Redefine.
* config/tc-tic54x.c (tic54x_start_label): Replace params with
nul_char and next_char. Step over trailing quote.
* config/tc-tic54x.h (TC_START_LABEL_WITHOUT_COLON): Redefine.
(tic54x_start_label): Update prototype.
* read.c (TC_START_LABEL): Redefine. Update invocation.
(TC_START_LABEL_WITHOUT_COLON): Update invocation.
* config/tc-nios2.c (s_nios2_set): Save initial input_line_pointer
and restore if calling s_set. Don't restore delim again.
These two statements were inverted by mistake in commit "Replace some
xmalloc-family functions with XNEW-family ones". It obviously doesn't
make sense to have them in this order, which is why I am pushing this as
obvious.
gdb/ChangeLog:
* m88k-tdep.c (m88k_analyze_prologue): Fix inverted allocation
statements.
I think it would be a good idea to document that gdb now has (basic)
support to read/write memory on architectures with non-8-bits memory.
Hopefully somebody will see it and say "Hey! We can now (more easily)
port GDB to our strange DSP that has 32-bits-addressable memory!" and do
it.
gdb/ChangeLog:
* NEWS: Document support for non-8-bits addressable memory.
Building in C++ mode shows:
int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
^
src/gdb/gdbserver/proc-service.c:93:64: error: invalid conversion from ‘int’ to ‘ps_err_e’ [-fpermissive]
return write_inferior_memory ((unsigned long) addr, buf, size);
^
It only works today by accident, write_inferior_memory does not return
a ps_err_e.
gdb/gdbserver/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* proc-service.c (ps_pdwrite): Return PS_ERR/PS_OK explicily.
Since we're using sighandler_t, nothing else refers to RETSIGTYPE in
gdb.
(Actually, given gdb/remote.c has been assuming signal handlers return
void for a long time, we could have gotten get rid of this even
without gnulib's sighandler_t.)
gdb/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* configure.ac: Remove AC_TYPE_SIGNAL call.
* configure, config.in: Regenerate.
This fixes 14 build errors like these in C++ mode:
src/gdb/extension.c: In function ‘void install_sigint_handler(const signal_handler*)’:
src/gdb/extension.c:698:41: error: invalid conversion from ‘void (*)()’ to ‘__sighandler_t {aka void (*)(int)}’ [-fpermissive]
signal (SIGINT, handler_state->handler);
^
In file included from build-gnulib/import/signal.h:52:0,
from ../../src/gdb/extension.c:24:
/usr/include/signal.h:102:23: error: initializing argument 2 of ‘void (* signal(int, __sighandler_t))(int)’ [-fpermissive]
extern __sighandler_t signal (int __sig, __sighandler_t __handler)
^
Instead of this everywhere:
- RETSIGTYPE (*handle_sigint_for_compare) () = handle_sigint;
+ RETSIGTYPE (*handle_sigint_for_compare) (int) = handle_sigint;
Use sighandler_t (a GNU extension). That's OK to use unconditionaly
because gnulib's signal.h replacement makes sure that it is available.
gdb/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* cp-support.c (gdb_demangle): Use sighandler_t. Remove cast.
* extension-priv.h: Include signal.h.
(struct signal_handler) <handler>: Change type to sighandler_t.
* extension.c (install_gdb_sigint_handler): Use sighandler_t.
* inflow.c (sigint_ours, sigquit_ours): Change type to
sighandler_t.
(child_terminal_inferior): Remove casts.
(child_terminal_ours_1, new_tty): Use sighandler_t. Remove casts.
(osig): Change type to sighandler_t.
* nto-procfs.c (ofunc): Change type to sighandler_t.
(procfs_wait): Remove casts.
* remote-m32r-sdi.c (m32r_wait, m32r_load): Use sighandler_t.
* remote-sim.c (gdbsim_wait): Use sighandler_t.
* utils.c (wait_to_die_with_timeout): Use sighandler_t.
This gives us a signal.h replacement that makes sure the sighandler_t
typedef (a GNU extension) is always available. A follow up patch will
make use of this.
gdb/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add signal-h.
* gnulib/aclocal.m4: Renegerate.
* gnulib/config.in: Renegerate.
* gnulib/configure: Renegerate.
* gnulib/import/Makefile.am: Update.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/m4/gnulib-cache.m4: Update.
* gnulib/import/m4/gnulib-comp.m4: Update.
* gnulib/import/m4/signal_h.m4: New file.
* gnulib/import/signal.in.h: New file.
The remote packet buffer size is currently capped to 16384 mostly for
historical reasons, related to use of alloca. Stop using alloca and
remove the limitation.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-27 Pedro Alves <palves@redhat.com>
* remote.c (DEFAULT_MAX_MEMORY_PACKET_SIZE)
(MIN_MEMORY_PACKET_SIZE): New.
(MAX_REMOTE_PACKET_SIZE, MIN_REMOTE_PACKET_SIZE): Delete.
(get_memory_packet_size): Adjust. No longer limit the max packet
size.
(set_memory_packet_size): Adjust, and remove dead code.
(remote_check_symbols): Use xmalloc and a cleanup instead of
alloca.
(remote_packet_size): No longer cap the packet size.
(putpkt_binary): Use xmalloc and a cleanup instead of alloca.
This patch improves one of the compile error messages by mentioning the
language.
Before - No compiler support for this language.
After - No compiler support for language <language>.
gdb/ChangeLog:
2015-08-26 Luis Machado <lgustavo@codesourcery.com>
* compile/compile.c (compile_to_object): Mention language in
error message.
Due to the lack of debug information in the binary, GDB is unable to figure
out what language is being used. This may be a problem when doing remote
debugging and the binary stops at the entry point containing asm code.
In this case GDB will switch to asm as current language and will not switch
back to C when it reaches main, which in turn causes the compile feature check
to malfunction.
This is solved by forcing the language to C after reaching main.
gdb/testsuite/ChangeLog:
2015-08-26 Luis Machado <lgustavo@codesourcery.com>
* gdb.compile/compile-ifunc.exp (with_test_prefix): Force language
to C.
We currently set attach_flag when attaching to a process, so we should
make sure to unset it when forking a new process. Otherwise attach_flag
would remain set after forking, if the previous process associated with
the inferior was attached to.
gdb/ChangeLog:
* target.c (target_pre_inferior): Unset attach_flag.
gdb/testsuite/ChangeLog:
* gdb.base/run-after-attach.exp: New test file.
* gdb.base/run-after-attach.c: New test file.
I made a mistake while handling my previous patch. A change in
gdbarch causes a build failure.
gdb/ChangeLog:
* gdbarch.sh (append_name): Fix type in XRESIZEVEC.
* gdbarch.c: Re-generate.
This patch fixes a segmentation fault in native GDB when
handling an exec event with follow-exec-mode set to "new".
The stack trace from the segfault was this:
0 0x0000000000669594 in gdbarch_data (gdbarch=0x0, data=0x20da7a0)
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/gdbarch.c:4847
1 0x00000000004d430e in get_remote_arch_state ()
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/remote.c:603
2 0x00000000004d431e in get_remote_state ()
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/remote.c:616
3 0x00000000004dda8b in discard_pending_stop_replies (inf=0x217c710)
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/remote.c:5775
4 0x00000000006a5928 in observer_inferior_exit_notification_stub (
data=0x4dda7a <discard_pending_stop_replies>, args_data=0x7fff12c258f0)
at ./observer.inc:1137
5 0x00000000006a419a in generic_observer_notify (subject=0x21dfbe0,
args=0x7fff12c258f0)
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/observer.c:167
6 0x00000000006a59ba in observer_notify_inferior_exit (inf=0x217c710)
at ./observer.inc:1162
7 0x00000000007981d5 in exit_inferior_1 (inftoex=0x217c710, silent=1)
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/inferior.c:244
8 0x00000000007982f2 in exit_inferior_num_silent (num=1)
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/inferior.c:286
9 0x000000000062f93d in follow_exec (ptid=...,
execd_pathname=0x7fff12c259a0 "/scratch/dbreazea/sandbox/exec-nat/build/gdb/testsuite/gdb.base/execd-prog")
at /scratch/dbreazea/sandbox/exec-nat/binutils-gdb/gdb/infrun.c:1195
In follow_exec we were creating a new inferior for the execd program,
as required by the exec mode, but we were doing it before calling
exit_inferior_num_silent on the original inferior. So on entry to
exit_inferior_num_silent we had two inferiors with the same ptid.
In the calls made by exit_inferior_num_silent, the current inferior
is temporarily saved and replaced in order to make use of functions
that only operate on the current inferior (for example, in
do_all_continuations, called while deleting the threads of the original
inferior). When we restored the original inferior, we just took the
first inferior that matched the ptid of the original and got the new
(wrong) one. It hadn't been initialized yet and had no gdbarch
pointer, and GDB segfaulted.
The fix for that is to call exit_inferior_num_silent before adding the new
inferior, so that we never have two inferiors with the same ptid. Then
exit_inferior_num_silent uses the original inferior as the current inferior
throughout, and can find a valid gdbarch pointer.
Once we have finished with the exit of the old inferior and added the
new one, we need to create a new thread for the new inferior. In the
function that called follow_exec, handle_inferior_event_1,
ecs->event_thread now points to the thread that was deleted with the
exit of the original inferior. To remedy this we create the new thread,
and once we return from follow_exec we reset ecs->event_thread.
Note that we are guaranteed that we can reset ecs->event_thread
safely using inferior_thread because we have set the current
inferior in follow_exec, and inferior_ptid was set by the call
to context_switch at the beginning of exec event handling.
gdb/ChangeLog:
* infrun.c (follow_exec): Re-order operations for
handling follow-exec-mode "new".
(handle_inferior_event_1): Assign ecs->event_thread
to the current thread.
* remote.c (get_remote_arch_state): Add an assertion.
This patch implements a new GDB test for follow-exec-mode. Although
there is a GDB test for debugging across an exec, there is no test for
follow-exec-mode. This test is derived from gdb.base/foll-exec.exp,
and re-uses execd-prog.c as the program to exec.
The following behavior is tested:
follow-exec-mode == "same"
- 'next' over the exec, check for one inferior
- 'continue' past the exec to a breakpoint, check for one inferior
- after the exec, use a 'run' command to run the current binary
follow-exec-mode == "new"
- 'next' over the exec, check for two inferiors
- 'continue' past the exec to a breakpoint, check for two inferiors
- after the exec, use a 'run' command to run the current binary
- after the exec, use the 'inferior' command to switch inferiors,
then use a 'run' command to run the current binary
Note that single-step breakpoints do not survive across an exec.
There has to be a breakpoint in the execed program in order for
it to stop right after the exec.
gdb/testsuite/ChangeLog:
* gdb.base/foll-exec-2.c: New test program.
* gdb.base/foll-exec-2.exp: New test.
A number of targets emit multiple relocs at a given r_offset, and
depend on those relocs staying in their original order.
PR 18867
* elflink.c (cmp_ext32l_r_offset, cmp_ext32b_r_offset): Delete.
(cmp_ext64l_r_offset, cmp_ext64b_r_offset): Delete.
(ext32l_r_offset, ext32b_r_offset, ext64l_r_offset, ext64b_r_offset):
New functions.
(elf_link_adjust_relocs): Use an insertion sort to sort relocs.
bfd PR ld/18401
* elfxx-mips.c (bfd_mips_isa_ext_mach): New function: Converts an
ISA value to a bfd machine number.
(bfd_mips_isa_ext): Update the ISA level and revision if
necessary. Use mips_mach_extends_p to decide if the ISA extension
needs to be set.
(_bfd_mips_elf_merge_private_bfd_data): Allow the ISA extension to
be inferred from the ABI setting. Set the ISA level from the
maximum of the incoming and outgoing ISA levels.
tests
* ld-mips-elf/mips-elf-flags.exp: Add more ISA conflict tests.
PR gas/18581
* config/tc-mn10200.c (md_assemble <mdr>): Move restore_line_pointer
call to where input line used to be restored.
* config/tc-mn10300.c (md_assemble <usp>): Remove redundant input
line restore.
* config/tc-tilepro.c (parse_reg_expression): Add regname var.