aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-02-21Automatic date update in version.inGDB Administrator1-1/+1
2015-02-20Fix gdb.base/solib-corrupted.exp after dtrace probes changesPedro Alves2-1/+6
Commit 6f9b8491 (Adapt `info probes' to support printing probes of different types.) added a new type column to "info probes". That caused a solib-corrupted.exp regression: ~~~~~~~~~~~~~~~~~~~~~ Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/solib-corrupted.exp ... FAIL: gdb.base/solib-corrupted.exp: corrupted list === gdb Summary === # of expected passes 2 # of unexpected failures 1 ~~~~~~~~~~~~~~~~~~~~~ Tested on x86_64 Fedora 20. gdb/testsuite/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * gdb.base/solib-corrupted.exp: Expect "stap" as first column of info probes.
2015-02-20GNU/Linux: Stop using libthread_db/td_ta_thr_iterPedro Alves10-172/+291
TL;DR - GDB can hang if something refreshes the thread list out of the target while the target is running. GDB hangs inside td_ta_thr_iter. The fix is to not use that libthread_db function anymore. Long version: Running the testsuite against my all-stop-on-top-of-non-stop series is still exposing latent non-stop bugs. I was originally seeing this with the multi-create.exp test, back when we were still using libthread_db thread event breakpoints. The all-stop-on-top-of-non-stop series forces a thread list refresh each time GDB needs to start stepping over a breakpoint (to pause all threads). That test hits the thread event breakpoint often, resulting in a bunch of step-over operations, thus a bunch of thread list refreshes while some threads in the target are running. The commit adds a real non-stop mode test that triggers the issue, based on multi-create.exp, that does an explicit "info threads" when a breakpoint is hit. IOW, it does the same things the as-ns series was doing when testing multi-create.exp. The bug is a race, so it unfortunately takes several runs for the test to trigger it. In fact, even when setting the test running in a loop, it sometimes takes several minutes for it to trigger for me. The race is related to libthread_db's td_ta_thr_iter. This is libthread_db's entry point for walking the thread list of the inferior. Sometimes, when GDB refreshes the thread list from the target, libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a cycle, and get stuck in an infinite loop. The issue is that when a thread exits, its thread control structure in glibc is moved from a "used" list to a "cache" list. These lists are simply circular linked lists where the "next/prev" pointers are embedded in the thread control structure itself. The "next" pointer of the last element of the list points back to the list's sentinel "head". There's only one set of "next/prev" pointers for both lists; thus a thread can only be in one of the lists at a time, not in both simultaneously. So when thread C exits, simplifying, the following happens. A-C are threads. stack_used and stack_cache are the list's heads. Before: stack_used -> A -> B -> C -> (&stack_used) stack_cache -> (&stack_cache) After: stack_used -> A -> B -> (&stack_used) stack_cache -> C -> (&stack_cache) td_ta_thr_iter starts by iterating at the list's head's next, and iterates until it sees a thread whose next pointer points to the list's head again. Thus in the before case above, C's next points to stack_used, indicating end of list. In the same case, the stack_cache list is empty. For each thread being iterated, td_ta_thr_iter reads the whole thread object out of the inferior. This includes the thread's "next" pointer. In the scenario above, it may happen that td_ta_thr_iter is iterating thread B and has already read B's thread structure just before thread C exits and its control structure moves to the cached list. Now, recall that td_ta_thr_iter is running in the context of GDB, and there's no locking between GDB and the inferior. From it's local copy of B, td_ta_thr_iter believes that the next thread after B is thread C, so it happilly continues iterating to C, a thread that has already exited, and is now in the stack cache list. After iterating C, td_ta_thr_iter finds the stack_cache head, which because it is not stack_used, td_ta_thr_iter assumes it's just another thread. After this, unless the reverse race triggers, GDB gets stuck in td_ta_thr_iter forever walking the stack_cache list, as no thread in thatlist has a next pointer that points back to stack_used (the terminating condition). Before fully understanding the issue, I tried adding cycle detection to GDB's td_ta_thr_iter callback. However, td_ta_thr_iter skips calling the callback in some cases, which means that it's possible that the callback isn't called at all, making it impossible for GDB to break the loop. I did manage to get GDB stuck in that state more than once. Fortunately, we can avoid the issue altogether. We don't really need td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE. We already know how to map and lwp id to a thread id without iterating (thread_from_lwp), so use that more. gdb/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_handle_extended_wait): Call thread_db_notice_clone whenever a new clone LWP is detected. (linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New functions. * linux-nat.h (thread_db_attach_lwp): Delete declaration. (thread_db_notice_clone, linux_stop_and_wait_all_lwps) (linux_unstop_all_lwps): Declare. * linux-thread-db.c (struct thread_get_info_inout): Delete. (thread_get_info_callback): Delete. (thread_from_lwp): Use td_thr_get_info and record_thread. (thread_db_attach_lwp): Delete. (thread_db_notice_clone): New function. (try_thread_db_load_1): If /proc is mounted and shows the process'es task list, walk over all LWPs and call thread_from_lwp instead of relying on td_ta_thr_iter. (attach_thread): Don't call check_thread_signals here. Split the tail part of the function (which adds the thread to the core GDB thread list) to ... (record_thread): ... this function. Call check_thread_signals here. (thread_db_wait): Don't call thread_db_find_new_threads_1. Always call thread_from_lwp. (thread_db_update_thread_list): Rename to ... (thread_db_update_thread_list_org): ... this. (thread_db_update_thread_list): New function. (thread_db_find_thread_from_tid): Delete. (thread_db_get_ada_task_ptid): Simplify. * nat/linux-procfs.c: Include <sys/stat.h>. (linux_proc_task_list_dir_exists): New function. * nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare. gdb/gdbserver/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * thread-db.c: Include "nat/linux-procfs.h". (thread_db_init): Skip listing new threads if the kernel supports PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible. gdb/testsuite/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20linux-nat.c: fix a few lin_lwp_attach_lwp issuesPedro Alves2-21/+47
This function has a few latent bugs that are triggered by a non-stop mode test that will be added in a subsequent patch. First, as described in the function's intro comment, the function is supposed to return 1 if we're already auto attached to the thread, but haven't processed the PTRACE_EVENT_CLONE event of its parent thread yet. Then, we may find that we're trying to attach to a clone child that hasn't yet stopped for its initial stop, and therefore 'waitpid(..., WNOHANG)' returns 0. In that case, we're currently adding the LWP to the stopped_pids list, which results in linux_handle_extended_wait skipping the waitpid call on the child, and thus confusing things later on when the child eventually reports the stop. Then, the tail end of lin_lwp_attach_lwp always sets the last_resume_kind of the LWP to resume_stop, which is wrong given that the user may be doing "info threads" while some threads are running. And then, the else branch of lin_lwp_attach_lwp always sets the stopped flag of the LWP. This branch is reached if the LWP is the main LWP, which may well be running at this point (to it's wrong to set its 'stopped' flag). AFAICS, there's no reason anymore for special-casing the main/leader LWP here: - For the "attach" case, linux_nat_attach already adds the main LWP to the lwp list, and sets its 'stopped' flag. - For the "run" case, after linux_nat_create_inferior, end up in linux_nat_wait_1 here: /* The first time we get here after starting a new inferior, we may not have added it to the LWP list yet - this is the earliest moment at which we know its PID. */ if (ptid_is_pid (inferior_ptid)) { /* Upgrade the main thread's ptid. */ thread_change_ptid (inferior_ptid, ptid_build (ptid_get_pid (inferior_ptid), ptid_get_pid (inferior_ptid), 0)); lp = add_initial_lwp (inferior_ptid); lp->resumed = 1; } ... which adds the LWP to the LWP list already, before lin_lwp_attach_lwp can ever be reached. gdb/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * linux-nat.c (lin_lwp_attach_lwp): No longer special case the main LWP. Handle the case of waitpid returning 0 if we're already attached to the LWP. Don't set the LWP's last_resume_kind to resume_stop if we already knew about the LWP. (linux_nat_filter_event): Add debug logs.
2015-02-20Garbage collect forward_target_decr_pc_after_breakPedro Alves2-4/+5
The definition was removed a year ago, but the declaration managed to stay behind. gdb/ChangeLog 2015-02-20 Pedro Alves <palves@redhat.com> * target.h (forward_target_decr_pc_after_break): Delete declaration.
2015-02-20fix gdbserver/linux-low'c's pending status handlingPedro Alves2-3/+6
Another fix I'm working made schedlock.exp fail with gdbserver frequently. Looking deeper, it turns out to be a pre-existing bug. status_pending_p_callback is filtering out LWPs incorrectly. The result is that that sometimes status_pending_p_callback returns a pending event for an LWP that isn't expected, and then GDBserver gets very confused. E.g,. when doing a step-over, linux_wait_for_event is called with a particular LWP's ptid, meaning events for all other LWPs should be left pending, but here we see it retuning an event for some other LWP: linux_wait_1: [<all threads>] step_over_bkpt set [LWP 29577.29577], doing a blocking wait <-------- my_waitpid (-1, 0x40000001) my_waitpid (-1, 0x80000001): status(57f), 0 LWFE: waitpid(-1, ...) returned 0, ERRNO-OK pc is 0x4007a0 src/gdb/gdbserver/linux-low.c:2587: A problem internal to GDBserver has been detected. linux_wait_1: got event for 29581 <-------- Remote connection closed (gdb) FAIL: gdb.threads/schedlock.exp: continue to breakpoint: return to loop (initial) delete breakpoints Tested on x86_64 Fedora 20. gdb/gdbserver/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * linux-low.c (status_pending_p_callback): Use ptid_match.
2015-02-20Fix no-attach-trace.exp with "target remote" / gdbserverPedro Alves2-9/+10
$ make check RUNTESTFLAGS="--target_board=native-gdbserver no-attach-trace.exp" ... (gdb) trace main Tracepoint 1 at 0x400594: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.trace/no-attach-trace.c, line 25. (gdb) PASS: gdb.trace/no-attach-trace.exp: set tracepoint on main tstart You can't do that when your target is `exec' (gdb) FAIL: gdb.trace/no-attach-trace.exp: tstart Even though this target supports tracing, the test restarts GDB and doesn't do gdb_run_cmd so does not reconnect to the remote target. So at that point, GDB only has the "exec" target, which obviously doesn't do tracing. The test is about doing "tstart" before running a program, so the fix is to do gdb_target_supports_trace with whatever target GDB ends up connected after clean_restart. Tested on x86_64 Fedora 20, native, native-gdbserver and native-extended-gdbserver boards. The test passes with the latter, and is skipped with the first two. gdb/testsuite/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> * gdb.trace/no-attach-trace.exp: Don't run to main. Do clean_restart before gdb_target_supports_trace.
2015-02-20PR18006: internal error if threaded program calls clone(CLONE_VM)Pedro Alves5-0/+130
On GNU/Linux, if a pthreaded program has a thread call clone(CLONE_VM) directly, and then that clone LWP hits a debug event (breakpoint, etc.) GDB internal errors. Threaded programs shouldn't really be calling clone directly, but GDB shouldn't crash either. The crash looks like this: (gdb) break clone_fn Breakpoint 2 at 0x4007d8: file clone-thread_db.c, line 35. (gdb) r ... [Thread debugging using libthread_db enabled] ... src/gdb/linux-nat.c:1030: internal-error: lin_lwp_attach_lwp: Assertion `lwpid > 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. The problem is that 'clone' ends up clearing the parent thread's tid field in glibc's thread data structure. For x86_64, the glibc code in question is here: sysdeps/unix/sysv/linux/x86_64/clone.S: ... testq $CLONE_THREAD, %rdi jne 1f testq $CLONE_VM, %rdi movl $-1, %eax <---- jne 2f movl $SYS_ify(getpid), %eax syscall 2: movl %eax, %fs:PID movl %eax, %fs:TID <---- 1: When GDB refreshes the thread list out of libthread_db, it finds a thread with LWP with pid -1 (the clone's parent), which naturally isn't yet on the thread list. GDB then tries to attach to that bogus LWP id, which is caught by that assertion. The fix is to detect the bad PID early. Tested on x86-64 Fedora 20. GDBserver doesn't need any fix. gdb/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> PR threads/18006 * linux-thread-db.c (thread_get_info_callback): Return early if the thread's lwp id is -1. gdb/testsuite/ChangeLog: 2015-02-20 Pedro Alves <palves@redhat.com> PR threads/18006 * gdb.threads/clone-thread_db.c: New file. * gdb.threads/clone-thread_db.exp: New file.
2015-02-20Document the GDB 7.9 release in gdb/ChangeLogJoel Brobecker1-0/+4
gdb/ChangeLog: GDB 7.9 released.
2015-02-20S390: Support new vector register sectionsAndreas Arnez7-0/+88
The IBM z13 has new 128-bit wide vector registers v0-v31, where v0-v15 include the existing 64-bit wide floating point registers. The Linux kernel presents the vector registers as two additional register sets, one for the right halves of v0-v15 and another one for the full registers v16-v31. Thus a new core file may contain two new register note sections, and this patch adds support to binutils for them. bfd/ * elf-bfd.h (elfcore_write_s390_vxrs_low): Add prototype. (elfcore_write_s390_vxrs_high): Likewise. * elf.c (elfcore_grok_s390_vxrs_low): New function. (elfcore_grok_s390_vxrs_high): New function. (elfcore_grok_note): Call them. (elfcore_write_s390_vxrs_low): New function. (elfcore_write_s390_vxrs_high): New function. (elfcore_write_register_note): Call them. binutils/ * readelf.c (get_note_type): Add NT_S390_VXRS_LOW and NT_S390_VXRS_HIGH. include/elf/ * common.h (NT_S390_VXRS_LOW): New macro. (NT_S390_VXRS_HIGH): Likewise.
2015-02-20sim: drop unused headersMike Frysinger9-288/+25
These look like left over hacks from the days where we had to protect ourselves from the compiler and C library. None of these checks are relevant, and we have common configure logic to do header tests. Punt them all now.
2015-02-19sim: drop unused sim_kill functionMike Frysinger10-36/+20
This has been deprecated for a long time and no one calls it.
2015-02-20Automatic date update in version.inGDB Administrator1-1/+1
2015-02-20sim: ChangeLog: Correct the related items position and format.Chen Gang4-20/+18
Move several items from sim/ChangeLog to sim/*/ChangeLog. Also remove the incorrect white space in sim/common/ChangeLog.
2015-02-19Wrap a few opcodes headers in extern "C" for C++Pedro Alves9-0/+69
These are sufficient to link an --enable-targets=all GDB build in C++ mode, on x86_64 Fedora 20. include/opcode/ 2015-02-19 Pedro Alves <palves@redhat.com> * cgen.h [__cplusplus]: Wrap in extern "C". * msp430-decode.h [__cplusplus]: Likewise. * nios2.h [__cplusplus]: Likewise. * rl78.h [__cplusplus]: Likewise. * rx.h [__cplusplus]: Likewise. * tilegx.h [__cplusplus]: Likewise. opcodes/ 2015-02-19 Pedro Alves <palves@redhat.com> * microblaze-dis.h [__cplusplus]: Wrap in extern "C".
2015-02-19floatformat.h: Wrap in extern "C"Pedro Alves2-0/+12
Just like libiberty.h. So that C++ programs, such as GDB when built as a C++ program, can use it. include/ChangeLog: 2015-02-19 Pedro Alves <palves@redhat.com> * floatformat.h [__cplusplus]: Wrap in extern "C".
2015-02-192015-02-19 Steve Ellcey <sellcey@imgtec.com>Steve Ellcey2-3/+12
* dtrace-probe.c (dtrace_process_dof_probe): Initialize arg.expr. (dtrace_get_probes) Change type of variable 'dof'.
2015-02-19Fix non executable stack handling when calling functions in the inferior.Antoine Tremblay9-18/+142
When gdb creates a dummy frame to execute a function in the inferior, the process may generate a SIGSEGV, SIGTRAP or SIGILL because the stack is non executable. If the signal handler set in gdb has option print or stop enabled for these signals gdb handles this correctly. However, in the case of noprint and nostop the signal is short-circuited and the inferior process is sent the signal directly. This causes the inferior to crash because of gdb. This patch adds a check for SIGSEGV, SIGTRAP or SIGILL so that these signals are sent to gdb rather than short-circuited in the inferior. gdb then handles them properly and the inferior process does not crash. This patch also fixes the same behavior in gdbserver. Also added a small testcase to test the issue called catch-gdb-caused-signals. This applies to Linux only, tested on Linux. gdb/ChangeLog: PR breakpoints/16812 * linux-nat.c (linux_nat_filter_event): Report SIGTRAP,SIGILL,SIGSEGV. * nat/linux-ptrace.c (linux_wstatus_maybe_breakpoint): Add. * nat/linux-ptrace.h: Add linux_wstatus_maybe_breakpoint. gdb/gdbserver/ChangeLog: PR breakpoints/16812 * linux-low.c (wstatus_maybe_breakpoint): Remove. (linux_low_filter_event): Update wstatus_maybe_breakpoint name. (linux_wait_1): Report SIGTRAP,SIGILL,SIGSEGV. gdb/testsuite/ChangeLog: PR breakpoints/16812 * gdb.base/catch-gdb-caused-signals.c: New file. * gdb.base/catch-gdb-caused-signals.exp: New file.
2015-02-19[gdb/ax] small "setv" fix and documentation's adjustment.David Taylor4-2/+10
gdb/doc/agentexpr.texi documents the "setv" opcode as follow: @item @code{setv} (0x2d) @var{n}: @result{} @var{v} Set trace state variable number @var{n} to the value found on the top of the stack. The stack is unchanged, so that the value is readily available if the assignment is part of a larger expression. The handling of @var{n} is as described for @code{getv}. The @item line is incorrect (and does not match with its description), so this patch fixes it. Additionally, in gdb/common/ax.def we find the line: DEFOP (setv, 2, 0, 0, 1, 0x2d) From the comment earlier in the file: Each line is of the form: DEFOP (name, size, data_size, consumed, produced, opcode) [...] CONSUMED is the number of stack elements consumed. PRODUCED is the number of stack elements produced. which is saying that nothing is consumed and one item is produced. Both should be 0 or both should be 1. This patch sets them both to 1, which seems better since if nothing is on the stack an error will occur. gdb/ChangeLog: * common/ax.def (setv): Fix consumed entry in setv DEFOP. gdb/doc/ChangeLog: * agentexpr.texi (Bytecode Descriptions): Fix summary line for setv. Tested on x86_64-linux.
2015-02-19Use nm/readelf with "failif"H.J. Lu4-0/+25
PR ld/4317 * ld-i386/compressed1.d: Use nm/readelf with "failif". * ld-x86-64/compressed1.d: Likewise. * ld-x86-64/pie1.d: Likewise.
2015-02-19Fix buffer overrun in verilog codeBranko Drevensek2-1/+6
PR 17995 * verilog.c (verilog_write_record): Correct buffer size.
2015-02-19sim: microblaze: fix build failure after opcodes updateMike Frysinger2-3/+7
Commit 07774fccc3280323f43db9ed204f628503b34663 update the microblaze opcodes table to avoid C++ collisions, but missed updating the sim. That caused it to fail to build due to missing keywords.
2015-02-19tidy _bfd_elf_define_linkage_symAlan Modra2-3/+6
* elflink.c (_bfd_elf_define_linkage_sym): Set 'bed' earlier.
2015-02-19gas doc warning fixesAlan Modra3-23/+28
* doc/as.texinfo (Local Symbol Names): Don't use ':' in pxref. * doc/c-i386.texi: Reorder i386-Bugs after i386-Arch.
2015-02-19Strip undefined symbols from .symtabAlan Modra19-56/+53
bfd/ PR ld/4317 * elflink.c (elf_link_input_bfd): Drop undefined local syms. (elf_link_output_extsym): Drop local and global undefined syms. Tidy. Expand comment. ld/testsuite/ PR ld/4317 * ld-aarch64/gc-tls-relocs.d, * ld-cris/locref2.d, * ld-elf/ehdr_start-weak.d, * ld-elf/group1.d, * ld-i386/compressed1.d, * ld-ia64/error1.d, * ld-ia64/error2.d, * ld-ia64/error3.d, * ld-mips-elf/pic-and-nonpic-1.nd, * ld-mmix/undef-3.d, * ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r, * ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r, * ld-x86-64/compressed1.d, * ld-x86-64/pie1.d: Update.
2015-02-19Automatic date update in version.inGDB Administrator1-1/+1
2015-02-18Add missing gdb/ChangeLog entry for previous change.Patrick Palka1-0/+15
2015-02-18Asynchronously resize the TUIPatrick Palka2-39/+41
This patch teaches the TUI to resize itself asynchronously instead of synchronously. Asynchronously resizing the screen when the underlying terminal gets resized is the more intuitive behavior and is surprisingly simple to implement thanks to GDB's async infrastructure. The implementation is straightforward. TUI's SIGWINCH handler is just tweaked to asynchronously invoke a new callback, tui_async_resize_screen, which is responsible for safely resizing the screen. Care must be taken to not to attempt to asynchronously resize the screen while the TUI is not active. When the TUI is not active, the callback will do nothing, but the screen will yet be resized in the next call to tui_enable() by virtue of win_resized being TRUE. (So, after the patch there are still two places where the screen gets resized: one in tui_enable() and the other now in tui_async_resize_screen() as opposed to being in tui_handle_resize_during_io(). The one in tui_enable() is still necessary to handle the case where the terminal gets resized inside the CLI: in that case, the TUI still needs resizing, but it must wait until the TUI gets re-enabled.) gdb/ChangeLog: * tui/tui-io.c (tui_handle_resize_during_io): Remove this function. (tui_putc): Don't call tui_handle_resize_during_io. (tui_getc): Likewise. (tui_mld_getc): Likewise. * tui/tui-win.c: Include event-loop.h and tui/tui-io.h. (tui_sigwinch_token): New static variable. (tui_initialize_win): Adjust documentation. Set tui_sigwinch_token. (tui_async_resize_screen): New asynchronous callback. (tui_sigwinch_handler): Adjust documentation. Asynchronously invoke tui_async_resize_screen.
2015-02-18Factorize target program transformations in the GDB_AC_TRANSFORM macro.Jose E. Marchesi10-60/+91
This patch introduces a new M4 macro GDB_AC_TRANSFORM to avoid repeating the common idiom which is the transformation of target program names, i.e. from gdb to sparc64-linux-gnu-gdb. It also makes gdb/configure.ac and gdb/testsuite/configure.ac to use the new macro. gdb/ChangeLog: 2015-02-18 Jose E. Marchesi <jose.marchesi@oracle.com> * configure: Regenerated. * configure.ac: Use GDB_AC_TRANSFORM. * Makefile.in (aclocal_m4_deps): Added transform.m4. * acinclude.m4: sinclude transform.m4. * transform.m4: New file. (GDB_AC_TRANSFORM): New macro. gdb/testsuite/ChangeLog: 2015-02-18 Jose E. Marchesi <jose.marchesi@oracle.com> * configure: Regenerated. * configure.ac: Use GDB_AC_TRANSFORM. * aclocal.m4: sinclude ../transform.m4.
2015-02-18Fix gold error: hidden symbol '...' is not defined locallyAlan Modra2-0/+7
Found when applying relocs in .debug that reference removed functions. PR 17954 * powerpc.cc (Global_symbol_visitor_opd::operator()): Set default visibility.
2015-02-18Automatic date update in version.inGDB Administrator1-1/+1
2015-02-17Simplify Garbage_collection::add_reference a bit.Rafael Ávila de Espíndola2-5/+6
this->section_reloc_map_[src_id] is created if it doesn't exist, so there is no point in doing a find.
2015-02-17avoid std::vector copy.Rafael Ávila de Espíndola2-1/+5
2015-02-17Use std::upper_bound to simplify code a bit.Rafael Ávila de Espíndola2-8/+9
With std::upper_bound we don't have to check p->input_offset > input_offset.
2015-02-17Announce the DTrace USDT probes support in NEWS.Jose E. Marchesi2-0/+7
This patch simply adds a small entry to `Changes since GDB 7.8' announcing the support for dtrace probes. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * NEWS: Announce the support for DTrace SDT probes.
2015-02-17Documentation for DTrace USDT probes.Jose E. Marchesi2-19/+47
This patch modifies the `Static Probe Points' section on the GDB manual in order to cover the support for DTrace USDT probes, in addition to SystemTap SDT probes. gdb/doc/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.texinfo (Static Probe Points): Add cindex `static probe point, DTrace'. (Static Probe Points): Modified to cover DTrace probes in addition to SystemTap probes. Also modified to cover the `enable probe' and `disable probe' commands.
2015-02-17Simple testsuite for DTrace USDT probes.Jose E. Marchesi8-0/+1357
This patch adds some simple tests testing the support for DTrace USDT probes. The testsuite will be skipped as unsupported in case the user does not have DTrace installed on her system. The tests included in the test suite test breakpointing on DTrace probes, enabling and disabling probes, printing of probe arguments of several types and also breakpointing on several probes with the same name. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * lib/dtrace.exp: New file. * gdb.base/dtrace-probe.exp: Likewise. * gdb.base/dtrace-probe.d: Likewise. * gdb.base/dtrace-probe.c: Likewise. * lib/pdtrace.in: Likewise. * configure.ac: Output variables with the transformed names of the strip, readelf, as and nm tools. AC_SUBST lib/pdtrace.in. * configure: Regenerated.
2015-02-17Support for DTrace USDT probes in x86_64 targets.Jose E. Marchesi2-0/+164
This patch adds the target-specific code in order to support the calculation of DTrace probes arguments in x86_64 targets, and also the enabling and disabling of probes. This is done by implementing the `dtrace_*' gdbarch handlers. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * amd64-linux-tdep.c: Include "parser-defs.h" and "user-regs.h". (amd64_dtrace_parse_probe_argument): New function. (amd64_dtrace_probe_is_enabled): Likewise. (amd64_dtrace_enable_probe): Likewise. (amd64_dtrace_disable_probe): Likewise. (amd64_linux_init_abi): Register the `gdbarch_dtrace_probe_argument', `gdbarch_dtrace_enable_probe', `gdbarch_dtrace_disable_probe' and `gdbarch_dtrace_probe_is_enabled' hooks. (amd64_dtrace_disabled_probe_sequence_1): New constant. (amd64_dtrace_disabled_probe_sequence_2): Likewise. (amd64_dtrace_enable_probe_sequence): Likewise. (amd64_dtrace_disable_probe_sequence): Likewise.
2015-02-17New probe type: DTrace USDT probes.Jose E. Marchesi6-4/+960
This patch adds a new type of probe to GDB: the DTrace USDT probes. The new type is added by providing functions implementing all the entries of the `probe_ops' structure defined in `probe.h'. The implementation is self-contained and does not depend on DTrace source code in any way. gdb/ChangeLog: 2015-02-7 Jose E. Marchesi <jose.marchesi@oracle.com> * breakpoint.c (BREAK_ARGS_HELP): Help string updated to mention the -probe-dtrace new vpossible value for PROBE_MODIFIER. * configure.ac (CONFIG_OBS): dtrace-probe.o added if BFD can handle ELF files. * Makefile.in (SFILES): dtrace-probe.c added. * configure: Regenerate. * dtrace-probe.c: New file. (SHT_SUNW_dof): New constant. (dtrace_probe_type): New enum. (dtrace_probe_arg): New struct. (dtrace_probe_arg_s): New typedef. (struct dtrace_probe_enabler): New struct. (dtrace_probe_enabler_s): New typedef. (dtrace_probe): New struct. (dtrace_probe_is_linespec): New function. (dtrace_dof_sect_type): New enum. (dtrace_dof_dofh_ident): Likewise. (dtrace_dof_encoding): Likewise. (DTRACE_DOF_ENCODE_LSB): Likewise. (DTRACE_DOF_ENCODE_MSB): Likewise. (dtrace_dof_hdr): New struct. (dtrace_dof_sect): Likewise. (dtrace_dof_provider): Likewise. (dtrace_dof_probe): Likewise. (DOF_UINT): New macro. (DTRACE_DOF_PTR): Likewise. (DTRACE_DOF_SECT): Likewise. (dtrace_process_dof_probe): New function. (dtrace_process_dof): Likewise. (dtrace_build_arg_exprs): Likewise. (dtrace_get_arg): Likewise. (dtrace_get_probes): Likewise. (dtrace_get_probe_argument_count): Likewise. (dtrace_can_evaluate_probe_arguments): Likewise. (dtrace_evaluate_probe_argument): Likewise. (dtrace_compile_to_ax): Likewise. (dtrace_probe_destroy): Likewise. (dtrace_gen_info_probes_table_header): Likewise. (dtrace_gen_info_probes_table_values): Likewise. (dtrace_probe_is_enabled): Likewise. (dtrace_probe_ops): New variable. (info_probes_dtrace_command): New function. (_initialize_dtrace_probe): Likewise. (dtrace_type_name): Likewise.
2015-02-17New gdbarch functions: dtrace_parse_probe_argument, dtrace_probe_is_enabled, ↵Jose E. Marchesi4-0/+189
dtrace_enable_probe, dtrace_disable_probe. This patch adds several gdbarch functions (along with the corresponding predicates): `dtrace_parse_probe_argument', `dtrace_probe_is_enabled', `dtrace_enable_probe' and `dtrace_disable_probe'. These functions will be implemented by target-specific code, and called from the DTrace probes implementation in order to calculate the value of probe arguments, and manipulate is-enabled probes. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * gdbarch.sh (dtrace_parse_probe_argument): New. (dtrace_probe_is_enabled): Likewise. (dtrace_enable_probe): Likewise. (dtrace_disable_probe): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2015-02-17New commands `enable probe' and `disable probe'.Jose E. Marchesi6-16/+198
This patch adds the above-mentioned commands to the generic probe abstraction implemented in probe.[ch]. The effects associated to enabling or disabling a probe depend on the type of probe being handled, and is triggered by invoking two back-end hooks in `probe_ops'. In case some particular probe type does not support the notion of enabling and/or disabling, the corresponding fields on `probe_ops' can be initialized to NULL. This is the case of SystemTap probes. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * stap-probe.c (stap_probe_ops): Add NULLs in the static stap_probe_ops for `enable_probe' and `disable_probe'. * probe.c (enable_probes_command): New function. (disable_probes_command): Likewise. (_initialize_probe): Define the cli commands `enable probe' and `disable probe'. (parse_probe_linespec): New function. (info_probes_for_ops): Use parse_probe_linespec. * probe.h (probe_ops): New hooks `enable_probe' and `disable_probe'. gdb/doc/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.texinfo (Static Probe Points): Cover the `enable probe' and `disable probe' commands.
2015-02-17Move `compute_probe_arg' and `compile_probe_arg' to probe.cJose E. Marchesi5-110/+127
This patch moves the `compute_probe_arg' and `compile_probe_arg' functions from stap-probe.c to probe.c. The rationale is that it is reasonable to assume that all backends will provide the `$_probe_argN' convenience variables, and that the user must be placed on the PC of the probe when requesting that information. The value and type of the argument can still be determined by the probe backend via the `pops->evaluate_probe_argument' and `pops->compile_to_ax' handlers. Note that a test in gdb.base/stap-probe.exp had to be adjusted because the "No SystemTap probe at PC" messages are now "No probe at PC". gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * probe.c (compute_probe_arg): Moved from stap-probe.c (compile_probe_arg): Likewise. (probe_funcs): Likewise. * stap-probe.c (compute_probe_arg): Moved to probe.c. (compile_probe_arg): Likewise. (probe_funcs): Likewise. gdb/testsuite/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.base/stap-probe.exp (stap_test): Remove "SystemTap" from expected message when trying to access $_probe_* convenience variables while not on a probe.
2015-02-17Adapt `info probes' to support printing probes of different types.Jose E. Marchesi4-10/+96
A "probe type" (backend for the probe abstraction implemented in probe.[ch]) can extend the information printed by `info probes' by defining additional columns. This means that when `info probes' is used to print all the probes regardless of their types, some of the columns will be "not applicable" to some of the probes (like, say, the Semaphore column only makes sense for SystemTap probes). This patch makes `info probes' fill these slots with "n/a" marks (currently it breaks the table) and not include headers for which no actual probe has been found in the list of defined probes. This patch also adds support for a new generic column "Type", that displays the type of each probe. SystemTap probes identify themselves as "stap" probes. gdb/ChangeLog: 2015-02-17 Jose E. Marchesi <jose.marchesi@oracle.com> * probe.c (print_ui_out_not_applicables): New function. (exists_probe_with_pops): Likewise. (info_probes_for_ops): Do not include column headers for probe types for which no probe has been actually found on any object. Also invoke `print_ui_out_not_applicables' in order to match the column rows with the header when probes of several types are listed. Print the "Type" column. * probe.h (probe_ops): Added a new probe operation `type_name'. * stap-probe.c (stap_probe_ops): Add `stap_type_name'. (stap_type_name): New function.
2015-02-18Properly place the NULL STT_FILE symbol revistitedAlan Modra33-93/+114
I was having a little closer look at what is going on here and noticed that HJ unconditionally emits a NULL STT_FILE symbol before emitting forced local symbols. That means we really don't need a second pass over forced local symbols. The only reason for two passes is when some forced local symbol can be emitted before the NULL STT_FILE. So I set about removing the second pass, updating the testsuite all over again. It's also unnecessary to emit the NULL STT_FILE when no previous file symbol has been emitted. bfd/ PR ld/17975 * elflink.c (struct elf_outext_info): Remove need_second_pass and second_pass. (elf_link_output_extsym): Delete code handling second forced local pass. Move code emitting NULL STT_FILE symbol later, so that it can be omitted if forced local is stripped. Don't emit the NULL STT_FILE if no file symbols have been output. (bfd_elf_final_link): Remove second forced local pass. * elf32-ppc.c (add_stub_sym): Set linker_def on linker syms. (ppc_elf_size_dynamic_sections): Likewise. * elf64-ppc.c (ppc_build_one_stub): Likewise. (build_global_entry_stubs): Likewise. (ppc64_elf_build_stubs): Likewise. ld/testsuite/ PR ld/17975 * ld-aarch64/gc-tls-relocs.d, * ld-alpha/tlspic.rd, * ld-cris/libdso-2.d, * ld-i386/tlsdesc-nacl.rd, * ld-i386/tlsdesc.rd, * ld-i386/tlsnopic-nacl.rd, * ld-i386/tlsnopic.rd, * ld-i386/tlspic-nacl.rd, * ld-i386/tlspic.rd, * ld-ia64/tlspic.rd, * ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r, * ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r, * ld-s390/tlspic.rd, * ld-s390/tlspic_64.rd, * ld-sparc/tlssunnopic32.rd, * ld-sparc/tlssunnopic64.rd, * ld-sparc/tlssunpic32.rd, * ld-sparc/tlssunpic64.rd, * ld-tic6x/shlib-1.rd, * ld-tic6x/shlib-1b.rd, * ld-tic6x/shlib-1r.rd, * ld-tic6x/shlib-1rb.rd, * ld-tic6x/shlib-noindex.rd, * ld-x86-64/tlsdesc-nacl.rd, * ld-x86-64/tlsdesc.rd, * ld-x86-64/tlspic-nacl.rd, * ld-x86-64/tlspic.rd: Update.
2015-02-17Remove superfluous function key_is_command_char()Patrick Palka2-15/+7
The function key_is_command_char() is simply a predicate that determines whether the function tui_dispatch_ctrl_char() will do anything useful. Since tui_dispatch_ctrl_char() performs the same checks as key_is_command_char() it is unnecessary to keep key_is_command_char() around. This patch removes this useless function and instead unconditionally calls tui_dispatch_ctrl_char() inside its only caller, tui_getc(). gdb/ChangeLog: * tui/tui-io.c (tui_getc): Don't call key_is_command_char. (key_is_command_char): Delete.
2015-02-17TUI: resize windows to new terminal size before displaying themPedro Alves2-6/+15
If the user: #1 - disables the TUI #2 - resizes the terminal #3 - and then re-enables the TUI the next wgetch() returns KEY_RESIZE. This indicates to the ncurses client that ncurses detected that the terminal has been resized. We don't handle KEY_RESIZE anywhere, so it gets passed on to readline which interprets it as a multibyte character, and then the end result is that the first key press after enabling the TUI is misinterpreted. We shouldn't really need to handle KEY_RESIZE (and not all ncurses implementations have that). We have our own SIGWINCH handler, and, when we re-enable the TUI, we explicitly detect terminal resizes and resize all windows. The reason ncurses currently does detects a resize is that something within tui_enable forces a refresh/display of some window before we get to do the actual resizing. Setting a break on ncurses' 'resizeterm' function helps find the culprit(s): (top-gdb) bt #0 resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462 #1 0x0000003b42812f3f in _nc_update_screensize (sp=0x2674730) at ../../ncurses/tinfo/lib_setup.c:443 #2 0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726 #3 0x0000003b08215539 in wrefresh (win=0x2a7bc00) at ../../ncurses/base/lib_refresh.c:65 #4 0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60 #5 0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269 #6 0x00000000005273a6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:321 #7 0x00000000005278c7 in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:494 #8 0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108 That is, tui_enable calls tui_set_key_mode before we've resized all windows, and that refreshes a window as side effect. And if we're already debugging something (there's a frame), then we'll instead show a window from within tui_show_frame_info: (top-gdb) bt #0 resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462 #1 0x0000003b42812f3f in _nc_update_screensize (sp=0x202e6c0) at ../../ncurses/tinfo/lib_setup.c:443 #2 0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726 #3 0x0000003b08215539 in wrefresh (win=0x2042890) at ../../ncurses/base/lib_refresh.c:65 #4 0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60 #5 0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269 #6 0x0000000000522931 in tui_show_frame_info (fi=0x16b9cc0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:364 #7 0x00000000005278ba in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:491 #8 0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108 The fix is to resize windows earlier. gdb/ChangeLog: 2015-02-17 Pedro Alves <palves@redhat.com> * tui/tui.c (tui_enable): Resize windows before anything might show a window.
2015-02-17Fix GDB build fail on Aarch64 when -fno-common is enabledMaxim Ostapenko3-3/+10
Current trunk GDB (and gdb-7.8.1 too) fails to build on Aarch64 when -fno-common is enabled. It fails during link stage due to multiple definition of `tdesc_aarch64': ... [ 199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64': [ 199s] /home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11: multiple definition of `tdesc_aarch64' [ 199s] aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540: first defined here [ 199s] aarch64-linux-nat.o: In function `initialize_tdesc_aarch64': [ 199s] /home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/features/aarch64.c:11: multiple definition of `tdesc_aarch64' [ 199s] aarch64-tdep.o:/home/abuild/rpmbuild/BUILD/gdb-7.8.1/gdb/objfiles.h:540: first defined here [ 199s] collect2: error: ld returned 1 exit status [ 199s] make[2]: *** [gdb] Error 1 ... This happens because struct target_desc *tdesc_aarch64 is defined in gdb/features/aarch64.c, which is included by two files (gdb/aarch64-linux-nat.c and gdb/aarch64-tdep.c). gdb/Changelog 2015-02-17 Max Ostapenko <m.ostapenko@partner.samsung.com> PR gdb/17984 * aarch64-linux-nat.c: Don't include features/aarch64.c anymore. (aarch64_linux_read_description): Remove initialize_tdesc_aarch64 call. * aarch64-tdep.h (tdesc_aarch64): Declare.
2015-02-17[gold] Recognize DWARF5/GCC5 DW_LANG_Fortran03 and DW_LANG_Fortran08.Mark Wielaard4-1/+20
DWARFv5 defines and GCC5 may output two new DW_LANG constants for the Fortran 2003 and Fortran 2008 standards. Recognize both in gold gdb-index as unsupported. For consistency also add the other new DWARF5/GCC5 language constants in the elfcpp::DW_LANG enum to match include/dwarf2.h. elfcpp/ChangeLog: * dwarf.h (enum DW_LANG): Add DW_LANG_C_plus_plus_11, DW_LANG_C11, DW_LANG_C_plus_plus_14, DW_LANG_Fortran03 and DW_LANG_Fortran08 from ../include/dwarf2.h. gold/ChangeLog: * gdb-index.cc (Gdb_index_info_reader::visit_top_die): Recognize DW_LANG_Fortran03 and DW_LANG_Fortran08.
2015-02-16Fix --dynamic-list so that symbols not in the list are still exported.Cary Coutant6-14/+20
In PR 13577, the complaint was that -Bsymbolic was overriding the binding behavior for symbols listed in the --dynamic-list by setting the DT_SYMBOLIC tag in the dynamic table. In reading the Gnu ld manual, I decided that --dynamic-list should be mutually exclusive of -Bsymbolic, and modified gold so that --dynamic-list would treat symbols listed as preemptible, and all other symbols as internally bound. I was wrong. PR 16992 shows that with --dynamic-list (and not -Bsymbolic), a symbol not listed in the dynamic list is being internally bound within the shared library, but because it's still in the dynamic symbol table, we expose it to a COPY relocation, and things go really bad from there. (I can reproduce the same failure, simply by turning on -Bsymbolic-functions with the Gnu linker. Even though the symbol is bound internally, it's still exported to the dynamic symbol table, and is exposed to a COPY relocation.) I've backed out part of the fix for PR 13577, and -Bsymbolic (or -Bsymbolic-functions) can now be used with --dynamic-list, but if the two are used together, we do not set DT_SYMBOLIC or DF_SYMBOLIC (this matches Gnu ld behavior). We now treat symbols listed in the dynamic list as premptible, but we do not automatically treat symbols not listed there as non-premptible. gold/ PR gold/13577 PR gold/16992 * layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or DF_SYMBOLIC if --dynamic-list option is used. * options.cc (General_options::finalize): --dynamic-list is not mutually exclusive with -Bsymbolic. * symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not listed in --dynamic-list. * testsuite/Makefile.am (dynamic_list_lib2.so): Add -Bsymbolic-functions. * testsuite/Makefile.in: Regenerate.
2015-02-16Remove redundant include of "output.h".Cary Coutant2-1/+5
gold/ PR gold/17971 * incremental.cc: Remove redundant include of "output.h".