aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-12-01Don't use BFD_TRADITIONAL_FORMAT flag in COFF supportAlan Modra6-24/+39
info->traditional_format is available, or can be easily made available. This relegates BFD_TRADITIONAL_FORMAT to AOUT use only. * coff-rs6000.c (_bfd_xcoff_put_symbol_name): Replace abfd param with info param. Test info->traditional_format rather than BFD_TRADITIONAL_FORMAT flag. * coff64-rs6000.c (_bfd_xcoff64_put_symbol_name): Likewise. * libxcoff.h (struct xcoff_backend_data_rec): Update _xcoff_put_symbol_name prototype. (bfd_xcoff_put_symbol_name): Add info param. * xcofflink.c (xcoff_find_tc0): Update bfd_xcoff_put_symbol_name call. (xcoff_write_global_symbol): Likewise. (xcoff_link_input_bfd): Test info->traditional_format rather than BFD_TRADITIONAL_FORMAT flag. * cofflink.c (_bfd_coff_final_link): Likewise. (_bfd_coff_link_input_bfd, _bfd_coff_write_global_sym): Likewise.
2015-12-01binutils/configure updateAlan Modra2-1/+5
Missed from f8c2a965. * configure: Regenerate.
2015-12-01SRC-POTFILES.in updateAlan Modra2-0/+6
* po/SRC-POTFILES.in: Regenerate.
2015-12-01Re: ARC port broken reloc processingAlan Modra2-14/+22
* elf32-arc.c (ARC_ELF_HOWTO): Delete. (arc_elf_howto): New function. (bfd_elf32_bfd_reloc_type_lookup): Use it in place of existing init code. (bfd_elf32_bfd_reloc_name_lookup): Use arc_elf_howto. (arc_info_to_howto_rel, elf_arc_relocate_section): Likwise. (elf_arc_check_relocs): Likewise.
2015-12-01ARC port broken reloc processingAlan Modra2-1/+6
This initialises howto.dst_mask so that relocations in debug sections are applied by the generic reloc processing used by objdump to display debug sections. * elf32-arc.c (arc_elf_howto_init): Init dst_mask.
2015-12-01Automatic date update in version.inGDB Administrator1-1/+1
2015-11-30Remove too simple breakpoint_reinsert_addr implementations.Antoine Tremblay7-88/+21
This patch removes too simple implementations of the breakpoint_reinsert_addr operation. The only reason to keep them around was to support thread events when PTRACE_EVENT_CLONE was not present but this support has been removed in a previous patch. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } Also compilation was tested on aarch64, bfin, cris, crisv32, m32r, mips, nios2, ppc, s390, sparc, tic6x, tile, xtensa. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_reinsert_addr): Remove function. (struct linux_target_ops <breakpoint_reinsert_addr>: Set to NULL. * linux-cris-low.c (cris_reinsert_addr> Remove function. (struct linux_target_ops) <breakpoint_reinsert_addr>: Set to NULL. * linux-crisv32-low.c (cris_reinsert_addr): Remove function. (struct linux_target_ops) <breakpoint_reinsert_addr>: Set to NULL. * linux-mips-low.c (mips_reinsert_addr): Remove function. (struct linux_target_ops) <breakpoint_reinsert_addr>: Set to NULL. * linux-nios2-low.c (nios2_reinsert_addr): Remove function. (struct linux_target_ops) <breakpoint_reinsert_addr>: Set to NULL. * linux-sparc-low.c (sparc_reinsert_addr): Remove function. (struct linux_target_ops) <breakpoint_reinsert_addr>: Set to NULL.
2015-11-30Remove support for thread events without PTRACE_EVENT_CLONE in GDBServer.Antoine Tremblay4-154/+25
This patch removes support for thread events if PTRACE_EVENT_CLONE is not supported in GDBServer. Before, on systems that did not support PTRACE_EVENT_CLONE, both GDB and GDBServer coordinated with libthread_db.so to insert breakpoints at magic locations in libpthread.so, in order to break at thread creation and thread death. Simple software single stepping support was implemented to step over these breakpoints in case there was no hardware single stepping support. However, these simple software single stepping implementations were not fit for any other use as discussed in : https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html These too simple implementations conflict with ongoing work to make proper implementations of software single stepping in GDBServer. The problem is that if some implementations are correct and others are not and only there for the thread magic breakpoint, we can't enable features based solely software single step support since some would be broken. To keep the incorrect implementations and allow the new proper ones at the same time we would need to implement fallback code and it quickly becomes ugly and confusing with multiple checks for legacy software single step or proper software single step. However, PTRACE_EVENT_CLONE was first introduced in Linux 2.5.46, released in November 2002. So I think it's reasonable to just remove support for kernels that don't support PTRACE_EVENT_CLONE, and sidestep the libthread_db breakpoints issues entirely. This thread on the mailling list discusses the issue : https://sourceware.org/ml/gdb/2015-10/msg00078.html No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_look_up_symbols): Don't call linux_supports_traceclone. * linux-low.h (thread_db_init): Remove use_events argument. * thread-db.c (thread_db_use_event): Remove global variable. (struct thread_db) <td_thr_event_enable_p>: Remove field. (struct thread_db) <td_create_bp>: Remove field. (thread_db_create_event): Remove function. (thread_db_enable_reporting): Likewise. (find_one_thread): Don't check for thread_db_use_events. (attach_thread): Likewise. (thread_db_load_search): Remove td_thr_event_enable_p initialization. (try_thread_db_load_1): Don't check for thread_db_use_events. (thread_db_init): Remove use_events argument and thread events handling. (remove_thread_event_breakpoints): Remove function. (thread_db_detach): Remove call to remove_thred_event_breakpoints.
2015-11-30Refactor queries for hardware and software single stepping support in GDBServer.Antoine Tremblay16-6/+355
Before this patch there was only one call: can_hardware_single_step. Its implementation was a check on breakpoint_reinsert_addr if NULL it assumed that the target could hardware single step. This patch prepares for the case where this is not true anymore. In order to improve software single stepping in GDBServer the breakpoint_reinsert_addr operation of targets that had a very simple software implementation used only for stepping over thread creation events will be removed. This will create a case where a target does not support hardware single step and has the operation breakpoint_reinsert_addr set to NULL, thus can_hardware_single_step needs to be implemented another way. A new target operation supports_hardware_single_step is introduced and is to return true if the target does support such a feature, support for the feature is manually hardcoded. Note that the hardware single step support was enabled as per the current behavior, I did not check if tile for example really has ptrace singlestep support but since the current implementation assumed it had, I kept it that way. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } Compilation tested on: aarch64,arm,bfind,crisv32,m32r,ppc,s390,tic6x,tile, xtensa. Not tested : sh. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-arm-low.c (arm_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-bfin-low.c (bfin_supports_hardware_single_step): New function. (struct linux_target_ops) <bfin_supports_hardware_single_step>: Initialize. * linux-crisv32-low.c (cris_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-low.c (can_hardware_single_step): Use supports_hardware_single_step. (can_software_single_step): New function. (start_step_over): Call can_software_single_step. (linux_supports_hardware_single_step): New function. (struct target_ops) <supports_software_single_step>: Initialize. * linux-low.h (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-m32r-low.c (m32r_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-ppc-low.c (ppc_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step> Initialize. * linux-s390-low.c (s390_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-sh-low.c (sh_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-tic6x-low.c (tic6x_supports_hardware_single_step): New function. (struct linux_target_ops) <tic6x_supports_hardware_single_step>: Initialize. * linux-tile-low.c (tile_supports_hardware_single_step): New function. (struct linux_target_ops) <tile_supports_hardware_single_step>: Initialize. * linux-x86-low.c (x86_supports_hardware_single_step) New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * linux-xtensa-low.c (xtensa_supports_hardware_single_step): New function. (struct linux_target_ops) <supports_hardware_single_step>: Initialize. * target.h (struct target_ops): <supports_software_single_step>: New field. (target_supports_software_single_step): New macro.
2015-11-30Fix instruction skipping when using software single step in GDBServerAntoine Tremblay4-7/+41
Without this patch, when doing a software single step, with for example a conditional breakpoint, gdbserver would wrongly avance the pc of breakpoint_len and skips an instruction. This is due to gdbserver assuming that it's hardware single stepping. When it resumes from the breakpoint address it expects the trap to be caused by ptrace and if it's rather caused by a software breakpoint it assumes this is a permanent breakpoint and that it needs to skip over it. However when software single stepping, this breakpoint is legitimate as it's the reinsert breakpoint gdbserver has put in place to break at the next instruction. Thus gdbserver wrongly advances the pc and skips an instruction. This patch fixes this behavior so that gdbserver checks if it is a reinsert breakpoint from software single stepping. If it is it won't advance the pc. And if there's no reinsert breakpoint there we assume then that it's a permanent breakpoint and advance the pc. Here's a commented log of what would happen before and after the fix on gdbserver : /* Here there is a conditional breakpoint at 0x10428 that needs to be stepped over. */ Need step over [LWP 11204]? yes, found breakpoint at 0x10428 ... /* e7f001f0 is a breakpoint instruction on arm Here gdbserver writes the software breakpoint we would like to hit */ Writing e7f001f0 to 0x0001042c in process 11204 ... Resuming lwp 11220 (continue, signal 0, stop not expected) pending reinsert at 0x10428 stop pc is 00010428 continue from pc 0x10428 ... /* Here gdbserver hit the software breakpoint that was in place for the step over */ stop pc is 0001042c pc is 0x1042c step-over for LWP 11220.11220 executed software breakpoint Finished step over. Could not find fast tracepoint jump at 0x10428 in list (reinserting). /* Here gdbserver writes back the original instruction */ Writing e50b3008 to 0x0001042c in process 11220 Step-over finished. Need step over [LWP 11220]? No /* Here because gdbserver assumes this is a permenant breakpoint it advances the pc of breakpoint_len, in this case 4 bytes, so we have just skipped the instruction that was written back here : Writing e50b3008 to 0x0001042c in process 11220 */ stop pc is 00010430 pc is 0x10430 Need step over [LWP 11220]? No, no breakpoint found at 0x10430 Proceeding, no step-over needed proceed_one_lwp: lwp 11220 stop pc is 00010430 This patch fixes this situation and we get the right behavior : Writing e50b3008 to 0x0001042c in process 11245 Hit a gdbserver breakpoint. Hit a gdbserver breakpoint. Step-over finished. proceeding all threads. Need step over [LWP 11245]? No stop pc is 0001042c pc is 0x1042c Need step over [LWP 11245]? No, no breakpoint found at 0x1042c Proceeding, no step-over needed proceed_one_lwp: lwp 11245 stop pc is 0001042c pc is 0x1042c Resuming lwp 11245 (continue, signal 0, stop not expected) stop pc is 0001042c continue from pc 0x1042c It also works if the value at 0x0001042c is a permanent breakpoint. If so gdbserver will finish the step over, remove the reinserted breakpoint, resume at that location and on the next SIGTRAP gdbserver will trigger the advance PC condition as reinsert_breakpoint_inserted_here will be false. I also tested this against bp-permanent.exp on arm (with a work in progress software single step patchset) without any regressions. It's also tested against x86 bp-permanent.exp without any regression. So both software and hardware single step are tested. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Fix pc advance condition. * mem-break.c (reinsert_breakpoint_inserted_here): New function. * mem-break.h (reinsert_breakpoint_inserted_here): New declaration.
2015-11-30Fix breakpoint size when stepping over a permanent breakpoint in GDBServer.Antoine Tremblay5-2/+83
When manually stepping over a permanent breakpoint on ARM we need to fetch the right breakpoint size based on the current instruction set used. Since this is not encoded in the stop_pc, the instruction mode needs to be fetched from the CPSR register. This is done by introducing a new target operation called : breakpoint_kind_from_current_state. For other targets that do not need this, breakpoint_kind_from_pc is used. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_is_thumb_mode): New function. (arm_breakpoint_at): Use arm_is_thumb_mode. (arm_breakpoint_kind_from_current_state): New function. (struct linux_target_ops) <breakpoint_kind_from_current_state>: Initialize. * linux-low.c (linux_wait_1): Call breakpoint_kind_from_current_state. (linux_breakpoint_kind_from_current_state): New function. (struct target_ops <breakpoint_kind_from_current_state>: Initialize. * linux-low.h (struct linux_target_ops) <breakpoint_kind_from_current_state>: New field. * target.h (struct target_ops): Likewise. (target_breakpoint_kind_from_current_state): New macro.
2015-11-30gdbserver: don't exit until GDB disconnectsPedro Alves2-27/+18
When testing with "target remote" with "maint set target-non-stop on", we regressions like this: Running /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/continue-pending-after-query.exp ... FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 6: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 10: continue until exit === gdb Summary === # of expected passes 28 # of unexpected failures 3 where gdb.log shows: continue Continuing. Remote communication error. Target disconnected.: Connection reset by peer. (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit Enabling gdb + gdbserver debug logs we see: gdbserver: <<<< exiting linux_wait_1 gdbserver: handling possible serial event gdbserver: Writing resume reply for LWP 11089.11089:0 gdbserver: handling possible serial event gdbserver: GDBserver exiting GDB: Packet received: OK GDB: infrun: prepare_to_wait GDB: Sending packet: $vStopped#55...Packet received: W0;process:2b51 GDB: Sending packet: $vStopped#55...Packet received: OK GDB: infrun: target_wait (-1.0.0, status) = GDB: infrun: -1.0.0 [Thread 0], GDB: infrun: status->kind = no-resumed GDB: Sending packet: $Hgp2b51.2b51#41...Remote connection closed (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 1: continue until exit Notice the "Packet received: W0;process:2b51" followed by vStopped->OK. That means the process exit notification was successfully sent to GDB and GDB fetched it. That makes gdbserver exit, in server.c:process_serial_event: if (!extended_protocol && have_ran && !target_running ()) { /* In non-stop, defer exiting until GDB had a chance to query the whole vStopped list (until it gets an OK). */ if (QUEUE_is_empty (notif_event_p, notif_stop.queue)) { /* Be transparent when GDB is connected through stdio -- no need to spam GDB's console. */ if (!remote_connection_is_stdio ()) fprintf (stderr, "GDBserver exiting\n"); remote_close (); exit (0); } } However, GDB is still busy processing an earlier "no-resumed" event, and sends a "Hg" packet, which errors out with "Remote connection closed". IOW, it's not enough to wait for GDB to query the whole vStopped list, gdbserver needs to wait until the exit event is really processed. The fix is to make gdbserver not disconnect until gdb does. Tested on x86_64 Fedora, native gdbserver, remote + extended-remote + with and without "maint set target-non-stop on". gdb/gdbserver/ChangeLog: 2015-10-14 Pedro Alves <palves@redhat.com> * remote-utils.c (readchar): Don't print "Got EOF" unless debugging gdbserver. * server.c (captured_main): Exit gdbserver if gdb disconnects when in "target remote" mode and there are no processes left to debug. (process_serial_event): Remove 'have_ran' static local and remove logic that exits gdbserver in "target remote" mode.
2015-11-30gdbserver/linux: Always wake up event loop after resumePedro Alves2-0/+10
Running killed-outside.exp in with "maint set target-non-stop on" hangs currently. This test has the inferior process die with a SIGKILL while stopped. gdbserver gets a SIGCHLD and reacts by retrieveing the SIGKILL events out of waitpid. But because the process is not resumed from GDB's perspective, the event is left pending. When GDB resumes the process afterwards, the process is not really resumed because it already has the event pending. But nothing wakes up the event loop to consume the event. Handle this in the same way nat/linux-nat.c:linux_nat_resume handles this. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume): Wake up the event loop before returning.
2015-11-30gdbserver:prepare_access_memory: pick another threadPedro Alves4-20/+131
Say GDB wants to access the inferior process's memory. The current remote general thread is 3, but GDB's switched to thread 2. Because both threads are of the same process, GDB skips making the remote thread be thread 2 as well (sending an Hg packet) before accessing memory (remote.c:set_general_process). However, if thread 3 has exited meanwhile, thread 3 no longer exists on the server and gdbserver points current_thread to NULL. The result is the memory access fails, even through the process still exists. Fix this by making prepare_to_access memory select the thread to access memory through. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * mem-break.c (check_gdb_bp_preconditions): Remove current_thread check. (set_gdb_breakpoint): If prepare_to_access_memory fails, set *ERR to -1. * target.c (struct thread_search): New structure. (thread_search_callback): New function. (prev_general_thread): New global. (prepare_to_access_memory, done_accessing_memory): New functions. * target.h (prepare_to_access_memory, done_accessing_memory): Replace macros with function declarations.
2015-11-30Implement TARGET_WAITKIND_NO_RESUMED in the remote protocolPedro Alves11-23/+143
Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30infrun: Fix TARGET_WAITKIND_NO_RESUMED handling in non-stop modePedro Alves2-13/+105
Running the testsuite against gdbserver with "maint set target-non-stop on" stumbled on a set of problems. See code comments for details. This handles my concerns expressed in PR14618. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * infrun.c (handle_no_resumed): New function. (handle_inferior_event_1) <TARGET_WAITKIND_NO_RESUMED>: Defer to handle_no_resumed.
2015-11-30testsuite: Range stepping and non-stop modePedro Alves2-2/+10
The range-stepping tests fail with "maint set target-non-stop on" mode because exec_cmd_expect_vCont_count doesn't know that in non-stop mode, vCont's reply is simply "OK". gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * lib/range-stepping-support.exp (exec_cmd_expect_vCont_count): Handle non-stop mode vCont replies.
2015-11-30gdbserver: fix killed-outside.expPedro Alves2-6/+31
killed-outside.exp regresses with "maint set target-non-stop on". The logs show: (gdb) continue Continuing. infrun: clear_proceed_status_thread (Thread 9028.9028) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming Thread 9028.9028 Sending packet: $Z0,3615a03966,1#4b... Notification received: Stop:X9;process:2344 Packet received: E01 Sending packet: $Z0,3615a13970,1#47...Packet received: E01 Sending packet: $Z0,3615a14891,1#4a...Packet received: E01 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 9028.9028] at 0x4005e4 Sending packet: $vCont;c:p2344.2344#1a...Packet received: E.target not running. Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n</threads>\n Sending packet: $vStopped#55...Packet received: OK Unexpected vCont reply in non-stop mode: E.target not running. (gdb) remote_async_inferior_event_handler infrun: target_wait (-1.0.0, status) = infrun: 9028.0.0 [process 9028], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting infrun: clear_step_over_info infrun: stop_all_threads remote_thread_exit_events(1) Note the "Unexpected vCont reply" error. I traced it to a problem in status_pending_p_callback. It resumes an LWP when it shouldn't. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (thread_still_has_status_pending_p): Don't check vCont;t here. (lwp_resumed): New function. (status_pending_p_callback): Return early if the LWP is not supposed to be resumed.
2015-11-30Remote thread create/exit eventsPedro Alves16-40/+402
When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30Make dprintf-non-stop.exp cope with remote testingPedro Alves2-3/+13
Testing with the extended-remote board with "maint set target-non-stop on" shows a dprintf-non-stop.exp regression. The issue is simply that the test is expecting output that is only valid for the native target: native: [process 8676] #1 stopped. remote: [Thread 8900.8900] #1 stopped. In order to expose this without "maint set target-non-stop on", this restarts gdb with non-stop mode already enabled. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.base/dprintf-non-stop.exp: Use build_executable instead of prepare_for_testing. Start gdb with "set non-stop on" appended to GDBFLAGS. Lax expected stop output.
2015-11-30gdbserver resume_stop handling bugPedro Alves2-1/+5
Running attach-many-short-lived-threads.exp with the extended-remote board with "maint set target-non-stop on" times out -- the attach never completes. Enabling infrun debug logs, we see that GDB is stuck stopping all threads: infrun: target_wait (-1.0.0, status) = infrun: 1639.22213.0 [Thread 1639.22213], infrun: status->kind = stopped, signal = GDB_SIGNAL_0 infrun: Thread 1639.22260 not executing infrun: Thread 1639.22256 not executing infrun: Thread 1639.22258 not executing infrun: Thread 1639.22257 not executing infrun: Thread 1639.22259 not executing infrun: Thread 1639.22255 not executing infrun: Thread 1639.22253 executing, already stopping infrun: Thread 1639.22251 executing, already stopping infrun: Thread 1639.22252 executing, already stopping infrun: Thread 1639.22250 executing, already stopping infrun: Thread 1639.22254 executing, already stopping infrun: Thread 1639.22247 executing, already stopping infrun: Thread 1639.22213 not executing infrun: Thread 1639.22207 not executing infrun: Thread 1639.22201 not executing infrun: Thread 1639.22219 not executing infrun: Thread 1639.1639 not executing ** HANG HERE ** GDB is waiting for the stop replies of any of those "already stopping" threads. Take 22253 for example. On the gdbserver logs we see: ... resume_stop request for LWP 22253 stopping LWP 22253 Sending sigstop to lwp 22253 linux_resume done ... and: my_waitpid (-1, 0x40000001) my_waitpid (-1, 0x80000001): status(3057f), 22253 LWFE: waitpid(-1, ...) returned 22253, ERRNO-OK LLW: waitpid 22253 received Trace/breakpoint trap (stopped) pc is 0x3615ef4ce1 HEW: Got clone event from LWP 22253, new child is LWP 22259 but from here on, we never see any other event for LWP 22253. In particular, we never see the expected SIGSTOP (from "Sending sigstop" above). The issue is that linux_resume_stopped_resumed_lwps never re-resumes the 22253 after the clone event. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (resume_stopped_resumed_lwps): Don't check whether the thread's last_resume_kind was resume_stop.
2015-11-30gdbserver crash if gdb attaches too fastPedro Alves2-12/+46
With "maint set target-non-stop on", the attach tests occasionally crash gdbserver. Basically, gdb attaches with vAttach;PID, and then shortly after reads the xml target description for that process, to figure out the process' architecture. On the gdbserver side, the target description is only filled in when the first process/thread in the thread group reports its initial PTRACE_ATTACH SIGSTOP. So if GDB is fast enough, it can read the target description _before_ that initial stop, and then gdbserver dies dereferencing a NULL tdesc pointer. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach): In non-stop mode, wait for one stop before returning.
2015-11-30New vCtrlC packet, non-stop mode equivalent of \003Pedro Alves7-11/+122
There's currently no non-stop equivalent of the all-stop ^C (\003) "packet" that GDB sends when a ctrl-c is pressed while a foreground command is active. There's vCont;t, but that's defined to cause a "signal 0" stop. This fixes many tests that type ^C, when testing with extended-remote with "maint set target-non-stop on". E.g.: Continuing. talk to me baby PASS: gdb.base/interrupt.exp: process is alive a a PASS: gdb.base/interrupt.exp: child process ate our char ^C [Thread 22730.22730] #1 stopped. 0x0000003615ee6650 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:81 81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) (gdb) FAIL: gdb.base/interrupt.exp: send_gdb control C p func1 () gdb/ 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New remote packets): Mention vCtrlC. * remote.c (PACKET_vCtrlC): New enum value. (async_remote_interrupt): Call target_interrupt instead of target_stop. (remote_interrupt_as): Remove 'ptid' parameter. (remote_interrupt_ns): New function. (remote_stop): Adjust. (remote_interrupt): If the target is in non-stop mode, try interrupting with vCtrlC. (initialize_remote): Install set remote ctrl-c packet. gdb/doc/ 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Bootstrapping): Add "interrupting remote targets" anchor. (Packets): Document vCtrlC. gdb/gdbserver/ 2015-11-30 Pedro Alves <palves@redhat.com> * server.c (handle_v_requests): Handle vCtrlC.
2015-11-30remote: stop reason and watchpoint data address per threadPedro Alves2-25/+61
Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state) <remote_watch_data_address, stop_reason>: Delete fields. (struct private_thread_info) <stop_reason, watch_data_address>: New fields. (resume_clear_thread_private_info): New function. (append_pending_thread_resumptions): Call it. (remote_resume): Clear all threads' private info. (process_stop_reply): Adjust. (remote_wait_as): Don't reference remote_state's stop_reason field. (remote_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint, remote_stopped_by_watchpoint) (remote_stopped_data_address): Adjust to refer get data from the current thread.
2015-11-30gdbserver crash running gdb.threads/non-ldr-exc-1.expPedro Alves4-0/+59
This fixes a gdbserver crash when running gdb.threads/non-ldr-exc-1.exp with "maint set target-non-stop on". The problem is that qSymbol is called when gdbserver has current_thread == NULL. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdbthread.h (find_any_thread_of_pid): Declare. * inferiors.c (thread_of_pid, find_any_thread_of_pid): New functions. * server.c (handle_query): If current_thread is NULL, look for another thread of the selected process.
2015-11-30attach + target always in non-stop mode: stop all threadsPedro Alves2-1/+30
When running with "maint set target-non-stop on", and in all-stop mode, nothing is stopping all threads after attaching. vAttach in non-stop can leave all threads running and GDB has to explicitly pause them. This is not visible with the native target, as in that case, attach always stops all threads (the core re-resumes them in case of "attach&"). In addition, it's not defined which thread manages to report the initial attach stop, so always pick the lowest one (otherwise multi-attach.exp regresses). gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * infcmd.c (attach_post_wait): If the target is always in non-stop mode, and the UI is in all-stop mode, stop all threads and pick the one with lowest number as current.
2015-11-30Remote all-stop-on-top-of-non-stopPedro Alves9-73/+321
This is the first pass at implementing support for all-stop mode running against the remote target using the non-stop variant of the protocol. The trickiest part here is the initial connection setup/synching. We need to fetch all inferiors' target descriptions etc. before stopping threads, because stop_all_threads needs to read the threads' registers (to record each thread's stop_pc). But OTOH, the initial inferior setup (target_post_attach, post_create_inferior, etc.), only works correctly if the inferior is stopped... So I've split that initial setup part from attach_command_post_wait to a separate function, and added a "still needs setup" flag to the inferior structure. This is similar to gdbserver/linux-low.c's handling of discovering the process's target description). Then if on connection all threads of the remote inferior are running, when we go about stopping them, as soon as they stop we call setup_inferior, from within stop_all_threads. Also, in all-stop, we need to process all the initial stop replies to learn about all the pending signal the threads may already be stopped for, and pick the one to report as current. This is exposed by gdb.threads/reconnect-signal.exp. gdb/ 2015-11-30 Pedro Alves <palves@redhat.com> * gdbthread.h (switch_to_thread_no_regs): Declare. * infcmd.c (setup_inferior): New function, factored out from ... (attach_command_post_wait): ... this. Rename to ... (attach_post_wait): ... this. Replace parameter async_exec with attach_post_wait_mode parameter. Adjust. (enum attach_post_wait_mode): New enum. (struct attach_command_continuation_args): Replace 'async_exec' field with 'mode' field. (attach_command_continuation): Adjust. (attach_command): Add comment. Mark the inferior as needing setup. Adjust to use enum attach_post_wait_mode. (notice_new_inferior): Use switch_to_thread_no_regs. Adjust to use enum attach_post_wait_mode. * inferior.h (setup_inferior): Declare. (struct inferior) <needs_setup>: New field. * infrun.c (set_last_target_status): Make extern. (stop_all_threads): Make extern. Setup inferior, if necessary. * infrun.h (set_last_target_status, stop_all_threads): Declare. * remote-notif.c (remote_async_get_pending_events_handler) (handle_notification): Replace non_stop checks with target_is_non_stop_p() checks. * remote.c (remote_notice_new_inferior): Remove non_stop check. (remote_update_thread_list): Replace non_stop check with target_is_non_stop_p() check. (print_one_stopped_thread): New function. (process_initial_stop_replies): New 'from_tty' parameter. "Notice" all new live inferiors after storing initial stops as pending status in each corresponding thread. If all-stop, stop all threads, try picking a signalled thread as current, and print the status of that one thread. Record the last target status. (remote_start_remote): Replace non_stop checks with target_is_non_stop_p() checks. Don't query for the remote current thread of use qOffsets here. Pass from_tty to process_initial_stop_replies. (extended_remote_attach): Replace non_stop checks with target_is_non_stop_p() checks. (extended_remote_post_attach): Send qOffsets here. (remote_vcont_resume, remote_resume, remote_stop) (remote_interrupt, remote_parse_stop_reply, remote_wait): Replace non_stop checks with target_is_non_stop_p() checks. (remote_async): If target is non-stop, mark/clear the pending events token. * thread.c (switch_to_thread_no_regs): New function.
2015-11-30Fix mi-nonstop.exp with extended-remotePedro Alves4-10/+41
Testing with "maint set target-non-stop on" makes mi-nonstop.exp run with the extended-remote board. That reveals that mi-nonstop.exp is using the wrong predicate to check for "using remote protocol". This is not visible today because non-stop tests all fail to run with extended-remote board, because they spawn gdb and then do "set non-stop on". However, with that board, gdb connects to the gdbserver from within mi_gdb_start, and changing non-stop when already connected doesn't work. Fix that by instead enabling non-stop mode on gdb's command line. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.mi/mi-nonstop.exp: Append "set non-stop on" to GDBFLAGS instead of issuing "-gdb-set non-stop 1" after starting gdb. Use mi_is_target_remote instead of checking "is_remote target". * lib/gdb.exp (gdb_is_target_remote): Rename to ... (gdb_is_target_remote_prompt): ... this, and add 'prompt_regexp' parameter. (gdb_is_target_remote): Reimplement. * lib/mi-support.exp (mi_is_target_remote): New procedure.
2015-11-30Fix ChangeLog entryPedro Alves1-1/+1
There should be only one date in multi-author entries.
2015-11-30objdump: Handle 32-bit base address in debug_ranges / debug_loc.Andrew Burgess6-11/+207
When the DWARF address size is 32-bit, but the host machine is 64-bit, objdump fails to spot base addresses specified in the .debug_ranges and .debug_loc lists. As an example, here is the output when dumping an example .debug_ranges section with the pre-patched objdump: Contents of the .debug_ranges section: Offset Begin End 00000000 ffffffff 00000004 (start > end) 00000000 00000000 00000004 00000000 ffffffff 00000008 (start > end) 00000000 00000000 00000004 00000000 <End of list> And this is what the same section looks like when dumped with the patched version of objdump: Contents of the .debug_ranges section: Offset Begin End 00000000 ffffffff 00000004 (base address) 00000000 00000004 00000008 00000000 ffffffff 00000008 (base address) 00000000 00000008 0000000c 00000000 <End of list> binutils/ChangeLog: * dwarf.c (is_max_address): New function. (display_loc_list): Remove out of date comment, use is_max_address. (display_debug_ranges): Likewise. binutils/testsuite/ChangeLog: * binutils-all/objdump.exp: Add test for .debug_ranges decode. * binutils-all/dw2-ranges.S: New file. * binutils-all/dw2-ranges.W: New file.
2015-11-30Automatic date update in version.inGDB Administrator1-1/+1
2015-11-28Update my email address in MAINTAINERS.Cary Coutant2-1/+5
binutils/ * MAINTAINERS: Update my email address.
2015-11-29Automatic date update in version.inGDB Administrator1-1/+1
2015-11-28Adjust GDB to demangler API changePedro Alves2-1/+6
Before commit 3a8724032abf, DEMANGLE_COMPONENT_CAST was used for both casts and conversion operators. We now have DEMANGLE_COMPONENT_CONVERSION for the latter. gdb/ChangeLog: 2014-11-28 Pedro Alves <palves@redhat.com> * cp-name-parser.y (conversion_op): Use DEMANGLE_COMPONENT_CONVERSION instead of DEMANGLE_COMPONENT_CAST.
2015-11-28libsanitizer merge from upstream r250806, compiler part.Maxim Ostapenko2-1/+6
gcc/ * asan.c (asan_emit_stack_protection): Don't pass local stack to asan_stack_malloc_[n] anymore. Check if asan_stack_malloc_[n] returned NULL and use local stack than. (asan_finish_file): Insert __asan_version_mismatch_check_v[n] call in addition to __asan_init. * sanitizer.def (BUILT_IN_ASAN_INIT): Rename to __asan_init. (BUILT_IN_ASAN_VERSION_MISMATCH_CHECK): Add new builtin call. * asan.h (asan_intercepted_p): Handle new string builtins. * ubsan.c (ubsan_use_new_style_p): New function. (ubsan_instrument_float_cast): If location is unknown, assign input_location to loc. Propagate loc to ubsan_create_data if ubsan_use_new_style_p returned true. config/ * bootstrap-asan.mk: Replace ASAN_OPTIONS=detect_leaks with LSAN_OPTIONS=detect_leaks. gcc/testsuite/ * c-c++-common/ubsan/float-cast-overflow-10.c: Adjust test. * c-c++-common/ubsan/float-cast-overflow-8.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-9.c: Likewise. * g++.dg/asan/default-options-1.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229112 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Port libvtv to SolarisRainer Orth2-0/+9
libstdc++-v3: * acinclude.m4 (GLIBCXX_ENABLE_VTABLE_VERIFY) <solaris2*>: Use -Wl,-R in VTV_CXXLINKFLAGS. * configure: Regenerate. * testsuite/18_support/bad_exception/23591_thread-1.c: Use -fvtable-verify=none on Solaris 12+. libgcc: * Makefile.in (VTV_CFLAGS): New variable. (vtv_start$(objext), vtv_end$(objext), vtv_end$(objext)) (vtv_start_preinit$(objext), vtv_end_preinit$(objext)): Use it. * config.host (*-*-solaris2*): Add t-crtstuff-pic to tmake_file. Add vtv_start.o, vtv_end.o, vtv_start_preinit.o, vtv_end_preinit.o to extra_parts if $enable_vtable_verify = yes. libvtv: * configure.tgt (*-*-solaris2.[1-9]*): Declare supported. * configure.ac: Call AC_USE_SYSTEM_EXTENSIONS. <*-*-solaris2*>: Check for init priority support. Check for getexecname, __fortify_fail, _obstack_begin. (VTV_NO_OBSTACK): New conditional. * configure: Regenerate. * Makefile.am [VTV_NO_OBSTACK] (obstack.c): Use new condition. Create empty config.h * Makefile.in: Regenerate. * vtv_rts.cc [HAVE_GETEXECNAME] (program_invocation_name): New variable. (read_section_offset_and_length) [HAVE_GETEXECNAME]: Set it. (dl_iterate_phdr_callback) [HAVE_GETEXECNAME]: Set it. (__fortify_fail): Wrap in HAVE___FORTIFY_FAIL [!HAVE___FORTIFY_FAIL]: Provide non-Cygwin implementation. (read_section_offset_and_length): Assert sh_size >= VTV_PAGE_SIZE. (iterate_modules): Fix typo. Use VTV_PAGE_SIZE. (dl_iterate_phdr_callback): Fix typo. Use VTV_PAGE_SIZE. (__VLTChangePermission): Fix typos. include: * vtv-change-permission.h (VTV_PAGE_SIZE) [__sun__ && __svr4__ && __sparc__]: Define. gcc: * config/sol2.h (SUPPORTS_INIT_PRIORITY): Move up. (STARTFILE_VTV_SPEC, ENDFILE_VTV_SPEC): Define. (STARTFILE_SPEC): Use %(startfile_vtv). (ENDFILE_SPEC): Use %(endfile_vtv). (SUBTARGET_EXTRA_SPECS): Handle STARTFILE_VTV_SPEC, ENDFILE_VTV_SPEC. * gcc.c (LINK_COMMAND_SPEC): Move VTABLE_VERIFICATION_SPEC after %{L*}. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230865 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28SH FDPIC backend supportRich Felker2-0/+36
gcc/ChangeLog * config.gcc: Handle --enable-fdpic. * config/sh/constraints.md (Ccl): New constraint. * config/sh/linux.h (SUBTARGET_LINK_EMUL_SUFFIX): Handle -mfdpic. * config/sh/sh-c.c (sh_cpu_cpp_builtins): Add __FDPIC__ and __SH_FDPIC__. * config/sh/sh-mem.cc (expand_block_move): Support FDPIC for calls to library functions. * config/sh/sh-protos.h (function_symbol_result): New struct. (function_symbol): Return function_symbol_result. (sh_get_fdpic_reg_initial_val, sh_load_function_descriptor): New declarations. * config/sh/sh.c (TARGET_ASM_INTEGER, sh_assemble_integer): Implement target hook. (TARGET_CANNOT_FORCE_CONST_MEM, sh_cannot_force_const_mem_p): Likewise. (sh_option_override): Force -fPIC if FDPIC is in effect. (sh_asm_output_addr_const_extra): Add UNSPEC_GOTFUNCDESC and UNSPEC_GOTOFFFUNCDESC cases. (prepare_move_operands): Use FDPIC initial GOT register for TLS-related GOT access; inhibit cross-section address offset constants for FDPIC. (sh_assemble_integer): New function. (sh_cannot_copy_insn_p): Inhibit copying insns that are FDPIC PC-relative call sites. (expand_ashiftrt): Adapt invocation of function_symbol. (sh_expand_prologue): Inhibit PC-relative GOT address load for FDPIC. (nonpic_symbol_mentioned_p): Add cases for UNSPEC_GOTFUNCDESC and UNSPEC_GOTOFFFUNCDESC. (legitimize_pic_address): Resolve function symbols to function descriptors for FDPIC. Do not use GOT-relative addressing for local data that may be read-only on FDPIC. (sh_emit_storesi, sh_emit_storehi): New functions. (sh_trampoline_init): Generate FDPIC trampolines. (sh_function_ok_for_sibcall): Add TARGET_FDPIC check. (sh_expand_sym_label2reg): Don't assume sibcalls are local. (sh_output_mi_thunk): Generate FDPIC call. (function_symbol): Return function_symbol_result. For SFUNC_STATIC on FDPIC, generate call site labels to use PC-relative addressing rather than GOT-relative addressing. (sh_conditional_register_usage): Make PIC register fixed and call used when FDPIC is in effect. (sh_legitimate_constant_p): Impose FDPIC constant constraints. (sh_cannot_force_const_mem_p, sh_load_function_descriptor) (sh_get_fdpic_reg_initial_val): New functions. * config/sh/sh.h (SUBTARGET_ASM_SPEC, SUBTARGET_LINK_EMUL_SUFFIX): Handle -mfdpic. (FDPIC_SELF_SPECS, SUBTARGET_DRIVER_SELF_SPECS) (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED) (SH_OFFSETS_MUST_BE_WITHIN_SECTIONS_P): New macros. (DRIVER_SELF_SPECS): Add SUBTARGET_DRIVER_SELF_SPECS and FDPIC_SELF_SPECS. (TRAMPOLINE_SIZE): Select trampoline size for FDPIC. (ASM_PREFERRED_EH_DATA_FORMAT): Add EH format constraints for FDPIC. (ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX): Handle FDPIC case. * config/sh/sh.md (UNSPEC_GOTFUNCDESC, UNSPEC_GOTOFFFUNCDESC): New constants. (calli_fdpic, call_valuei_fdpic, sibcalli_fdpic) (sibcalli_pcrel_fdpic, sibcall_pcrel_fdpic, sibcall_valuei_fdpic) (sibcall_valuei_pcrel_fdpic, sibcall_value_pcrel_fdpic) (sym2GOTFUNCDESC, symGOTFUNCDESC2reg, sym2GOTOFFFUNCDESC) (symGOTOFFFUNCDESC2reg): New patterns. (udivsi3_i1, udivsi3_i4, udivsi3_i4_single, udivsi3, *divsi_inv_call_combine, divsi3_i4, divsi3_i4_single, divsi3) (ashlsi3, ashlsi3_d_call, ashrsi3_n, lshrsi3, lshrsi3_d_call) (calli, call_valuei, call, call_value, sibcalli, sibcalli_pcrel) (sibcall_pcrel, sibcall, sibcall_valuei, sibcall_valuei_pcrel) (sibcall_value_pcrel, sibcall_value, GOTaddr2picreg, symGOT_load) (symGOTOFF2reg, block_move_real, block_lump_real) (block_move_real_i4, block_lump_real_i4): Add support for FDPIC calls. (mulsi3, ic_invalidate_line, initialize_trampoline, call_pop, call_value_pop): Adjust for new function_symbol signature. * config/sh/sh.opt (-mfdpic): New option. * doc/install.texi (Options specification): Document --enable-fdpic. * doc/invoke.texi (SH Options): Document -mfdpic. include/ChangeLog: * longlong.h (udiv_qrnnd): Add FDPIC compatible version for SH. libitm/ChangeLog: * config/sh/sjlj.S (_ITM_beginTransaction): Bypass PLT calling GTM_begin_transaction for compatibility with FDPIC. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229438 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28PR other/61321 - demangler crash on casts in template parametersPedro Alves5-8/+81
The fix for bug 59195: [C++ demangler handles conversion operator incorrectly] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59195 unfortunately makes the demangler crash due to infinite recursion, in case of casts in template parameters. For example, with: template<int> struct A {}; template <typename Y> void function_temp(A<sizeof ((Y)(999))>) {} template void function_temp<int>(A<sizeof (int)>); The 'function_temp<int>' instantiation above mangles to: _Z13function_tempIiEv1AIXszcvT_Li999EEE The demangler parses this as: typed name template name 'function_temp' template argument list builtin type int function type builtin type void argument list template (*) name 'A' template argument list unary operator operator sizeof unary operator cast template parameter 0 (**) literal builtin type int name '999' And after the fix for 59195, due to: static void d_print_cast (struct d_print_info *dpi, int options, const struct demangle_component *dc) { ... /* For a cast operator, we need the template parameters from the enclosing template in scope for processing the type. */ if (dpi->current_template != NULL) { dpt.next = dpi->templates; dpi->templates = &dpt; dpt.template_decl = dpi->current_template; } when printing the template argument list of A (what should be "<sizeof (int)>"), the template parameter 0 (that is, "T_", the '**' above) now refers to the first parameter of the the template argument list of the 'A' template (the '*' above), exactly what we were already trying to print. This leads to infinite recursion, and stack exaustion. The template parameter 0 should actually refer to the first parameter of the 'function_temp' template. Where it reads "for the cast operator" in the comment in d_print_cast (above), it's really talking about a conversion operator, like: struct A { template <typename U> explicit operator U(); }; We don't want to inject the template parameters from the enclosing template in scope when processing a cast _expression_, only when handling a conversion operator. The problem is that DEMANGLE_COMPONENT_CAST is currently ambiguous, and means _both_ 'conversion operator' and 'cast expression'. Fix this by adding a new DEMANGLE_COMPONENT_CONVERSION component type, which does what DEMANGLE_COMPONENT_CAST does today, and making DEMANGLE_COMPONENT_CAST just simply print its component subtree. I think we could instead reuse DEMANGLE_COMPONENT_CAST and in d_print_comp_inner still do: @@ -5001,9 +5013,9 @@ d_print_comp_inner (struct d_print_info *dpi, int options, d_print_comp (dpi, options, dc->u.s_extended_operator.name); return; case DEMANGLE_COMPONENT_CAST: d_append_string (dpi, "operator "); - d_print_cast (dpi, options, dc); + d_print_conversion (dpi, options, dc); return; leaving the unary cast case below calling d_print_cast, but seems to me that spliting the component types makes it easier to reason about the code. g++'s testsuite actually generates three symbols that crash the demangler in the same way. I've added those as tests in the demangler testsuite as well. And then this fixes PR other/61233 too, which happens to be a demangler crash originally reported to GDB, at: https://sourceware.org/bugzilla/show_bug.cgi?id=16957 Bootstrapped and regtested on x86_64 Fedora 20. Also ran this through GDB's testsuite. GDB will require a small update to use DEMANGLE_COMPONENT_CONVERSION in one place it's using DEMANGLE_COMPONENT_CAST in its sources. libiberty/ 2015-11-27 Pedro Alves <palves@redhat.com> PR other/61321 PR other/61233 * demangle.h (enum demangle_component_type) <DEMANGLE_COMPONENT_CONVERSION>: New value. * cp-demangle.c (d_demangle_callback, d_make_comp): Handle DEMANGLE_COMPONENT_CONVERSION. (is_ctor_dtor_or_conversion): Handle DEMANGLE_COMPONENT_CONVERSION instead of DEMANGLE_COMPONENT_CAST. (d_operator_name): Return a DEMANGLE_COMPONENT_CONVERSION component if handling a conversion. (d_count_templates_scopes, d_print_comp_inner): Handle DEMANGLE_COMPONENT_CONVERSION. (d_print_comp_inner): Handle DEMANGLE_COMPONENT_CONVERSION instead of DEMANGLE_COMPONENT_CAST. (d_print_cast): Rename as ... (d_print_conversion): ... this. Adjust comments. (d_print_cast): Rewrite - simply print the left subcomponent. * cp-demint.c (cplus_demangle_fill_component): Handle DEMANGLE_COMPONENT_CONVERSION. * testsuite/demangle-expected: Add tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231020 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28libiberty TAGSMike Stump2-1/+5
* Makefile.in (etags tags TAGS): Use && instead of ;. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230270 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28(Makefiles): PATCH to include libcpp and libiberty in GCC etagsJason Merrill2-5/+7
gcc/c/ * Make-lang.in (c.tags): Also include libcpp TAGS. gcc/cp/ * Make-lang.in (c++.tags): Also include libcpp TAGS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229504 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Fix PR63758 by using the _NSGetEnviron() API on DarwinIain Sandoe6-12/+55
include/ Roland McGrath <roland@gnu.org> PR other/63758 * environ.h: New file. libiberty/ Roland McGrath <roland@gnu.org> Iain Sandoe <iain@codesourcery.com> PR other/63758 * pex-unix.c: Obtain the environment interface from settings in environ.h rather than in-line code. Update copyright date. * setenv.c: Likewise. * xmalloc.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228942 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Implement N4514, C++ Extensions for Transactional Memory.Jason Merrill4-5/+45
gcc/ * builtins.def (BUILT_IN_ABORT): Add transaction_pure attribute. gcc/c-family/ * c-common.c (c_common_reswords): Add C++ TM TS keywords. (c_common_attribute_table): Add transaction_safe_dynamic. transaction_safe now affects type identity. (handle_tm_attribute): Handle transaction_safe_dynamic. * c-common.h (enum rid): Add RID_ATOMIC_NOEXCEPT, RID_ATOMIC_CANCEL, RID_SYNCHRONIZED. (OBJC_IS_CXX_KEYWORD): Add RID_SYNCHRONIZED. (D_TRANSMEM): New. * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_transactional_memory. * c-pretty-print.c (pp_c_attributes_display): Don't print transaction_safe in C++. gcc/c/ * c-parser.c (c_lex_one_token): Handle @synchronized. * c-decl.c (match_builtin_function_types): A declaration of a built-in can change whether the function is transaction_safe. gcc/cp/ * cp-tree.h (struct cp_declarator): Add tx_qualifier field. (BCS_NORMAL, BCS_TRANSACTION): New enumerators. * lex.c (init_reswords): Limit TM kewords to -fgnu-tm. * parser.c (cp_lexer_get_preprocessor_token): Fix @synchronized. (make_call_declarator): Take tx_qualifier. (cp_parser_tx_qualifier_opt): New. (cp_parser_lambda_declarator_opt): Use it. (cp_parser_direct_declarator): Likewise. (cp_parser_statement): Handle atomic_noexcept, atomic_cancel. (cp_parser_compound_statement): Change in_try parameter to bcs_flags. (cp_parser_std_attribute): Map optimize_for_synchronized to transaction_callable. (cp_parser_transaction): Take the token. Handle atomic_noexcept. * lambda.c (maybe_add_lambda_conv_op): Handle transaction-safety. * call.c (enum conversion_kind): Add ck_tsafe. (standard_conversion): Handle transaction-safety conversion. (convert_like_real, resolve_address_of_overloaded_function): Likewise. (check_methods): Diagnose transaction_safe_dynamic on non-virtual function. (look_for_tm_attr_overrides): Don't inherit transaction_safe_dynamic. * cvt.c (tx_safe_fn_type_p, tx_unsafe_fn_variant) (can_convert_tx_safety): New. * typeck.c (composite_pointer_type): Handle transaction-safety. * name-lookup.h (enum scope_kind): Add sk_transaction. * name-lookup.c (begin_scope): Handle it. * semantics.c (begin_compound_stmt): Pass it. * decl.c (check_previous_goto_1): Check it. (struct named_label_entry): Add in_transaction_scope. (poplevel_named_label_1): Set it. (check_goto): Check it. (duplicate_decls): A specialization can be transaction_safe independently of its template. (grokdeclarator): Handle tx-qualifier. * rtti.c (ptr_initializer): Handle transaction-safe. * search.c (check_final_overrider): Check transaction_safe_dynamic. Don't check transaction_safe. * mangle.c (write_function_type): Mangle transaction_safe here. (write_CV_qualifiers_for_type): Not here. (write_type): Preserve transaction_safe when stripping attributes. * error.c (dump_type_suffix): Print transaction_safe. libiberty/ * cp-demangle.c (d_cv_qualifiers): Dx means transaction_safe. (cplus_demangle_type): Let d_cv_qualifiers handle it. (d_dump, d_make_comp, has_return_type, d_encoding) (d_count_templates_scopes, d_print_comp_inner) (d_print_mod_list, d_print_mod, d_print_function_type) (is_ctor_or_dtor): Handle DEMANGLE_COMPONENT_TRANSACTION_SAFE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228462 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Fix several crashes of C++ demangler on fuzzed input.Mikhail Maltsev4-8/+94
libiberty/ * cp-demangle.c (d_dump): Fix syntax error. (d_identifier): Adjust type of len to match d_source_name. (d_expression_1): Fix out-of-bounds access. Check code variable for NULL before dereferencing it. (d_find_pack): Do not recurse for FIXED_TYPE, DEFAULT_ARG and NUMBER. (d_print_comp_inner): Add NULL pointer check. * cp-demangle.h (d_peek_next_char): Define as inline function when CHECK_DEMANGLER is defined. (d_advance): Likewise. * testsuite/demangle-expected: Add new testcases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225727 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Avoid "enum conversion when passing argument 1 of 'getrusage' is invalid in ↵Uros Bizjak2-7/+7
C++" warning * getruntime.c (RUSAGE_SELF): Define if not already defined. (get_runtime): Use RUSAGE_SELF as argument 1 of getrusage call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225614 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Avoid "enum conversion when passing argument 1 of 'getrusage' is invalid in ↵Uros Bizjak2-0/+9
C++" warning * getruntime.c (get_run_time) [__USE_GNU]: Use RUSAGE_SELF as argument 1 of getrusage call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225534 138bc75d-0d04-0410-961f-82ee72b054a4
2015-11-28Automatic date update in version.inGDB Administrator1-1/+1
2015-11-27[AArch64][PATCH 3/3] Add floating-point FP16 instructionsMatthew Wahab8-682/+1292
ARMv8.2 adds 16-bit floating point operations as an optional extension to the ARMv8 FP support. This patch adds the new FP16 instructions, making them available when the architecture extension +fp+fp16 is specified. The instructions added are: - Comparisons and conditionals: FCMP, FCCMPE, FCMP, FCMPE and FCSEL. - Arithmetic: FABS, FNEG, FSQRT, FMUL, FDIV, FADD, FSUB, FMADD, FMSUB, FNMADD and FNMSUB. - Rounding: FRINTN, FRINTP, FRINTM, FRINTZ, FRINTA, FRINTX and FRINTI. - Conversions: SCVTF (fixed-point), SCVTF (integer), UCVTF (fixed-point) UCVTF (integer), FCVTZS (fixed-point), FCVTZS (integer), FCVTZU (fixed-point), FCVTZU (integer), FCVTNS, FCVTNU, FCVTAS, FCVTAU, FCVTPS, FCVTPU, FCVTMS and FCVTMU. - Scalar FMOV: immediate, general and register gas/testsuite/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * gas/aarch64/float-fp16.d: New. * gas/aarch64/float-fp16.s: New. opcodes/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * aarch64-asm-2.c: Regenerate. * aarch64-dis-2.c: Regenerate. * aarch64-opc-2.c: Regenerate. * aarch64-tbl.h (QL_FIX2FP_H, QL_FP2FIX_H): New. (QL_INT2FP_H, QL_FP2INT_H): New. (QL_FP2_H, QL_FP3_H, QL_FP4_H): New (QL_DST_H): New. (QL_FCCMP_H): New. (aarch64_opcode_table): Add 16-bit variants of scvt, ucvtf, fcvtzs, fcvtzu, fcvtns, fcvtnu, scvtf, ucvtf, fcvtas, fcvtau, fmov, fcvtpos, fcvtpu, fcvtms, fcvtmu, fcvtzs, fcvtzu, fccmp, fccmpe, fcmp, fcmpe, fabs, fneg, fsqrt, frintn, frintp, frintm, frintz, frinta, frintx, frinti, fmul, fdiv, fadd, fsub, fmax, fmin, fmaxnm, fminnm, fnmul, fmadd, fmsub, fnmadd, fnmsub and fcsel. Change-Id: Ie6d40bd1b215a9bc024e12ba75e52afbe1675eb7
2015-11-27[AArch64][PATCH 2/3] Adjust a utility function for floating point values.Matthew Wahab2-7/+37
ARMv8.2 adds 16-bit floating point operations as an optional extension. This patch adjusts the utility function expand_fp_imm to support 16-bit values. The function is intended to convert an 8-bit immediate representing a floating point value to a representation that can be passed to fprintf. Because of the limited use of the results, the only change made to the function is to treat a request for a 16-bit float as a request for a 32-bit float. opcodes/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * aarch64-opc.c (half_conv_t): New. (expand_fp_imm): Replace is_dp flag with the parameter size to specify the number of bytes for the required expansion. Treat a 16-bit expansion like a 32-bit expansion. Add check for an unsupported size request. Update comment. (aarch64_print_operand): Update to support 16-bit floating point values. Update for changes to expand_fp_imm. Change-Id: I1ae3df3864be375d71925197ab03397ed1ad2d15
2015-11-27[AArch64][PATCH 1/3] Support ARMv8.2 FP16 floating point instructions.Matthew Wahab2-0/+8
ARMv8.2 adds 16-bit floating point operations as an optional extension to the ARMv8 FP support. This patch set adds support for the 16-bit FP instructions to binutils, enabling the instructions when both +fp and +fp16 architecture extensions are enabled. The patches in this series: - Add a feature macro for use by the encoding/decoding mechanism. - Adjust a utility function, used when disassembling, to support 16-bit floating point values. - Add the new scalar floating-point instructions. This patch adds the feature macro FP_F16 to the AArch64 encoding/decoding mechanism, enabling it when both +fp and +fp16 are selected. opcodes/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * aarch64-tbl.h (aarch64_feature_fp_f16): New. (FP_F16): New. Change-Id: Ie370e43e3d77a7d54b4416b4be901b363a37f3d5
2015-11-27[AArch64] Add ARMv8.2 instruction alias REV64.Matthew Wahab8-768/+814
This patch adds the alias REV64 <Rd>, <Rs> as an alias for REV <Rd>, <Rs>. However, REV is still the preferred form for the instruction. gas/testsuite/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * gas/aarch64/alias-2.d: Add tests for REV. * gas/aarch64/alias-2.s: Likewise. opcodes/ 2015-11-27 Matthew Wahab <matthew.wahab@arm.com> * aarch64-asm-2.c: Regenerate. * aarch64-dis-2.c: Regenerate. * aarch64-opc-2.c: Regenerate. * aarch64-tbl.h (aarchr64_opcode_table): Update "rev", add "rev64". Change-Id: I331567c8d3618ba9fec1673c6e0b5977222dde61