aboutsummaryrefslogtreecommitdiff
path: root/gdb/target-delegates.c
AgeCommit message (Collapse)AuthorFilesLines
2015-03-04garbage collect target_decr_pc_after_breakPedro Alves1-27/+0
record-btrace was the only target making use of this, and it no longer uses it. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * target.h (struct target_ops) <to_decr_pc_after_break>: Delete. (target_decr_pc_after_break): Delete declaration. * target.c (default_target_decr_pc_after_break) (target_decr_pc_after_break): Delete. * linux-nat.c (check_stopped_by_breakpoint, linux_nat_wait_1): Use gdbarch_decr_pc_after_break instead of target_decr_pc_after_break. * linux-thread-db.c (check_event): Likewise. * infrun.c (adjust_pc_after_break): Likewise. * darwin-nat.c (cancel_breakpoint): Likewise. * aix-thread.c (aix_thread_wait): Likewise. * target-delegates.c: Regenerate.
2015-03-04Teach GDB about targets that can tell whether a trap is a breakpoint eventPedro Alves1-0/+124
The moribund locations heuristics are problematic. This patch teaches GDB about targets that can reliably tell whether a trap was caused by a software or hardware breakpoint, and thus don't need moribund locations, thus bypassing all the problems that mechanism has. The non-stop-fair-events.exp test is frequently failing currently. E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html. The root cause is a fundamental problem with moribund locations. For example, the stepped_breakpoint logic added by af48d08f breaks in this case (which is what happens with that test): - Step thread A, no breakpoint is set at PC. - The kernel doesn't schedule thread A yet. - Insert breakpoint at A's PC, for some reason (e.g., a step-resume breakpoint for thread B). - Kernel finally schedules thread A. - thread A's stepped_breakpoint flag is not set, even though it now stepped a breakpoint instruction. - adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but stepped_breakpoint is not set. We needed the stepped_breakpoint logic to workaround moribund locations, because otherwise adjust_pc_after_break could apply an adjustment when it shouldn't just because there _used_ to be a breakpoint at PC (a moribund breakpoint location). For example, on x86, that's wrong if the thread really hasn't executed an int3, but instead executed some other 1-byte long instruction. Getting the PC adjustment wrong of course leads to the inferior executing the wrong instruction. Other problems with moribund locations are: - if a true SIGTRAP happens to be raised when the program is executing the PC that used to have a breakpoint, GDB will assume that is a trap for a breakpoint that has recently been removed, and thus we miss reporting the random signal to the user. - to minimize that, we get rid of moribund location after a while. That while is defined as just a certain number of events being processed. That number of events sometimes passes by before a delayed breakpoint is processed, and GDB confuses the trap for a random signal, thus reporting the random trap. Once the user resumes the thread, the program crashes because the PC was not adjusted... The fix for all this is to bite the bullet and get rid of heuristics and instead rely on the target knowing accurately what caused the SIGTRAP. The target/kernel/stub is in the best position to know what that, because it can e.g. consult priviledged CPU flags GDB has no access to, or by knowing which exception vector entry was called when the instruction trapped, etc. Most debug APIs I've seen to date report breakpoint hits as a distinct event in some fashion. For example, on the Linux kernel, whether a breakpoint was executed is exposed to userspace in the si_code field of the SIGTRAP's siginfo. On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception code. We needed to keep around deleted breakpoints in an on-the-side list (the moribund locations) for two main reasons: - Know that a SIGTRAP actually is a delayed event for a hit of a breakpoint that was removed before the event was processed, and thus should not be reported as a random signal. - So we still do the decr_pc_after_break adjustment in that case, so that the thread is resumed at the correct address. In the new model, if GDB processes an event the target tells is a breakpoint trap, and GDB doesn't find the corresponding breakpoint in its breakpoint tables, it means that event is a delayed event for a breakpoint that has since been removed, and thus the event should be ignored. For the decr_pc_after_after issue, it ends up being much simpler that on targets that can reliably tell whether a breakpoint trapped, for the breakpoint trap to present the PC already adjusted. Proper multi-threading support already implies that targets needs to be doing decr_pc_after_break adjustment themselves, otherwise for example, in all-stop if two threads hit a breakpoint simultaneously, and the user does "info threads", he'll see the non-event thread that hit the breakpoint stopped at the wrong PC. This way (target adjusts) also ends up eliminating the need for some awkward re-incrementing of the PC in the record-full and Linux targets that we do today, and the need for the target_decr_pc_after_break hook. If the target always adjusts, then there's a case where GDB needs to re-increment the PC. Say, on x86, an "int3" instruction that was explicitly written in the program traps. In this case, GDB should report a random SIGTRAP signal to the user, with the PC pointing at the instruction past the int3, just like if GDB was not debugging the program. The user may well decide to pass the SIGTRAP to the program because the program being debugged has a SIGTRAP handler that handles its own breakpoints, and expects the PC to be unadjusted. Tested on x86-64 Fedora 20. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * breakpoint.c (need_moribund_for_location_type): New function. (bpstat_stop_status): Don't skipping checking moribund locations of breakpoint types which the target tell caused a stop. (program_breakpoint_here_p): New function, factored out from ... (bp_loc_is_permanent): ... this. (update_global_location_list): Don't create a moribund location if the target supports reporting stops of the type of the removed breakpoint. * breakpoint.h (program_breakpoint_here_p): New declaration. * infrun.c (adjust_pc_after_break): Return early if the target has already adjusted the PC. Add comments. (handle_signal_stop): If nothing explains a signal, and the target tells us the stop was caused by a software breakpoint, check if there's a breakpoint instruction in the memory. If so, adjust the PC before presenting the stop to the user. Otherwise, ignore the trap. If nothing explains a signal, and the target tells us the stop was caused by a hardware breakpoint, ignore the trap. * target.h (struct target_ops) <to_stopped_by_sw_breakpoint, to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_supports_stopped_by_hw_breakpoint>: New fields. (target_stopped_by_sw_breakpoint) (target_supports_stopped_by_sw_breakpoint) (target_stopped_by_hw_breakpoint) (target_supports_stopped_by_hw_breakpoint): Define. * target-delegates.c: Regenerate.
2015-02-09record btrace: add configuration structMarkus Metzger1-5/+40
Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2015-02-09btrace: add format argument to supports_btraceMarkus Metzger1-5/+7
Add a format argument to the various supports_btrace functions to check for support of a specific btrace format. This is to prepare for a new format. Removed two redundant calls. The check will be made in the subsequent btrace_enable call. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (btrace_enable): Pass BTRACE_FORMAT_BTS. * record-btrace.c (record_btrace_open): Remove call to target_supports_btrace. * remote.c (remote_supports_btrace): Update parameters. * target.c (target_supports_btrace): Update parameters. * target.h (to_supports_btrace, target_supports_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_btrace_format): New. * nat/linux-btrace.c (kernel_supports_btrace): Rename into ... (kernel_supports_bts): ... this. Update users. Update warning text. (intel_supports_btrace): Rename into ... (intel_supports_bts): ... this. Update users. (cpu_supports_btrace): Rename into ... (cpu_supports_bts): ... this. Update users. (linux_supports_btrace): Update parameters. Split into this and ... (linux_supports_bts): ... this. * nat/linux-btrace.h (linux_supports_btrace): Update parameters. gdbserver/ * server.c (handle_btrace_general_set): Remove call to target_supports_btrace. (supported_btrace_packets): New. (handle_query): Call supported_btrace_packets. * target.h: include btrace-common.h. (btrace_target_info): Removed. (supports_btrace, target_supports_btrace): Update parameters.
2015-02-09btrace: add struct btrace_dataMarkus Metzger1-4/+4
Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2014-10-15Push pruning old threads down to the targetPedro Alves1-11/+11
When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-08-27Fix terminal state corruption when starting a program from within TUIPatrick Palka1-26/+0
The TUI terminal state becomes corrupted (e.g. key sequences such as Alt_F and Alt_B no longer work) when one attaches to an inferior process (via "run" or "attach") from within TUI. This terminal corruption remains until you switch out of TUI mode. This happens because the terminal state is not properly saved when switching to and out from TUI mode. Although the functions tui_enable() and tui_disable() both call the function target_terminal_save_ours() to save the terminal state, this function is a no-op unless GDB has already attached to an inferior process. This is because only the "native" target has a useful implementation of target_terminal_save_ours() (namely child_terminal_save_ours()) and we only have the "native" target in our target vector if GDB has already attached to an inferior process. So without an inferior process, switching to and from TUI mode does not actually save the terminal state. Therefore when you attach to an inferior process from within TUI mode, the proper terminal state is not restored (after swapping from the inferior's terminal back to the GDB terminal). To fix this we just have to ensure that the terminal state is always being properly saved when switching from and to TUI mode. To achieve this, this patch removes the polymorphic function target_terminal_save_ours() and replaces it with a regular function gdb_save_tty_state() that always saves the terminal state. Tested on x86_64-unknown-linux-gnu by running "make check", no new regressions. gdb/ChangeLog: * target.h (struct target_ops::to_terminal_save_ours): Remove declaration. (target_terminal_save_ours): Remove macro. * target-delegates.c: Regenerate. * inf-child.c (inf_child_target): Don't set the nonexistent field to_terminal_save_ours. * inferior.h (child_terminal_save_ours): Remove declaration. * terminal.h (gdb_save_tty_state): New declaration. * inflow.c (child_terminal_save_ours): Rename to ... (gdb_save_tty_state): ... this. * tui/tui.c: Include terminal.h. (tui_enable): Use gdb_save_tty_state instead of target_terminal_save_ours. (tui_disable): Likewise.
2014-07-24auto-generate most target debug methodsTom Tromey1-4/+2228
The target debug methods are inconsistently maintained. Most to_* methods have some kind of targetdebug awareness, but not all of them do. The ones that do vary in the quantity and quality of output they generate. This patch changes most of the target debug methods to be automatically generated. All the arguments are printed, and separate lines are printed for entering and existing the outermost call to the target stack. For example now you'd see: -> multi-thread->to_terminal_ours (...) -> multi-thread->to_is_async_p (...) <- multi-thread->to_is_async_p (0x1ebb580) = 1 <- multi-thread->to_terminal_ours (0x1ebb580) -> multi-thread->to_thread_address_space (...) <- multi-thread->to_thread_address_space (0x1ebb580, 26802) = 1 In this case you can see nested calls. The "multi-thread" on the left hand side is the topmost target's shortname. There are some oddities with this patch. I'm on the fence about it all, I really just wrote it on a whim. It's not simple to convert every possible method, since a few don't participate in target delegation. Printing is done by type, so I introduced some new debug-printing-specific typedefs to handle cases where it is nicer to do something else. On the plus side, this lays the groundwork for making targetdebug affect every layer of the target stack. The idea would be to wrap each target_ops in the stack with its own debug_target, and then you could see calls propagate down the stack and back up; I suppose with indentation to make it prettier. (That said there are some gotchas lurking in this idea due to target stack introspection.) Regtested on x86-64 Fedora 20. 2014-07-24 Tom Tromey <tromey@redhat.com> * make-target-delegates (munge_type, write_debugmethod): New functions. (debug_names): New global. ($TARGET_DEBUG_PRINTER): New global. (write_function_header): Strip TARGET_DEBUG_PRINTER from the type name. Write debug methods. Generate init_debug_target. * target-debug.h: New file. * target-delegates.c: Rebuild. * target.c: Include target-debug.h. (debug_target): Hoist definition. (target_kill, target_get_section_table, target_memory_map) (target_flash_erase, target_flash_done, target_detach) (target_disconnect, target_wait, target_resume) (target_pass_signals, target_program_signals, target_follow_fork) (target_mourn_inferior, target_search_memory) (target_thread_address_space, target_close) (target_find_new_threads, target_core_of_thread) (target_verify_memory, target_insert_mask_watchpoint) (target_remove_mask_watchpoint): Remove targetdebug code. (debug_to_post_attach, debug_to_prepare_to_store) (debug_to_files_info, debug_to_insert_breakpoint) (debug_to_remove_breakpoint, debug_to_can_use_hw_breakpoint) (debug_to_region_ok_for_hw_watchpoint) (debug_to_can_accel_watchpoint_condition) (debug_to_stopped_by_watchpoint, debug_to_stopped_data_address) (debug_to_watchpoint_addr_within_range) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint) (debug_to_insert_watchpoint, debug_to_remove_watchpoint) (debug_to_terminal_init, debug_to_terminal_inferior) (debug_to_terminal_ours_for_output, debug_to_terminal_ours) (debug_to_terminal_save_ours, debug_to_terminal_info) (debug_to_load, debug_to_post_startup_inferior) (debug_to_insert_fork_catchpoint) (debug_to_remove_fork_catchpoint) (debug_to_insert_vfork_catchpoint) (debug_to_remove_vfork_catchpoint) (debug_to_insert_exec_catchpoint) (debug_to_remove_exec_catchpoint, debug_to_has_exited) (debug_to_can_run, debug_to_thread_architecture, debug_to_stop) (debug_to_rcmd, debug_to_pid_to_exec_file): Remove. (setup_target_debug): Call init_debug_target. * target.h (TARGET_DEBUG_PRINTER): New macro. (struct target_ops) <to_resume, to_wait, to_pass_signals, to_program_signals>: Use TARGET_DEBUG_PRINTER.
2014-07-23rewrite make-target-delegates matching codeTom Tromey1-14/+14
This patch rewrites the make-target-delegates matching code a little bit. The result is functionally the same (the output has some small whitespace differences), but the new code is more forgiving regarding the formatting of target.h. In particular now there's no need to ensure that the return type and the method name appear on the same line. 2014-07-23 Tom Tromey <tromey@redhat.com> * make-target-delegates ($ARGS_PART): Match trailing close paren. ($INTRO_PART): Don't match whitespace. ($METHOD_TRAILER): Move earlier. Remove trailing semicolon and argument matching. ($METHOD): Add $METHOD_TRAILER. (trim): Rewrite. (scan_target_h): New sub. Change main loop not to collect state. * target-delegates.c: Rebuild.
2014-07-16rebuild target-delegates.cTom Tromey1-0/+15
target-delegates.c was out of date. This patch rebuilds it. Built and regtested on x86-64 Fedora 20. Committed as obvious. 2014-07-16 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild.
2014-07-07convert to_get_thread_local_address to use target delegationTom Tromey1-0/+16
This converts to_get_thread_local_address to use TARGET_DEFAULT_NORETURN. One possible oddity is that this changes the text of the kind of exception thrown in some cases. This doesn't seem to be a problem; in fact perhaps the final call to 'error' in target_translate_tls_address should be changed to call generic_tls_error. 2014-07-07 Tom Tromey <tromey@redhat.com> * target.h (struct target_ops) <to_get_thread_local_address>: Use TARGET_DEFAULT_NORETURN. * target.c (generic_tls_error): New function. (target_translate_tls_address): Don't search target stack. * target-delegates.c: Rebuild. * ppc-linux-tdep.c (ppc_linux_spe_context): Don't search target stack. * linux-thread-db.c (thread_db_get_thread_local_address): Unconditionally call beneath target.
2014-06-26constify get_bookmark and goto_bookmarkTom Tromey1-4/+4
This makes arguments to to_get_bookmark and to_goto_bookmark const and fixes the fallout. Tested by rebuilding. The only thing of note is the new split between cmd_record_goto and record_goto -- basically separating the CLI function from a new internal API, to allow const propagation. 2014-06-26 Tom Tromey <tromey@redhat.com> * record-full.c (record_full_get_bookmark): Make "args" const. (record_full_goto_bookmark): Make "raw_bookmark" const. * record.c (record_goto): New function. (cmd_record_goto): Use it. Now static. * record.h (record_goto): Declare. (cmd_record_goto): Remove declaration. * target-delegates.c: Rebuild. * target.h (struct target_ops) <to_get_bookmark, to_goto_bookmark>: Make parameter const.
2014-06-26constify to_loadTom Tromey1-2/+2
This makes the argument to the target_ops to_load method "const", and fixes up the fallout. Tested by rebuilding all the affected files. 2014-06-26 Tom Tromey <tromey@redhat.com> * defs.h (generic_load): Update. * m32r-rom.c (m32r_load_gen): Make "filename" const. * monitor.c (monitor_load): Make "args" const. * remote-m32r-sdi.c (m32r_load): Make "args" const. * remote-mips.c (mips_load_srec, pmon_load_fast): Make "args" const. (mips_load): Make "file" const. * remote-sim.c (gdbsim_load): Make "args" const. * remote.c (remote_load): Make "name" const. * symfile.c (generic_load): Make "args" const. * target-delegates.c: Rebuild. * target.c (target_load): Make "arg" const. (debug_to_load): Make "args" const. * target.h (struct target_ops) <to_load>: Make parameter const. (target_load): Update.
2014-06-25gcore, target: allow target to prepare/cleanup for/after core file generationMarkus Metzger1-0/+30
Add new target functions to_prepare_to_generate_core and to_done_generating_core that are called before and after generating a core file, respectively. This allows targets to prepare for core file generation and to clean up afterwards. gdb/ * target.h (target_ops) <to_prepare_to_generate_core> <to_done_generating_core>: New. (target_prepare_to_generate_core, target_done_generating_core): New. * target.c (target_prepare_to_generate_core) (target_done_generating_core): New. * target-delegates.c: Regenerate. * gcore.c: (write_gcore_file): Rename to ... (write_gcore_file_1): ...this. (write_gcore_file): Call target_prepare_to_generate_core and target_done_generating_core.
2014-06-16constify to_disconnectTom Tromey1-2/+2
This constifies an parameter of to_disconnect and updates target_disconnect as well. 2014-06-16 Tom Tromey <tromey@redhat.com> * target.h (struct target_ops) <to_disconnect>: Make parameter const. (target_disconnect): Update. * target.c (target_disconnect): Make "args" const. * target-delegates.c: Rebuild. * remote.c (remote_disconnect): Update. * record.h (record_disconnect): Update. * record.c (record_disconnect): Update. * inf-child.c (inf_child_disconnect): Update.
2014-06-16constify to_rcmdTom Tromey1-1/+1
This makes the "command" parameter of the to_rcmd target method const. 2014-06-16 Tom Tromey <tromey@redhat.com> * target.h (struct target_ops) <to_rcmd>: Make "command" const. * target.c (debug_to_rcmd, default_rcmd): Update. * target-delegates.c: Rebuild. * remote.c (remote_rcmd): Update. * monitor.c (monitor_rcmd): Update.
2014-06-04convert to_thread_address_space to use TARGET_DEFAULT_FUNCTom Tromey1-0/+10
This converts to_thread_address_space to use TARGET_DEFAULT_FUNC. This method was one of a handful not using the normal target delegation approach. The only rationale here is consistency in the target vector. Built and regtested on x86-64 Fedora 20. 2014-06-04 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (default_thread_address_space): New function. (target_thread_address_space): Simplify. * target.h (struct target_ops) <to_thread_address_space>: Add TARGET_DEFAULT_FUNC.
2014-05-20Make compare-sections work against all targets; add compare-sections [-r] tests.Pedro Alves1-7/+1
This does two things: 1. Adds a test. Recently compare-sections got a new "-r" switch, but given no test existed for compare-sections, the patch was allowed in with no testsuite addition. This now adds a test for both compare-sections and compare-sections -r. 2. Makes the compare-sections command work against all targets. Currently, compare-sections only works with remote targets, and only those that support the qCRC packet. The patch makes it so that if the target doesn't support accelerating memory verification, then GDB falls back to comparing memory itself. This is of course slower, but it's better than nothing, IMO. While testing against extended-remote GDBserver I noticed that we send the qCRC request to the target if we're connected, but not yet running a program. That can't work of course -- the patch fixes that. This all also goes in the direction of bridging the local/remote parity gap. I didn't decouple 1. from 2., because that would mean that the test would need to handle the case of the target not supporting the command. Tested on x86_64 Fedora 17, native, remote GDBserver, and extended-remote GDBserver. I also hack-disabled qCRC support to make sure the fallback paths in remote.c work. gdb/doc/ 2014-05-20 Pedro Alves <palves@redhat.com> * gdb.texinfo (Memory) <compare-sections>: Generalize comments to not be remote specific. Add cross reference to the qCRC packet. (Separate Debug Files): Update cross reference to the qCRC packet. (General Query Packets) <qCRC packet>: Add anchor. gdb/ 2014-05-20 Pedro Alves <palves@redhat.com> * NEWS: Mention that compare-sections now works with all targets. * remote.c (PACKET_qCRC): New enum value. (remote_verify_memory): Don't send qCRC if the target has no execution. Use packet_support/packet_ok. If the target doesn't support the qCRC packet, fallback to a deep memory copy. (compare_sections_command): Say "target image" instead of "remote executable". (_initialize_remote): Add PACKET_qCRC to the list of config packets that have no associated command. Extend comment. * target.c (simple_verify_memory, default_verify_memory): New function. * target.h (struct target_ops) <to_verify_memory>: Default to default_verify_memory. (simple_verify_memory): New declaration. * target-delegates.c: Regenerate. gdb/testsuite/ 2014-05-20 Pedro Alves <palves@redhat.com> * gdb.base/compare-sections.c: New file. * gdb.base/compare-sections.exp: New file.
2014-03-12fix regressions with target-asyncTom Tromey1-12/+30
A patch in the target cleanup series caused a regression when using record with target-async. Version 4 of the patch is here: https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html The immediate problem is that record supplies to_can_async_p and to_is_async_p methods, but does not supply a to_async method. So, when target-async is set, record claims to support async -- but if the underlying target does not support async, then the to_async method call will end up in that method's default implementation, namely tcomplain. This worked previously because the record target used to provide a to_async method; one that (erroneously, only at push time) checked the other members of the target stack, and then simply dropped to_async calls in the "does not implement async" case. My first thought was to simply drop tcomplain as the default for to_async. This works, but Pedro pointed out that the only reason record has to supply to_can_async_p and to_is_async_p is that these default to using the find_default_run_target machinery -- and these defaults are only needed by "run" and "attach". So, a nicer solution presents itself: change run and attach to explicitly call into the default run target when needed; and change to_is_async_p and to_can_async_p to default to "return 0". This makes the target stack simpler to use and lets us remove the method implementations from record. This is also in harmony with other plans for the target stack; namely trying to reduce the impact of find_default_run_target. This approach makes it clear that find_default_is_async_p is not needed -- it is asking whether a target that may not even be pushed is actually async, which seems like a nonsensical question. While an improvement, this approach proved to introduce the same bug when using the core target. Looking a bit deeper, the issue is that code in "attach" and "run" may need to use either the current target stack or the default run target -- but different calls into the target API in those functions could wind up querying different targets. This new patch makes the target to use more explicit in "run" and "attach". Then these commands explicitly make the needed calls against that target. This ensures that a single target is used for all relevant operations. This lets us remove a couple find_default_* functions from various targets, including the dummy target. I think this is a decent understandability improvement. One issue I see with this patch is that the new calls in "run" and "attach" are not very much like the rest of the target API. I think fundamentally this is due to bad factoring in the target API, which may need to be fixed for multi-target. Tackling that seemed ambitious for a regression fix. While working on this I noticed that there don't seem to be any test cases that involve both target-async and record, so this patch changes break-precsave.exp to add some. It also changes corefile.exp to add some target-async tests; these pass with current trunk and with this patch applied, but fail with the v1 patch. This patch differs from v4 in that it moves initialization of to_can_async_p and to_supports_non_stop into inf-child, adds some assertions to complete_target_initialization, and adds some comments to target.h. Built and regtested on x86-64 Fedora 20. 2014-03-12 Tom Tromey <tromey@redhat.com> * inf-child.c (return_zero): New function. (inf_child_target): Set to_can_async_p, to_supports_non_stop. * aix-thread.c (aix_thread_inferior_created): New function. (aix_thread_attach): Remove. (init_aix_thread_ops): Don't set to_attach. (_initialize_aix_thread): Register inferior_created observer. * corelow.c (init_core_ops): Don't set to_attach or to_create_inferior. * exec.c (init_exec_ops): Don't set to_attach or to_create_inferior. * infcmd.c (run_command_1): Use find_run_target. Make direct target calls. (attach_command): Use find_attach_target. Make direct target calls. * record-btrace.c (init_record_btrace_ops): Don't set to_create_inferior. * record-full.c (record_full_can_async_p, record_full_is_async_p): Remove. (init_record_full_ops, init_record_full_core_ops): Update. Don't set to_create_inferior. * target.c (complete_target_initialization): Add assertion. (target_create_inferior): Remove. (find_default_attach, find_default_create_inferior): Remove. (find_attach_target, find_run_target): New functions. (find_default_is_async_p, find_default_can_async_p) (target_supports_non_stop, target_attach): Remove. (init_dummy_target): Don't set to_create_inferior or to_supports_non_stop. * target.h (struct target_ops) <to_attach>: Add comment. Remove TARGET_DEFAULT_FUNC. <to_create_inferior>: Add comment. <to_can_async_p, to_is_async_p, to_supports_non_stop>: Use TARGET_DEFAULT_RETURN. <to_can_async_p, to_supports_non_stop, to_can_run>: Add comments. (find_attach_target, find_run_target): Declare. (target_create_inferior): Remove. (target_has_execution_1): Update comment. (target_supports_non_stop): Remove. * target-delegates.c: Rebuild. 2014-03-12 Tom Tromey <tromey@redhat.com> * gdb.base/corefile.exp (corefile_test_run, corefile_test_attach): New procs. Add target-async tests. * gdb.reverse/break-precsave.exp (precsave_tests): New proc. Add target-async tests.
2014-03-06Change the default implementation of to_traceframe_info to tcomplainYao Qi1-1/+1
This patch is to change the default implementation of to_traceframe_info from 'return NULL' to tcomplain, which is intended. If new target supports tracepoint, this method should be implemented, otherwise, an error is thrown. gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> * target.h (struct target_ops) <to_traceframe_info>: Use TARGET_DEFAULT_NORETURN (tcomplain ()). * target-delegates.c: Regenerated.
2014-02-19convert to_get_unwinder and to_get_tailcall_unwinder to methodsTom Tromey1-0/+32
This converts to_get_unwinder and to_get_tailcall_unwinder to methods and arranges for them to use the new delegation scheme. This just lets us avoid having a differing style (neither new-style nor INHERIT) of delegation in the tree. 2014-02-19 Tom Tromey <tromey@redhat.com> * target.c (target_get_unwinder): Rewrite. (target_get_tailcall_unwinder): Rewrite. * record-btrace.c (record_btrace_to_get_unwinder): New function. (record_btrace_to_get_tailcall_unwinder): New function. (init_record_btrace_ops): Update. * target.h (struct target_ops) <to_get_unwinder, to_get_tailcall_unwinder>: Now function pointers. Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_decr_pc_after_breakTom Tromey1-0/+10
This converts to_decr_pc_after_break to the new style of delegation, removing forward_target_decr_pc_after_break. 2014-02-19 Tom Tromey <tromey@redhat.com> * record-btrace.c (record_btrace_decr_pc_after_break): Delegate directly. * target-delegates.c: Rebuild. * target.h (struct target_ops) <to_decr_pc_after_break>: Use TARGET_DEFAULT_FUNC. * target.c (default_target_decr_pc_after_break): Rename from forward_target_decr_pc_after_break. Simplify. (target_decr_pc_after_break): Rely on delegation.
2014-02-19pass NULL to TARGET_DEFAULT_RETURN when appropriateTom Tromey1-7/+7
This changes instances of TARGET_DEFAULT_RETURN(0) to TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a relic from an earlier implementation of make-target-delegates; and I didn't want to go back through the long patch series, fixing up conflicts, just to change this small detail. 2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.h (struct target_ops) <to_extra_thread_info, to_thread_name, to_pid_to_exec_file, to_get_section_table, to_memory_map, to_read_description, to_traceframe_info>: Use NULL, not 0, in TARGET_DEFAULT_RETURN.
2014-02-19change delegation for to_read_descriptionTom Tromey1-0/+16
This switches to_read_description to the "new normal" delegation scheme. This one was a bit trickier than the other changes due to the way that target_read_description handled delegation. I examined all the target implementations of to_read_description and changed the ones returning NULL to instead delegate. 2014-02-19 Tom Tromey <tromey@redhat.com> * arm-linux-nat.c (arm_linux_read_description): Delegate when needed. * corelow.c (core_read_description): Delegate when needed. * remote.c (remote_read_description): Delegate when needed. * target-delegates.c: Rebuild. * target.c (target_read_description): Rewrite. * target.h (struct target_ops) <to_read_description>: Update comment. Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_can_runTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (update_current_target): Don't inherit or default to_can_run. (find_default_run_target): Check against delegate_can_run. * target.h (struct target_ops) <to_can_run>: Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_disconnectTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_disconnect): Unconditionally delegate. * target.h (struct target_ops) <to_disconnect>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_stop_recordingTom Tromey1-0/+15
2014-02-19 Tom Tromey <tromey@redhat.com> * record.c (record_stop): Unconditionally delegate. * target-delegates.c: Rebuild. * target.c (target_stop_recording): Unconditionally delegate. * target.h (struct target_ops) <to_stop_recording>: Use TARGET_DEFAULT_IGNORE.
2014-02-19convert to_enable_btraceTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_enable_btrace): Unconditionally delegate. * target.h (struct target_ops) <to_enable_btrace>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_read_btraceTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_read_btrace): Unconditionally delegate. * target.h (struct target_ops) <to_read_btrace>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_teardown_btraceTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_teardown_btrace): Unconditionally delegate. * target.h (struct target_ops) <to_teardown_btrace>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_disable_btraceTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_disable_btrace): Unconditionally delegate. * target.h (struct target_ops) <to_disable_btrace>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_search_memoryTom Tromey1-0/+10
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (default_search_memory): New function. (simple_search_memory): Update comment. (target_search_memory): Unconditionally delegate. * target.h (struct target_ops) <to_search_memory>: Use TARGET_DEFAULT_FUNC.
2014-02-19convert to_auxv_parseTom Tromey1-0/+10
2014-02-19 Tom Tromey <tromey@redhat.com> * auxv.c (default_auxv_parse): No longer static. (target_auxv_parse): Unconditionally delegate. * auxv.h (default_auxv_parse): Declare. * target-delegates.c: Rebuild. * target.c: Include auxv.h. * target.h (struct target_ops) <to_auxv_parse>: Use TARGET_DEFAULT_FUNC.
2014-02-19convert to_memory_mapTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_memory_map): Unconditionally delegate. * target.h (struct target_ops) <to_memory_map>: Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_thread_aliveTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_thread_alive): Unconditionally delegate. * target.h (struct target_ops) <to_thread_alive>: Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_save_recordTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_save_record): Unconditionally delegate. * target.h (struct target_ops) <to_save_record>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_delete_recordTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_delete_record): Unconditionally delegate. * target.h (struct target_ops) <to_delete_record>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_record_is_replayingTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_record_is_replaying): Unconditionally delegate. * target.h (struct target_ops) <to_record_is_replaying>: Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_goto_record_beginTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_goto_record_begin): Unconditionally delegate. * target.h (struct target_ops) <to_goto_record_begin>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_goto_record_endTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_goto_record_end): Unconditionally delegate. * target.h (struct target_ops) <to_goto_record_end>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_goto_recordTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_goto_record): Unconditionally delegate. * target.h (struct target_ops) <to_goto_record>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_insn_historyTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_insn_history): Unconditionally delegate. * target.h (struct target_ops) <to_insn_history>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_insn_history_fromTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_insn_history_from): Unconditionally delegate. * target.h (struct target_ops) <to_insn_history_from>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_insn_history_rangeTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_insn_history_range): Unconditionally delegate. * target.h (struct target_ops) <to_insn_history_range>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_call_historyTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_call_history): Unconditionally delegate. * target.h (struct target_ops) <to_call_history>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_call_history_fromTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_call_history_from): Unconditionally delegate. * target.h (struct target_ops) <to_call_history_from>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_call_history_rangeTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_call_history_range): Unconditionally delegate. * target.h (struct target_ops) <to_call_history_range>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_verify_memoryTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_verify_memory): Unconditionally delegate. * target.h (struct target_ops) <to_verify_memory>: Use TARGET_DEFAULT_NORETURN.
2014-02-19convert to_core_of_threadTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_core_of_thread): Unconditionally delegate. * target.h (struct target_ops) <to_core_of_thread>: Use TARGET_DEFAULT_RETURN.
2014-02-19convert to_flash_doneTom Tromey1-0/+16
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_flash_done): Unconditionally delegate. * target.h (struct target_ops) <to_flash_done>: Use TARGET_DEFAULT_NORETURN.