binutils-gdb/gdb/remote.c

13120 lines
371 KiB
C
Raw Normal View History

/* Remote target communications for serial-line targets in custom GDB protocol
2002-01-17 23:15:18 +01:00
Copyright (C) 1988-2015 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1999-07-07 22:19:36 +02:00
/* See the GDB User Guide for details of the GDB remote protocol. */
1999-07-07 22:19:36 +02:00
#include "defs.h"
#include <ctype.h>
#include <fcntl.h>
#include "inferior.h"
Add new infrun.h header. Move infrun.c declarations out of inferior.h to a new infrun.h file. Tested by building on: i686-w64-mingw32, enable-targets=all x86_64-linux, enable-targets=all i586-pc-msdosdjgpp And also grepped the whole tree for each symbol moved to find where infrun.h might be necessary. gdb/ 2014-05-22 Pedro Alves <palves@redhat.com> * inferior.h (debug_infrun, debug_displaced, stop_on_solib_events) (sync_execution, sched_multi, step_stop_if_no_debug, non_stop) (disable_randomization, enum exec_direction_kind) (execution_direction, stop_registers, start_remote) (clear_proceed_status, proceed, resume, user_visible_resume_ptid) (wait_for_inferior, normal_stop, get_last_target_status) (prepare_for_detach, fetch_inferior_event, init_wait_for_inferior) (insert_step_resume_breakpoint_at_sal) (follow_inferior_reset_breakpoints, stepping_past_instruction_at) (set_step_info, print_stop_event, signal_stop_state) (signal_print_state, signal_pass_state, signal_stop_update) (signal_print_update, signal_pass_update) (update_signals_program_target, clear_exit_convenience_vars) (displaced_step_dump_bytes, update_observer_mode) (signal_catch_update, gdb_signal_from_command): Move declarations ... * infrun.h: ... to this new file. * amd64-tdep.c: Include infrun.h. * annotate.c: Include infrun.h. * arch-utils.c: Include infrun.h. * arm-linux-tdep.c: Include infrun.h. * arm-tdep.c: Include infrun.h. * break-catch-sig.c: Include infrun.h. * breakpoint.c: Include infrun.h. * common/agent.c: Include infrun.h instead of inferior.h. * corelow.c: Include infrun.h. * event-top.c: Include infrun.h. * go32-nat.c: Include infrun.h. * i386-tdep.c: Include infrun.h. * inf-loop.c: Include infrun.h. * infcall.c: Include infrun.h. * infcmd.c: Include infrun.h. * infrun.c: Include infrun.h. * linux-fork.c: Include infrun.h. * linux-nat.c: Include infrun.h. * linux-thread-db.c: Include infrun.h. * monitor.c: Include infrun.h. * nto-tdep.c: Include infrun.h. * procfs.c: Include infrun.h. * record-btrace.c: Include infrun.h. * record-full.c: Include infrun.h. * remote-m32r-sdi.c: Include infrun.h. * remote-mips.c: Include infrun.h. * remote-notif.c: Include infrun.h. * remote-sim.c: Include infrun.h. * remote.c: Include infrun.h. * reverse.c: Include infrun.h. * rs6000-tdep.c: Include infrun.h. * s390-linux-tdep.c: Include infrun.h. * solib-irix.c: Include infrun.h. * solib-osf.c: Include infrun.h. * solib-svr4.c: Include infrun.h. * target.c: Include infrun.h. * top.c: Include infrun.h. * windows-nat.c: Include infrun.h. * mi/mi-interp.c: Include infrun.h. * mi/mi-main.c: Include infrun.h. * python/py-threadevent.c: Include infrun.h.
2014-05-22 13:29:11 +02:00
#include "infrun.h"
#include "bfd.h"
#include "symfile.h"
#include "target.h"
1999-07-07 22:19:36 +02:00
/*#include "terminal.h" */
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
#include "gdbthread.h"
1999-09-22 05:28:34 +02:00
#include "remote.h"
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
#include "remote-notif.h"
#include "regcache.h"
2001-10-21 19:19:38 +02:00
#include "value.h"
#include "observer.h"
* solib.h (CLEAR_SOLIB, SOLIB_ADD) (SOLIB_CREATE_INFERIOR_HOOK, SOLIB_REMOVE_INFERIOR_HOOK) (SOLIB_IN_DYNAMIC_LINKER, SOLIB_RESTART) (DISABLE_UNSETTABLE_BREAK, PC_SOLIB) (IN_SOLIB_DYNSYM_RESOLVE_CODE): Remove defines and orphaned comments. * breakpoint.c: Include "solib.h". (insert_bp_location) [!DISABLE_UNSETTABLE_BREAK]: Call solib_address. (remove_solib_event_breakpoints, create_solib_event_breakpoint) (disable_breakpoints_in_shlibs) (disable_breakpoints_in_unloaded_shlib) (re_enable_breakpoints_in_shlibs): Compile if SOLIB_ADD isn't defined. If PC_SOLIB isn't defined, call solib_address. (_initialize_breakpoint): Unconditionally install observer. * corelow.c: Include "solib.h". [SOLIB_ADD] (solib_add_stub): Remove prototype. (core_close) [!CLEAR_SOLIB]: Call clear_solib. (solib_add_stub) [!SOLIB_ADD] Call solib_add. (core_open): Unconditionally call solib_add_stub. * fork-child.c: Include "solib.h". (fork_inferior) [!SOLIB_CREATE_INFERIOR_HOOK]: Call solib_create_inferior_hook. * infcmd.c: Include "solib.h". (attach_command) [!SOLIB_ADD]: Call shlib_rescan. Unconditionally call re_enable_breakpoints_in_shlibs. * infrun.c: Include "solib.h". (SOLIB_IN_SYNSYM_RESOLVE_CODE): Don't define if not already defined. (stop_on_solib_events, show_stop_on_solib_events): Include unconditionally. (follow_exec) [!SOLIB_CREATE_INFERIOR_HOOK]: Call solib_create_inferior_hook. (handle_inferior_event) [!SOLIB_ADD]: Call shlib_add. [!IN_SOLIB_DYNSYM_RESOLVE_CODE]: Call in_solib_dynsym_resolve_code. (_initialize_infrun): Unconditionally add "stop_on_solib-events" command. * remote.c: Include "solib.h". (remote_open_1): Unconditionally call no_shared_libraries. [!SOLIB_CREATE_INFERIOR_HOOK] Call solib_create_inferior_hook. * stack.c: Include "solib.h". (print_frame) [!PC_SOLIB] Call shlib_for_pc. * xcoffsolib.c (no_shared_libraries): Remove function. * Makefile.in (SFILES): Add solib.c. (ALLDEPFILES): Remove solib.c. (COMMON_OBS): Add solib.o. (breakpoint.o, corelow.o, fork-chiled.o, infcmd.o, infrun.o) (remote.o, stack.o): Update dependencies.
2005-05-12 22:21:18 +02:00
#include "solib.h"
#include "cli/cli-decode.h"
#include "cli/cli-setshow.h"
#include "target-descriptions.h"
2012-07-18 21:34:57 +02:00
#include "gdb_bfd.h"
PR gdb/7912: * Makefile.in (SFILES): Add filestuff.c (COMMON_OBS): Add filestuff.o. (filestuff.o): New target. * auto-load.c (auto_load_objfile_script_1): Use gdb_fopen_cloexec. * auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec. * cli/cli-cmds.c (shell_escape): Call close_most_fds. * cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec. * common/agent.c (gdb_connect_sync_socket): Use gdb_socket_cloexec. * common/filestuff.c: New file. * common/filestuff.h: New file. * common/linux-osdata.c (linux_common_core_of_thread) (command_from_pid, commandline_from_pid, print_source_lines) (linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use gdb_fopen_cloexec. * common/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_has_state): Use gdb_fopen_cloexec. * config.in, configure: Rebuild. * configure.ac: Don't check for sys/socket.h. Check for fdwalk, pipe2. * corelow.c (core_open): Use gdb_open_cloexec. * dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec. * fork-child.c (fork_inferior): Call close_most_fds. * gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec. * inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec. * linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals): Use gdb_fopen_cloexec. (linux_proc_xfer_partial, linux_proc_xfer_spu): Use gdb_open_cloexec. (linux_async_pipe): Use gdb_pipe_cloexec. * remote-fileio.c (remote_fileio_func_open): Use gdb_open_cloexec. * remote.c (remote_file_put, remote_file_get): Use gdb_fopen_cloexec. * ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec, close_most_fds. * ser-tcp.c (net_open): Use gdb_socket_cloexec. * ser-unix.c (hardwire_open): Use gdb_open_cloexec. * solib.c (solib_find): Use gdb_open_cloexec. * source.c (openp, find_and_open_source): Use gdb_open_cloexec. * tracepoint.c (tfile_start): Use gdb_fopen_cloexec. (tfile_open): Use gdb_open_cloexec. * tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec. * ui-file.c (gdb_fopen): Use gdb_fopen_cloexec. * xml-support.c (xml_fetch_content_from_file): Use gdb_fopen_cloexec. * main.c (captured_main): Call notice_open_fds. gdbserver * Makefile.in (SFILES): Add filestuff.c. (OBS): Add filestuff.o. (filestuff.o): New target. * config.in, configure: Rebuild. * configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
#include "filestuff.h"
move some rsp bits into rsp-low.h This moves various low-level remote serial protocol bits into common/rsp-low.[ch]. This is as close to a pure move as possible. There are some redundancies remaining but those will be dealt with in a subsequent patch. Note that the two variants of remote_escape_output disagreed on the treatment of "*". On the theory that quoting cannot hurt but the absence possibly can, I chose the gdbserver variant to be the canonical one. 2014-02-12 Tom Tromey <tromey@redhat.com> * tracepoint.c: Include rsp-low.h. * remote.h (hex2bin, bin2hex, unpack_varlen_hex): Don't declare. * remote.c: Include rsp-low.h. (hexchars, ishex, unpack_varlen_hex, pack_nibble, pack_hex_byte) (fromhex, hex2bin, tohex, bin2hex, remote_escape_output) (remote_unescape_input): Move to common/rsp-low.c. * common/rsp-low.h: New file. * common/rsp-low.c: New file. * Makefile.in (SFILES): Add common/rsp-low.c. (HFILES_NO_SRCDIR): Add common/rsp-low.h. (COMMON_OBS): Add rsp-low.o. (rsp-low.o): New target. 2014-02-12 Tom Tromey <tromey@redhat.com> * tracepoint.c: Include rsp-low.h. * server.c: Include rsp-low.h. * remote-utils.h (convert_ascii_to_int, convert_int_to_ascii) (unhexify, hexify, remote_escape_output, unpack_varlen_hex): Don't declare. * remote-utils.c: Include rsp-low.h. (fromhex, hexchars, ishex, unhexify, tohex, hexify) (remote_escape_output, remote_unescape_input, unpack_varlen_hex) (convert_int_to_ascii, convert_ascii_to_int): Move to common/rsp-low.c. * regcache.c: Include rsp-low.h. * ax.c: Include rsp-low.h. * Makefile.in (SFILES): Add common/rsp-low.c. (OBS): Add rsp-low.o. (rsp-low.o): New target.
2014-01-18 22:32:47 +01:00
#include "rsp-low.h"
Remove isize output argument from fast_tracepoint_valid_at This patch removes the isize output argument from the fast_tracepoint_valid_at gdbarch hook. It was used to return the size of the instruction that needs to be replaced when installing a fast tracepoint. Instead of getting this value from the fast_tracepoint_valid_at hook, we can call the gdb_insn_length function. If we do not do this, then architectures which do not have a restriction on where to install the fast tracepoint will send uninitialized memory off to GDBserver. See remote_download_tracepoint: ~~~ int isize; if (gdbarch_fast_tracepoint_valid_at (target_gdbarch (), tpaddr, &isize, NULL)) xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x", isize); ~~~ The default implementation of fast_tracepoint_valid_at will not set isize resulting in uninitialized memory being sent. Later on, GDBserver could use this information to compute a jump offset. gdb/ChangeLog: * arch-utils.c (default_fast_tracepoint_valid_at): Remove unused isize argument. * arch-utils.h (default_fast_tracepoint_valid_at): Likewise. * breakpoint.c (check_fast_tracepoint_sals): Adjust call to gdbarch_fast_tracepoint_valid_at. * gdbarch.sh (fast_tracepoint_valid_at): Remove isize argument. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): Remove isize argument. Do not set it. * remote.c (remote_download_tracepoint): Adjust call to gdbarch_fast_tracepoint_valid_at. Call gdb_insn_length to get the instruction length.
2015-07-30 19:05:00 +02:00
#include "disasm.h"
Explicit locations: use new location API This patch converts the code base to use the new struct event_location API being introduced. This patch preserves the current functionality and adds no new features. The "big picture" API usage introduced by this patch may be illustrated with a simple exmaple. Where previously developers would write: void my_command (char *arg, int from_tty) { create_breakpoint (..., arg, ...); ... } one now uses: void my_command (char *arg, int from_tty) { struct event_locaiton *location; struct cleanup *back_to; location = string_to_event_locaiton (&arg, ...); back_to = make_cleanup_delete_event_location (location); create_breakpoint (..., location, ...); do_cleanups (back_to); } Linespec-decoding functions (now called location-decoding) such as decode_line_full no longer skip argument pointers over processed input. That functionality has been moved into string_to_event_location as demonstrated above. gdb/ChangeLog * ax-gdb.c: Include location.h. (agent_command_1) Use linespec location instead of address string. * break-catch-throw.c: Include location.h. (re_set_exception_catchpoint): Use linespec locations instead of address strings. * breakpoint.c: Include location.h. (create_overlay_event_breakpoint, create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint, update_breakpoints_after_exec): Use linespec location instead of address string. (print_breakpoint_location): Use locations and event_location_to_string. Print extra_string for pending locations for non-MI streams. (print_one_breakpoint_location): Use locations and event_location_to_string. (init_raw_breakpoint_without_location): Initialize b->location. (create_thread_event_breakpoint): Use linespec location instead of address string. (init_breakpoint_sal): Likewise. Only save extra_string if it is non-NULL and not the empty string. Use event_location_to_string instead of `addr_string'. Constify `p' and `endp'. Use skip_spaces_const/skip_space_const instead of non-const versions. Copy the location into the breakpoint. If LOCATION is NULL, save the breakpoint address as a linespec location instead of an address string. (create_breakpoint_sal): Change `addr_string' parameter to a struct event_location. All uses updated. (create_breakpoints_sal): Likewise for local variable `addr_string'. (parse_breakpoint_sals): Use locations instead of address strings. Remove check for empty linespec with conditional. Refactor. (decode_static_tracepoint_spec): Make argument const and update function. (create_breakpoint): Change `arg' to a struct event_location and rename. Remove `copy_arg' and `addr_start'. If EXTRA_STRING is empty, set it to NULL. Don't populate `canonical' for pending breakpoints. Pass `extra_string' to find_condition_and_thread. Clear `extra_string' if `rest' was NULL. Do not error with "garbage after location" if setting a dprintf breakpoint. Copy the location into the breakpoint instead of an address string. (break_command_1): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Check against `arg_cp' for a probe linespec. (dprintf_command): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Throw an exception if no format string was specified. (print_recreate_ranged_breakpoint): Use event_location_to_string instead of address strings. (break_range_command, until_break_command) (init_ada_exception_breakpoint): Use locations instead of address strings. (say_where): Print out extra_string for pending locations. (base_breakpoint_dtor): Delete `location' and `location_range_end' of the breakpoint. (base_breakpoint_create_sals_from_location): Use struct event_location instead of address string. Remove `addr_start' and `copy_arg' parameters. (base_breakpoint_decode_location): Use struct event_location instead of address string. (bkpt_re_set): Use locations instead of address strings. Use event_location_empty_p to check for unset location. (bkpt_print_recreate): Use event_location_to_string instead of an address string. Print out extra_string for pending locations. (bkpt_create_sals_from_location, bkpt_decode_location) (bkpt_probe_create_sals_from_location): Use struct event_location instead of address string. (bkpt_probe_decode_location): Use struct event_location instead of address string. (tracepoint_print_recreate): Use event_location_to_string to recreate the tracepoint. (tracepoint_create_sals_from_location, tracepoint_decode_location) (tracepoint_probe_create_sals_from_location) (tracepoint_probe_decode_location): Use struct event_location instead of address string. (dprintf_print_recreate): Use event_location_to_string to recreate the dprintf. (dprintf_re_set): Remove check for valid/missing format string. (strace_marker_create_sals_from_location) (strace_marker_create_breakpoints_sal, strace_marker_decode_location) (update_static_tracepoint): Use struct event_location instead of address string. (location_to_sals): Likewise. Pass `extra_string' to find_condition_and_thread. For newly resolved pending breakpoint locations, clear the location's string representation. Assert that the breakpoint's condition string is NULL when condition_not_parsed. (breakpoint_re_set_default, create_sals_from_location_default) (decode_location_default, trace_command, ftrace_command) (strace_command, create_tracepoint_from_upload): Use locations instead of address strings. * breakpoint.h (struct breakpoint_ops) <create_sals_from_location>: Use struct event_location instead of address string. Update all uses. <decode_location>: Likewise. (struct breakpoint) <addr_string>: Change to struct event_location and rename `location'. <addr_string_range_end>: Change to struct event_location and rename `location_range_end'. (create_breakpoint): Use struct event_location instead of address string. * cli/cli-cmds.c: Include location.h. (edit_command, list_command): Use locations instead of address strings. * elfread.c: Include location.h. (elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string. * guile/scm-breakpoint.c: Include location.h. (bpscm_print_breakpoint_smob): Use event_location_to_string. (gdbscm_register_breakpoint): Use locations instead of address strings. * linespec.c: Include location.h. (struct ls_parser) <stream>: Change to const char *. (PARSER_STREAM): Update. (lionespec_lexer_lex_keyword): According to find_condition_and_thread, keywords must be followed by whitespace. (canonicalize_linespec): Save a linespec location into `canonical'. Save a canonical linespec into `canonical'. (parse_linespec): Change `argptr' to const char * and rename `arg'. All uses updated. Update function description. (linespec_parser_new): Initialize `parser'. Update initialization of parsing stream. (event_location_to_sals): New function. (decode_line_full): Change `argptr' to a struct event_location and rename it `location'. Use locations instead of address strings. Call event_location_to_sals instead of parse_linespec. (decode_line_1): Likewise. (decode_line_with_current_source, decode_line_with_last_displayed) Use locations instead of address strings. (decode_objc): Likewise. Change `argptr' to const char * and rename `arg'. (destroy_linespec_result): Delete the linespec result's location instead of freeing the address string. * linespec.h (struct linespec_result) <addr_string>: Change to struct event_location and rename to ... <location>: ... this. (decode_line_1, decode_line_full): Change `argptr' to struct event_location. All callers updated. * mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h. (mi_cmd_break_insert_1): Use locations instead of address strings. Throw an error if there was "garbage" at the end of the specified linespec. * probe.c: Include location.h. (parse_probes): Change `argptr' to struct event_location. Use event locations instead of address strings. * probe.h (parse_probes): Change `argptr' to struct event_location. * python/py-breakpoint.c: Include location.h. (bppy_get_location): Constify local variable `str'. Use event_location_to_string. (bppy_init): Use locations instead of address strings. * python/py-finishbreakpoint.c: Include location.h. (bpfinishpy_init): Remove local variable `addr_str'. Use locations instead of address strings. * python/python.c: Include location.h. (gdbpy_decode_line): Use locations instead of address strings. * remote.c: Include location.h. (remote_download_tracepoint): Use locations instead of address strings. * spu-tdep.c: Include location.h. (spu_catch_start): Remove local variable `buf'. Use locations instead of address strings. * tracepoint.c: Include location.h. (scope_info): Use locations instead of address strings. (encode_source_string): Constify parameter `src'. * tracepoint.h (encode_source_string): Likewise. gdb/testsuite/ChangeLog * gdb.base/dprintf-pending.exp: Update dprintf "without format" test. Add tests for missing ",FMT" and ",".
2015-08-12 02:09:35 +02:00
#include "location.h"
1999-07-07 19:31:57 +02:00
#include <sys/time.h>
1999-07-05 19:58:44 +02:00
#include "event-loop.h"
1999-09-22 05:28:34 +02:00
#include "event-top.h"
1999-10-06 01:13:56 +02:00
#include "inf-loop.h"
1999-07-05 19:58:44 +02:00
#include <signal.h>
#include "serial.h"
#include "gdbcore.h" /* for exec_bfd */
#include "remote-fileio.h"
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
#include "gdb/fileio.h"
remove gdb_stat.h This patch is purely mechanical. It removes gdb_stat.h and changes the code to use sys/stat.h. 2013-11-18 Tom Tromey <tromey@redhat.com> * common/gdb_stat.h: Remove. * ada-lang.c: Use sys/stat.h, not gdb_stat.h. * common/filestuff.c: Use sys/stat.h, not gdb_stat.h. * common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h. * corefile.c: Use sys/stat.h, not gdb_stat.h. * ctf.c: Use sys/stat.h, not gdb_stat.h. * darwin-nat.c: Use sys/stat.h, not gdb_stat.h. * dbxread.c: Use sys/stat.h, not gdb_stat.h. * dwarf2read.c: Use sys/stat.h, not gdb_stat.h. * exec.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h. * inf-child.c: Use sys/stat.h, not gdb_stat.h. * jit.c: Use sys/stat.h, not gdb_stat.h. * linux-nat.c: Use sys/stat.h, not gdb_stat.h. * m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h. * main.c: Use sys/stat.h, not gdb_stat.h. * mdebugread.c: Use sys/stat.h, not gdb_stat.h. * mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h. * nto-tdep.c: Use sys/stat.h, not gdb_stat.h. * objfiles.c: Use sys/stat.h, not gdb_stat.h. * procfs.c: Use sys/stat.h, not gdb_stat.h. * remote-fileio.c: Use sys/stat.h, not gdb_stat.h. * remote-mips.c: Use sys/stat.h, not gdb_stat.h. * remote.c: Use sys/stat.h, not gdb_stat.h. * rs6000-nat.c: Use sys/stat.h, not gdb_stat.h. * sol-thread.c: Use sys/stat.h, not gdb_stat.h. * solib-spu.c: Use sys/stat.h, not gdb_stat.h. * source.c: Use sys/stat.h, not gdb_stat.h. * symfile.c: Use sys/stat.h, not gdb_stat.h. * symmisc.c: Use sys/stat.h, not gdb_stat.h. * symtab.c: Use sys/stat.h, not gdb_stat.h. * top.c: Use sys/stat.h, not gdb_stat.h. * xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-06 15:55:51 +01:00
#include <sys/stat.h>
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
#include "xml-support.h"
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
#include "memory-map.h"
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
#include "tracepoint.h"
#include "ax.h"
#include "ax-gdb.h"
#include "agent.h"
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
#include "btrace.h"
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
/* Temp hacks for tracepoint encoding migration. */
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static char *target_buf;
static long target_buf_size;
/* The size to align memory write packets, when practical. The protocol
does not guarantee any alignment, and gdb will generate short
writes and unaligned writes, but even as a best-effort attempt this
can improve bulk transfers. For instance, if a write is misaligned
relative to the target's data bus, the stub may need to make an extra
round trip fetching data from the target. This doesn't make a
huge difference, but it's easy to do, so we try to be helpful.
The alignment chosen is arbitrary; usually data bus width is
important here, not the possibly larger cache line size. */
enum { REMOTE_ALIGN_WRITES = 16 };
/* Prototypes for local functions. */
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
static void async_cleanup_sigint_signal_handler (void *dummy);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
static int getpkt_sane (char **buf, long *sizeof_buf, int forever);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static int getpkt_or_notif_sane (char **buf, long *sizeof_buf,
int forever, int *is_notif);
1999-09-28 23:55:21 +02:00
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
static void async_handle_remote_sigint (int);
static void async_handle_remote_sigint_twice (int);
1999-07-05 19:58:44 +02:00
2000-05-28 03:12:42 +02:00
static void remote_files_info (struct target_ops *ignore);
static void remote_prepare_to_store (struct target_ops *self,
struct regcache *regcache);
static void remote_open_1 (const char *, int, struct target_ops *,
int extended_p);
static void remote_close (struct target_ops *self);
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
struct remote_state;
static int remote_vkill (int pid, struct remote_state *rs);
Kill pthread_ops_hack * target.h (struct target_ops): Make to_attach, to_detach, to_create_inferior and to_mourn_inferior accept a pointer to struct target_ops. (target_attach, target_create_inferior, target_create_inferior): Convert from macros to function. Find the right target to invoke a method of. (find_default_attach, find_default_create_inferior): New parameter ops. * corefile.c (core_file_command): Pass target to to_detach. * corelow.c (core_detach): Add 'ops' parameter. * fork-child.c (fork_inferior): Return the pid. Allow init_trace_fun to be NULL. * inf-ptrace (ptrace_ops_hack): Remove. (inf_ptrace_him): Remove, moving all logic into.... (inf_ptrace_create_inferior): ... here. Push the target passed as parameter. (inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach): Push/pop target passed as parameter, no ptrace_ops_hack. (inf_ptrace_target): Don't remember result. * inferior.h (fork_inferior): Adjust prototype. * linux-nat.c (linux_nat_create_inferior, linux_nat_attach) (linux_nat_detach, linux_nat_mourn_inferior): New parameter ops. Pass it to linux_ops target. * linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior): New parameter ops. Pass it to the target beneath. * remote.c (remote_mourn, extended_remote_mourn, remote_detach) (extended_remote_create_inferior): New parameter ops. Pass it further. * target.c (debug_to_attach, debug_to_detach) (debug_to_mourn_inferior): New parameter ops. (target_create_inferior): New. (update_current_target): Do not inherit to_attach, to_detach, to_create_inferiour, to_mourn_inferior. Do not default to_detach and to_mourn_inferior. (target_detach): Find the right target to use. (target_mourn_inferior): New. (find_default_attach, find_default_create_inferior): New parameter ops. Pass the found target when calling its method. (init_dummy_target): Provide fallback definition of to_detach. (target_attach): New. (debug_to_attach, debug_to_detach, debug_to_create_inferior) (debug_to_mourn_inferiour): New parameter ops. * aix-thread.c: Adjust. * bsd-uthread.c: Adjust. * gnu-nat.c: Adjust. * go32-nat.c: Adjust. * hpux-thread.c: Adjust. * inf-ttrace.c: Ajust. * monitor.c: Adjust. * nto-procfs.c: Adjust. * procfs.c: Adjust. * remote-m32r-sdi.c: Adjust. * remote-mips.c: Adjust. * remote-sim.c: Adjust. * rs6000-nat.c: Adjust. * sol-thread.c: Adjust. * win32-nat.c: Adjust. * dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
static void remote_mourn (struct target_ops *ops);
2000-05-28 03:12:42 +02:00
static void extended_remote_restart (void);
Kill pthread_ops_hack * target.h (struct target_ops): Make to_attach, to_detach, to_create_inferior and to_mourn_inferior accept a pointer to struct target_ops. (target_attach, target_create_inferior, target_create_inferior): Convert from macros to function. Find the right target to invoke a method of. (find_default_attach, find_default_create_inferior): New parameter ops. * corefile.c (core_file_command): Pass target to to_detach. * corelow.c (core_detach): Add 'ops' parameter. * fork-child.c (fork_inferior): Return the pid. Allow init_trace_fun to be NULL. * inf-ptrace (ptrace_ops_hack): Remove. (inf_ptrace_him): Remove, moving all logic into.... (inf_ptrace_create_inferior): ... here. Push the target passed as parameter. (inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach): Push/pop target passed as parameter, no ptrace_ops_hack. (inf_ptrace_target): Don't remember result. * inferior.h (fork_inferior): Adjust prototype. * linux-nat.c (linux_nat_create_inferior, linux_nat_attach) (linux_nat_detach, linux_nat_mourn_inferior): New parameter ops. Pass it to linux_ops target. * linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior): New parameter ops. Pass it to the target beneath. * remote.c (remote_mourn, extended_remote_mourn, remote_detach) (extended_remote_create_inferior): New parameter ops. Pass it further. * target.c (debug_to_attach, debug_to_detach) (debug_to_mourn_inferior): New parameter ops. (target_create_inferior): New. (update_current_target): Do not inherit to_attach, to_detach, to_create_inferiour, to_mourn_inferior. Do not default to_detach and to_mourn_inferior. (target_detach): Find the right target to use. (target_mourn_inferior): New. (find_default_attach, find_default_create_inferior): New parameter ops. Pass the found target when calling its method. (init_dummy_target): Provide fallback definition of to_detach. (target_attach): New. (debug_to_attach, debug_to_detach, debug_to_create_inferior) (debug_to_mourn_inferiour): New parameter ops. * aix-thread.c: Adjust. * bsd-uthread.c: Adjust. * gnu-nat.c: Adjust. * go32-nat.c: Adjust. * hpux-thread.c: Adjust. * inf-ttrace.c: Ajust. * monitor.c: Adjust. * nto-procfs.c: Adjust. * procfs.c: Adjust. * remote-m32r-sdi.c: Adjust. * remote-mips.c: Adjust. * remote-sim.c: Adjust. * rs6000-nat.c: Adjust. * sol-thread.c: Adjust. * win32-nat.c: Adjust. * dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
static void extended_remote_mourn (struct target_ops *);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
static void remote_send (char **buf, long *sizeof_buf_p);
2000-05-28 03:12:42 +02:00
static int readchar (int timeout);
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
static void remote_serial_write (const char *str, int len);
static void remote_kill (struct target_ops *ops);
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
static int remote_can_async_p (struct target_ops *);
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
static int remote_is_async_p (struct target_ops *);
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
static void remote_async (struct target_ops *ops, int enable);
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
static void sync_remote_interrupt_twice (int signo);
1999-04-26 20:34:20 +02:00
2000-05-28 03:12:42 +02:00
static void interrupt_query (void);
static void set_general_thread (struct ptid ptid);
static void set_continue_thread (struct ptid ptid);
2000-05-28 03:12:42 +02:00
static void get_offsets (void);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
static void skip_frame (void);
static long read_frame (char **buf_p, long *sizeof_buf);
2000-05-28 03:12:42 +02:00
static int hexnumlen (ULONGEST num);
2000-05-28 03:12:42 +02:00
static void init_remote_ops (void);
2000-05-28 03:12:42 +02:00
static void init_extended_remote_ops (void);
static void remote_stop (struct target_ops *self, ptid_t);
2000-05-28 03:12:42 +02:00
static int stubhex (int ch);
2000-05-28 03:12:42 +02:00
static int hexnumstr (char *, ULONGEST);
2000-05-28 03:12:42 +02:00
static int hexnumnstr (char *, ULONGEST, int);
1999-10-12 06:37:53 +02:00
2000-05-28 03:12:42 +02:00
static CORE_ADDR remote_address_masked (CORE_ADDR);
static void print_packet (const char *);
2000-05-28 03:12:42 +02:00
static void compare_sections_command (char *, int);
2000-05-28 03:12:42 +02:00
static void packet_command (char *, int);
2000-05-28 03:12:42 +02:00
static int stub_unpack_int (char *buff, int fieldlength);
2001-05-04 06:15:33 +02:00
static ptid_t remote_current_thread (ptid_t oldptid);
static int putpkt_binary (const char *buf, int cnt);
2000-05-28 03:12:42 +02:00
static void check_binary_download (CORE_ADDR addr);
1999-07-27 02:51:29 +02:00
struct packet_config;
2000-05-28 03:12:42 +02:00
static void show_packet_config_cmd (struct packet_config *config);
1999-07-27 02:51:29 +02:00
static void show_remote_protocol_packet_cmd (struct ui_file *file,
int from_tty,
struct cmd_list_element *c,
const char *value);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
static char *write_ptid (char *buf, const char *endbuf, ptid_t ptid);
static ptid_t read_ptid (char *buf, char **obuf);
static void remote_set_permissions (struct target_ops *self);
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
static int remote_get_trace_status (struct target_ops *self,
struct trace_status *ts);
2010-01-06 21:31:28 +01:00
static int remote_upload_tracepoints (struct target_ops *self,
struct uploaded_tp **utpp);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
static int remote_upload_trace_state_variables (struct target_ops *self,
struct uploaded_tsv **utsvp);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
static void remote_query_supported (void);
static void remote_check_symbols (void);
2000-05-28 03:12:42 +02:00
void _initialize_remote (void);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
struct stop_reply;
static void stop_reply_xfree (struct stop_reply *);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
static void remote_parse_stop_reply (char *, struct stop_reply *);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void push_stop_reply (struct stop_reply *);
static void discard_pending_stop_replies_in_queue (struct remote_state *);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static int peek_stop_reply (ptid_t ptid);
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
struct threads_listing_context;
static void remove_new_fork_children (struct threads_listing_context *);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void remote_async_inferior_event_handler (gdb_client_data);
static void remote_terminal_ours (struct target_ops *self);
static int remote_read_description_p (struct target_ops *target);
static void remote_console_output (char *msg);
static int remote_supports_cond_breakpoints (struct target_ops *self);
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
static int remote_can_run_breakpoint_commands (struct target_ops *self);
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
static void remote_btrace_reset (void);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
/* For "remote". */
static struct cmd_list_element *remote_cmdlist;
/* For "set remote" and "show remote". */
static struct cmd_list_element *remote_set_cmdlist;
static struct cmd_list_element *remote_show_cmdlist;
/* Stub vCont actions support.
Each field is a boolean flag indicating whether the stub reports
support for the corresponding action. */
struct vCont_action_support
{
/* vCont;t */
int t;
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
/* vCont;r */
int r;
};
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
/* Controls whether GDB is willing to use range stepping. */
static int use_range_stepping = 1;
#define OPAQUETHREADBYTES 8
/* a 64 bit opaque identifier */
typedef unsigned char threadref[OPAQUETHREADBYTES];
/* About this many threadisds fit in a packet. */
#define MAXTHREADLISTRESULTS 32
/* Description of the remote protocol state for the currently
connected target. This is per-target state, and independent of the
selected architecture. */
struct remote_state
{
/* A buffer to use for incoming packets, and its current size. The
buffer is grown dynamically for larger incoming packets.
Outgoing packets may also be constructed in this buffer.
BUF_SIZE is always at least REMOTE_PACKET_SIZE;
REMOTE_PACKET_SIZE should be used to limit the length of outgoing
packets. */
char *buf;
long buf_size;
/* True if we're going through initial connection setup (finding out
about the remote side's threads, relocating symbols, etc.). */
int starting_up;
/* If we negotiated packet size explicitly (and thus can bypass
heuristics for the largest packet size that will not overflow
a buffer in the stub), this will be set to that packet size.
Otherwise zero, meaning to use the guessed size. */
long explicit_packet_size;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* remote_wait is normally called when the target is running and
waits for a stop reply packet. But sometimes we need to call it
when the target is already stopped. We can send a "?" packet
and have remote_wait read the response. Or, if we already have
the response, we can stash it in BUF and tell remote_wait to
skip calling getpkt. This flag is set when BUF contains a
stop reply packet and the target is not waiting. */
int cached_wait_status;
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
/* True, if in no ack mode. That is, neither GDB nor the stub will
expect acks from each other. The connection is assumed to be
reliable. */
int noack_mode;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* True if we're connected in extended remote mode. */
int extended;
/* True if we resumed the target and we're waiting for the target to
stop. In the mean time, we can't start another command/query.
The remote server wouldn't be ready to process it, so we'd
timeout waiting for a reply that would never come and eventually
we'd close the connection. This can happen in asynchronous mode
because we allow GDB commands while the target is running. */
int waiting_for_stop_reply;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* The status of the stub support for the various vCont actions. */
struct vCont_action_support supports_vCont;
/* Nonzero if the user has pressed Ctrl-C, but the target hasn't
responded to that. */
int ctrlc_pending_p;
/* Descriptor for I/O to remote machine. Initialize it to NULL so that
remote_open knows that we don't have a file open when the program
starts. */
struct serial *remote_desc;
/* These are the threads which we last sent to the remote system. The
TID member will be -1 for all or -2 for not sent yet. */
ptid_t general_thread;
ptid_t continue_thread;
/* This is the traceframe which we last selected on the remote system.
It will be -1 if no traceframe is selected. */
int remote_traceframe_number;
char *last_pass_packet;
/* The last QProgramSignals packet sent to the target. We bypass
sending a new program signals list down to the target if the new
packet is exactly the same as the last we sent. IOW, we only let
the target know about program signals list changes. */
char *last_program_signals_packet;
enum gdb_signal last_sent_signal;
int last_sent_step;
char *finished_object;
char *finished_annex;
ULONGEST finished_offset;
/* Should we try the 'ThreadInfo' query packet?
This variable (NOT available to the user: auto-detect only!)
determines whether GDB will use the new, simpler "ThreadInfo"
query or the older, more complex syntax for thread queries.
This is an auto-detect variable (set to true at each connect,
and set to false when the target fails to recognize it). */
int use_threadinfo_query;
int use_threadextra_query;
/* This is set to the data address of the access causing the target
to stop for a watchpoint. */
CORE_ADDR remote_watch_data_address;
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
/* Whether the target stopped for a breakpoint/watchpoint. */
enum target_stop_reason stop_reason;
threadref echo_nextthread;
threadref nextthread;
threadref resultthreadlist[MAXTHREADLISTRESULTS];
/* The state of remote notification. */
struct remote_notif_state *notif_state;
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* The branch trace configuration. */
struct btrace_config btrace_config;
/* The argument to the last "vFile:setfs:" packet we sent, used
to avoid sending repeated unnecessary "vFile:setfs:" packets.
Initialized to -1 to indicate that no "vFile:setfs:" packet
has yet been sent. */
int fs_pid;
};
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
/* Private data that we'll store in (struct thread_info)->private. */
struct private_thread_info
{
char *extra;
int core;
};
static void
free_private_thread_info (struct private_thread_info *info)
{
xfree (info->extra);
xfree (info);
}
/* This data could be associated with a target, but we do not always
have access to the current target when we need it, so for now it is
static. This will be fine for as long as only one target is in use
at a time. */
static struct remote_state *remote_state;
static struct remote_state *
get_remote_state_raw (void)
{
return remote_state;
}
/* Allocate a new struct remote_state with xmalloc, initialize it, and
return it. */
static struct remote_state *
new_remote_state (void)
{
struct remote_state *result = XCNEW (struct remote_state);
/* The default buffer size is unimportant; it will be expanded
whenever a larger buffer is needed. */
result->buf_size = 400;
result->buf = xmalloc (result->buf_size);
result->remote_traceframe_number = -1;
result->last_sent_signal = GDB_SIGNAL_0;
result->fs_pid = -1;
return result;
}
/* Description of the remote protocol for a given architecture. */
struct packet_reg
{
long offset; /* Offset into G packet. */
long regnum; /* GDB's internal register number. */
LONGEST pnum; /* Remote protocol register number. */
int in_g_packet; /* Always part of G packet. */
/* long size in bytes; == register_size (target_gdbarch (), regnum);
at present. */
/* char *name; == gdbarch_register_name (target_gdbarch (), regnum);
2007-06-09 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (REGISTER_NAME): Replace by gdbarch_register_name. * tracepoint.c (scope_info): Likewise. * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * sh-tdep.c (sh_register_reggroup_p): Likewise. * sh64-tdep.c (sh64_do_fp_register, sh64_do_register) (sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_reggroup_p): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. * remote.c (packet_reg): Likewise (comment). * reggroups.c (default_register_reggroup_p): Likewise. * regcache.c (regcache_dump): Likewise. * printcmd.c (address_info): Likewise. * ppc-linux-nat.c (fetch_register, store_register): Likewise. * mt-dep.c (mt_registers_info): Likewise. * mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Likewise (comment). * mips-tdep.c (mips_register_reggroup_p, mips_read_fp_register_single) (mips_read_fp_register_double, mips_print_fp_register) (mips_print_register, print_gp_register_row, mips_print_registers_info) (mips_register_sim_regno): Likewise. * m68klinux-nat.c (regmap, fetch_register, store_register): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register) (inf_ptrace_store_register): Likewise. * infcmd.c (default_print_registers_info): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register) (ia64_linux_store_register): Likewise. * i386-linux-nat.c (fetch_register, store_register): Likewise. * i386gnu-nat.c (gnu_fetch_registers, gnu_store_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register) (hppa_hpux_store_register): Likewise. * findvar.c (locate_var_value): Likewise. * dwarf2loc.c (locexpr_describe_location): Likewise. * dwarf2-frame.c (execute_cfa_program): Likewise. * arm-tdep.c (arm_push_dummy_call): Likewise. * arch-utils.c (legacy_register_sim_regno): Likewise. * alpha-tdep.c (alpha_register_reggroup_p): Likewise. * alpha-nat.c (fetch_osf_core_registers): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers, mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * gdbarch.c, gdbarch.h: Regenerate.
2007-06-09 15:42:16 +02:00
at present. */
};
struct remote_arch_state
{
/* Description of the remote protocol registers. */
long sizeof_g_packet;
/* Description of the remote protocol registers indexed by REGNUM
2007-05-31 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (NUM_REGS): Replace by gdbarch_num_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * inf-ptrace.c (inf_ptrace_fetch_registers) (inf_ptrace_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * i386-linux-nat.c (supply_gregset, fill_gregset) (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers): Likewise. * remote.c (init_remote_state,packet_reg_from_regnum) (packet_reg_from_pnum,process_g_packet,remote_fetch_registers) (remote_prepare_to_store,store_registers_using_G) (remote_store_registers,remote_arch_state): Likewise. * tracepoint.c (encode_actions): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * tui/tui-regs.c (tui_show_register_group) (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * xtensa-tdep.c (xtensa_register_name,xtensa_register_type) (xtensa_reg_to_regnum,xtensa_pseudo_register_read) (xtensa_pseudo_register_write,xtensa_register_reggroup_p): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers,fetch_elf_core_registers * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target-descriptions.c (tdesc_use_registers): Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_do_pseudo_register,sh64_print_register) (sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * rs6000-nat.c (fetch_register,store_register): Likewise. * remote-sim.c (one2one_register_sim_regno,gdbsim_fetch_register) (gdbsim_fetch_register,gdbsim_store_register): Likewise. * remote-mips.c (mips_fetch_registers,mips_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * reggroups.c (default_register_reggroup_p): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save) (regcache_restore,regcache_dump): Likewise. * monitor.c (monitor_fetch_registers,monitor_store_registers): Likewise. * mips-tdep.c (mips_xfer_register,mips_register_name) (mips_register_reggroup_p,mips_pseudo_register_read) (mips_pseudo_register_write,mips_convert_register_p,mips_register_type) (mips_unwind_pc,mips_unwind_sp,mips_unwind_dummy_id,set_reg_offset) (mips16_scan_prologue,mips_insn16_frame_cache,reset_saved_regs) (mips32_scan_prologue,mips_insn32_frame_cache,read_next_frame_reg) (mips_n32n64_return_value,mips_o32_return_value,mips_o64_return_value) (print_gp_register_row,mips_print_registers_info) (mips_stab_reg_to_regnum,mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_register_sim_regno): Likewise. * mips-linux-tdep.c (mips_linux_o32_sigframe_init) (mips_linux_n32n64_sigframe_init): Likewise. * mips-linux-nat.c (mips_linux_register_addr) (mips64_linux_register_addr): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * mips64obsd-tdep.c (mips64obsd_sigframe_init): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache(: Likewise. * m32r-tdep.c (m32r_frame_unwind_cache): Likewise. * ia64-linux-nat.c (ia64_register_addr,ia64_cannot_fetch_register) (ia64_cannot_store_register,ia64_linux_fetch_registers) (ia64_linux_store_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers) (hpux_thread_store_registers): Likewise. * h8300-tdep.c (E_PSEUDO_CCR_REGNUM,E_PSEUDO_EXR_REGNUM) (h8300_init_frame_cache,h8300_frame_cache,h8300_frame_prev_register) (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache) (dwarf2_frame_state_alloc_regs): Likewise. * cris-tdep.c (cris_register_size,cris_cannot_fetch_register) (cris_cannot_store_register,crisv32_cannot_fetch_register) (crisv32_cannot_store_register,cris_register_name): Likewise. * avr-tdep.c (avr_frame_unwind_cache): Likewise. * arch-utils.c (legacy_register_sim_regno) (legacy_virtual_frame_pointer): Likewise. * arm-tdep.c (arm_make_prologue_cache,arm_register_sim_regno):Likewise. * arm-tdep.h: Likewise (comment). * frv-tdep.c (frv_register_sim_regno): Likewise. * m68klinux-nat.c (old_fetch_inferior_registers) (old_store_inferior_registers): Likewise. * m32c-tdep.c (m32c_virtual_frame_pointer): Likewise. * irix5-nat.c (fetch_core_registers): Likewise. * hppa-tdep.c (hppa_frame_cache): Likewise. * hppa-linux-nat.c (hppa_linux_register_addr) (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_inferior_registers) (hppa_hpux_store_inferior_registers): Likewise. * amd64-nat.c (amd64_native_gregset_reg_offset) (amd64_supply_native_gregset,amd64_collect_native_gregset): Likewise. * dbug-rom.c (dbug_regname): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache) (HARD_PAGE_REGNUM (comment)): Likewise. * gdbarch.sh (NUM_PSEUDO_REGS): Replace by gdbarch_num_pseudo_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * gdbarch.c, gdbarch.h: Regenerate. * tui/tui-regs.c (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_print_register,sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save (regcache_restore,regcache_dump): Likewise. * mips-tdep.c (print_gp_register_row,mips_print_registers_info) (mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_stab_reg_to_regnum): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * frame.h (SIZEOF_FRAME_SAVED_REGS): Likewise. * xtensa-tdep.c (xtensa_register_type,xtensa_reg_to_regnum) (xtensa_pseudo_register_read,xtensa_pseudo_register_write): Likewise. * parse.c: Remove comment. * gdbarch.c, gdbarch.h: Regenerate
2007-05-31 19:32:22 +02:00
(making an array gdbarch_num_regs in size). */
struct packet_reg *regs;
/* This is the size (in chars) of the first response to the ``g''
packet. It is used as a heuristic when determining the maximum
size of memory-read and memory-write packets. A target will
typically only reserve a buffer large enough to hold the ``g''
packet. The size does not include packet overhead (headers and
trailers). */
long actual_register_packet_size;
/* This is the maximum size (in chars) of a non read/write packet.
It is also used as a cap on the size of read/write packets. */
long remote_packet_size;
};
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
/* Utility: generate error from an incoming stub packet. */
static void
trace_error (char *buf)
{
if (*buf++ != 'E')
return; /* not an error msg */
switch (*buf)
{
case '1': /* malformed packet error */
if (*++buf == '0') /* general case: */
error (_("remote.c: error in outgoing packet."));
else
error (_("remote.c: error in outgoing packet at field #%ld."),
strtol (buf, NULL, 16));
default:
error (_("Target returns error code '%s'."), buf);
}
}
/* Utility: wait for reply from stub, while accepting "O" packets. */
static char *
remote_get_noisy_reply (char **buf_p,
long *sizeof_buf)
{
do /* Loop on reply from remote stub. */
{
char *buf;
QUIT; /* Allow user to bail out with ^C. */
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
getpkt (buf_p, sizeof_buf, 0);
buf = *buf_p;
if (buf[0] == 'E')
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
trace_error (buf);
else if (startswith (buf, "qRelocInsn:"))
{
ULONGEST ul;
CORE_ADDR from, to, org_to;
char *p, *pp;
int adjusted_size = 0;
Normalize TRY_CATCH exception handling block This normalizes some exception catch blocks that check for ex.reason to look like this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ALL) { ... } if (ex.reason < 0) { ... } ~~~ This is a preparation step for running a script that converts all TRY_CATCH uses to look like this instead: ~~~ TRY { ... } CATCH (ex, RETURN_MASK_ALL) { ... } END_CATCH ~~~ The motivation for that change is being able to reimplent TRY/CATCH in terms of C++ try/catch. This commit makes it so that: - no condition other than ex.reason < 0 is checked in the if predicate - there's no "else" block to check whether no exception was caught - there's no code between the TRY_CATCH (TRY) block and the 'if (ex.reason < 0)' block (CATCH). - the exception object is no longer referred to outside the if/catch block. Note the local volatile exception objects that are currently defined inside functions that use TRY_CATCH will disappear. In cases it's more convenient to still refer to the exception outside the catch block, a new non-volatile local is added and copy to that object is made within the catch block. The following patches should make this all clearer. gdb/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Normal exception handling code. * break-catch-throw.c (check_status_exception_catchpoint) (re_set_exception_catchpoint): Ditto. * cli/cli-interp.c (safe_execute_command): * cli/cli-script.c (script_from_file): Ditto. * compile/compile-c-symbols.c (generate_c_for_for_one_variable): Ditto. * compile/compile-object-run.c (compile_object_run): Ditto. * cp-abi.c (baseclass_offset): Ditto. * cp-valprint.c (cp_print_value): Ditto. * exceptions.c (catch_exceptions_with_msg): * frame-unwind.c (frame_unwind_try_unwinder): Ditto. * frame.c (get_frame_address_in_block_if_available): Ditto. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Ditto. * infcmd.c (post_create_inferior): Ditto. * linespec.c (parse_linespec, find_linespec_symbols): * p-valprint.c (pascal_object_print_value): Ditto. * parse.c (parse_expression_for_completion): Ditto. * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto. * remote.c (remote_get_noisy_reply): Ditto. * s390-linux-tdep.c (s390_frame_unwind_cache): Ditto. * solib-svr4.c (solib_svr4_r_map): Ditto.
2015-03-07 15:50:04 +01:00
int relocated = 0;
p = buf + strlen ("qRelocInsn:");
pp = unpack_varlen_hex (p, &ul);
if (*pp != ';')
error (_("invalid qRelocInsn packet: %s"), buf);
from = ul;
p = pp + 1;
unpack_varlen_hex (p, &ul);
to = ul;
org_to = to;
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
TRY
{
gdbarch_relocate_instruction (target_gdbarch (), &to, from);
Normalize TRY_CATCH exception handling block This normalizes some exception catch blocks that check for ex.reason to look like this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ALL) { ... } if (ex.reason < 0) { ... } ~~~ This is a preparation step for running a script that converts all TRY_CATCH uses to look like this instead: ~~~ TRY { ... } CATCH (ex, RETURN_MASK_ALL) { ... } END_CATCH ~~~ The motivation for that change is being able to reimplent TRY/CATCH in terms of C++ try/catch. This commit makes it so that: - no condition other than ex.reason < 0 is checked in the if predicate - there's no "else" block to check whether no exception was caught - there's no code between the TRY_CATCH (TRY) block and the 'if (ex.reason < 0)' block (CATCH). - the exception object is no longer referred to outside the if/catch block. Note the local volatile exception objects that are currently defined inside functions that use TRY_CATCH will disappear. In cases it's more convenient to still refer to the exception outside the catch block, a new non-volatile local is added and copy to that object is made within the catch block. The following patches should make this all clearer. gdb/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Normal exception handling code. * break-catch-throw.c (check_status_exception_catchpoint) (re_set_exception_catchpoint): Ditto. * cli/cli-interp.c (safe_execute_command): * cli/cli-script.c (script_from_file): Ditto. * compile/compile-c-symbols.c (generate_c_for_for_one_variable): Ditto. * compile/compile-object-run.c (compile_object_run): Ditto. * cp-abi.c (baseclass_offset): Ditto. * cp-valprint.c (cp_print_value): Ditto. * exceptions.c (catch_exceptions_with_msg): * frame-unwind.c (frame_unwind_try_unwinder): Ditto. * frame.c (get_frame_address_in_block_if_available): Ditto. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Ditto. * infcmd.c (post_create_inferior): Ditto. * linespec.c (parse_linespec, find_linespec_symbols): * p-valprint.c (pascal_object_print_value): Ditto. * parse.c (parse_expression_for_completion): Ditto. * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto. * remote.c (remote_get_noisy_reply): Ditto. * s390-linux-tdep.c (s390_frame_unwind_cache): Ditto. * solib-svr4.c (solib_svr4_r_map): Ditto.
2015-03-07 15:50:04 +01:00
relocated = 1;
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
CATCH (ex, RETURN_MASK_ALL)
Normalize TRY_CATCH exception handling block This normalizes some exception catch blocks that check for ex.reason to look like this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ALL) { ... } if (ex.reason < 0) { ... } ~~~ This is a preparation step for running a script that converts all TRY_CATCH uses to look like this instead: ~~~ TRY { ... } CATCH (ex, RETURN_MASK_ALL) { ... } END_CATCH ~~~ The motivation for that change is being able to reimplent TRY/CATCH in terms of C++ try/catch. This commit makes it so that: - no condition other than ex.reason < 0 is checked in the if predicate - there's no "else" block to check whether no exception was caught - there's no code between the TRY_CATCH (TRY) block and the 'if (ex.reason < 0)' block (CATCH). - the exception object is no longer referred to outside the if/catch block. Note the local volatile exception objects that are currently defined inside functions that use TRY_CATCH will disappear. In cases it's more convenient to still refer to the exception outside the catch block, a new non-volatile local is added and copy to that object is made within the catch block. The following patches should make this all clearer. gdb/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Normal exception handling code. * break-catch-throw.c (check_status_exception_catchpoint) (re_set_exception_catchpoint): Ditto. * cli/cli-interp.c (safe_execute_command): * cli/cli-script.c (script_from_file): Ditto. * compile/compile-c-symbols.c (generate_c_for_for_one_variable): Ditto. * compile/compile-object-run.c (compile_object_run): Ditto. * cp-abi.c (baseclass_offset): Ditto. * cp-valprint.c (cp_print_value): Ditto. * exceptions.c (catch_exceptions_with_msg): * frame-unwind.c (frame_unwind_try_unwinder): Ditto. * frame.c (get_frame_address_in_block_if_available): Ditto. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Ditto. * infcmd.c (post_create_inferior): Ditto. * linespec.c (parse_linespec, find_linespec_symbols): * p-valprint.c (pascal_object_print_value): Ditto. * parse.c (parse_expression_for_completion): Ditto. * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto. * remote.c (remote_get_noisy_reply): Ditto. * s390-linux-tdep.c (s390_frame_unwind_cache): Ditto. * solib-svr4.c (solib_svr4_r_map): Ditto.
2015-03-07 15:50:04 +01:00
{
if (ex.error == MEMORY_ERROR)
{
/* Propagate memory errors silently back to the
target. The stub may have limited the range of
addresses we can write to, for example. */
}
else
{
/* Something unexpectedly bad happened. Be verbose
so we can tell what, and propagate the error back
to the stub, so it doesn't get stuck waiting for
a response. */
exception_fprintf (gdb_stderr, ex,
_("warning: relocating instruction: "));
}
putpkt ("E01");
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
END_CATCH
Normalize TRY_CATCH exception handling block This normalizes some exception catch blocks that check for ex.reason to look like this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ALL) { ... } if (ex.reason < 0) { ... } ~~~ This is a preparation step for running a script that converts all TRY_CATCH uses to look like this instead: ~~~ TRY { ... } CATCH (ex, RETURN_MASK_ALL) { ... } END_CATCH ~~~ The motivation for that change is being able to reimplent TRY/CATCH in terms of C++ try/catch. This commit makes it so that: - no condition other than ex.reason < 0 is checked in the if predicate - there's no "else" block to check whether no exception was caught - there's no code between the TRY_CATCH (TRY) block and the 'if (ex.reason < 0)' block (CATCH). - the exception object is no longer referred to outside the if/catch block. Note the local volatile exception objects that are currently defined inside functions that use TRY_CATCH will disappear. In cases it's more convenient to still refer to the exception outside the catch block, a new non-volatile local is added and copy to that object is made within the catch block. The following patches should make this all clearer. gdb/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Normal exception handling code. * break-catch-throw.c (check_status_exception_catchpoint) (re_set_exception_catchpoint): Ditto. * cli/cli-interp.c (safe_execute_command): * cli/cli-script.c (script_from_file): Ditto. * compile/compile-c-symbols.c (generate_c_for_for_one_variable): Ditto. * compile/compile-object-run.c (compile_object_run): Ditto. * cp-abi.c (baseclass_offset): Ditto. * cp-valprint.c (cp_print_value): Ditto. * exceptions.c (catch_exceptions_with_msg): * frame-unwind.c (frame_unwind_try_unwinder): Ditto. * frame.c (get_frame_address_in_block_if_available): Ditto. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Ditto. * infcmd.c (post_create_inferior): Ditto. * linespec.c (parse_linespec, find_linespec_symbols): * p-valprint.c (pascal_object_print_value): Ditto. * parse.c (parse_expression_for_completion): Ditto. * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto. * remote.c (remote_get_noisy_reply): Ditto. * s390-linux-tdep.c (s390_frame_unwind_cache): Ditto. * solib-svr4.c (solib_svr4_r_map): Ditto.
2015-03-07 15:50:04 +01:00
if (relocated)
{
adjusted_size = to - org_to;
xsnprintf (buf, *sizeof_buf, "qRelocInsn:%x", adjusted_size);
putpkt (buf);
}
}
else if (buf[0] == 'O' && buf[1] != 'K')
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
remote_console_output (buf + 1); /* 'O' message from stub */
else
return buf; /* Here's the actual reply. */
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
while (1);
}
/* Handle for retreving the remote protocol data from gdbarch. */
static struct gdbarch_data *remote_gdbarch_data_handle;
static struct remote_arch_state *
get_remote_arch_state (void)
{
return gdbarch_data (target_gdbarch (), remote_gdbarch_data_handle);
}
/* Fetch the global remote target state. */
static struct remote_state *
get_remote_state (void)
{
/* Make sure that the remote architecture state has been
initialized, because doing so might reallocate rs->buf. Any
function which calls getpkt also needs to be mindful of changes
to rs->buf, but this call limits the number of places which run
into trouble. */
get_remote_arch_state ();
return get_remote_state_raw ();
}
static int
compare_pnums (const void *lhs_, const void *rhs_)
{
const struct packet_reg * const *lhs = lhs_;
const struct packet_reg * const *rhs = rhs_;
if ((*lhs)->pnum < (*rhs)->pnum)
return -1;
else if ((*lhs)->pnum == (*rhs)->pnum)
return 0;
else
return 1;
}
static int
map_regcache_remote_table (struct gdbarch *gdbarch, struct packet_reg *regs)
{
int regnum, num_remote_regs, offset;
struct packet_reg **remote_regs;
for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
{
struct packet_reg *r = &regs[regnum];
if (register_size (gdbarch, regnum) == 0)
/* Do not try to fetch zero-sized (placeholder) registers. */
r->pnum = -1;
else
r->pnum = gdbarch_remote_register_number (gdbarch, regnum);
r->regnum = regnum;
}
/* Define the g/G packet format as the contents of each register
with a remote protocol number, in order of ascending protocol
number. */
remote_regs = alloca (gdbarch_num_regs (gdbarch)
* sizeof (struct packet_reg *));
2007-05-31 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (NUM_REGS): Replace by gdbarch_num_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * inf-ptrace.c (inf_ptrace_fetch_registers) (inf_ptrace_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * i386-linux-nat.c (supply_gregset, fill_gregset) (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers): Likewise. * remote.c (init_remote_state,packet_reg_from_regnum) (packet_reg_from_pnum,process_g_packet,remote_fetch_registers) (remote_prepare_to_store,store_registers_using_G) (remote_store_registers,remote_arch_state): Likewise. * tracepoint.c (encode_actions): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * tui/tui-regs.c (tui_show_register_group) (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * xtensa-tdep.c (xtensa_register_name,xtensa_register_type) (xtensa_reg_to_regnum,xtensa_pseudo_register_read) (xtensa_pseudo_register_write,xtensa_register_reggroup_p): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers,fetch_elf_core_registers * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target-descriptions.c (tdesc_use_registers): Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_do_pseudo_register,sh64_print_register) (sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * rs6000-nat.c (fetch_register,store_register): Likewise. * remote-sim.c (one2one_register_sim_regno,gdbsim_fetch_register) (gdbsim_fetch_register,gdbsim_store_register): Likewise. * remote-mips.c (mips_fetch_registers,mips_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * reggroups.c (default_register_reggroup_p): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save) (regcache_restore,regcache_dump): Likewise. * monitor.c (monitor_fetch_registers,monitor_store_registers): Likewise. * mips-tdep.c (mips_xfer_register,mips_register_name) (mips_register_reggroup_p,mips_pseudo_register_read) (mips_pseudo_register_write,mips_convert_register_p,mips_register_type) (mips_unwind_pc,mips_unwind_sp,mips_unwind_dummy_id,set_reg_offset) (mips16_scan_prologue,mips_insn16_frame_cache,reset_saved_regs) (mips32_scan_prologue,mips_insn32_frame_cache,read_next_frame_reg) (mips_n32n64_return_value,mips_o32_return_value,mips_o64_return_value) (print_gp_register_row,mips_print_registers_info) (mips_stab_reg_to_regnum,mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_register_sim_regno): Likewise. * mips-linux-tdep.c (mips_linux_o32_sigframe_init) (mips_linux_n32n64_sigframe_init): Likewise. * mips-linux-nat.c (mips_linux_register_addr) (mips64_linux_register_addr): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * mips64obsd-tdep.c (mips64obsd_sigframe_init): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache(: Likewise. * m32r-tdep.c (m32r_frame_unwind_cache): Likewise. * ia64-linux-nat.c (ia64_register_addr,ia64_cannot_fetch_register) (ia64_cannot_store_register,ia64_linux_fetch_registers) (ia64_linux_store_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers) (hpux_thread_store_registers): Likewise. * h8300-tdep.c (E_PSEUDO_CCR_REGNUM,E_PSEUDO_EXR_REGNUM) (h8300_init_frame_cache,h8300_frame_cache,h8300_frame_prev_register) (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache) (dwarf2_frame_state_alloc_regs): Likewise. * cris-tdep.c (cris_register_size,cris_cannot_fetch_register) (cris_cannot_store_register,crisv32_cannot_fetch_register) (crisv32_cannot_store_register,cris_register_name): Likewise. * avr-tdep.c (avr_frame_unwind_cache): Likewise. * arch-utils.c (legacy_register_sim_regno) (legacy_virtual_frame_pointer): Likewise. * arm-tdep.c (arm_make_prologue_cache,arm_register_sim_regno):Likewise. * arm-tdep.h: Likewise (comment). * frv-tdep.c (frv_register_sim_regno): Likewise. * m68klinux-nat.c (old_fetch_inferior_registers) (old_store_inferior_registers): Likewise. * m32c-tdep.c (m32c_virtual_frame_pointer): Likewise. * irix5-nat.c (fetch_core_registers): Likewise. * hppa-tdep.c (hppa_frame_cache): Likewise. * hppa-linux-nat.c (hppa_linux_register_addr) (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_inferior_registers) (hppa_hpux_store_inferior_registers): Likewise. * amd64-nat.c (amd64_native_gregset_reg_offset) (amd64_supply_native_gregset,amd64_collect_native_gregset): Likewise. * dbug-rom.c (dbug_regname): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache) (HARD_PAGE_REGNUM (comment)): Likewise. * gdbarch.sh (NUM_PSEUDO_REGS): Replace by gdbarch_num_pseudo_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * gdbarch.c, gdbarch.h: Regenerate. * tui/tui-regs.c (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_print_register,sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save (regcache_restore,regcache_dump): Likewise. * mips-tdep.c (print_gp_register_row,mips_print_registers_info) (mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_stab_reg_to_regnum): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * frame.h (SIZEOF_FRAME_SAVED_REGS): Likewise. * xtensa-tdep.c (xtensa_register_type,xtensa_reg_to_regnum) (xtensa_pseudo_register_read,xtensa_pseudo_register_write): Likewise. * parse.c: Remove comment. * gdbarch.c, gdbarch.h: Regenerate
2007-05-31 19:32:22 +02:00
for (num_remote_regs = 0, regnum = 0;
regnum < gdbarch_num_regs (gdbarch);
2007-05-31 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (NUM_REGS): Replace by gdbarch_num_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * inf-ptrace.c (inf_ptrace_fetch_registers) (inf_ptrace_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * i386-linux-nat.c (supply_gregset, fill_gregset) (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers): Likewise. * remote.c (init_remote_state,packet_reg_from_regnum) (packet_reg_from_pnum,process_g_packet,remote_fetch_registers) (remote_prepare_to_store,store_registers_using_G) (remote_store_registers,remote_arch_state): Likewise. * tracepoint.c (encode_actions): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * tui/tui-regs.c (tui_show_register_group) (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * xtensa-tdep.c (xtensa_register_name,xtensa_register_type) (xtensa_reg_to_regnum,xtensa_pseudo_register_read) (xtensa_pseudo_register_write,xtensa_register_reggroup_p): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers,fetch_elf_core_registers * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target-descriptions.c (tdesc_use_registers): Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_do_pseudo_register,sh64_print_register) (sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * rs6000-nat.c (fetch_register,store_register): Likewise. * remote-sim.c (one2one_register_sim_regno,gdbsim_fetch_register) (gdbsim_fetch_register,gdbsim_store_register): Likewise. * remote-mips.c (mips_fetch_registers,mips_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * reggroups.c (default_register_reggroup_p): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save) (regcache_restore,regcache_dump): Likewise. * monitor.c (monitor_fetch_registers,monitor_store_registers): Likewise. * mips-tdep.c (mips_xfer_register,mips_register_name) (mips_register_reggroup_p,mips_pseudo_register_read) (mips_pseudo_register_write,mips_convert_register_p,mips_register_type) (mips_unwind_pc,mips_unwind_sp,mips_unwind_dummy_id,set_reg_offset) (mips16_scan_prologue,mips_insn16_frame_cache,reset_saved_regs) (mips32_scan_prologue,mips_insn32_frame_cache,read_next_frame_reg) (mips_n32n64_return_value,mips_o32_return_value,mips_o64_return_value) (print_gp_register_row,mips_print_registers_info) (mips_stab_reg_to_regnum,mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_register_sim_regno): Likewise. * mips-linux-tdep.c (mips_linux_o32_sigframe_init) (mips_linux_n32n64_sigframe_init): Likewise. * mips-linux-nat.c (mips_linux_register_addr) (mips64_linux_register_addr): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * mips64obsd-tdep.c (mips64obsd_sigframe_init): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache(: Likewise. * m32r-tdep.c (m32r_frame_unwind_cache): Likewise. * ia64-linux-nat.c (ia64_register_addr,ia64_cannot_fetch_register) (ia64_cannot_store_register,ia64_linux_fetch_registers) (ia64_linux_store_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers) (hpux_thread_store_registers): Likewise. * h8300-tdep.c (E_PSEUDO_CCR_REGNUM,E_PSEUDO_EXR_REGNUM) (h8300_init_frame_cache,h8300_frame_cache,h8300_frame_prev_register) (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache) (dwarf2_frame_state_alloc_regs): Likewise. * cris-tdep.c (cris_register_size,cris_cannot_fetch_register) (cris_cannot_store_register,crisv32_cannot_fetch_register) (crisv32_cannot_store_register,cris_register_name): Likewise. * avr-tdep.c (avr_frame_unwind_cache): Likewise. * arch-utils.c (legacy_register_sim_regno) (legacy_virtual_frame_pointer): Likewise. * arm-tdep.c (arm_make_prologue_cache,arm_register_sim_regno):Likewise. * arm-tdep.h: Likewise (comment). * frv-tdep.c (frv_register_sim_regno): Likewise. * m68klinux-nat.c (old_fetch_inferior_registers) (old_store_inferior_registers): Likewise. * m32c-tdep.c (m32c_virtual_frame_pointer): Likewise. * irix5-nat.c (fetch_core_registers): Likewise. * hppa-tdep.c (hppa_frame_cache): Likewise. * hppa-linux-nat.c (hppa_linux_register_addr) (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_inferior_registers) (hppa_hpux_store_inferior_registers): Likewise. * amd64-nat.c (amd64_native_gregset_reg_offset) (amd64_supply_native_gregset,amd64_collect_native_gregset): Likewise. * dbug-rom.c (dbug_regname): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache) (HARD_PAGE_REGNUM (comment)): Likewise. * gdbarch.sh (NUM_PSEUDO_REGS): Replace by gdbarch_num_pseudo_regs. * i386-tdep.c (i386_dbx_reg_to_regnum) (i386_svr4_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers,mi_cmd_data_list_register_values) (mi_cmd_data_write_register_values): Likewise. * gdbarch.c, gdbarch.h: Regenerate. * tui/tui-regs.c (tui_show_register_group): Likewise. * xtensa-tdep.h (FP_ALIAS): Likewise. * user-regs.h: Likewise (comment). * user-regs.c (user_reg, user_reg_map_name_to_regnum): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * target-descriptions.h: Likewise (comment). * target.c (debug_print_register): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh64-tdep.c (sh64_print_register,sh64_media_print_registers_info) (sh64_compact_print_registers_info): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. * regcache.c (init_regcache_descr,register_size,regcache,regcache_save (regcache_restore,regcache_dump): Likewise. * mips-tdep.c (print_gp_register_row,mips_print_registers_info) (mips_dwarf_dwarf2_ecoff_reg_to_regnum) (mips_stab_reg_to_regnum): Likewise. * findvar.c (value_of_register): Likewise. * infcmd.c (default_print_registers_info,registers_info) (print_vector_info,print_float_info): Likewise. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * frame.h (SIZEOF_FRAME_SAVED_REGS): Likewise. * xtensa-tdep.c (xtensa_register_type,xtensa_reg_to_regnum) (xtensa_pseudo_register_read,xtensa_pseudo_register_write): Likewise. * parse.c: Remove comment. * gdbarch.c, gdbarch.h: Regenerate
2007-05-31 19:32:22 +02:00
regnum++)
if (regs[regnum].pnum != -1)
remote_regs[num_remote_regs++] = &regs[regnum];
qsort (remote_regs, num_remote_regs, sizeof (struct packet_reg *),
compare_pnums);
for (regnum = 0, offset = 0; regnum < num_remote_regs; regnum++)
{
remote_regs[regnum]->in_g_packet = 1;
remote_regs[regnum]->offset = offset;
offset += register_size (gdbarch, remote_regs[regnum]->regnum);
}
return offset;
}
/* Given the architecture described by GDBARCH, return the remote
protocol register's number and the register's offset in the g/G
packets of GDB register REGNUM, in PNUM and POFFSET respectively.
If the target does not have a mapping for REGNUM, return false,
otherwise, return true. */
int
remote_register_number_and_offset (struct gdbarch *gdbarch, int regnum,
int *pnum, int *poffset)
{
int sizeof_g_packet;
struct packet_reg *regs;
struct cleanup *old_chain;
gdb_assert (regnum < gdbarch_num_regs (gdbarch));
regs = xcalloc (gdbarch_num_regs (gdbarch), sizeof (struct packet_reg));
old_chain = make_cleanup (xfree, regs);
sizeof_g_packet = map_regcache_remote_table (gdbarch, regs);
*pnum = regs[regnum].pnum;
*poffset = regs[regnum].offset;
do_cleanups (old_chain);
return *pnum != -1;
}
static void *
init_remote_state (struct gdbarch *gdbarch)
{
struct remote_state *rs = get_remote_state_raw ();
struct remote_arch_state *rsa;
rsa = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_arch_state);
/* Use the architecture to build a regnum<->pnum table, which will be
1:1 unless a feature set specifies otherwise. */
rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch,
gdbarch_num_regs (gdbarch),
struct packet_reg);
/* Record the maximum possible size of the g packet - it may turn out
to be smaller. */
rsa->sizeof_g_packet = map_regcache_remote_table (gdbarch, rsa->regs);
/* Default maximum number of characters in a packet body. Many
remote stubs have a hardwired buffer size of 400 bytes
(c.f. BUFMAX in m68k-stub.c and i386-stub.c). BUFMAX-1 is used
as the maximum packet-size to ensure that the packet and an extra
NUL character can always fit in the buffer. This stops GDB
trashing stubs that try to squeeze an extra NUL into what is
already a full buffer (As of 1999-12-04 that was most stubs). */
rsa->remote_packet_size = 400 - 1;
/* This one is filled in when a ``g'' packet is received. */
rsa->actual_register_packet_size = 0;
/* Should rsa->sizeof_g_packet needs more space than the
default, adjust the size accordingly. Remember that each byte is
encoded as two characters. 32 is the overhead for the packet
header / footer. NOTE: cagney/1999-10-26: I suspect that 8
(``$NN:G...#NN'') is a better guess, the below has been padded a
little. */
if (rsa->sizeof_g_packet > ((rsa->remote_packet_size - 32) / 2))
rsa->remote_packet_size = (rsa->sizeof_g_packet * 2 + 32);
/* Make sure that the packet buffer is plenty big enough for
this architecture. */
if (rs->buf_size < rsa->remote_packet_size)
{
rs->buf_size = 2 * rsa->remote_packet_size;
rs->buf = xrealloc (rs->buf, rs->buf_size);
}
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
return rsa;
}
/* Return the current allowed size of a remote packet. This is
inferred from the current architecture, and should be used to
limit the length of outgoing packets. */
static long
get_remote_packet_size (void)
{
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
if (rs->explicit_packet_size)
return rs->explicit_packet_size;
return rsa->remote_packet_size;
}
static struct packet_reg *
packet_reg_from_regnum (struct remote_arch_state *rsa, long regnum)
{
if (regnum < 0 && regnum >= gdbarch_num_regs (target_gdbarch ()))
return NULL;
else
{
struct packet_reg *r = &rsa->regs[regnum];
gdb_assert (r->regnum == regnum);
return r;
}
}
static struct packet_reg *
packet_reg_from_pnum (struct remote_arch_state *rsa, LONGEST pnum)
{
int i;
for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
{
struct packet_reg *r = &rsa->regs[i];
if (r->pnum == pnum)
return r;
}
return NULL;
}
static struct target_ops remote_ops;
static struct target_ops extended_remote_ops;
1999-09-28 23:55:21 +02:00
/* FIXME: cagney/1999-09-23: Even though getpkt was called with
``forever'' still use the normal timeout mechanism. This is
currently used by the ASYNC code to guarentee that target reads
during the initial connect always time-out. Once getpkt has been
modified to return a timeout indication and, in turn
remote_wait()/wait_for_inferior() have gained a timeout parameter
this can go away. */
1999-09-28 23:55:21 +02:00
static int wait_forever_enabled_p = 1;
/* Allow the user to specify what sequence to send to the remote
when he requests a program interruption: Although ^C is usually
what remote systems expect (this is the default, here), it is
sometimes preferable to send a break. On other systems such
as the Linux kernel, a break followed by g, which is Magic SysRq g
is required in order to interrupt the execution. */
const char interrupt_sequence_control_c[] = "Ctrl-C";
const char interrupt_sequence_break[] = "BREAK";
const char interrupt_sequence_break_g[] = "BREAK-g";
gdb/ Code cleanup: Make 1440 bytes of data segment read-only. * arch-utils.c (endian_enum): Make it const char *const []. * arm-tdep.c (fp_model_strings, arm_abi_strings, arm_mode_strings): Likewise. * breakpoint.c (always_inserted_enums): Likewise. * cli/cli-cmds.c (script_ext_enums): Likewise. * cli/cli-decode.c (add_setshow_enum_cmd, complete_on_enum): Make the enumlist parameter const char *const *. * cli/cli-decode.h (struct cmd_list_element): Make the enums field const char *const *. * command.h (complete_on_enum, add_setshow_enum_cmd): Make the enumlist parameter const char *const *. * cris-tdep.c (cris_modes): Make it const char *const []. * filesystem.c (target_file_system_kinds): Likewise. * i386-tdep.c (valid_flavors, valid_conventions): Likewise. * infrun.c (follow_fork_mode_kind_names, follow_exec_mode_names) (can_use_displaced_stepping_enum, scheduler_enums) (exec_direction_names): Likewise. * language.c (_initialize_language): Make the type_or_range_names and case_sensitive_names variables const char *const []. * mips-tdep.c (mips_abi_strings): Make it const char *const []. * python/python.c (python_excp_enums): Likewise. * remote.c (interrupt_sequence_modes): Likewise. * rs6000-tdep.c (powerpc_vector_strings): Likewise. * serial.c (logbase_enums): Likewise. * sh-tdep.c (sh_cc_enum): Likewise. * stack.c (print_frame_arguments_choices, print_entry_values_choices): Likewise. * symtab.c (multiple_symbols_modes): Likewise. * tui/tui-win.c (tui_border_kind_enums, tui_border_mode_enums): Likewise. * utils.c (internal_problem_modes): Likewise.
2012-01-28 19:08:22 +01:00
static const char *const interrupt_sequence_modes[] =
{
interrupt_sequence_control_c,
interrupt_sequence_break,
interrupt_sequence_break_g,
NULL
};
static const char *interrupt_sequence_mode = interrupt_sequence_control_c;
static void
show_interrupt_sequence (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
if (interrupt_sequence_mode == interrupt_sequence_control_c)
fprintf_filtered (file,
_("Send the ASCII ETX character (Ctrl-c) "
"to the remote target to interrupt the "
"execution of the program.\n"));
else if (interrupt_sequence_mode == interrupt_sequence_break)
fprintf_filtered (file,
_("send a break signal to the remote target "
"to interrupt the execution of the program.\n"));
else if (interrupt_sequence_mode == interrupt_sequence_break_g)
fprintf_filtered (file,
_("Send a break signal and 'g' a.k.a. Magic SysRq g to "
"the remote target to interrupt the execution "
"of Linux kernel.\n"));
else
internal_error (__FILE__, __LINE__,
_("Invalid value for interrupt_sequence_mode: %s."),
interrupt_sequence_mode);
}
1999-09-28 23:55:21 +02:00
/* This boolean variable specifies whether interrupt_sequence is sent
to the remote target when gdb connects to it.
This is mostly needed when you debug the Linux kernel: The Linux kernel
expects BREAK g which is Magic SysRq g for connecting gdb. */
static int interrupt_on_connect = 0;
/* This variable is used to implement the "set/show remotebreak" commands.
Since these commands are now deprecated in favor of "set/show remote
interrupt-sequence", it no longer has any effect on the code. */
static int remote_break;
static void
set_remotebreak (char *args, int from_tty, struct cmd_list_element *c)
{
if (remote_break)
interrupt_sequence_mode = interrupt_sequence_break;
else
interrupt_sequence_mode = interrupt_sequence_control_c;
}
static void
show_remotebreak (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
}
/* This variable sets the number of bits in an address that are to be
sent in a memory ("M" or "m") packet. Normally, after stripping
leading zeros, the entire address would be sent. This variable
restricts the address to REMOTE_ADDRESS_SIZE bits. HISTORY: The
initial implementation of remote.c restricted the address sent in
memory packets to ``host::sizeof long'' bytes - (typically 32
bits). Consequently, for 64 bit targets, the upper 32 bits of an
address was never sent. Since fixing this bug may cause a break in
some remote targets this variable is principly provided to
facilitate backward compatibility. */
static unsigned int remote_address_size;
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
/* Temporary to track who currently owns the terminal. See
remote_terminal_* for more details. */
1999-09-28 23:55:21 +02:00
static int remote_async_terminal_ours_p;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* The executable file to use for "run" on the remote side. */
static char *remote_exec_file = "";
1999-11-09 02:23:30 +01:00
/* User configurable variables for the number of characters in a
memory read/write packet. MIN (rsa->remote_packet_size,
rsa->sizeof_g_packet) is the default. Some targets need smaller
values (fifo overruns, et.al.) and some users need larger values
(speed up transfers). The variables ``preferred_*'' (the user
request), ``current_*'' (what was actually set) and ``forced_*''
(Positive - a soft limit, negative - a hard limit). */
1999-11-09 02:23:30 +01:00
struct memory_packet_config
{
char *name;
long size;
int fixed_p;
};
/* Compute the current size of a read/write packet. Since this makes
use of ``actual_register_packet_size'' the computation is dynamic. */
static long
get_memory_packet_size (struct memory_packet_config *config)
{
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
1999-11-09 02:23:30 +01:00
/* NOTE: The somewhat arbitrary 16k comes from the knowledge (folk
law?) that some hosts don't cope very well with large alloca()
calls. Eventually the alloca() code will be replaced by calls to
xmalloc() and make_cleanups() allowing this restriction to either
be lifted or removed. */
1999-11-09 02:23:30 +01:00
#ifndef MAX_REMOTE_PACKET_SIZE
#define MAX_REMOTE_PACKET_SIZE 16384
#endif
/* NOTE: 20 ensures we can write at least one byte. */
1999-11-09 02:23:30 +01:00
#ifndef MIN_REMOTE_PACKET_SIZE
#define MIN_REMOTE_PACKET_SIZE 20
1999-11-09 02:23:30 +01:00
#endif
long what_they_get;
if (config->fixed_p)
{
if (config->size <= 0)
what_they_get = MAX_REMOTE_PACKET_SIZE;
else
what_they_get = config->size;
}
else
{
what_they_get = get_remote_packet_size ();
/* Limit the packet to the size specified by the user. */
1999-11-09 02:23:30 +01:00
if (config->size > 0
&& what_they_get > config->size)
what_they_get = config->size;
/* Limit it to the size of the targets ``g'' response unless we have
permission from the stub to use a larger packet size. */
if (rs->explicit_packet_size == 0
&& rsa->actual_register_packet_size > 0
&& what_they_get > rsa->actual_register_packet_size)
what_they_get = rsa->actual_register_packet_size;
1999-11-09 02:23:30 +01:00
}
if (what_they_get > MAX_REMOTE_PACKET_SIZE)
what_they_get = MAX_REMOTE_PACKET_SIZE;
if (what_they_get < MIN_REMOTE_PACKET_SIZE)
what_they_get = MIN_REMOTE_PACKET_SIZE;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Make sure there is room in the global buffer for this packet
(including its trailing NUL byte). */
if (rs->buf_size < what_they_get + 1)
{
rs->buf_size = 2 * what_they_get;
rs->buf = xrealloc (rs->buf, 2 * what_they_get);
}
1999-11-09 02:23:30 +01:00
return what_they_get;
}
/* Update the size of a read/write packet. If they user wants
something really big then do a sanity check. */
1999-11-09 02:23:30 +01:00
static void
set_memory_packet_size (char *args, struct memory_packet_config *config)
{
int fixed_p = config->fixed_p;
long size = config->size;
1999-11-09 02:23:30 +01:00
if (args == NULL)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Argument required (integer, `fixed' or `limited')."));
1999-11-09 02:23:30 +01:00
else if (strcmp (args, "hard") == 0
|| strcmp (args, "fixed") == 0)
fixed_p = 1;
else if (strcmp (args, "soft") == 0
|| strcmp (args, "limit") == 0)
fixed_p = 0;
else
{
char *end;
1999-11-09 02:23:30 +01:00
size = strtoul (args, &end, 0);
if (args == end)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Invalid %s (bad syntax)."), config->name);
1999-11-09 02:23:30 +01:00
#if 0
/* Instead of explicitly capping the size of a packet to
MAX_REMOTE_PACKET_SIZE or dissallowing it, the user is
instead allowed to set the size to something arbitrarily
large. */
1999-11-09 02:23:30 +01:00
if (size > MAX_REMOTE_PACKET_SIZE)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Invalid %s (too large)."), config->name);
1999-11-09 02:23:30 +01:00
#endif
}
/* Extra checks? */
1999-11-09 02:23:30 +01:00
if (fixed_p && !config->fixed_p)
{
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
if (! query (_("The target may not be able to correctly handle a %s\n"
"of %ld bytes. Change the packet size? "),
1999-11-09 02:23:30 +01:00
config->name, size))
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Packet size not changed."));
1999-11-09 02:23:30 +01:00
}
/* Update the config. */
1999-11-09 02:23:30 +01:00
config->fixed_p = fixed_p;
config->size = size;
}
static void
show_memory_packet_size (struct memory_packet_config *config)
{
printf_filtered (_("The %s is %ld. "), config->name, config->size);
1999-11-09 02:23:30 +01:00
if (config->fixed_p)
printf_filtered (_("Packets are fixed at %ld bytes.\n"),
1999-11-09 02:23:30 +01:00
get_memory_packet_size (config));
else
printf_filtered (_("Packets are limited to %ld bytes.\n"),
1999-11-09 02:23:30 +01:00
get_memory_packet_size (config));
}
static struct memory_packet_config memory_write_packet_config =
{
"memory-write-packet-size",
};
static void
set_memory_write_packet_size (char *args, int from_tty)
{
set_memory_packet_size (args, &memory_write_packet_config);
}
static void
show_memory_write_packet_size (char *args, int from_tty)
{
show_memory_packet_size (&memory_write_packet_config);
}
static long
get_memory_write_packet_size (void)
{
return get_memory_packet_size (&memory_write_packet_config);
}
static struct memory_packet_config memory_read_packet_config =
{
"memory-read-packet-size",
};
static void
set_memory_read_packet_size (char *args, int from_tty)
{
set_memory_packet_size (args, &memory_read_packet_config);
}
static void
show_memory_read_packet_size (char *args, int from_tty)
{
show_memory_packet_size (&memory_read_packet_config);
}
static long
get_memory_read_packet_size (void)
{
long size = get_memory_packet_size (&memory_read_packet_config);
1999-11-09 02:23:30 +01:00
/* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an
extra buffer size argument before the memory read size can be
increased beyond this. */
if (size > get_remote_packet_size ())
size = get_remote_packet_size ();
1999-11-09 02:23:30 +01:00
return size;
}
1999-07-27 02:51:29 +02:00
/* Generic configuration support for packets the stub optionally
supports. Allows the user to specify the use of the packet as well
as allowing GDB to auto-detect support in the remote stub. */
1999-07-27 02:51:29 +02:00
enum packet_support
{
PACKET_SUPPORT_UNKNOWN = 0,
PACKET_ENABLE,
PACKET_DISABLE
};
struct packet_config
{
const char *name;
const char *title;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* If auto, GDB auto-detects support for this packet or feature,
either through qSupported, or by trying the packet and looking
at the response. If true, GDB assumes the target supports this
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
packet. If false, the packet is disabled. Configs that don't
have an associated command always have this set to auto. */
enum auto_boolean detect;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Does the target support this packet? */
1999-07-27 02:51:29 +02:00
enum packet_support support;
};
/* Analyze a packet's return value and update the packet config
accordingly. */
enum packet_result
{
PACKET_ERROR,
PACKET_OK,
PACKET_UNKNOWN
};
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
static enum packet_support packet_config_support (struct packet_config *config);
static enum packet_support packet_support (int packet);
1999-07-27 02:51:29 +02:00
static void
2000-07-30 03:48:28 +02:00
show_packet_config_cmd (struct packet_config *config)
1999-07-27 02:51:29 +02:00
{
char *support = "internal-error";
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_config_support (config))
1999-07-27 02:51:29 +02:00
{
case PACKET_ENABLE:
support = "enabled";
break;
case PACKET_DISABLE:
support = "disabled";
break;
case PACKET_SUPPORT_UNKNOWN:
support = "unknown";
break;
}
switch (config->detect)
{
case AUTO_BOOLEAN_AUTO:
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
printf_filtered (_("Support for the `%s' packet "
"is auto-detected, currently %s.\n"),
config->name, support);
1999-07-27 02:51:29 +02:00
break;
case AUTO_BOOLEAN_TRUE:
case AUTO_BOOLEAN_FALSE:
printf_filtered (_("Support for the `%s' packet is currently %s.\n"),
config->name, support);
break;
1999-07-27 02:51:29 +02:00
}
}
static void
add_packet_config_cmd (struct packet_config *config, const char *name,
const char *title, int legacy)
{
1999-07-27 02:51:29 +02:00
char *set_doc;
char *show_doc;
char *cmd_name;
1999-07-27 02:51:29 +02:00
config->name = name;
config->title = title;
set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet",
name, title);
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
show_doc = xstrprintf ("Show current use of remote "
"protocol `%s' (%s) packet",
name, title);
/* set/show TITLE-packet {auto,on,off} */
cmd_name = xstrprintf ("%s-packet", title);
add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
&config->detect, set_doc,
show_doc, NULL, /* help_doc */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
NULL,
show_remote_protocol_packet_cmd,
&remote_set_cmdlist, &remote_show_cmdlist);
/* The command code copies the documentation strings. */
xfree (set_doc);
xfree (show_doc);
/* set/show remote NAME-packet {auto,on,off} -- legacy. */
if (legacy)
{
char *legacy_name;
legacy_name = xstrprintf ("%s-packet", name);
add_alias_cmd (legacy_name, cmd_name, class_obscure, 0,
&remote_set_cmdlist);
add_alias_cmd (legacy_name, cmd_name, class_obscure, 0,
&remote_show_cmdlist);
}
1999-07-27 02:51:29 +02:00
}
static enum packet_result
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
packet_check_result (const char *buf)
1999-07-27 02:51:29 +02:00
{
if (buf[0] != '\0')
1999-07-27 02:51:29 +02:00
{
/* The stub recognized the packet request. Check that the
operation succeeded. */
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (buf[0] == 'E'
&& isxdigit (buf[1]) && isxdigit (buf[2])
&& buf[3] == '\0')
/* "Enn" - definitly an error. */
return PACKET_ERROR;
/* Always treat "E." as an error. This will be used for
more verbose error messages, such as E.memtypes. */
if (buf[0] == 'E' && buf[1] == '.')
return PACKET_ERROR;
/* The packet may or may not be OK. Just assume it is. */
return PACKET_OK;
}
else
/* The stub does not support the packet. */
return PACKET_UNKNOWN;
}
static enum packet_result
packet_ok (const char *buf, struct packet_config *config)
{
enum packet_result result;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (config->detect != AUTO_BOOLEAN_TRUE
&& config->support == PACKET_DISABLE)
internal_error (__FILE__, __LINE__,
_("packet_ok: attempt to use a disabled packet"));
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
result = packet_check_result (buf);
switch (result)
{
case PACKET_OK:
case PACKET_ERROR:
/* The stub recognized the packet request. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (config->support == PACKET_SUPPORT_UNKNOWN)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
"Packet %s (%s) is supported\n",
config->name, config->title);
config->support = PACKET_ENABLE;
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
break;
case PACKET_UNKNOWN:
/* The stub does not support the packet. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (config->detect == AUTO_BOOLEAN_AUTO
&& config->support == PACKET_ENABLE)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* If the stub previously indicated that the packet was
supported then there is a protocol error. */
error (_("Protocol error: %s (%s) conflicting enabled responses."),
config->name, config->title);
}
else if (config->detect == AUTO_BOOLEAN_TRUE)
{
/* The user set it wrong. */
error (_("Enabled packet %s (%s) not recognized by stub"),
config->name, config->title);
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"Packet %s (%s) is NOT supported\n",
config->name, config->title);
config->support = PACKET_DISABLE;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
break;
1999-07-27 02:51:29 +02:00
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
return result;
1999-07-27 02:51:29 +02:00
}
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
enum {
PACKET_vCont = 0,
PACKET_X,
PACKET_qSymbol,
PACKET_P,
PACKET_p,
PACKET_Z0,
PACKET_Z1,
PACKET_Z2,
PACKET_Z3,
PACKET_Z4,
PACKET_vFile_setfs,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
PACKET_vFile_open,
PACKET_vFile_pread,
PACKET_vFile_pwrite,
PACKET_vFile_close,
PACKET_vFile_unlink,
PACKET_vFile_readlink,
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
PACKET_vFile_fstat,
PACKET_qXfer_auxv,
XML feature description support. * NEWS: Mention target descriptions, "set tdesc filename", "unset tdesc filename", "show tdesc filename", and qXfer:features:read. * arch-utils.c (choose_architecture_for_target): New function. (gdbarch_info_fill): Call it. * target-descriptions.c (struct property): Make members non-const. (struct target_desc): Add arch member. (target_description_filename): New variable. (target_find_description): Try via XML first. (tdesc_architecture): New. (free_target_description, make_cleanup_free_target_description): New. (set_tdesc_property): Call xstrdup. (set_tdesc_architecture, tdesc_set_cmdlist, tdesc_show_cmdlist) (tdesc_unset_cmdlist, unset_tdesc_cmd, unset_tdesc_filename_cmd) (set_tdesc_cmd, show_tdesc_cmd, set_tdesc_filename_cmd) (show_tdesc_filename_cmd, _initialize_target_descriptions): New. * target-descriptions.h (tdesc_architecture) (make_cleanup_free_target_description, set_tdesc_architecture): New prototypes. * Makefile.in (SFILES): Add xml-tdesc.c. (COMMON_OBS): Add xml-tdesc.o. (target-descriptions.o): Update. (xml-tdesc.o): New rule. * xml-tdesc.c, xml-tdesc.h: New files. * remote.c (PACKET_qXfer_features): New enum. (remote_protocol_features): Add qXfer:features:read. (remote_xfer_partial): Handle TARGET_OBJECT_AVAILABLE_FEATURES. (_initialize_remote): Register qXfer:features:read. * target.h (enum target_object): Add TARGET_OBJECT_AVAILABLE_FEATURES. * features/gdb-target.dtd: New file. * linux-i386-low.c (the_low_target): Set arch_string. * linux-x86-64-low.c (the_low_target): Likewise. * linux-low.c (linux_arch_string): New. (linux_target_ops): Add it. * linux-low.h (struct linux_target_ops): Add arch_string. * server.c (write_qxfer_response): Use const void * for DATA. (get_features_xml): New. (handle_query): Handle qXfer:features:read. Report it for qSupported. * target.h (struct target_ops): Add arch_string method. * gdb.texinfo (Target Descriptions): New section. (General Query Packets): Add QPassSignals anchor. Mention qXfer:features:read under qSupported. Expand mentions of qXfer:memory-map:read and QPassSignals. Document qXfer:features:read.
2007-01-09 23:55:10 +01:00
PACKET_qXfer_features,
PACKET_qXfer_exec_file,
PACKET_qXfer_libraries,
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
PACKET_qXfer_libraries_svr4,
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
PACKET_qXfer_memory_map,
PACKET_qXfer_spu_read,
PACKET_qXfer_spu_write,
PACKET_qXfer_osdata,
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
PACKET_qXfer_threads,
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
PACKET_qXfer_statictrace_read,
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
PACKET_qXfer_traceframe_info,
PACKET_qXfer_uib,
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
PACKET_qGetTIBAddr,
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
PACKET_qGetTLSAddr,
PACKET_qSupported,
PACKET_qTStatus,
PACKET_QPassSignals,
PACKET_QProgramSignals,
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
PACKET_qCRC,
PACKET_qSearch_memory,
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
PACKET_vAttach,
PACKET_vRun,
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
PACKET_QStartNoAckMode,
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
PACKET_vKill,
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
PACKET_qXfer_siginfo_read,
PACKET_qXfer_siginfo_write,
PACKET_qAttached,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for conditional tracepoints. */
PACKET_ConditionalTracepoints,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for target-side breakpoint conditions. */
PACKET_ConditionalBreakpoints,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for target-side breakpoint commands. */
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
PACKET_BreakpointCommands,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for fast tracepoints. */
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
PACKET_FastTracepoints,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for static tracepoints. */
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
PACKET_StaticTracepoints,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for installing tracepoints while a trace experiment is
running. */
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
PACKET_InstallInTrace,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
PACKET_bc,
PACKET_bs,
PACKET_TracepointSource,
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
PACKET_QAllow,
PACKET_qXfer_fdpic,
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
PACKET_QDisableRandomization,
PACKET_QAgent,
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
PACKET_QTBuffer_size,
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
PACKET_Qbtrace_off,
PACKET_Qbtrace_bts,
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
PACKET_Qbtrace_pt,
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
PACKET_qXfer_btrace,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Support for the QNonStop packet. */
PACKET_QNonStop,
/* Support for multi-process extensions. */
PACKET_multiprocess_feature,
/* Support for enabling and disabling tracepoints while a trace
experiment is running. */
PACKET_EnableDisableTracepoints_feature,
/* Support for collecting strings using the tracenz bytecode. */
PACKET_tracenz_feature,
/* Support for continuing to run a trace experiment while GDB is
disconnected. */
PACKET_DisconnectedTracing_feature,
/* Support for qXfer:libraries-svr4:read with a non-empty annex. */
PACKET_augmented_libraries_svr4_read_feature,
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* Support for the qXfer:btrace-conf:read packet. */
PACKET_qXfer_btrace_conf,
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
/* Support for the Qbtrace-conf:bts:size packet. */
PACKET_Qbtrace_conf_bts_size,
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
/* Support for swbreak+ feature. */
PACKET_swbreak_feature,
/* Support for hwbreak+ feature. */
PACKET_hwbreak_feature,
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
/* Support for fork events. */
PACKET_fork_event_feature,
/* Support for vfork events. */
PACKET_vfork_event_feature,
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
/* Support for the Qbtrace-conf:pt:size packet. */
PACKET_Qbtrace_conf_pt_size,
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
PACKET_MAX
};
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
static struct packet_config remote_protocol_packets[PACKET_MAX];
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
/* Returns the packet's corresponding "set remote foo-packet" command
state. See struct packet_config for more details. */
static enum auto_boolean
packet_set_cmd_state (int packet)
{
return remote_protocol_packets[packet].detect;
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Returns whether a given packet or feature is supported. This takes
into account the state of the corresponding "set remote foo-packet"
command, which may be used to bypass auto-detection. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
static enum packet_support
packet_config_support (struct packet_config *config)
{
switch (config->detect)
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
case AUTO_BOOLEAN_TRUE:
return PACKET_ENABLE;
case AUTO_BOOLEAN_FALSE:
return PACKET_DISABLE;
case AUTO_BOOLEAN_AUTO:
return config->support;
default:
gdb_assert_not_reached (_("bad switch"));
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
}
/* Same as packet_config_support, but takes the packet's enum value as
argument. */
static enum packet_support
packet_support (int packet)
{
struct packet_config *config = &remote_protocol_packets[packet];
return packet_config_support (config);
}
1999-07-27 02:51:29 +02:00
static void
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
show_remote_protocol_packet_cmd (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
1999-07-27 02:51:29 +02:00
{
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
struct packet_config *packet;
1999-07-27 02:51:29 +02:00
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
for (packet = remote_protocol_packets;
packet < &remote_protocol_packets[PACKET_MAX];
packet++)
{
if (&packet->detect == c->var)
{
show_packet_config_cmd (packet);
return;
}
}
internal_error (__FILE__, __LINE__, _("Could not find config for %s"),
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
c->name);
1999-07-27 02:51:29 +02:00
}
/* Should we try one of the 'Z' requests? */
enum Z_packet_type
{
Z_PACKET_SOFTWARE_BP,
Z_PACKET_HARDWARE_BP,
Z_PACKET_WRITE_WP,
Z_PACKET_READ_WP,
Z_PACKET_ACCESS_WP,
NR_Z_PACKET_TYPES
};
1999-08-09 23:36:23 +02:00
/* For compatibility with older distributions. Provide a ``set remote
Z-packet ...'' command that updates all the Z packet types. */
static enum auto_boolean remote_Z_packet_detect;
1999-08-09 23:36:23 +02:00
static void
2000-07-30 03:48:28 +02:00
set_remote_protocol_Z_packet_cmd (char *args, int from_tty,
struct cmd_list_element *c)
1999-08-09 23:36:23 +02:00
{
int i;
for (i = 0; i < NR_Z_PACKET_TYPES; i++)
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
remote_protocol_packets[PACKET_Z0 + i].detect = remote_Z_packet_detect;
1999-08-09 23:36:23 +02:00
}
static void
2005-02-16 Andrew Cagney <cagney@gnu.org> Merge setshow print and show parameters. * command.h (show_value_ftype): Define. (deprecated_show_value_hack): Declare. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Change type of show_func to show_value_ftype. * cli/cli-decode.h (struct cmd_list_element): Replace fprint_setshow with show_value_func. * cli/cli-decode.c (add_setshow_cmd_full): Update show_func parameter. Set show_value_func. Do not set cmd_sfunc. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Update. * complaints.c (complaints_show_value): Replace fprint_setshow_complaints. (_initialize_complaints): Update. * mips-tdep.c (show_mask_address): Update. * arm-tdep.c (show_fp_model): Update. * cli/cli-setshow.c (do_setshow_command): Call show_value_func instead of fprint_setshow. Use deprecated_show_value_hack. (deprecated_show_value_hack): New function. * remote.c (add_packet_config_cmd, show_remote_cmd): (show_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_binary_download_cmd) (show_remote_protocol_p_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_vcont_packet_cmd): Update.
2005-02-16 18:20:59 +01:00
show_remote_protocol_Z_packet_cmd (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
1999-08-09 23:36:23 +02:00
{
int i;
for (i = 0; i < NR_Z_PACKET_TYPES; i++)
{
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
show_packet_config_cmd (&remote_protocol_packets[PACKET_Z0 + i]);
}
1999-08-09 23:36:23 +02:00
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
/* Returns true if the multi-process extensions are in effect. */
static int
remote_multi_process_p (struct remote_state *rs)
{
return packet_support (PACKET_multiprocess_feature) == PACKET_ENABLE;
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Returns true if fork events are supported. */
static int
remote_fork_event_p (struct remote_state *rs)
{
return packet_support (PACKET_fork_event_feature) == PACKET_ENABLE;
}
2015-05-12 18:52:45 +02:00
/* Returns true if vfork events are supported. */
static int
remote_vfork_event_p (struct remote_state *rs)
{
return packet_support (PACKET_vfork_event_feature) == PACKET_ENABLE;
}
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
/* Insert fork catchpoint target routine. If fork events are enabled
then return success, nothing more to do. */
static int
remote_insert_fork_catchpoint (struct target_ops *ops, int pid)
{
struct remote_state *rs = get_remote_state ();
return !remote_fork_event_p (rs);
}
/* Remove fork catchpoint target routine. Nothing to do, just
return success. */
static int
remote_remove_fork_catchpoint (struct target_ops *ops, int pid)
{
return 0;
}
/* Insert vfork catchpoint target routine. If vfork events are enabled
then return success, nothing more to do. */
static int
remote_insert_vfork_catchpoint (struct target_ops *ops, int pid)
{
struct remote_state *rs = get_remote_state ();
return !remote_vfork_event_p (rs);
}
/* Remove vfork catchpoint target routine. Nothing to do, just
return success. */
static int
remote_remove_vfork_catchpoint (struct target_ops *ops, int pid)
{
return 0;
}
/* Tokens for use by the asynchronous signal handlers for SIGINT. */
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
static struct async_signal_handler *async_sigint_remote_twice_token;
static struct async_signal_handler *async_sigint_remote_token;
1999-07-05 19:58:44 +02:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Asynchronous signal handle registered as event loop source for
when we have pending events ready to be passed to the core. */
static struct async_event_handler *remote_async_inferior_event_token;
static ptid_t magic_null_ptid;
static ptid_t not_sent_ptid;
static ptid_t any_thread_ptid;
/* Find out if the stub attached to PID (and hence GDB should offer to
detach instead of killing it when bailing out). */
static int
remote_query_attached (int pid)
{
struct remote_state *rs = get_remote_state ();
size_t size = get_remote_packet_size ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qAttached) == PACKET_DISABLE)
return 0;
if (remote_multi_process_p (rs))
xsnprintf (rs->buf, size, "qAttached:%x", pid);
else
xsnprintf (rs->buf, size, "qAttached");
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
switch (packet_ok (rs->buf,
&remote_protocol_packets[PACKET_qAttached]))
{
case PACKET_OK:
if (strcmp (rs->buf, "1") == 0)
return 1;
break;
case PACKET_ERROR:
warning (_("Remote failure reply: %s"), rs->buf);
break;
case PACKET_UNKNOWN:
break;
}
return 0;
}
/* Add PID to GDB's inferior table. If FAKE_PID_P is true, then PID
has been invented by GDB, instead of reported by the target. Since
we can be connected to a remote system before before knowing about
any inferior, mark the target with execution when we find the first
inferior. If ATTACHED is 1, then we had just attached to this
inferior. If it is 0, then we just created this inferior. If it
is -1, then try querying the remote stub to find out if it had
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
attached to the inferior or not. If TRY_OPEN_EXEC is true then
attempt to open this inferior's executable as the main executable
if no main executable is open already. */
static struct inferior *
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
remote_add_inferior (int fake_pid_p, int pid, int attached,
int try_open_exec)
{
struct inferior *inf;
/* Check whether this process we're learning about is to be
considered attached, or if is to be considered to have been
spawned by the stub. */
if (attached == -1)
attached = remote_query_attached (pid);
if (gdbarch_has_global_solist (target_gdbarch ()))
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
{
/* If the target shares code across all inferiors, then every
attach adds a new inferior. */
inf = add_inferior (pid);
/* ... and every inferior is bound to the same program space.
However, each inferior may still have its own address
space. */
inf->aspace = maybe_new_address_space ();
inf->pspace = current_program_space;
}
else
{
/* In the traditional debugging scenario, there's a 1-1 match
between program/address spaces. We simply bind the inferior
to the program space's address space. */
inf = current_inferior ();
inferior_appeared (inf, pid);
}
inf->attach_flag = attached;
inf->fake_pid_p = fake_pid_p;
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
/* If no main executable is currently open then attempt to
open the file that was executed to create this inferior. */
if (try_open_exec && get_exec_file (0) == NULL)
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
exec_file_locate_attach (pid, 1);
return inf;
}
/* Add thread PTID to GDB's thread list. Tag it as executing/running
according to RUNNING. */
static void
remote_add_thread (ptid_t ptid, int running)
{
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
struct remote_state *rs = get_remote_state ();
/* GDB historically didn't pull threads in the initial connection
setup. If the remote target doesn't even have a concept of
threads (e.g., a bare-metal target), even if internally we
consider that a single-threaded target, mentioning a new thread
might be confusing to the user. Be silent then, preserving the
age old behavior. */
if (rs->starting_up)
add_thread_silent (ptid);
else
add_thread (ptid);
set_executing (ptid, running);
set_running (ptid, running);
}
/* Come here when we learn about a thread id from the remote target.
It may be the first time we hear about such thread, so take the
opportunity to add it to GDB's thread list. In case this is the
first time we're noticing its corresponding inferior, add it to
GDB's inferior list as well. */
static void
remote_notice_new_inferior (ptid_t currthread, int running)
{
/* If this is a new thread, add it to GDB's thread list.
If we leave it up to WFI to do this, bad things will happen. */
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (in_thread_list (currthread) && is_exited (currthread))
{
/* We're seeing an event on a thread id we knew had exited.
This has to be a new thread reusing the old id. Add it. */
remote_add_thread (currthread, running);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
return;
}
if (!in_thread_list (currthread))
{
struct inferior *inf = NULL;
int pid = ptid_get_pid (currthread);
if (ptid_is_pid (inferior_ptid)
&& pid == ptid_get_pid (inferior_ptid))
{
/* inferior_ptid has no thread member yet. This can happen
with the vAttach -> remote_wait,"TAAthread:" path if the
stub doesn't support qC. This is the first stop reported
after an attach, so this is the main thread. Update the
ptid in the thread list. */
if (in_thread_list (pid_to_ptid (pid)))
thread_change_ptid (inferior_ptid, currthread);
else
{
remote_add_thread (currthread, running);
inferior_ptid = currthread;
}
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
return;
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (ptid_equal (magic_null_ptid, inferior_ptid))
{
/* inferior_ptid is not set yet. This can happen with the
vRun -> remote_wait,"TAAthread:" path if the stub
doesn't support qC. This is the first stop reported
after an attach, so this is the main thread. Update the
ptid in the thread list. */
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
thread_change_ptid (inferior_ptid, currthread);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
return;
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* When connecting to a target remote, or to a target
extended-remote which already was debugging an inferior, we
may not know about it yet. Add it before adding its child
thread, so notifications are emitted in a sensible order. */
if (!in_inferior_list (ptid_get_pid (currthread)))
{
struct remote_state *rs = get_remote_state ();
int fake_pid_p = !remote_multi_process_p (rs);
inf = remote_add_inferior (fake_pid_p,
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
ptid_get_pid (currthread), -1, 1);
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* This is really a new thread. Add it. */
remote_add_thread (currthread, running);
/* If we found a new inferior, let the common code do whatever
it needs to with it (e.g., read shared libraries, insert
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
breakpoints), unless we're just setting up an all-stop
connection. */
if (inf != NULL)
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
{
struct remote_state *rs = get_remote_state ();
if (non_stop || !rs->starting_up)
notice_new_inferior (currthread, running, 0);
}
}
}
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
/* Return the private thread data, creating it if necessary. */
2012-03-01 Pedro Alves <palves@redhat.com> * amd64-linux-tdep.c (amd64_linux_record_signal): Make static. * breakpoint.c (create_exception_master_breakpoint, trace_command) (ftrace_command, strace_command): Make static. * d-lang.c (_initialize_d_language): Declare. * dwarf2expr.c (_initialize_dwarf2expr): Declare. * dwarf2loc.c (_initialize_dwarf2loc): * dwarf2read.c (process_psymtab_comp_unit): Make static. * exec.c (exec_get_section_table): Make static. * i386-linux-tdep.c (i386_linux_record_signal): Make static. * infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static. * inferior.c (remove_inferior_command, add_inferior_command) (clone_inferior_command): Make static. * linux-nat.c (linux_nat_thread_address_space) (linux_nat_core_of_thread): Make static. * linux-tdep.c (_initialize_linux_tdep): Declare. * objc-lang.c (_initialize_objc_lang): Declare. * opencl-lang.c (builtin_opencl_type, opencl_language_arch_info): Make static. (_initialize_opencl_language): Declare. * record.c (_initialize_record): Declare. * remote.c (demand_private_info, remote_get_tib_address) (remote_supports_cond_tracepoints) (remote_supports_fast_tracepoints, remote_get_tracepoint_status): Make static. * skip.c (_initialize_step_skip): Declare. * symtab.c (skip_prologue_using_lineinfo): Make static. * tracepoint.c (delete_trace_state_variable) (trace_variable_command, delete_trace_variable_command) (get_uploaded_tsv, find_matching_tracepoint_location) (find_matching_tsv, create_tsv_from_upload, get_traceframe_info): Make static. * value.c (pack_unsigned_long): Make static. * varobj.c (varobj_ensure_python_env): Make static. * windows-tdep.c (_initialize_windows_tdep): Declare. * xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
static struct private_thread_info *
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
demand_private_info (ptid_t ptid)
{
struct thread_info *info = find_thread_ptid (ptid);
gdb_assert (info);
if (!info->priv)
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
{
info->priv = xmalloc (sizeof (*(info->priv)));
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
info->private_dtor = free_private_thread_info;
info->priv->core = -1;
info->priv->extra = 0;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
}
return info->priv;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Call this function as a result of
1) A halt indication (T packet) containing a thread id
2) A direct query of currthread
3) Successful execution of set thread */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
record_currthread (struct remote_state *rs, ptid_t currthread)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
rs->general_thread = currthread;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* If 'QPassSignals' is supported, tell the remote stub what signals
it can simply pass through to the inferior without reporting. */
static void
remote_pass_signals (struct target_ops *self,
int numsigs, unsigned char *pass_signals)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QPassSignals) != PACKET_DISABLE)
{
char *pass_packet, *p;
int count = 0, i;
struct remote_state *rs = get_remote_state ();
gdb_assert (numsigs < 256);
for (i = 0; i < numsigs; i++)
{
* target.h (struct target_ops): Remove to_notice_signals; add to_pass_signals. (target_notice_signals): Remove. (target_pass_signals): Add prototype. * target.c (update_current_target): Remove to_notice_signals; mention to_pass_signals. (target_pass_signals): New function. (debug_to_notice_signals): Remove. (setup_target_debug): Do not install debug_to_notice_signals. * infrun.c (signal_pass): New global. (resume): Call target_pass_signals. (handle_inferior_event): Report all signals while stepping over non-steppable watchpoint. Reset trap_expected to ensure breakpoints are re-inserted when stepping over a signal handler. (signal_cache_update): New function. (signal_stop_update): Call it. (signal_print_update): Likewise. (signal_pass_update): Likewise. (handle_command): Call signal_cache_update and target_pass_signals instead of target_notice_signals. (_initialize_infrun): Initialize signal_pass. * linux-nat.c (pass_mask): New global. (linux_nat_pass_signals): New function. (linux_nat_create_inferior): Report all signals initially. (linux_nat_attach): Likewise. (linux_nat_resume): Use pass_mask to decide whether to directly handle an inferior signal. (linux_nat_wait_1): Likewise. (linux_nat_add_target): Install to_pass_signals callback. * nto-procfs.c (notice_signals): Remove. (procfs_resume): Do not call notice_signals. (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (init_procfs_ops): Install to_pass_signals callback instead of to_notice_signals callback. (_initialize_procfs): Report all signals initially. * procfs.c (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (procfs_target): Install to_pass_signals callback instead of to_notice_signals callback. (register_gdb_signals): Remove. (procfs_debug_inferior): Report all signals initially. (procfs_init_inferior): Remove redundant register_gdb_signals call. * remote.c (remote_pass_signals): Add numsigs and pass_signals parameters; use them instead of calling signal_..._state routines. (remote_notice_signals): Remove. (remote_start_remote): Report all signals initially. (remote_resume): Do not call remote_pass_signals. (_initialize_remote): Install to_pass_signals callback instead of to_notice_signals callback.
2011-04-27 15:29:15 +02:00
if (pass_signals[i])
count++;
}
pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1);
strcpy (pass_packet, "QPassSignals:");
p = pass_packet + strlen (pass_packet);
for (i = 0; i < numsigs; i++)
{
* target.h (struct target_ops): Remove to_notice_signals; add to_pass_signals. (target_notice_signals): Remove. (target_pass_signals): Add prototype. * target.c (update_current_target): Remove to_notice_signals; mention to_pass_signals. (target_pass_signals): New function. (debug_to_notice_signals): Remove. (setup_target_debug): Do not install debug_to_notice_signals. * infrun.c (signal_pass): New global. (resume): Call target_pass_signals. (handle_inferior_event): Report all signals while stepping over non-steppable watchpoint. Reset trap_expected to ensure breakpoints are re-inserted when stepping over a signal handler. (signal_cache_update): New function. (signal_stop_update): Call it. (signal_print_update): Likewise. (signal_pass_update): Likewise. (handle_command): Call signal_cache_update and target_pass_signals instead of target_notice_signals. (_initialize_infrun): Initialize signal_pass. * linux-nat.c (pass_mask): New global. (linux_nat_pass_signals): New function. (linux_nat_create_inferior): Report all signals initially. (linux_nat_attach): Likewise. (linux_nat_resume): Use pass_mask to decide whether to directly handle an inferior signal. (linux_nat_wait_1): Likewise. (linux_nat_add_target): Install to_pass_signals callback. * nto-procfs.c (notice_signals): Remove. (procfs_resume): Do not call notice_signals. (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (init_procfs_ops): Install to_pass_signals callback instead of to_notice_signals callback. (_initialize_procfs): Report all signals initially. * procfs.c (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (procfs_target): Install to_pass_signals callback instead of to_notice_signals callback. (register_gdb_signals): Remove. (procfs_debug_inferior): Report all signals initially. (procfs_init_inferior): Remove redundant register_gdb_signals call. * remote.c (remote_pass_signals): Add numsigs and pass_signals parameters; use them instead of calling signal_..._state routines. (remote_notice_signals): Remove. (remote_start_remote): Report all signals initially. (remote_resume): Do not call remote_pass_signals. (_initialize_remote): Install to_pass_signals callback instead of to_notice_signals callback.
2011-04-27 15:29:15 +02:00
if (pass_signals[i])
{
if (i >= 16)
*p++ = tohex (i >> 4);
*p++ = tohex (i & 15);
if (count)
*p++ = ';';
else
break;
count--;
}
}
*p = 0;
if (!rs->last_pass_packet || strcmp (rs->last_pass_packet, pass_packet))
{
putpkt (pass_packet);
getpkt (&rs->buf, &rs->buf_size, 0);
packet_ok (rs->buf, &remote_protocol_packets[PACKET_QPassSignals]);
if (rs->last_pass_packet)
xfree (rs->last_pass_packet);
rs->last_pass_packet = pass_packet;
}
else
xfree (pass_packet);
}
}
/* If 'QProgramSignals' is supported, tell the remote stub what
signals it should pass through to the inferior when detaching. */
static void
remote_program_signals (struct target_ops *self,
int numsigs, unsigned char *signals)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QProgramSignals) != PACKET_DISABLE)
{
char *packet, *p;
int count = 0, i;
struct remote_state *rs = get_remote_state ();
gdb_assert (numsigs < 256);
for (i = 0; i < numsigs; i++)
{
if (signals[i])
count++;
}
packet = xmalloc (count * 3 + strlen ("QProgramSignals:") + 1);
strcpy (packet, "QProgramSignals:");
p = packet + strlen (packet);
for (i = 0; i < numsigs; i++)
{
if (signal_pass_state (i))
{
if (i >= 16)
*p++ = tohex (i >> 4);
*p++ = tohex (i & 15);
if (count)
*p++ = ';';
else
break;
count--;
}
}
*p = 0;
if (!rs->last_program_signals_packet
|| strcmp (rs->last_program_signals_packet, packet) != 0)
{
putpkt (packet);
getpkt (&rs->buf, &rs->buf_size, 0);
packet_ok (rs->buf, &remote_protocol_packets[PACKET_QProgramSignals]);
xfree (rs->last_program_signals_packet);
rs->last_program_signals_packet = packet;
}
else
xfree (packet);
}
}
/* If PTID is MAGIC_NULL_PTID, don't set any thread. If PTID is
MINUS_ONE_PTID, set the thread to -1, so the stub returns the
thread. If GEN is set, set the general thread, if not, then set
the step/continue thread. */
static void
set_thread (struct ptid ptid, int gen)
{
struct remote_state *rs = get_remote_state ();
ptid_t state = gen ? rs->general_thread : rs->continue_thread;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
if (ptid_equal (state, ptid))
return;
*buf++ = 'H';
*buf++ = gen ? 'g' : 'c';
if (ptid_equal (ptid, magic_null_ptid))
xsnprintf (buf, endbuf - buf, "0");
else if (ptid_equal (ptid, any_thread_ptid))
xsnprintf (buf, endbuf - buf, "0");
else if (ptid_equal (ptid, minus_one_ptid))
xsnprintf (buf, endbuf - buf, "-1");
else
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
write_ptid (buf, endbuf, ptid);
putpkt (rs->buf);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (gen)
rs->general_thread = ptid;
else
rs->continue_thread = ptid;
}
static void
set_general_thread (struct ptid ptid)
{
set_thread (ptid, 1);
}
static void
set_continue_thread (struct ptid ptid)
{
set_thread (ptid, 0);
}
/* Change the remote current process. Which thread within the process
ends up selected isn't important, as long as it is the same process
as what INFERIOR_PTID points to.
This comes from that fact that there is no explicit notion of
"selected process" in the protocol. The selected process for
general operations is the process the selected general thread
belongs to. */
static void
set_general_process (void)
{
struct remote_state *rs = get_remote_state ();
/* If the remote can't handle multiple processes, don't bother. */
if (!rs->extended || !remote_multi_process_p (rs))
return;
/* We only need to change the remote current thread if it's pointing
at some other process. */
if (ptid_get_pid (rs->general_thread) != ptid_get_pid (inferior_ptid))
set_general_thread (inferior_ptid);
}
Workaround remote targets that report an empty list to qfThreadInfo In https://sourceware.org/ml/gdb-patches/2014-10/msg00652.html, Sandra shows a target that was broken by the recent update_thread_list optimization: (gdb) target remote qa8-centos32-cs:10514 ... (gdb) continue Continuing. Cannot execute this command without a live selected thread. (gdb) The error means that the current thread is in "exited" state when the continue command is processed. The root of the problem was found here: > Sending packet: $Hg0#df...Packet received: ... > Sending packet: $?#3f...Packet received: S00 > Sending packet: $qfThreadInfo#bb...Packet received: l > Sending packet: $Hc-1#09...Packet received: > Sending packet: $qC#b4...Packet received: unset This target doesn't really support threads (no thread indication in stop reply packets; no support for qC), but then supports qfThreadInfo, and returns an empty thread list to GDB. See https://sourceware.org/ml/gdb-patches/2014-10/msg00665.html for why the target does that. As remote_update_thread_list deletes threads from GDB's list that are not found in the thread list that the target reports, the result is that GDB deletes the "fake" main thread that GDB added itself. (As that thread is currently selected, it is marked "exited" instead of being deleted straight away.) This commit avoids deleting the main thread in this scenario. gdb/ 2014-10-27 Pedro Alves <palves@redhat.com> * remote.c (remote_thread_alive): New, factored out from ... (remote_thread_alive): ... this. (remote_update_thread_list): Bail out before deleting threads if the target returned an empty list, and, the current thread has a magic/fake ptid.
2014-10-28 12:35:10 +01:00
/* Return nonzero if this is the main thread that we made up ourselves
to model non-threaded targets as single-threaded. */
static int
Workaround remote targets that report an empty list to qfThreadInfo In https://sourceware.org/ml/gdb-patches/2014-10/msg00652.html, Sandra shows a target that was broken by the recent update_thread_list optimization: (gdb) target remote qa8-centos32-cs:10514 ... (gdb) continue Continuing. Cannot execute this command without a live selected thread. (gdb) The error means that the current thread is in "exited" state when the continue command is processed. The root of the problem was found here: > Sending packet: $Hg0#df...Packet received: ... > Sending packet: $?#3f...Packet received: S00 > Sending packet: $qfThreadInfo#bb...Packet received: l > Sending packet: $Hc-1#09...Packet received: > Sending packet: $qC#b4...Packet received: unset This target doesn't really support threads (no thread indication in stop reply packets; no support for qC), but then supports qfThreadInfo, and returns an empty thread list to GDB. See https://sourceware.org/ml/gdb-patches/2014-10/msg00665.html for why the target does that. As remote_update_thread_list deletes threads from GDB's list that are not found in the thread list that the target reports, the result is that GDB deletes the "fake" main thread that GDB added itself. (As that thread is currently selected, it is marked "exited" instead of being deleted straight away.) This commit avoids deleting the main thread in this scenario. gdb/ 2014-10-27 Pedro Alves <palves@redhat.com> * remote.c (remote_thread_alive): New, factored out from ... (remote_thread_alive): ... this. (remote_update_thread_list): Bail out before deleting threads if the target returned an empty list, and, the current thread has a magic/fake ptid.
2014-10-28 12:35:10 +01:00
remote_thread_always_alive (struct target_ops *ops, ptid_t ptid)
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
struct remote_state *rs = get_remote_state ();
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
char *p, *endp;
if (ptid_equal (ptid, magic_null_ptid))
/* The main thread is always alive. */
return 1;
if (ptid_get_pid (ptid) != 0 && ptid_get_lwp (ptid) == 0)
/* The main thread is always alive. This can happen after a
vAttach, if the remote side doesn't support
multi-threading. */
return 1;
Workaround remote targets that report an empty list to qfThreadInfo In https://sourceware.org/ml/gdb-patches/2014-10/msg00652.html, Sandra shows a target that was broken by the recent update_thread_list optimization: (gdb) target remote qa8-centos32-cs:10514 ... (gdb) continue Continuing. Cannot execute this command without a live selected thread. (gdb) The error means that the current thread is in "exited" state when the continue command is processed. The root of the problem was found here: > Sending packet: $Hg0#df...Packet received: ... > Sending packet: $?#3f...Packet received: S00 > Sending packet: $qfThreadInfo#bb...Packet received: l > Sending packet: $Hc-1#09...Packet received: > Sending packet: $qC#b4...Packet received: unset This target doesn't really support threads (no thread indication in stop reply packets; no support for qC), but then supports qfThreadInfo, and returns an empty thread list to GDB. See https://sourceware.org/ml/gdb-patches/2014-10/msg00665.html for why the target does that. As remote_update_thread_list deletes threads from GDB's list that are not found in the thread list that the target reports, the result is that GDB deletes the "fake" main thread that GDB added itself. (As that thread is currently selected, it is marked "exited" instead of being deleted straight away.) This commit avoids deleting the main thread in this scenario. gdb/ 2014-10-27 Pedro Alves <palves@redhat.com> * remote.c (remote_thread_alive): New, factored out from ... (remote_thread_alive): ... this. (remote_update_thread_list): Bail out before deleting threads if the target returned an empty list, and, the current thread has a magic/fake ptid.
2014-10-28 12:35:10 +01:00
return 0;
}
/* Return nonzero if the thread PTID is still alive on the remote
system. */
static int
remote_thread_alive (struct target_ops *ops, ptid_t ptid)
{
struct remote_state *rs = get_remote_state ();
char *p, *endp;
/* Check if this is a thread that we made up ourselves to model
non-threaded targets as single-threaded. */
if (remote_thread_always_alive (ops, ptid))
return 1;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
p = rs->buf;
endp = rs->buf + get_remote_packet_size ();
*p++ = 'T';
write_ptid (p, endp, ptid);
putpkt (rs->buf);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
return (rs->buf[0] == 'O' && rs->buf[1] == 'K');
}
/* About these extended threadlist and threadinfo packets. They are
variable length packets but, the fields within them are often fixed
length. They are redundent enough to send over UDP as is the
remote protocol in general. There is a matching unit test module
in libstub. */
/* WARNING: This threadref data structure comes from the remote O.S.,
libstub protocol encoding, and remote.c. It is not particularly
changable. */
1999-06-07 21:19:32 +02:00
/* Right now, the internal structure is int. We want it to be bigger.
Plan to fix this. */
1999-06-07 21:19:32 +02:00
typedef int gdb_threadref; /* Internal GDB thread reference. */
1999-06-07 21:19:32 +02:00
/* gdb_ext_thread_info is an internal GDB data structure which is
equivalent to the reply of the remote threadinfo packet. */
1999-06-07 21:19:32 +02:00
struct gdb_ext_thread_info
1999-07-07 22:19:36 +02:00
{
threadref threadid; /* External form of thread reference. */
int active; /* Has state interesting to GDB?
regs, stack. */
char display[256]; /* Brief state display, name,
blocked/suspended. */
char shortname[32]; /* To be used to name threads. */
char more_display[256]; /* Long info, statistics, queue depth,
whatever. */
1999-07-07 22:19:36 +02:00
};
1999-06-07 21:19:32 +02:00
/* The volume of remote transfers can be limited by submitting
a mask containing bits specifying the desired information.
Use a union of these values as the 'selection' parameter to
get_thread_info. FIXME: Make these TAG names more thread specific. */
1999-06-07 21:19:32 +02:00
#define TAG_THREADID 1
#define TAG_EXISTS 2
#define TAG_DISPLAY 4
#define TAG_THREADNAME 8
1999-07-07 22:19:36 +02:00
#define TAG_MOREDISPLAY 16
1999-06-07 21:19:32 +02:00
#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES * 2)
2000-05-28 03:12:42 +02:00
static char *unpack_nibble (char *buf, int *val);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static char *unpack_byte (char *buf, int *value);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static char *pack_int (char *buf, int value);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static char *unpack_int (char *buf, int *value);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static char *unpack_string (char *src, char *dest, int length);
1999-06-07 21:19:32 +02:00
static char *pack_threadid (char *pkt, threadref *id);
1999-06-07 21:19:32 +02:00
static char *unpack_threadid (char *inbuf, threadref *id);
1999-06-07 21:19:32 +02:00
void int_to_threadref (threadref *id, int value);
1999-06-07 21:19:32 +02:00
static int threadref_to_int (threadref *ref);
1999-06-07 21:19:32 +02:00
static void copy_threadref (threadref *dest, threadref *src);
1999-06-07 21:19:32 +02:00
static int threadmatch (threadref *dest, threadref *src);
1999-06-07 21:19:32 +02:00
static char *pack_threadinfo_request (char *pkt, int mode,
threadref *id);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static int remote_unpack_thread_info_response (char *pkt,
threadref *expectedref,
2000-05-28 03:12:42 +02:00
struct gdb_ext_thread_info
*info);
1999-06-07 21:19:32 +02:00
static int remote_get_threadinfo (threadref *threadid,
int fieldset, /*TAG mask */
2000-05-28 03:12:42 +02:00
struct gdb_ext_thread_info *info);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static char *pack_threadlist_request (char *pkt, int startflag,
int threadcount,
threadref *nextthread);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static int parse_threadlist_response (char *pkt,
int result_limit,
threadref *original_echo,
threadref *resultlist,
int *doneflag);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static int remote_get_threadlist (int startflag,
threadref *nextthread,
2000-05-28 03:12:42 +02:00
int result_limit,
int *done,
int *result_count,
threadref *threadlist);
1999-06-07 21:19:32 +02:00
typedef int (*rmt_thread_action) (threadref *ref, void *context);
1999-06-07 21:19:32 +02:00
2000-05-28 03:12:42 +02:00
static int remote_threadlist_iterator (rmt_thread_action stepfunction,
void *context, int looplimit);
1999-06-07 21:19:32 +02:00
static int remote_newthread_step (threadref *ref, void *context);
1999-06-07 21:19:32 +02:00
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* Write a PTID to BUF. ENDBUF points to one-passed-the-end of the
buffer we're allowed to write to. Returns
BUF+CHARACTERS_WRITTEN. */
static char *
write_ptid (char *buf, const char *endbuf, ptid_t ptid)
{
int pid, tid;
struct remote_state *rs = get_remote_state ();
if (remote_multi_process_p (rs))
{
pid = ptid_get_pid (ptid);
if (pid < 0)
buf += xsnprintf (buf, endbuf - buf, "p-%x.", -pid);
else
buf += xsnprintf (buf, endbuf - buf, "p%x.", pid);
}
tid = ptid_get_lwp (ptid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (tid < 0)
buf += xsnprintf (buf, endbuf - buf, "-%x", -tid);
else
buf += xsnprintf (buf, endbuf - buf, "%x", tid);
return buf;
}
/* Extract a PTID from BUF. If non-null, OBUF is set to the to one
passed the last parsed char. Returns null_ptid on error. */
static ptid_t
read_ptid (char *buf, char **obuf)
{
char *p = buf;
char *pp;
ULONGEST pid = 0, tid = 0;
if (*p == 'p')
{
/* Multi-process ptid. */
pp = unpack_varlen_hex (p + 1, &pid);
if (*pp != '.')
error (_("invalid remote ptid: %s"), p);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
p = pp;
pp = unpack_varlen_hex (p + 1, &tid);
if (obuf)
*obuf = pp;
return ptid_build (pid, tid, 0);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
/* No multi-process. Just a tid. */
pp = unpack_varlen_hex (p, &tid);
remote.c: Make read_ptid return a null value when no thread id is found. When using GDB to debug an RX target using the GDB remote protocol, using a Renesas supplied debug agent, I encountered the following assertion error: thread.c:85: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n Command aborted. This assertion error occurs due to the fact that the value associated with inferior_ptid is not on the thread list. The remote debug output (obtained with "set debug remote 1") is fairly short, so I will include it up to the point where things go wrong - which is somewhat before the assertion failure: (gdb) target remote coyote.lan:61234 Remote debugging using coyote.lan:61234 Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+#c9...Ack Packet received: PacketSize=c00;qXfer:memory-map:read-;qXfer:features:read-;QStartNoAckMode+;multiprocess+;QNonStop+ Packet qSupported (supported-packets) is supported Sending packet: $QStartNoAckMode#b0...Ack Packet received: OK Sending packet: $Hgp0.0#ad...Packet received: OK Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $qTStatus#49...Packet received: Packet qTStatus (trace-status) is NOT supported Sending packet: $?#3f...Packet received: S02 Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Sending packet: $Hc-1#09...Packet received: OK Sending packet: $qC#b4...Packet received: QC not supported Above is the trace starting from the invocation of "target remote" through the call of get_current_thread() in remote_start_remote(). Below, I've pasted this line of code along with additional lines of context. The test following the call is especially important to understanding both the problem and my patch. /* We have thread information; select the thread the target says should be current. If we're reconnecting to a multi-threaded program, this will ideally be the thread that last reported an event before GDB disconnected. */ inferior_ptid = get_current_thread (wait_status); if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } } Prior to getting to the code pasted above, remote_start_remote() made a call to target_update_thread_list(). This corresponds to the following lines from the above trace: Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Once target_update_thread_list has completed, the thread list contains a single entry: {pid = 42000, lwp = 1, tid = 0}. remote_start_remote() then makes a call to set_continue_thread(), accounting for this line of the trace: Sending packet: $Hc-1#09...Packet received: OK Finally, the call to get_current_thread() is responsible for the last line of the trace that I provided above: Sending packet: $qC#b4...Packet received: QC not supported get_current_thread() calls stop_reply_extract_thread() with the wait status. This returns null_ptid. get_current_thread() then calls remote_current_thread with a null inferior_ptid. After the calls to putpkt() and getpkt(), rs->buf[0] is 'Q', so read_ptid() is called and its result is returned. The buffer passed to read_ptid() is " not supported". read_ptid ultimately returns a ptid of {pid = 4200, lwp = 0, tid = 0}. However, this thread is not on the thread list. As noted earlier, the call to target_update_thread_list() had placed {pid = 42000, lwp = 1, tid = 0} on the list. This is the only thread in the list. When these calls ultimately return to remote_start_remote(), inferior_ptid gets set to {pid = 4200, lwp = 0, tid = 0}, which (again) is not on the thread list. It appears to me that the string " not supported" is coming from the debug agent. If so, it should be fixed, but I don't see a reason to not consult the thread list in order to place a valid thread id in inferior_ptid. This (consultation of the thread list) is what is done when inferior_ptid is null_ptid: if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } My patch causes a null inferior_ptid to be returned by read_ptid when no thread id is found in the response from the debug agent. This return value ends up being returned by remote_current_thread() and then by get_current_thread. The assignment then places this null value into inferior_ptid. That, in turn, allows the ptid_equal test (noted above) to fetch a valid thread from the thread list. I no longer see the assertion failure due a good value (which is on the thread list) being placed in inferior_ptid. This patch also adds two log warnings that may be output when "set debug remote 1" is used. When running against the Renesas debug agent mentioned earlier, this is the relevant portion of the log output: Sending packet: $qC#b4...Packet received: QC not supported warning: garbage in qC reply warning: couldn't determine remote current thread; picking first in list. gdb/ChangeLog: * remote.c (read_ptid): Return null_ptid when no thread id is found. (remote_current_thread): Add log warning for malformed qC reply. (remote_start_remote): Add log warning when current thread not found.
2015-07-10 19:25:29 +02:00
/* Return null_ptid when no thread id is found. */
if (p == pp)
{
if (obuf)
*obuf = pp;
return null_ptid;
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* Since the stub is not sending a process id, then default to
what's in inferior_ptid, unless it's null at this point. If so,
then since there's no way to know the pid of the reported
threads, use the magic number. */
if (ptid_equal (inferior_ptid, null_ptid))
pid = ptid_get_pid (magic_null_ptid);
else
pid = ptid_get_pid (inferior_ptid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (obuf)
*obuf = pp;
return ptid_build (pid, tid, 0);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
static int
2000-07-30 03:48:28 +02:00
stubhex (int ch)
{
if (ch >= 'a' && ch <= 'f')
return ch - 'a' + 10;
if (ch >= '0' && ch <= '9')
return ch - '0';
if (ch >= 'A' && ch <= 'F')
return ch - 'A' + 10;
return -1;
}
static int
2000-07-30 03:48:28 +02:00
stub_unpack_int (char *buff, int fieldlength)
{
int nibble;
int retval = 0;
while (fieldlength)
{
nibble = stubhex (*buff++);
retval |= nibble;
fieldlength--;
if (fieldlength)
retval = retval << 4;
}
return retval;
}
static char *
2000-07-30 03:48:28 +02:00
unpack_nibble (char *buf, int *val)
{
*val = fromhex (*buf++);
return buf;
}
static char *
2000-07-30 03:48:28 +02:00
unpack_byte (char *buf, int *value)
{
*value = stub_unpack_int (buf, 2);
return buf + 2;
}
static char *
2000-07-30 03:48:28 +02:00
pack_int (char *buf, int value)
{
buf = pack_hex_byte (buf, (value >> 24) & 0xff);
buf = pack_hex_byte (buf, (value >> 16) & 0xff);
buf = pack_hex_byte (buf, (value >> 8) & 0x0ff);
buf = pack_hex_byte (buf, (value & 0xff));
return buf;
}
static char *
2000-07-30 03:48:28 +02:00
unpack_int (char *buf, int *value)
{
*value = stub_unpack_int (buf, 8);
return buf + 8;
}
#if 0 /* Currently unused, uncomment when needed. */
2000-05-28 03:12:42 +02:00
static char *pack_string (char *pkt, char *string);
static char *
2000-07-30 03:48:28 +02:00
pack_string (char *pkt, char *string)
{
char ch;
int len;
len = strlen (string);
if (len > 200)
len = 200; /* Bigger than most GDB packets, junk??? */
pkt = pack_hex_byte (pkt, len);
while (len-- > 0)
{
ch = *string++;
if ((ch == '\0') || (ch == '#'))
ch = '*'; /* Protect encapsulation. */
*pkt++ = ch;
}
return pkt;
}
#endif /* 0 (unused) */
static char *
2000-07-30 03:48:28 +02:00
unpack_string (char *src, char *dest, int length)
{
while (length--)
*dest++ = *src++;
*dest = '\0';
return src;
}
static char *
2000-07-30 03:48:28 +02:00
pack_threadid (char *pkt, threadref *id)
{
char *limit;
unsigned char *altid;
altid = (unsigned char *) id;
limit = pkt + BUF_THREAD_ID_SIZE;
while (pkt < limit)
pkt = pack_hex_byte (pkt, *altid++);
return pkt;
}
static char *
2000-07-30 03:48:28 +02:00
unpack_threadid (char *inbuf, threadref *id)
{
char *altref;
char *limit = inbuf + BUF_THREAD_ID_SIZE;
int x, y;
altref = (char *) id;
while (inbuf < limit)
{
x = stubhex (*inbuf++);
y = stubhex (*inbuf++);
*altref++ = (x << 4) | y;
}
return inbuf;
}
/* Externally, threadrefs are 64 bits but internally, they are still
ints. This is due to a mismatch of specifications. We would like
to use 64bit thread references internally. This is an adapter
function. */
void
2000-07-30 03:48:28 +02:00
int_to_threadref (threadref *id, int value)
{
unsigned char *scan;
scan = (unsigned char *) id;
{
int i = 4;
while (i--)
*scan++ = 0;
}
*scan++ = (value >> 24) & 0xff;
*scan++ = (value >> 16) & 0xff;
*scan++ = (value >> 8) & 0xff;
*scan++ = (value & 0xff);
}
static int
2000-07-30 03:48:28 +02:00
threadref_to_int (threadref *ref)
{
int i, value = 0;
unsigned char *scan;
scan = *ref;
scan += 4;
i = 4;
while (i-- > 0)
value = (value << 8) | ((*scan++) & 0xff);
return value;
}
static void
2000-07-30 03:48:28 +02:00
copy_threadref (threadref *dest, threadref *src)
{
int i;
unsigned char *csrc, *cdest;
csrc = (unsigned char *) src;
cdest = (unsigned char *) dest;
i = 8;
while (i--)
*cdest++ = *csrc++;
}
static int
2000-07-30 03:48:28 +02:00
threadmatch (threadref *dest, threadref *src)
{
/* Things are broken right now, so just assume we got a match. */
#if 0
unsigned char *srcp, *destp;
int i, result;
srcp = (char *) src;
destp = (char *) dest;
result = 1;
while (i-- > 0)
result &= (*srcp++ == *destp++) ? 1 : 0;
return result;
#endif
return 1;
}
/*
1999-07-07 22:19:36 +02:00
threadid:1, # always request threadid
context_exists:2,
display:4,
unique_name:8,
more_display:16
*/
/* Encoding: 'Q':8,'P':8,mask:32,threadid:64 */
static char *
2000-07-30 03:48:28 +02:00
pack_threadinfo_request (char *pkt, int mode, threadref *id)
{
*pkt++ = 'q'; /* Info Query */
*pkt++ = 'P'; /* process or thread info */
pkt = pack_int (pkt, mode); /* mode */
pkt = pack_threadid (pkt, id); /* threadid */
*pkt = '\0'; /* terminate */
return pkt;
}
/* These values tag the fields in a thread info response packet. */
/* Tagging the fields allows us to request specific fields and to
add more fields as time goes by. */
#define TAG_THREADID 1 /* Echo the thread identifier. */
1999-07-07 22:19:36 +02:00
#define TAG_EXISTS 2 /* Is this process defined enough to
fetch registers and its stack? */
1999-07-07 22:19:36 +02:00
#define TAG_DISPLAY 4 /* A short thing maybe to put on a window */
#define TAG_THREADNAME 8 /* string, maps 1-to-1 with a thread is. */
#define TAG_MOREDISPLAY 16 /* Whatever the kernel wants to say about
the process. */
static int
2000-07-30 03:48:28 +02:00
remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
struct gdb_ext_thread_info *info)
{
struct remote_state *rs = get_remote_state ();
int mask, length;
int tag;
threadref ref;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *limit = pkt + rs->buf_size; /* Plausible parsing limit. */
int retval = 1;
/* info->threadid = 0; FIXME: implement zero_threadref. */
info->active = 0;
info->display[0] = '\0';
info->shortname[0] = '\0';
info->more_display[0] = '\0';
/* Assume the characters indicating the packet type have been
stripped. */
pkt = unpack_int (pkt, &mask); /* arg mask */
pkt = unpack_threadid (pkt, &ref);
if (mask == 0)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("Incomplete response to threadinfo request."));
if (!threadmatch (&ref, expectedref))
{ /* This is an answer to a different request. */
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("ERROR RMT Thread info mismatch."));
return 0;
}
copy_threadref (&info->threadid, &ref);
/* Loop on tagged fields , try to bail if somthing goes wrong. */
/* Packets are terminated with nulls. */
while ((pkt < limit) && mask && *pkt)
{
pkt = unpack_int (pkt, &tag); /* tag */
pkt = unpack_byte (pkt, &length); /* length */
if (!(tag & mask)) /* Tags out of synch with mask. */
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("ERROR RMT: threadinfo tag mismatch."));
retval = 0;
break;
}
if (tag == TAG_THREADID)
{
if (length != 16)
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("ERROR RMT: length of threadid is not 16."));
retval = 0;
break;
}
pkt = unpack_threadid (pkt, &ref);
mask = mask & ~TAG_THREADID;
continue;
}
if (tag == TAG_EXISTS)
{
info->active = stub_unpack_int (pkt, length);
pkt += length;
mask = mask & ~(TAG_EXISTS);
if (length > 8)
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("ERROR RMT: 'exists' length too long."));
retval = 0;
break;
}
continue;
}
if (tag == TAG_THREADNAME)
{
pkt = unpack_string (pkt, &info->shortname[0], length);
mask = mask & ~TAG_THREADNAME;
continue;
}
if (tag == TAG_DISPLAY)
{
pkt = unpack_string (pkt, &info->display[0], length);
mask = mask & ~TAG_DISPLAY;
continue;
}
if (tag == TAG_MOREDISPLAY)
{
pkt = unpack_string (pkt, &info->more_display[0], length);
mask = mask & ~TAG_MOREDISPLAY;
continue;
}
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("ERROR RMT: unknown thread info tag."));
break; /* Not a tag we know about. */
}
return retval;
}
static int
2000-07-30 03:48:28 +02:00
remote_get_threadinfo (threadref *threadid, int fieldset, /* TAG mask */
struct gdb_ext_thread_info *info)
{
struct remote_state *rs = get_remote_state ();
int result;
pack_threadinfo_request (rs->buf, fieldset, threadid);
putpkt (rs->buf);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == '\0')
return 0;
result = remote_unpack_thread_info_response (rs->buf + 2,
threadid, info);
return result;
}
/* Format: i'Q':8,i"L":8,initflag:8,batchsize:16,lastthreadid:32 */
static char *
2000-07-30 03:48:28 +02:00
pack_threadlist_request (char *pkt, int startflag, int threadcount,
threadref *nextthread)
{
*pkt++ = 'q'; /* info query packet */
*pkt++ = 'L'; /* Process LIST or threadLIST request */
pkt = pack_nibble (pkt, startflag); /* initflag 1 bytes */
pkt = pack_hex_byte (pkt, threadcount); /* threadcount 2 bytes */
pkt = pack_threadid (pkt, nextthread); /* 64 bit thread identifier */
*pkt = '\0';
return pkt;
}
/* Encoding: 'q':8,'M':8,count:16,done:8,argthreadid:64,(threadid:64)* */
static int
2000-07-30 03:48:28 +02:00
parse_threadlist_response (char *pkt, int result_limit,
threadref *original_echo, threadref *resultlist,
int *doneflag)
{
struct remote_state *rs = get_remote_state ();
char *limit;
int count, resultcount, done;
resultcount = 0;
/* Assume the 'q' and 'M chars have been stripped. */
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
limit = pkt + (rs->buf_size - BUF_THREAD_ID_SIZE);
/* done parse past here */
pkt = unpack_byte (pkt, &count); /* count field */
pkt = unpack_nibble (pkt, &done);
/* The first threadid is the argument threadid. */
pkt = unpack_threadid (pkt, original_echo); /* should match query packet */
while ((count-- > 0) && (pkt < limit))
{
pkt = unpack_threadid (pkt, resultlist++);
if (resultcount++ >= result_limit)
break;
}
if (doneflag)
*doneflag = done;
return resultcount;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
/* Fetch the next batch of threads from the remote. Returns -1 if the
qL packet is not supported, 0 on error and 1 on success. */
static int
2000-07-30 03:48:28 +02:00
remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
int *done, int *result_count, threadref *threadlist)
{
struct remote_state *rs = get_remote_state ();
int result = 1;
/* Trancate result limit to be smaller than the packet size. */
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10)
>= get_remote_packet_size ())
result_limit = (get_remote_packet_size () / BUF_THREAD_ID_SIZE) - 2;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
pack_threadlist_request (rs->buf, startflag, result_limit, nextthread);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (*rs->buf == '\0')
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
{
/* Packet not supported. */
return -1;
}
*result_count =
parse_threadlist_response (rs->buf + 2, result_limit,
&rs->echo_nextthread, threadlist, done);
if (!threadmatch (&rs->echo_nextthread, nextthread))
{
/* FIXME: This is a good reason to drop the packet. */
/* Possably, there is a duplicate response. */
/* Possabilities :
retransmit immediatly - race conditions
retransmit after timeout - yes
exit
wait for packet, then exit
*/
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("HMM: threadlist did not echo arg thread, dropping it."));
return 0; /* I choose simply exiting. */
}
if (*result_count <= 0)
{
if (*done != 1)
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("RMT ERROR : failed to get remote thread list."));
result = 0;
}
return result; /* break; */
}
if (*result_count > result_limit)
{
*result_count = 0;
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("RMT ERROR: threadlist response longer than requested."));
return 0;
}
return result;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
/* Fetch the list of remote threads, with the qL packet, and call
STEPFUNCTION for each thread found. Stops iterating and returns 1
if STEPFUNCTION returns true. Stops iterating and returns 0 if the
STEPFUNCTION returns false. If the packet is not supported,
returns -1. */
static int
2000-07-30 03:48:28 +02:00
remote_threadlist_iterator (rmt_thread_action stepfunction, void *context,
int looplimit)
{
struct remote_state *rs = get_remote_state ();
int done, i, result_count;
int startflag = 1;
int result = 1;
int loopcount = 0;
done = 0;
while (!done)
{
if (loopcount++ > looplimit)
{
result = 0;
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("Remote fetch threadlist -infinite loop-."));
break;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
result = remote_get_threadlist (startflag, &rs->nextthread,
MAXTHREADLISTRESULTS,
&done, &result_count,
rs->resultthreadlist);
if (result <= 0)
break;
/* Clear for later iterations. */
startflag = 0;
/* Setup to resume next batch of thread references, set nextthread. */
if (result_count >= 1)
copy_threadref (&rs->nextthread,
&rs->resultthreadlist[result_count - 1]);
i = 0;
while (result_count--)
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
{
if (!(*stepfunction) (&rs->resultthreadlist[i++], context))
{
result = 0;
break;
}
}
}
return result;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
/* A thread found on the remote target. */
typedef struct thread_item
{
/* The thread's PTID. */
ptid_t ptid;
/* The thread's extra info. May be NULL. */
char *extra;
/* The core the thread was running on. -1 if not known. */
int core;
} thread_item_t;
DEF_VEC_O(thread_item_t);
/* Context passed around to the various methods listing remote
threads. As new threads are found, they're added to the ITEMS
vector. */
struct threads_listing_context
{
/* The threads found on the remote target. */
VEC (thread_item_t) *items;
};
/* Discard the contents of the constructed thread listing context. */
static void
clear_threads_listing_context (void *p)
{
struct threads_listing_context *context = p;
int i;
struct thread_item *item;
for (i = 0; VEC_iterate (thread_item_t, context->items, i, item); ++i)
xfree (item->extra);
VEC_free (thread_item_t, context->items);
}
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
/* Remove the thread specified as the related_pid field of WS
from the CONTEXT list. */
static void
threads_listing_context_remove (struct target_waitstatus *ws,
struct threads_listing_context *context)
{
struct thread_item *item;
int i;
ptid_t child_ptid = ws->value.related_pid;
for (i = 0; VEC_iterate (thread_item_t, context->items, i, item); ++i)
{
if (ptid_equal (item->ptid, child_ptid))
{
VEC_ordered_remove (thread_item_t, context->items, i);
break;
}
}
}
static int
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
remote_newthread_step (threadref *ref, void *data)
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
struct threads_listing_context *context = data;
struct thread_item item;
int pid = ptid_get_pid (inferior_ptid);
2001-05-04 06:15:33 +02:00
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
item.ptid = ptid_build (pid, threadref_to_int (ref), 0);
item.core = -1;
item.extra = NULL;
VEC_safe_push (thread_item_t, context->items, &item);
return 1; /* continue iterator */
}
#define CRAZY_MAX_THREADS 1000
2001-05-04 06:15:33 +02:00
static ptid_t
remote_current_thread (ptid_t oldpid)
{
struct remote_state *rs = get_remote_state ();
putpkt ("qC");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == 'Q' && rs->buf[1] == 'C')
remote.c: Make read_ptid return a null value when no thread id is found. When using GDB to debug an RX target using the GDB remote protocol, using a Renesas supplied debug agent, I encountered the following assertion error: thread.c:85: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n Command aborted. This assertion error occurs due to the fact that the value associated with inferior_ptid is not on the thread list. The remote debug output (obtained with "set debug remote 1") is fairly short, so I will include it up to the point where things go wrong - which is somewhat before the assertion failure: (gdb) target remote coyote.lan:61234 Remote debugging using coyote.lan:61234 Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+#c9...Ack Packet received: PacketSize=c00;qXfer:memory-map:read-;qXfer:features:read-;QStartNoAckMode+;multiprocess+;QNonStop+ Packet qSupported (supported-packets) is supported Sending packet: $QStartNoAckMode#b0...Ack Packet received: OK Sending packet: $Hgp0.0#ad...Packet received: OK Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $qTStatus#49...Packet received: Packet qTStatus (trace-status) is NOT supported Sending packet: $?#3f...Packet received: S02 Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Sending packet: $Hc-1#09...Packet received: OK Sending packet: $qC#b4...Packet received: QC not supported Above is the trace starting from the invocation of "target remote" through the call of get_current_thread() in remote_start_remote(). Below, I've pasted this line of code along with additional lines of context. The test following the call is especially important to understanding both the problem and my patch. /* We have thread information; select the thread the target says should be current. If we're reconnecting to a multi-threaded program, this will ideally be the thread that last reported an event before GDB disconnected. */ inferior_ptid = get_current_thread (wait_status); if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } } Prior to getting to the code pasted above, remote_start_remote() made a call to target_update_thread_list(). This corresponds to the following lines from the above trace: Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Once target_update_thread_list has completed, the thread list contains a single entry: {pid = 42000, lwp = 1, tid = 0}. remote_start_remote() then makes a call to set_continue_thread(), accounting for this line of the trace: Sending packet: $Hc-1#09...Packet received: OK Finally, the call to get_current_thread() is responsible for the last line of the trace that I provided above: Sending packet: $qC#b4...Packet received: QC not supported get_current_thread() calls stop_reply_extract_thread() with the wait status. This returns null_ptid. get_current_thread() then calls remote_current_thread with a null inferior_ptid. After the calls to putpkt() and getpkt(), rs->buf[0] is 'Q', so read_ptid() is called and its result is returned. The buffer passed to read_ptid() is " not supported". read_ptid ultimately returns a ptid of {pid = 4200, lwp = 0, tid = 0}. However, this thread is not on the thread list. As noted earlier, the call to target_update_thread_list() had placed {pid = 42000, lwp = 1, tid = 0} on the list. This is the only thread in the list. When these calls ultimately return to remote_start_remote(), inferior_ptid gets set to {pid = 4200, lwp = 0, tid = 0}, which (again) is not on the thread list. It appears to me that the string " not supported" is coming from the debug agent. If so, it should be fixed, but I don't see a reason to not consult the thread list in order to place a valid thread id in inferior_ptid. This (consultation of the thread list) is what is done when inferior_ptid is null_ptid: if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } My patch causes a null inferior_ptid to be returned by read_ptid when no thread id is found in the response from the debug agent. This return value ends up being returned by remote_current_thread() and then by get_current_thread. The assignment then places this null value into inferior_ptid. That, in turn, allows the ptid_equal test (noted above) to fetch a valid thread from the thread list. I no longer see the assertion failure due a good value (which is on the thread list) being placed in inferior_ptid. This patch also adds two log warnings that may be output when "set debug remote 1" is used. When running against the Renesas debug agent mentioned earlier, this is the relevant portion of the log output: Sending packet: $qC#b4...Packet received: QC not supported warning: garbage in qC reply warning: couldn't determine remote current thread; picking first in list. gdb/ChangeLog: * remote.c (read_ptid): Return null_ptid when no thread id is found. (remote_current_thread): Add log warning for malformed qC reply. (remote_start_remote): Add log warning when current thread not found.
2015-07-10 19:25:29 +02:00
{
char *obuf;
ptid_t result;
result = read_ptid (&rs->buf[2], &obuf);
if (*obuf != '\0' && remote_debug)
fprintf_unfiltered (gdb_stdlog,
"warning: garbage in qC reply\n");
return result;
}
else
return oldpid;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
/* List remote threads using the deprecated qL packet. */
1999-06-07 21:19:32 +02:00
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
static int
remote_get_threads_with_ql (struct target_ops *ops,
struct threads_listing_context *context)
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
if (remote_threadlist_iterator (remote_newthread_step, context,
CRAZY_MAX_THREADS) >= 0)
return 1;
return 0;
}
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
#if defined(HAVE_LIBEXPAT)
static void
start_thread (struct gdb_xml_parser *parser,
const struct gdb_xml_element *element,
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
struct threads_listing_context *data = user_data;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
struct thread_item item;
char *id;
struct gdb_xml_value *attr;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
id = xml_find_attribute (attributes, "id")->value;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
item.ptid = read_ptid (id, NULL);
attr = xml_find_attribute (attributes, "core");
if (attr != NULL)
item.core = *(ULONGEST *) attr->value;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
else
item.core = -1;
item.extra = 0;
VEC_safe_push (thread_item_t, data->items, &item);
}
static void
end_thread (struct gdb_xml_parser *parser,
const struct gdb_xml_element *element,
void *user_data, const char *body_text)
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
struct threads_listing_context *data = user_data;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
if (body_text && *body_text)
VEC_last (thread_item_t, data->items)->extra = xstrdup (body_text);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
}
const struct gdb_xml_attribute thread_attributes[] = {
{ "id", GDB_XML_AF_NONE, NULL, NULL },
{ "core", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
const struct gdb_xml_element thread_children[] = {
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
const struct gdb_xml_element threads_children[] = {
{ "thread", thread_attributes, thread_children,
GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL,
start_thread, end_thread },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
const struct gdb_xml_element threads_elements[] = {
{ "threads", NULL, threads_children,
GDB_XML_EF_NONE, NULL, NULL },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
#endif
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
/* List remote threads using qXfer:threads:read. */
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
static int
remote_get_threads_with_qxfer (struct target_ops *ops,
struct threads_listing_context *context)
1999-06-14 20:08:47 +02:00
{
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
#if defined(HAVE_LIBEXPAT)
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
char *xml = target_read_stralloc (ops, TARGET_OBJECT_THREADS, NULL);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
struct cleanup *back_to = make_cleanup (xfree, xml);
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
if (xml != NULL && *xml != '\0')
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
gdb_xml_parse_quick (_("threads"), "threads.dtd",
threads_elements, xml, context);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
}
do_cleanups (back_to);
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
return 1;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
}
#endif
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
return 0;
}
/* List remote threads using qfThreadInfo/qsThreadInfo. */
static int
remote_get_threads_with_qthreadinfo (struct target_ops *ops,
struct threads_listing_context *context)
{
struct remote_state *rs = get_remote_state ();
if (rs->use_threadinfo_query)
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
char *bufp;
putpkt ("qfThreadInfo");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
bufp = rs->buf;
if (bufp[0] != '\0') /* q packet recognized */
{
while (*bufp++ == 'm') /* reply contains one or more TID */
{
do
{
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
struct thread_item item;
item.ptid = read_ptid (bufp, &bufp);
item.core = -1;
item.extra = NULL;
VEC_safe_push (thread_item_t, context->items, &item);
}
while (*bufp++ == ','); /* comma-separated list */
putpkt ("qsThreadInfo");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
bufp = rs->buf;
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
return 1;
}
else
{
/* Packet not recognized. */
rs->use_threadinfo_query = 0;
}
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
return 0;
}
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
/* Implement the to_update_thread_list function for the remote
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
targets. */
static void
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
remote_update_thread_list (struct target_ops *ops)
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
{
struct remote_state *rs = get_remote_state ();
struct threads_listing_context context;
struct cleanup *old_chain;
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
int got_list = 0;
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
context.items = NULL;
old_chain = make_cleanup (clear_threads_listing_context, &context);
/* We have a few different mechanisms to fetch the thread list. Try
them all, starting with the most preferred one first, falling
back to older methods. */
if (remote_get_threads_with_qxfer (ops, &context)
|| remote_get_threads_with_qthreadinfo (ops, &context)
|| remote_get_threads_with_ql (ops, &context))
{
int i;
struct thread_item *item;
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
struct thread_info *tp, *tmp;
got_list = 1;
Workaround remote targets that report an empty list to qfThreadInfo In https://sourceware.org/ml/gdb-patches/2014-10/msg00652.html, Sandra shows a target that was broken by the recent update_thread_list optimization: (gdb) target remote qa8-centos32-cs:10514 ... (gdb) continue Continuing. Cannot execute this command without a live selected thread. (gdb) The error means that the current thread is in "exited" state when the continue command is processed. The root of the problem was found here: > Sending packet: $Hg0#df...Packet received: ... > Sending packet: $?#3f...Packet received: S00 > Sending packet: $qfThreadInfo#bb...Packet received: l > Sending packet: $Hc-1#09...Packet received: > Sending packet: $qC#b4...Packet received: unset This target doesn't really support threads (no thread indication in stop reply packets; no support for qC), but then supports qfThreadInfo, and returns an empty thread list to GDB. See https://sourceware.org/ml/gdb-patches/2014-10/msg00665.html for why the target does that. As remote_update_thread_list deletes threads from GDB's list that are not found in the thread list that the target reports, the result is that GDB deletes the "fake" main thread that GDB added itself. (As that thread is currently selected, it is marked "exited" instead of being deleted straight away.) This commit avoids deleting the main thread in this scenario. gdb/ 2014-10-27 Pedro Alves <palves@redhat.com> * remote.c (remote_thread_alive): New, factored out from ... (remote_thread_alive): ... this. (remote_update_thread_list): Bail out before deleting threads if the target returned an empty list, and, the current thread has a magic/fake ptid.
2014-10-28 12:35:10 +01:00
if (VEC_empty (thread_item_t, context.items)
&& remote_thread_always_alive (ops, inferior_ptid))
{
/* Some targets don't really support threads, but still
reply an (empty) thread list in response to the thread
listing packets, instead of replying "packet not
supported". Exit early so we don't delete the main
thread. */
do_cleanups (old_chain);
return;
}
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
/* CONTEXT now holds the current thread list on the remote
target end. Delete GDB-side threads no longer found on the
target. */
update thread list, delete exited threads On GNU/Linux, if the running kernel supports clone events, then linux-thread-db.c defers thread listing to the target beneath: static void thread_db_update_thread_list (struct target_ops *ops) { ... if (target_has_execution && !thread_db_use_events ()) ops->beneath->to_update_thread_list (ops->beneath); else thread_db_update_thread_list_td_ta_thr_iter (ops); ... } However, when live debugging, the target beneath, linux-nat.c, does not implement the to_update_thread_list method. The result is that if a thread is marked exited (because it can't be deleted right now, e.g., it was the selected thread), then it won't ever be deleted, until the process exits or is killed/detached. A similar thing happens with the remote.c target. Because its target_update_thread_list implementation skips exited threads when it walks the current thread list looking for threads that no longer exits on the target side, using ALL_NON_EXITED_THREADS_SAFE, stale exited threads are never deleted. This is not a big deal -- I can't think of any way this might be user visible, other than gdb's memory growing a tiny bit whenever a thread gets stuck in exited state. Still, might as well clean things up properly. All other targets use prune_threads, so are unaffected. The fix adds a ALL_THREADS_SAFE macro, that like ALL_NON_EXITED_THREADS_SAFE, walks the thread list and allows deleting the iterated thread, and uses that in places that are walking the thread list in order to delete threads. Actually, after converting linux-nat.c and remote.c to use this, we find the only other user of ALL_NON_EXITED_THREADS_SAFE is also walking the list to delete threads. So we convert that too, and end up deleting ALL_NON_EXITED_THREADS_SAFE. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog 2015-04-07 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ... (ALL_THREADS_SAFE): ... this, and don't skip exited threads. (delete_exited_threads): New declaration. * infrun.c (follow_exec): Use ALL_THREADS_SAFE. * linux-nat.c (linux_nat_update_thread_list): New function. (linux_nat_add_target): Install it. * remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE. * thread.c (prune_threads): Use ALL_THREADS_SAFE. (delete_exited_threads): New function.
2015-04-07 16:47:22 +02:00
ALL_THREADS_SAFE (tp, tmp)
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
{
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
for (i = 0;
VEC_iterate (thread_item_t, context.items, i, item);
++i)
{
if (ptid_equal (item->ptid, tp->ptid))
break;
}
if (i == VEC_length (thread_item_t, context.items))
{
/* Not found. */
delete_thread (tp->ptid);
}
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
}
/* Remove any unreported fork child threads from CONTEXT so
that we don't interfere with follow fork, which is where
creation of such threads is handled. */
remove_new_fork_children (&context);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
/* And now add threads we don't know about yet to our list. */
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
for (i = 0;
VEC_iterate (thread_item_t, context.items, i, item);
++i)
{
if (!ptid_equal (item->ptid, null_ptid))
{
struct private_thread_info *info;
/* In non-stop mode, we assume new found threads are
running until proven otherwise with a stop reply. In
all-stop, we can only get here if all threads are
stopped. */
int running = non_stop ? 1 : 0;
remote_notice_new_inferior (item->ptid, running);
info = demand_private_info (item->ptid);
info->core = item->core;
info->extra = item->extra;
item->extra = NULL;
}
}
}
remote: get rid of all the T packets when syncing the thread list This commit avoids the prune_threads call in the remote target's target_update_thread_list's implementation, eliminating all the "thread alive" RSP traffic (one packet per thread) whenever we fetch the thread list. IOW, this: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK ... more T packets; it's one per previously known live thread ... 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 Becomes: 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 Tested on x86_64 Fedora 20, native gdbserver: - tests the qXfer:threads:read method. Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read force-disabled in gdbserver: - So that GDB falls back to the qfThreadInfo/qsThreadInfo method. And also manually smoked tested force disabling both qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro. * remote.c (remote_update_thread_list): Skip calling prune_threads if any thread listing method is supported, and instead walk over the set of remote threads listed, deleting those that are not found in GDB's thread list.
2014-10-15 23:44:00 +02:00
if (!got_list)
{
/* If no thread listing method is supported, then query whether
each known thread is alive, one by one, with the T packet.
If the target doesn't support threads at all, then this is a
no-op. See remote_thread_alive. */
prune_threads ();
}
Merge remote thread listing methods We have three methods to list the current remote thread list: 1. The qXfer:threads:read method (the preferred one nowadays), builds a remote thread list while parsing the XML, and then after the XML parsing is done, goes over the built list and adds threads GDB doesn't know about yet to GDB's list. 2. If the qXfer method isn't available, we fallback to using the qfThreadInfo/qsThreadInfo packets. When we do this, we adds threads to GDB's list immediately as we parse the qfThreadInfo/qsThreadInfo packet replies. 3. And then if the previous method isn't available either, we try the old deprecated qL packet. This path is already looking somewhat broken for not using remote_notice_new_inferior to add threads to GDB's list. This patch makes all variants work in two passes, like the qXfer method, and then makes all variants share the code path that adds threads to GDB's list. Tested on x86_64 Fedora 20 with native gdbserver. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * remote.c (remote_get_threadlist, remote_threadlist_iterator): Add describing comment. Return -1 if the qL packet is not supported. (struct thread_item, thread_item_t): Move higher up in the file. Add comments. (struct threads_parsing_context): Move higher up in the file, add comments, and remote to ... (struct threads_listing_context): ... this. (remote_newthread_step): Don't add the thread to GDB's thread database here. Instead push it to the thread_listing_context list. (remote_find_new_threads): Rename to ... (remote_get_threads_with_ql): ... this. Add target_ops and targets_listing_context parameters. Pass down context. (start_thread): Adjust. (clear_threads_parsing_context): Rename to ... (clear_threads_listing_context): ... this. (remote_get_threads_with_qxfer): New, with parts salvaged from old remote_threads_info. (remote_get_threads_with_qthreadinfo): Ditto. (remote_threads_info): Reimplement.
2014-10-15 23:43:59 +02:00
do_cleanups (old_chain);
}
/*
* Collect a descriptive string about the given thread.
* The target may say anything it wants to about the thread
* (typically info about its blocked / runnable state, name, etc.).
* This string will appear in the info threads display.
*
* Optional: targets are not required to implement this function.
*/
static char *
remote_threads_extra_info (struct target_ops *self, struct thread_info *tp)
{
struct remote_state *rs = get_remote_state ();
int result;
int set;
threadref id;
struct gdb_ext_thread_info threadinfo;
static char display_buf[100]; /* arbitrary... */
int n = 0; /* position in display_buf */
if (rs->remote_desc == 0) /* paranoia */
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("remote_threads_extra_info"));
if (ptid_equal (tp->ptid, magic_null_ptid)
|| (ptid_get_pid (tp->ptid) != 0 && ptid_get_lwp (tp->ptid) == 0))
/* This is the main thread which was added by GDB. The remote
server doesn't know about it. */
return NULL;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
{
struct thread_info *info = find_thread_ptid (tp->ptid);
if (info && info->priv)
return info->priv->extra;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
else
return NULL;
}
if (rs->use_threadextra_query)
{
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
char *b = rs->buf;
char *endb = rs->buf + get_remote_packet_size ();
xsnprintf (b, endb - b, "qThreadExtraInfo,");
b += strlen (b);
write_ptid (b, endb, tp->ptid);
putpkt (rs->buf);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] != 0)
{
n = min (strlen (rs->buf) / 2, sizeof (display_buf));
result = hex2bin (rs->buf, (gdb_byte *) display_buf, n);
display_buf [result] = '\0';
return display_buf;
}
1999-06-14 20:08:47 +02:00
}
/* If the above query fails, fall back to the old method. */
rs->use_threadextra_query = 0;
set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
| TAG_MOREDISPLAY | TAG_DISPLAY;
int_to_threadref (&id, ptid_get_lwp (tp->ptid));
if (remote_get_threadinfo (&id, set, &threadinfo))
if (threadinfo.active)
1999-06-14 20:08:47 +02:00
{
if (*threadinfo.shortname)
n += xsnprintf (&display_buf[0], sizeof (display_buf) - n,
" Name: %s,", threadinfo.shortname);
if (*threadinfo.display)
n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
" State: %s,", threadinfo.display);
if (*threadinfo.more_display)
n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
" Priority: %s", threadinfo.more_display);
if (n > 0)
1999-07-07 22:19:36 +02:00
{
/* For purely cosmetic reasons, clear up trailing commas. */
if (',' == display_buf[n-1])
display_buf[n-1] = ' ';
return display_buf;
1999-07-07 22:19:36 +02:00
}
1999-06-14 20:08:47 +02:00
}
return NULL;
1999-06-14 20:08:47 +02:00
}
1999-07-07 22:19:36 +02:00
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
static int
remote_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR addr,
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
struct static_tracepoint_marker *marker)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
xsnprintf (p, get_remote_packet_size (), "qTSTMat:");
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
p += strlen (p);
p += hexnumstr (p, addr);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
if (*p == 'E')
error (_("Remote failure reply: %s"), p);
if (*p++ == 'm')
{
parse_static_tracepoint_marker_definition (p, &p, marker);
return 1;
}
return 0;
}
static VEC(static_tracepoint_marker_p) *
remote_static_tracepoint_markers_by_strid (struct target_ops *self,
const char *strid)
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
{
struct remote_state *rs = get_remote_state ();
VEC(static_tracepoint_marker_p) *markers = NULL;
struct static_tracepoint_marker *marker = NULL;
struct cleanup *old_chain;
char *p;
/* Ask for a first packet of static tracepoint marker
definition. */
putpkt ("qTfSTM");
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
if (*p == 'E')
error (_("Remote failure reply: %s"), p);
old_chain = make_cleanup (free_current_marker, &marker);
while (*p++ == 'm')
{
if (marker == NULL)
marker = XCNEW (struct static_tracepoint_marker);
do
{
parse_static_tracepoint_marker_definition (p, &p, marker);
if (strid == NULL || strcmp (strid, marker->str_id) == 0)
{
VEC_safe_push (static_tracepoint_marker_p,
markers, marker);
marker = NULL;
}
else
{
release_static_tracepoint_marker (marker);
memset (marker, 0, sizeof (*marker));
}
}
while (*p++ == ','); /* comma-separated list */
/* Ask for another packet of static tracepoint definition. */
putpkt ("qTsSTM");
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
}
do_cleanups (old_chain);
return markers;
}
/* Implement the to_get_ada_task_ptid function for the remote targets. */
static ptid_t
remote_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
{
return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0);
}
/* Restart the remote side; this is an extended protocol operation. */
static void
2000-07-30 03:48:28 +02:00
extended_remote_restart (void)
{
struct remote_state *rs = get_remote_state ();
/* Send the restart command; for reasons I don't understand the
remote side really expects a number after the "R". */
xsnprintf (rs->buf, get_remote_packet_size (), "R%x", 0);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
remote_fileio_reset ();
}
/* Clean up connection to a remote debugger. */
static void
remote_close (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
if (rs->remote_desc == NULL)
return; /* already closed */
/* Make sure we leave stdin registered in the event loop, and we
don't leave the async SIGINT signal handler installed. */
remote_terminal_ours (self);
serial_close (rs->remote_desc);
rs->remote_desc = NULL;
/* We don't have a connection to the remote stub anymore. Get rid
of all the inferiors and their threads we were controlling.
Reset inferior_ptid to null_ptid first, as otherwise has_stack_frame
will be unable to find the thread corresponding to (pid, 0, 0). */
inferior_ptid = null_ptid;
discard_all_inferiors ();
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
/* We are closing the remote target, so we should discard
everything of this target. */
discard_pending_stop_replies_in_queue (rs);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (remote_async_inferior_event_token)
delete_async_event_handler (&remote_async_inferior_event_token);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
remote_notif_state_xfree (rs->notif_state);
trace_reset_local_state ();
}
/* Query the remote side for the text, data and bss offsets. */
static void
2000-07-30 03:48:28 +02:00
get_offsets (void)
{
struct remote_state *rs = get_remote_state ();
char *buf;
1999-06-28 18:06:02 +02:00
char *ptr;
2007-06-18 17:46:38 +02:00
int lose, num_segments = 0, do_sections, do_segments;
CORE_ADDR text_addr, data_addr, bss_addr, segments[2];
struct section_offsets *offs;
2007-06-18 17:46:38 +02:00
struct symfile_segment_data *data;
if (symfile_objfile == NULL)
return;
putpkt ("qOffsets");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
buf = rs->buf;
if (buf[0] == '\000')
return; /* Return silently. Stub doesn't support
this command. */
if (buf[0] == 'E')
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("Remote failure reply: %s"), buf);
return;
}
/* Pick up each field in turn. This used to be done with scanf, but
scanf will make trouble if CORE_ADDR size doesn't match
conversion directives correctly. The following code will work
with any size of CORE_ADDR. */
text_addr = data_addr = bss_addr = 0;
ptr = buf;
lose = 0;
if (startswith (ptr, "Text="))
{
ptr += 5;
/* Don't use strtol, could lose on big values. */
while (*ptr && *ptr != ';')
text_addr = (text_addr << 4) + fromhex (*ptr++);
if (startswith (ptr, ";Data="))
2007-06-18 17:46:38 +02:00
{
ptr += 6;
while (*ptr && *ptr != ';')
data_addr = (data_addr << 4) + fromhex (*ptr++);
}
else
lose = 1;
if (!lose && startswith (ptr, ";Bss="))
2007-06-18 17:46:38 +02:00
{
ptr += 5;
while (*ptr && *ptr != ';')
bss_addr = (bss_addr << 4) + fromhex (*ptr++);
2007-06-18 17:46:38 +02:00
if (bss_addr != data_addr)
warning (_("Target reported unsupported offsets: %s"), buf);
}
else
lose = 1;
}
else if (startswith (ptr, "TextSeg="))
{
2007-06-18 17:46:38 +02:00
ptr += 8;
/* Don't use strtol, could lose on big values. */
while (*ptr && *ptr != ';')
2007-06-18 17:46:38 +02:00
text_addr = (text_addr << 4) + fromhex (*ptr++);
num_segments = 1;
if (startswith (ptr, ";DataSeg="))
2007-06-18 17:46:38 +02:00
{
ptr += 9;
while (*ptr && *ptr != ';')
data_addr = (data_addr << 4) + fromhex (*ptr++);
num_segments++;
}
}
else
lose = 1;
if (lose)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Malformed response to offset query, %s"), buf);
2007-06-18 17:46:38 +02:00
else if (*ptr != '\0')
warning (_("Target reported unsupported offsets: %s"), buf);
offs = ((struct section_offsets *)
alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections)));
memcpy (offs, symfile_objfile->section_offsets,
SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
2007-06-18 17:46:38 +02:00
data = get_symfile_segment_data (symfile_objfile->obfd);
do_segments = (data != NULL);
do_sections = num_segments == 0;
if (num_segments > 0)
2007-06-18 17:46:38 +02:00
{
segments[0] = text_addr;
segments[1] = data_addr;
}
/* If we have two segments, we can still try to relocate everything
by assuming that the .text and .data offsets apply to the whole
text and data segments. Convert the offsets given in the packet
to base addresses for symfile_map_offsets_to_segments. */
else if (data && data->num_segments == 2)
{
segments[0] = data->segment_bases[0] + text_addr;
segments[1] = data->segment_bases[1] + data_addr;
num_segments = 2;
}
/* If the object file has only one segment, assume that it is text
rather than data; main programs with no writable data are rare,
but programs with no code are useless. Of course the code might
have ended up in the data segment... to detect that we would need
the permissions here. */
else if (data && data->num_segments == 1)
{
segments[0] = data->segment_bases[0] + text_addr;
num_segments = 1;
}
/* There's no way to relocate by segment. */
else
do_segments = 0;
2007-06-18 17:46:38 +02:00
if (do_segments)
{
int ret = symfile_map_offsets_to_segments (symfile_objfile->obfd, data,
offs, num_segments, segments);
if (ret == 0 && !do_sections)
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
error (_("Can not handle qOffsets TextSeg "
"response with this symbol file"));
2007-06-18 17:46:38 +02:00
if (ret > 0)
do_sections = 0;
}
if (data)
free_symfile_segment_data (data);
2007-06-18 17:46:38 +02:00
if (do_sections)
{
offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
/* This is a temporary kludge to force data and bss to use the
same offsets because that's what nlmconv does now. The real
solution requires changes to the stub and remote.c that I
don't have time to do right now. */
2007-06-18 17:46:38 +02:00
offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
}
objfile_relocate (symfile_objfile, offs);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Callback for iterate_over_threads. Set the STOP_REQUESTED flags in
threads we know are stopped already. This is used during the
initial remote connection in non-stop mode --- threads that are
reported as already being stopped are left stopped. */
static int
set_stop_requested_callback (struct thread_info *thread, void *data)
{
/* If we have a stop reply for this thread, it must be stopped. */
if (peek_stop_reply (thread->ptid))
set_stop_requested (thread->ptid, 1);
return 0;
}
/* Send interrupt_sequence to remote target. */
static void
send_interrupt_sequence (void)
{
struct remote_state *rs = get_remote_state ();
if (interrupt_sequence_mode == interrupt_sequence_control_c)
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("\x03", 1);
else if (interrupt_sequence_mode == interrupt_sequence_break)
serial_send_break (rs->remote_desc);
else if (interrupt_sequence_mode == interrupt_sequence_break_g)
{
serial_send_break (rs->remote_desc);
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("g", 1);
}
else
internal_error (__FILE__, __LINE__,
_("Invalid value for interrupt_sequence_mode: %s."),
interrupt_sequence_mode);
}
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
/* If STOP_REPLY is a T stop reply, look for the "thread" register,
and extract the PTID. Returns NULL_PTID if not found. */
static ptid_t
stop_reply_extract_thread (char *stop_reply)
{
if (stop_reply[0] == 'T' && strlen (stop_reply) > 3)
{
char *p;
/* Txx r:val ; r:val (...) */
p = &stop_reply[3];
/* Look for "register" named "thread". */
while (*p != '\0')
{
char *p1;
p1 = strchr (p, ':');
if (p1 == NULL)
return null_ptid;
if (strncmp (p, "thread", p1 - p) == 0)
return read_ptid (++p1, &p);
p1 = strchr (p, ';');
if (p1 == NULL)
return null_ptid;
p1++;
p = p1;
}
}
return null_ptid;
}
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
/* Determine the remote side's current thread. If we have a stop
reply handy (in WAIT_STATUS), maybe it's a T stop reply with a
"thread" register we can extract the current thread from. If not,
ask the remote which is the current thread with qC. The former
method avoids a roundtrip. */
static ptid_t
get_current_thread (char *wait_status)
{
Fix using uninitialised values We did a code refacotr here https://sourceware.org/ml/gdb-patches/2013-11/msg00063.html > (get_current_thread): New function, factored out from ... > (add_current_inferior_and_thread): ... this. Adjust. > >@@ -3332,18 +3371,8 @@ add_current_inferior_and_thread (char *wait_status) > > inferior_ptid = null_ptid; > >- /* Now, if we have thread information, update inferior_ptid. First >- if we have a stop reply handy, maybe it's a T stop reply with a >- "thread" register we can extract the current thread from. If >- not, ask the remote which is the current thread, with qC. The >- former method avoids a roundtrip. Note we don't use >- remote_parse_stop_reply as that makes use of the target >- architecture, which we haven't yet fully determined at this >- point. */ >- if (wait_status != NULL) >- ptid = stop_reply_extract_thread (wait_status); >- if (ptid_equal (ptid, null_ptid)) >- ptid = remote_current_thread (inferior_ptid); >+ /* Now, if we have thread information, update inferior_ptid. */ >+ ptid = get_current_thread (wait_status); but after the refactor, local variable ptid is used without initialisation. However, before this change, ptid is initialised to null_ptid. This error can be found by valgrind too... ==3298== at 0x6B99BA: ptid_equal (ptid.c:80) ==3298== by 0x4C67FF: get_current_thread (remote.c:3484) ==3298== by 0x4C6951: add_current_inferior_and_thread (remote.c:3511) ==3298== by 0x4C762C: extended_remote_create_inferior (remote.c:8506) ==3298== by 0x5A5312: run_command_1 (infcmd.c:606) ==3298== by 0x68B4FB: execute_command (top.c:463) ==3298== by 0x5C7214: command_handler (event-top.c:494) ==3298== by 0x5C78A3: command_line_handler (event-top.c:692) ==3298== by 0x6DEB57: rl_callback_read_char (callback.c:220) ==3298== by 0x5C7278: rl_callback_read_char_wrapper (event-top.c:171) ==3298== by 0x5C72C2: stdin_event_handler (event-top.c:432) ==3298== by 0x5C6194: gdb_wait_for_event (event-loop.c:834) This patch initialises local variable ptid to null in get_current_thread. We don't need to initialise ptid in add_current_inferior_and_thread, so this patch also removes the ptid initialisation. gdb: 2015-07-17 Yao Qi <yao.qi@linaro.org> * remote.c (get_current_thread): Initialise ptid to null_ptid. (add_current_inferior_and_thread): Don't initialise ptid.
2015-07-17 13:14:59 +02:00
ptid_t ptid = null_ptid;
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
/* Note we don't use remote_parse_stop_reply as that makes use of
the target architecture, which we haven't yet fully determined at
this point. */
if (wait_status != NULL)
ptid = stop_reply_extract_thread (wait_status);
if (ptid_equal (ptid, null_ptid))
ptid = remote_current_thread (inferior_ptid);
return ptid;
}
/* Query the remote target for which is the current thread/process,
add it to our tables, and update INFERIOR_PTID. The caller is
responsible for setting the state such that the remote end is ready
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
to return the current thread.
This function is called after handling the '?' or 'vRun' packets,
whose response is a stop reply from which we can also try
extracting the thread. If the target doesn't support the explicit
qC query, we infer the current thread from that stop reply, passed
in in WAIT_STATUS, which may be NULL. */
static void
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
add_current_inferior_and_thread (char *wait_status)
{
struct remote_state *rs = get_remote_state ();
int fake_pid_p = 0;
Fix using uninitialised values We did a code refacotr here https://sourceware.org/ml/gdb-patches/2013-11/msg00063.html > (get_current_thread): New function, factored out from ... > (add_current_inferior_and_thread): ... this. Adjust. > >@@ -3332,18 +3371,8 @@ add_current_inferior_and_thread (char *wait_status) > > inferior_ptid = null_ptid; > >- /* Now, if we have thread information, update inferior_ptid. First >- if we have a stop reply handy, maybe it's a T stop reply with a >- "thread" register we can extract the current thread from. If >- not, ask the remote which is the current thread, with qC. The >- former method avoids a roundtrip. Note we don't use >- remote_parse_stop_reply as that makes use of the target >- architecture, which we haven't yet fully determined at this >- point. */ >- if (wait_status != NULL) >- ptid = stop_reply_extract_thread (wait_status); >- if (ptid_equal (ptid, null_ptid)) >- ptid = remote_current_thread (inferior_ptid); >+ /* Now, if we have thread information, update inferior_ptid. */ >+ ptid = get_current_thread (wait_status); but after the refactor, local variable ptid is used without initialisation. However, before this change, ptid is initialised to null_ptid. This error can be found by valgrind too... ==3298== at 0x6B99BA: ptid_equal (ptid.c:80) ==3298== by 0x4C67FF: get_current_thread (remote.c:3484) ==3298== by 0x4C6951: add_current_inferior_and_thread (remote.c:3511) ==3298== by 0x4C762C: extended_remote_create_inferior (remote.c:8506) ==3298== by 0x5A5312: run_command_1 (infcmd.c:606) ==3298== by 0x68B4FB: execute_command (top.c:463) ==3298== by 0x5C7214: command_handler (event-top.c:494) ==3298== by 0x5C78A3: command_line_handler (event-top.c:692) ==3298== by 0x6DEB57: rl_callback_read_char (callback.c:220) ==3298== by 0x5C7278: rl_callback_read_char_wrapper (event-top.c:171) ==3298== by 0x5C72C2: stdin_event_handler (event-top.c:432) ==3298== by 0x5C6194: gdb_wait_for_event (event-loop.c:834) This patch initialises local variable ptid to null in get_current_thread. We don't need to initialise ptid in add_current_inferior_and_thread, so this patch also removes the ptid initialisation. gdb: 2015-07-17 Yao Qi <yao.qi@linaro.org> * remote.c (get_current_thread): Initialise ptid to null_ptid. (add_current_inferior_and_thread): Don't initialise ptid.
2015-07-17 13:14:59 +02:00
ptid_t ptid;
inferior_ptid = null_ptid;
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
/* Now, if we have thread information, update inferior_ptid. */
ptid = get_current_thread (wait_status);
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
if (!ptid_equal (ptid, null_ptid))
{
if (!remote_multi_process_p (rs))
fake_pid_p = 1;
inferior_ptid = ptid;
}
else
{
/* Without this, some commands which require an active target
(such as kill) won't work. This variable serves (at least)
double duty as both the pid of the target process (if it has
such), and as a flag indicating that a target is active. */
inferior_ptid = magic_null_ptid;
fake_pid_p = 1;
}
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
remote_add_inferior (fake_pid_p, ptid_get_pid (inferior_ptid), -1, 1);
/* Add the main thread. */
add_thread_silent (inferior_ptid);
}
static void
remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
{
struct remote_state *rs = get_remote_state ();
struct packet_config *noack_config;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
char *wait_status = NULL;
immediate_quit++; /* Allow user to interrupt it. */
QUIT;
if (interrupt_on_connect)
send_interrupt_sequence ();
/* Ack any packet which the remote side has already sent. */
serial_write (rs->remote_desc, "+", 1);
/* Signal other parts that we're going through the initial setup,
and so things may not be stable yet. */
rs->starting_up = 1;
/* The first packet we send to the target is the optional "supported
packets" request. If the target can answer this, it will tell us
which later probes to skip. */
remote_query_supported ();
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
/* If the stub wants to get a QAllow, compose one and send it. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QAllow) != PACKET_DISABLE)
remote_set_permissions (target);
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
/* Next, we possibly activate noack mode.
If the QStartNoAckMode packet configuration is set to AUTO,
enable noack mode if the stub reported a wish for it with
qSupported.
If set to TRUE, then enable noack mode even if the stub didn't
report it in qSupported. If the stub doesn't reply OK, the
session ends with an error.
If FALSE, then don't activate noack mode, regardless of what the
stub claimed should be the default with qSupported. */
noack_config = &remote_protocol_packets[PACKET_QStartNoAckMode];
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_config_support (noack_config) != PACKET_DISABLE)
{
putpkt ("QStartNoAckMode");
getpkt (&rs->buf, &rs->buf_size, 0);
if (packet_ok (rs->buf, noack_config) == PACKET_OK)
rs->noack_mode = 1;
}
if (extended_p)
{
/* Tell the remote that we are using the extended protocol. */
putpkt ("!");
getpkt (&rs->buf, &rs->buf_size, 0);
}
/* Let the target know which signals it is allowed to pass down to
the program. */
update_signals_program_target ();
/* Next, if the target can specify a description, read it. We do
this before anything involving memory or registers. */
target_find_description ();
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
/* Next, now that we know something about the target, update the
address spaces in the program spaces. */
update_address_spaces ();
/* On OSs where the list of libraries is global to all
processes, we fetch them early. */
if (gdbarch_has_global_solist (target_gdbarch ()))
solib_add (NULL, from_tty, target, auto_solib_add);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (non_stop)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QNonStop) != PACKET_ENABLE)
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
error (_("Non-stop mode requested, but remote "
"does not support non-stop"));
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
putpkt ("QNonStop:1");
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") != 0)
error (_("Remote refused setting non-stop mode with: %s"), rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Find about threads and processes the stub is already
controlling. We default to adding them in the running state.
The '?' query below will then tell us about which threads are
stopped. */
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
remote_update_thread_list (target);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
else if (packet_support (PACKET_QNonStop) == PACKET_ENABLE)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
/* Don't assume that the stub can operate in all-stop mode.
Request it explicitly. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
putpkt ("QNonStop:0");
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") != 0)
error (_("Remote refused setting all-stop mode with: %s"), rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* Upload TSVs regardless of whether the target is running or not. The
remote stub, such as GDBserver, may have some predefined or builtin
TSVs, even if the target is not running. */
if (remote_get_trace_status (target, current_trace_status ()) != -1)
{
struct uploaded_tsv *uploaded_tsvs = NULL;
remote_upload_trace_state_variables (target, &uploaded_tsvs);
merge_uploaded_trace_state_variables (&uploaded_tsvs);
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Check whether the target is running now. */
putpkt ("?");
getpkt (&rs->buf, &rs->buf_size, 0);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (!non_stop)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
ptid_t ptid;
int fake_pid_p = 0;
struct inferior *inf;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (rs->buf[0] == 'W' || rs->buf[0] == 'X')
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
if (!extended_p)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
error (_("The target is not running (try extended-remote?)"));
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
/* We're connected, but not running. Drop out before we
call start_remote. */
rs->starting_up = 0;
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
return;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
else
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
/* Save the reply for later. */
wait_status = alloca (strlen (rs->buf) + 1);
strcpy (wait_status, rs->buf);
}
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
/* Fetch thread list. */
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
target_update_thread_list ();
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Let the stub know that we want it to return the thread. */
set_continue_thread (minus_one_ptid);
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
if (thread_count () == 0)
{
/* Target has no concept of threads at all. GDB treats
non-threaded target as single-threaded; add a main
thread. */
add_current_inferior_and_thread (wait_status);
}
else
{
/* We have thread information; select the thread the target
says should be current. If we're reconnecting to a
multi-threaded program, this will ideally be the thread
that last reported an event before GDB disconnected. */
inferior_ptid = get_current_thread (wait_status);
if (ptid_equal (inferior_ptid, null_ptid))
{
/* Odd... The target was able to list threads, but not
tell us which thread was current (no "thread"
register in T stop reply?). Just pick the first
thread in the thread list then. */
remote.c: Make read_ptid return a null value when no thread id is found. When using GDB to debug an RX target using the GDB remote protocol, using a Renesas supplied debug agent, I encountered the following assertion error: thread.c:85: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n Command aborted. This assertion error occurs due to the fact that the value associated with inferior_ptid is not on the thread list. The remote debug output (obtained with "set debug remote 1") is fairly short, so I will include it up to the point where things go wrong - which is somewhat before the assertion failure: (gdb) target remote coyote.lan:61234 Remote debugging using coyote.lan:61234 Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+#c9...Ack Packet received: PacketSize=c00;qXfer:memory-map:read-;qXfer:features:read-;QStartNoAckMode+;multiprocess+;QNonStop+ Packet qSupported (supported-packets) is supported Sending packet: $QStartNoAckMode#b0...Ack Packet received: OK Sending packet: $Hgp0.0#ad...Packet received: OK Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $qTStatus#49...Packet received: Packet qTStatus (trace-status) is NOT supported Sending packet: $?#3f...Packet received: S02 Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Sending packet: $Hc-1#09...Packet received: OK Sending packet: $qC#b4...Packet received: QC not supported Above is the trace starting from the invocation of "target remote" through the call of get_current_thread() in remote_start_remote(). Below, I've pasted this line of code along with additional lines of context. The test following the call is especially important to understanding both the problem and my patch. /* We have thread information; select the thread the target says should be current. If we're reconnecting to a multi-threaded program, this will ideally be the thread that last reported an event before GDB disconnected. */ inferior_ptid = get_current_thread (wait_status); if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } } Prior to getting to the code pasted above, remote_start_remote() made a call to target_update_thread_list(). This corresponds to the following lines from the above trace: Sending packet: $qfThreadInfo#bb...Packet received: m1 Sending packet: $qsThreadInfo#c8...Packet received: l Sending packet: $qAttached:a410#bf...Packet received: 0 Packet qAttached (query-attached) is supported Once target_update_thread_list has completed, the thread list contains a single entry: {pid = 42000, lwp = 1, tid = 0}. remote_start_remote() then makes a call to set_continue_thread(), accounting for this line of the trace: Sending packet: $Hc-1#09...Packet received: OK Finally, the call to get_current_thread() is responsible for the last line of the trace that I provided above: Sending packet: $qC#b4...Packet received: QC not supported get_current_thread() calls stop_reply_extract_thread() with the wait status. This returns null_ptid. get_current_thread() then calls remote_current_thread with a null inferior_ptid. After the calls to putpkt() and getpkt(), rs->buf[0] is 'Q', so read_ptid() is called and its result is returned. The buffer passed to read_ptid() is " not supported". read_ptid ultimately returns a ptid of {pid = 4200, lwp = 0, tid = 0}. However, this thread is not on the thread list. As noted earlier, the call to target_update_thread_list() had placed {pid = 42000, lwp = 1, tid = 0} on the list. This is the only thread in the list. When these calls ultimately return to remote_start_remote(), inferior_ptid gets set to {pid = 4200, lwp = 0, tid = 0}, which (again) is not on the thread list. It appears to me that the string " not supported" is coming from the debug agent. If so, it should be fixed, but I don't see a reason to not consult the thread list in order to place a valid thread id in inferior_ptid. This (consultation of the thread list) is what is done when inferior_ptid is null_ptid: if (ptid_equal (inferior_ptid, null_ptid)) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" register in T stop reply?). Just pick the first thread in the thread list then. */ inferior_ptid = thread_list->ptid; } My patch causes a null inferior_ptid to be returned by read_ptid when no thread id is found in the response from the debug agent. This return value ends up being returned by remote_current_thread() and then by get_current_thread. The assignment then places this null value into inferior_ptid. That, in turn, allows the ptid_equal test (noted above) to fetch a valid thread from the thread list. I no longer see the assertion failure due a good value (which is on the thread list) being placed in inferior_ptid. This patch also adds two log warnings that may be output when "set debug remote 1" is used. When running against the Renesas debug agent mentioned earlier, this is the relevant portion of the log output: Sending packet: $qC#b4...Packet received: QC not supported warning: garbage in qC reply warning: couldn't determine remote current thread; picking first in list. gdb/ChangeLog: * remote.c (read_ptid): Return null_ptid when no thread id is found. (remote_current_thread): Add log warning for malformed qC reply. (remote_start_remote): Add log warning when current thread not found.
2015-07-10 19:25:29 +02:00
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"warning: couldn't determine remote "
"current thread; picking first in list.\n");
[remote/gdbserver] Don't lose signals when reconnecting. Currently, when GDB connects in all-stop mode, GDBserver always responds to the status packet with a GDB_SIGNAL_TRAP, even if the program is actually stopped for some other signal. (gdb) tar rem ... ... (gdb) c Program received signal SIGUSR1, User defined signal 1. (gdb) disconnect (gdb) tar rem ... (gdb) c (Or a GDB crash instead of an explicit disconnect.) This results in the program losing that signal on that last continue, because gdb will tell the target to resume with no signal (to suppress the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will actually suppress the real signal the program had stopped for (SIGUSR1). To fix that, I think we should make GDBserver report the real signal the thread had stopped for in response to the status packet: @item ? @cindex @samp{?} packet Indicate the reason the target halted. The reply is the same as for step and continue. But, that raises the question -- which thread are we reporting the status for? Due to how the RSP in all-stop works, we can only report one status. The status packet's response is a stop reply packet, so it includes the thread identifier, so it's not a problem packet-wise. However, GDBserver is currently always reporting the status for first thread in the thread list, even though that may well not be the thread that got the signal that caused the program to stop. So the next logical step would be to report the status for the last_ptid/last_status thread (the last event reported to gdb), if it's still around; and if not, fallback to some other thread. There's an issue on the GDB side with that, though... GDB currently always adds the thread reported in response to the status query as the first thread in its list. That means that if we start with e.g., (gdb) info threads 3 Thread 1003 ... * 2 Thread 1002 ... 1 Thread 1001 ... And reconnect: (gdb) disconnect (gdb) tar rem ... We end up with: (gdb) info threads 3 Thread 1003 ... 2 Thread 1001 ... * 1 Thread 1002 ... Not a real big issue, but it's reasonably fixable, by having GDB fetch/sync the thread list before fetching the status/'?', and then using the status to select the right thread as current on the GDB side. Holes in the thread numbers are squashed before/after reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved, which I think is both good, and good enough. However (yes, there's more...), the previous GDB that was connected might have had gdbserver running in non-stop mode, or could have left gdbserver doing disconnected tracing (which also forces non-stop), and if the new gdb/connection is in all-stop mode, we can end up with more than one thread with a signal to report back to gdb. As we can only report one thread/status (in the all-stop RSP variant; the non-stop variant doesn't have this issue), we get to do what we do at every other place we have this situation -- leave events we can't report right now as pending, so that the next resume picks them up. Note all this ammounts to a QoI change, within the existing framework. There's really no RSP change here. The only user visible change (other than that the signal is program is stopped at isn't lost / is passed to the program), is in "info program", that now can show the signal the program stopped for. Of course, the next resume will respect the pass/nopass setting for the signal in question. It'd be reasonable to have the initial connection tell the user the program was stopped with a signal, similar to when we load a core to debug, but I'm leaving that out for a future change. I think we'll need to either change how handle_inferior_event & co handle stop_soon, or maybe bypass them completely (like fork-child.c:startup_inferior) for that. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_info) <status_pending_p>: New field. * server.c (visit_actioned_threads, handle_pending_status): New function. (handle_v_cont): Factor out parts to ... (resume): ... this new function. If in all-stop, and a thread being resumed has a pending status, report it without actually resuming. (myresume): Adjust to use the new 'resume' function. (clear_pending_status_callback, set_pending_status_callback) (find_status_pending_thread_callback): New functions. (handle_status): Handle the case of multiple threads having interesting statuses to report. Report threads' real last signal instead of always reporting GDB_SIGNAL_TRAP. Look for a thread with an interesting thread to report the status for, instead of always reporting the status of the first thread. gdb/ 2014-01-08 Pedro Alves <palves@redhat.com> * remote.c (remote_add_thread): Add threads silently if starting up. (remote_notice_new_inferior): If in all-stop, and starting up, don't call notice_new_inferior. (get_current_thread): New function, factored out from ... (add_current_inferior_and_thread): ... this. Adjust. (remote_start_remote) <all-stop>: Fetch the thread list. If we found any thread, then select the remote's current thread as GDB's current thread too. gdb/testsuite/ 2014-01-08 Pedro Alves <palves@redhat.com> * gdb.threads/reconnect-signal.c: New file. * gdb.threads/reconnect-signal.exp: New file.
2014-01-08 19:55:51 +01:00
inferior_ptid = thread_list->ptid;
}
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* init_wait_for_inferior should be called before get_offsets in order
to manage `inserted' flag in bp loc in a correct state.
breakpoint_init_inferior, called from init_wait_for_inferior, set
`inserted' flag to 0, while before breakpoint_re_set, called from
start_remote, set `inserted' flag to 1. In the initialization of
inferior, breakpoint_init_inferior should be called first, and then
breakpoint_re_set can be called. If this order is broken, state of
`inserted' flag is wrong, and cause some problems on breakpoint
manipulation. */
init_wait_for_inferior ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
get_offsets (); /* Get text, data & bss offsets. */
/* If we could not find a description using qXfer, and we know
how to do it some other way, try again. This is not
supported for non-stop; it could be, but it is tricky if
there are no stopped threads when we connect. */
if (remote_read_description_p (target)
&& gdbarch_target_desc (target_gdbarch ()) == NULL)
{
target_clear_description ();
target_find_description ();
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Use the previously fetched status. */
gdb_assert (wait_status != NULL);
strcpy (rs->buf, wait_status);
rs->cached_wait_status = 1;
immediate_quit--;
start_remote (from_tty); /* Initialize gdb process mechanisms. */
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
else
{
/* Clear WFI global state. Do this before finding about new
threads and inferiors, and setting the current inferior.
Otherwise we would clear the proceed status of the current
inferior when we want its stop_soon state to be preserved
(see notice_new_inferior). */
init_wait_for_inferior ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* In non-stop, we will either get an "OK", meaning that there
are no stopped threads at this time; or, a regular stop
reply. In the latter case, there may be more than one thread
stopped --- we pull them all out using the vStopped
mechanism. */
if (strcmp (rs->buf, "OK") != 0)
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct notif_client *notif = &notif_client_stop;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* remote_notif_get_pending_replies acks this one, and gets
the rest out. */
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
rs->notif_state->pending_event[notif_client_stop.id]
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
= remote_notif_parse (notif, rs->buf);
remote_notif_get_pending_events (notif);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Make sure that threads that were stopped remain
stopped. */
iterate_over_threads (set_stop_requested_callback, NULL);
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (target_can_async_p ())
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
target_async (1);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (thread_count () == 0)
{
if (!extended_p)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
error (_("The target is not running (try extended-remote?)"));
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
/* We're connected, but not running. Drop out before we
call start_remote. */
rs->starting_up = 0;
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
return;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Let the stub know that we want it to return the thread. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Force the stub to choose a thread. */
set_general_thread (null_ptid);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Query it. */
inferior_ptid = remote_current_thread (minus_one_ptid);
if (ptid_equal (inferior_ptid, minus_one_ptid))
error (_("remote didn't report the current thread in non-stop mode"));
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
get_offsets (); /* Get text, data & bss offsets. */
/* In non-stop mode, any cached wait status will be stored in
the stop reply queue. */
gdb_assert (wait_status == NULL);
* target.h (struct target_ops): Remove to_notice_signals; add to_pass_signals. (target_notice_signals): Remove. (target_pass_signals): Add prototype. * target.c (update_current_target): Remove to_notice_signals; mention to_pass_signals. (target_pass_signals): New function. (debug_to_notice_signals): Remove. (setup_target_debug): Do not install debug_to_notice_signals. * infrun.c (signal_pass): New global. (resume): Call target_pass_signals. (handle_inferior_event): Report all signals while stepping over non-steppable watchpoint. Reset trap_expected to ensure breakpoints are re-inserted when stepping over a signal handler. (signal_cache_update): New function. (signal_stop_update): Call it. (signal_print_update): Likewise. (signal_pass_update): Likewise. (handle_command): Call signal_cache_update and target_pass_signals instead of target_notice_signals. (_initialize_infrun): Initialize signal_pass. * linux-nat.c (pass_mask): New global. (linux_nat_pass_signals): New function. (linux_nat_create_inferior): Report all signals initially. (linux_nat_attach): Likewise. (linux_nat_resume): Use pass_mask to decide whether to directly handle an inferior signal. (linux_nat_wait_1): Likewise. (linux_nat_add_target): Install to_pass_signals callback. * nto-procfs.c (notice_signals): Remove. (procfs_resume): Do not call notice_signals. (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (init_procfs_ops): Install to_pass_signals callback instead of to_notice_signals callback. (_initialize_procfs): Report all signals initially. * procfs.c (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (procfs_target): Install to_pass_signals callback instead of to_notice_signals callback. (register_gdb_signals): Remove. (procfs_debug_inferior): Report all signals initially. (procfs_init_inferior): Remove redundant register_gdb_signals call. * remote.c (remote_pass_signals): Add numsigs and pass_signals parameters; use them instead of calling signal_..._state routines. (remote_notice_signals): Remove. (remote_start_remote): Report all signals initially. (remote_resume): Do not call remote_pass_signals. (_initialize_remote): Install to_pass_signals callback instead of to_notice_signals callback.
2011-04-27 15:29:15 +02:00
/* Report all signals during attach/startup. */
remote_pass_signals (target, 0, NULL);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* If we connected to a live target, do some additional setup. */
if (target_has_execution)
{
if (symfile_objfile) /* No use without a symbol-file. */
remote_check_symbols ();
}
2010-01-06 21:31:28 +01:00
/* Possibly the target has been engaged in a trace run started
previously; find out where things are at. */
if (remote_get_trace_status (target, current_trace_status ()) != -1)
2010-01-06 21:31:28 +01:00
{
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
struct uploaded_tp *uploaded_tps = NULL;
if (current_trace_status ()->running)
printf_filtered (_("Trace is already running on the target.\n"));
remote_upload_tracepoints (target, &uploaded_tps);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
merge_uploaded_tracepoints (&uploaded_tps);
2010-01-06 21:31:28 +01:00
}
/* The thread and inferior lists are now synchronized with the
target, our symbols have been relocated, and we're merged the
target's tracepoints with ours. We're done with basic start
up. */
rs->starting_up = 0;
Fix "breakpoint always-inserted off"; remove "breakpoint always-inserted auto" By default, GDB removes all breakpoints from the target when the target stops and the prompt is given back to the user. This is useful in case GDB crashes while the user is interacting, as otherwise, there's a higher chance breakpoints would be left planted on the target. But, as long as any thread is running free, we need to make sure to keep breakpoints inserted, lest a thread misses a breakpoint. With that in mind, in preparation for non-stop mode, we added a "breakpoint always-inserted on" mode. This traded off the extra crash protection for never having threads miss breakpoints, and in addition is more efficient if there's a ton of breakpoints to remove/insert at each user command (e.g., at each "step"). When we added non-stop mode, and for a period, we required users to manually set "always-inserted on" when they enabled non-stop mode, as otherwise GDB removes all breakpoints from the target as soon as any thread stops, which means the other threads still running will miss breakpoints. The test added by this patch exercises this. That soon revealed a nuisance, and so later we added an extra "breakpoint always-inserted auto" mode, that made GDB behave like "always-inserted on" when non-stop was enabled, and "always-inserted off" when non-stop was disabled. "auto" was made the default at the same time. In hindsight, this "auto" setting was unnecessary, and not the ideal solution. Non-stop mode does depends on breakpoints always-inserted mode, but only as long as any thread is running. If no thread is running, no breakpoint can be missed. The same is true for all-stop too. E.g., if, in all-stop mode, and the user does: (gdb) c& (gdb) b foo That breakpoint at "foo" should be inserted immediately, but it currently isn't -- currently it'll end up inserted only if the target happens to trip on some event, and is re-resumed, e.g., an internal breakpoint triggers that doesn't cause a user-visible stop, and so we end up in keep_going calling insert_breakpoints. The test added by this patch also covers this. IOW, no matter whether in non-stop or all-stop, if the target fully stops, we can remove breakpoints. And no matter whether in all-stop or non-stop, if any thread is running in the target, then we need breakpoints to be immediately inserted. And then, if the target has global breakpoints, we need to keep breakpoints even when the target is stopped. So with that in mind, and aiming at reducing all-stop vs non-stop differences for all-stop-on-stop-of-non-stop, this patch fixes "breakpoint always-inserted off" to not remove breakpoints from the target until it fully stops, and then removes the "auto" setting as unnecessary. I propose removing it straight away rather than keeping it as an alias, unless someone complains they have scripts that need it and that can't adjust. Tested on x86_64 Fedora 20. gdb/ 2014-09-22 Pedro Alves <palves@redhat.com> * NEWS: Mention merge of "breakpoint always-inserted" modes "off" and "auto" merged. * breakpoint.c (enum ugll_insert_mode): New enum. (always_inserted_mode): Now a plain boolean. (show_always_inserted_mode): No longer handle AUTO_BOOLEAN_AUTO. (breakpoints_always_inserted_mode): Delete. (breakpoints_should_be_inserted_now): New function. (insert_breakpoints): Pass UGLL_INSERT to update_global_location_list instead of calling insert_breakpoint_locations manually. (create_solib_event_breakpoint_1): New, factored out from ... (create_solib_event_breakpoint): ... this. (create_and_insert_solib_event_breakpoint): Use create_solib_event_breakpoint_1 instead of calling insert_breakpoint_locations manually. (update_global_location_list): Change parameter type from boolean to enum ugll_insert_mode. All callers adjusted. Adjust to use breakpoints_should_be_inserted_now and handle UGLL_INSERT. (update_global_location_list_nothrow): Change parameter type from boolean to enum ugll_insert_mode. (_initialize_breakpoint): "breakpoint always-inserted" option is now a boolean command. Update help text. * breakpoint.h (breakpoints_always_inserted_mode): Delete declaration. (breakpoints_should_be_inserted_now): New declaration. * infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>: Remove breakpoints_always_inserted_mode check. (normal_stop): Adjust to use breakpoints_should_be_inserted_now. * remote.c (remote_start_remote): Likewise. gdb/doc/ 2014-09-22 Pedro Alves <palves@redhat.com> * gdb.texinfo (Set Breaks): Document that "set breakpoint always-inserted off" is the default mode now. Delete documentation of "set breakpoint always-inserted auto". gdb/testsuite/ 2014-09-22 Pedro Alves <palves@redhat.com> * gdb.threads/break-while-running.exp: New file. * gdb.threads/break-while-running.c: New file.
2014-09-22 10:56:55 +02:00
/* Maybe breakpoints are global and need to be inserted now. */
if (breakpoints_should_be_inserted_now ())
insert_breakpoints ();
}
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
static void
remote_open (const char *name, int from_tty)
{
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
remote_open_1 (name, from_tty, &remote_ops, 0);
1999-07-05 19:58:44 +02:00
}
/* Open a connection to a remote debugger using the extended
remote gdb protocol. NAME is the filename used for communication. */
static void
extended_remote_open (const char *name, int from_tty)
{
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */);
1999-07-05 19:58:44 +02:00
}
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
/* Reset all packets back to "unknown support". Called when opening a
new connection to a remote target. */
static void
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
reset_all_packet_configs_support (void)
{
int i;
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
for (i = 0; i < PACKET_MAX; i++)
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
}
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
/* Initialize all packet configs. */
static void
init_all_packet_configs (void)
{
int i;
for (i = 0; i < PACKET_MAX; i++)
{
remote_protocol_packets[i].detect = AUTO_BOOLEAN_AUTO;
remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
}
}
/* Symbol look-up. */
static void
remote_check_symbols (void)
{
struct remote_state *rs = get_remote_state ();
char *msg, *reply, *tmp;
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol sym;
int end;
/* The remote side has no concept of inferiors that aren't running
yet, it only knows about running processes. If we're connected
but our current inferior is not running, we should not invite the
remote target to request symbol lookups related to its
(unrelated) current process. */
if (!target_has_execution)
return;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qSymbol) == PACKET_DISABLE)
return;
/* Make sure the remote is pointing at the right process. Note
there's no way to select "no process". */
set_general_process ();
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Allocate a message buffer. We can't reuse the input buffer in RS,
because we need both at the same time. */
msg = alloca (get_remote_packet_size ());
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Invite target to request symbol lookups. */
putpkt ("qSymbol::");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSymbol]);
reply = rs->buf;
while (startswith (reply, "qSymbol:"))
{
start change to progspace independence This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) <find_pc_sect_symtab>: Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update.
2013-08-15 16:46:35 +02:00
struct bound_minimal_symbol sym;
tmp = &reply[8];
end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2);
msg[end] = '\0';
sym = lookup_minimal_symbol (msg, NULL, NULL);
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
if (sym.minsym == NULL)
xsnprintf (msg, get_remote_packet_size (), "qSymbol::%s", &reply[8]);
else
{
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
start change to progspace independence This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) <find_pc_sect_symtab>: Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update.
2013-08-15 16:46:35 +02:00
CORE_ADDR sym_addr = BMSYMBOL_VALUE_ADDRESS (sym);
/* If this is a function address, return the start of code
instead of any data function descriptor. */
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
&current_target);
xsnprintf (msg, get_remote_packet_size (), "qSymbol:%s:%s",
* defs.h (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter. * utils.c (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter, use it instead of current_gdbarch. * ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter. * ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter, use it instead of current_gdbarch. Update calls to ui_out_field_core_addr to pass architecture: * ada-lang.c (print_one_exception): Update. * breakpoint.c (print_one_breakpoint_location, print_one_exception_catchpoint): Update. * disasm.c (dump_insns): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * mi/mi-main.c (mi_cmd_data_read_memory): Update. * mi/mi-symbol-cmds.c: Include "objfiles.h". (mi_cmd_symbol_list_lines): Update. * stack.c (print_frame_info, print_frame): Update. Update callers of paddress to pass architecture: * ada-tasks.c (info_task): Update. * ada-valprint.c (ada_val_print_1): Update. * annotate.c (annotate_source, annotate_frame_begin): Update. * breakpoint.c (insert_bp_location, describe_other_breakpoints, mention): Update. * cli/cli-cmds.c (edit_command, list_command, print_disassembly): Update. * corefile.c (memory_error): Update. * c-valprint.c (print_function_pointer_address, c_val_print): Update. * disasm.c (dis_asm_print_address): Update. * exec.c (print_section_info): Update. * f-valprint.c (f_val_print): Update. * infcmd.c: Include "arch-utils.h". (jump_command, program_info): Update. * linux-fork.c: Include "arch-utils.h". (info_forks_command): Update. * m2-valprint.c (print_function_pointer_address, print_unpacked_pointer, print_variable_at_address, m2_val_print): Update. * m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command): Update. * printcmd.c (print_address, print_address_demangle, address_info): Update. * p-valprint.c (pascal_val_print): Update. * source.c: Include "arch-utils.h". (line_info): Update. * stack.c (frame_info, print_block_frame_labels): Update. * symfile.c (add_symbol_file_command, list_overlays_command): Update. * symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1, print_symbol, print_partial_symbols, maintenance_info_psymtabs, maintenance_check_symtabs): Update. * symtab.c (find_pc_sect_symtab): Update. * target.c (deprecated_debug_xfer_memory): Update. * tracepoint.c (scope_info): Update. * tui/tui-stack.c (tui_make_status_line): Update. * valprint.c (val_print_string): Update. Update callers of paddr_nz to use paddress instead (keeping user-visible output identical): * alpha-tdep.c (alpha_heuristic_proc_start): Update. * amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn, amd64_displaced_step_fixup): Update. * arch-utils.c (simple_displaced_step_copy_insn): Update. * auxv.c (fprint_target_auxv): Update. * breakpoint.c (insert_single_step_breakpoint): Update. * buildsym.c (finish_block): Update. * cli/cli-dump.c (restore_section_callback): Update. * fbsd-nat.c (fbsd_find_memory_regions): Update. * frame.c (frame_unwind_register_value): Update. * gcore.c (gcore_create_callback): Update. * hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm, i386_process_record): Update. * ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id, ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id, ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update. * infrun.c (displaced_step_prepare, displaced_step_fixup, handle_inferior_event, insert_step_resume_breakpoint_at_sal, insert_longjmp_resume_breakpoint): Update. * linux-nat.c (linux_nat_find_memory_regions): Update. * linux-record.c (record_linux_system_call): Update. * mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call): Update. * monitor.c (monitor_error, monitor_remove_breakpoint): Update. * record.c (record_arch_list_add_mem, record_wait, record_xfer_partial): Update. * remote-mips.c (mips_fetch_word, mips_check_lsi_error, mips_common_breakpoint): Update. * remote-sim.c (gdbsim_xfer_inferior_memory): Update. * rs6000-tdep.c (ppc_displaced_step_fixup): Update. * solib-som.c (som_current_sos): Update. * symfile.c (load_progress, generic_load): Update. * symfile-mem.c (add_vsyscall_page): Update. * valops.c (value_fetch_lazy): Update. * windows-tdep.c (windows_xfer_shared_library): Update. Update callers of paddr_nz to use paddress instead (changing user-visible output to make it more correct): * dwarf2loc.c (locexpr_describe_location): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint, ia64_memory_remove_breakpoint): Update. * jv-valprint.c (java_value_print): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. * monitor.c (monitor_read_memory): Update. Update callers of paddr to use paddress instead (changing user-visible output to make it more correct): * arm-tdep.c (arm_push_dummy_call): Update. * breakpoint.c (insert_bp_location, create_thread_event_breakpoint, create_breakpoint): Update. * darwin-nat-info.c (darwin_debug_regions): Update. * dcache.c (dcache_info): Update. * dsrec.c (load_srec, make_srec): Update. * dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program, dwarf2_frame_cache): Update. * gcore.c (gcore_copy_callback): Update. * gnu-nat.c (gnu_xfer_memory): Update. * mips-linux-nat.c (mips_show_dr): Update. * monitor.c (monitor_write_memory, monitor_insert_breakpoint, monitor_remove_breakpoint): Update. * remote.c (compare_sections_command): Update. * remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint, m32r_remove_breakpoint, m32r_insert_watchpoint, m32r_remove_watchpoint): Update. * sol-thread.c (info_cb): Update. * symfile.c (load_progress): Update. Update callers of paddress or paddr_nz to use hex_string instead (changes output of internal/error/debug messages only): * dwarf2read.c (dump_die_shallow): Update. * frame.c (fprint_field, fprint_frame, frame_pc_unwind, get_frame_func, create_new_frame): Update. * hppa-tdep.c (find_unwind_entry, unwind_command): Update. * ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x, ia64_get_dyn_info_list): Update. * maint.c (maintenance_translate_address): Update. * mi/mi-cmd-var.c (mi_cmd_var_create): Update. * target.c (target_flash_erase): Update. Update callers of paddr/paddr_nz to use phex/phex_nz instead, using an appropriate address size. Remove use of strlen_paddr. * exec.c (exec_files_info): Update. * i386-nat.c (i386_show_dr): Update. * remote.c (remote_flash_erase): Update. * m32r-rom.c (m32r_load_section): Update. * monitor.c (monitor_vsprintf, monitor_store_register): Update. * remote.c (remote_check_symbols, remote_search_memory): Update. * remote-mips.c (mips_request, mips_common_breakpoint): Update. * scm-valprint.c (scm_ipruk, scm_scmval_print): Update. * sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs, sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs, sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs, sh_dsp_show_regs): Update. * xcoffsolib.c (sharedlibrary_command): Update. * maint.c (maint_print_section_info): Add ADDR_SIZE parameter. Use hex_string_custom instead of paddr. (print_bfd_section_info): Pass address size. (print_objfile_section_info): Likewise. * annotate.h (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * annotate.c (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * source.c (identify_source_line): Update call to annotate_source. * stack.c (print_frame_info, print_frame): Update call to annotate_frame_begin. * breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter. (create_breakpoint, create_ada_exception_breakpoint): Update call. * stack.c (print_block_frame_labels): Add GDBARCH parameter. (print_frame_label_vars): Update call. * symmisc.c (print_partial_symbols): Add GDBARCH parameter. (dump_psymtab): Update call to print_partial_symbols. (struct print_symbol_args): Add GDBARCH member. (dump_symtab_1): Set print_symbol_args architecture member. (print_symbol): Use it. * windows-tdep.h (windows_xfer_shared_library): Add GDBARCH parameter. * windows-tdep.c (windows_xfer_shared_library): Likewise. * i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member. (core_process_module_section): Pass architecture from cpms_data to windows_xfer_shared_library. (windows_core_xfer_shared_libraries): Initialize cmps_data architecture member. * windows-nat.c (windows_xfer_shared_libraries): Pass architecture to windows_xfer_shared_library. * defs.h (print_address): Add GDBARCH parameter. * printcmd.c (print_address): Add GDBARCH parameter. (print_scalar_formatted, do_examine): Update call. * findcmd.c (find_command): Update call. * tracepoint.c: Include "arch-utils.h". (trace_find_line_command): Update call. * tui/tui-disasm.c (tui_disassemble): Update call. * value.h (print_address_demangle): Add GDBARCH parameter. * printcmd.c (print_address_demangle): Add GDBARCH parameter. * c-valprint.c (print_function_pointer_address, c_val_print): Update call. * f-valprint.c (f_val_print): Update call. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update call. * jv-valprint.c (java_val_print): Update call. * m2-valprint.c (print_function_pointer_address, m2_val_print): Update call. * p-valprint.c (pascal_val_print): Update call. * disasm.c (gdb_disassemble_info): Install architecture into di.application_data field. testsuite/ChangeLog: * gdb.threads/tls-shared.exp: Update to locexpr_describe_location change to prefix TLS offset in hex with 0x. doc/ChangeLog: * gdbint.texinfo (Item Output Functions): Update signature for ui_out_field_core_addr.
2009-07-02 19:21:10 +02:00
phex_nz (sym_addr, addr_size), &reply[8]);
}
putpkt (msg);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
reply = rs->buf;
}
}
static struct serial *
remote_serial_open (const char *name)
{
static int udp_warning = 0;
/* FIXME: Parsing NAME here is a hack. But we want to warn here instead
of in ser-tcp.c, because it is the remote protocol assuming that the
serial connection is reliable and not the serial connection promising
to be. */
if (!udp_warning && startswith (name, "udp:"))
{
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
warning (_("The remote protocol may be unreliable over UDP.\n"
"Some events may be lost, rendering further debugging "
"impossible."));
udp_warning = 1;
}
return serial_open (name);
}
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
/* Inform the target of our permission settings. The permission flags
work without this, but if the target knows the settings, it can do
a couple things. First, it can add its own check, to catch cases
that somehow manage to get by the permissions checks in target
methods. Second, if the target is wired to disallow particular
settings (for instance, a system in the field that is not set up to
be able to stop at a breakpoint), it can object to any unavailable
permissions. */
void
remote_set_permissions (struct target_ops *self)
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
{
struct remote_state *rs = get_remote_state ();
xsnprintf (rs->buf, get_remote_packet_size (), "QAllow:"
"WriteReg:%x;WriteMem:%x;"
"InsertBreak:%x;InsertTrace:%x;"
"InsertFastTrace:%x;Stop:%x",
may_write_registers, may_write_memory,
may_insert_breakpoints, may_insert_tracepoints,
may_insert_fast_tracepoints, may_stop);
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
/* If the target didn't like the packet, warn the user. Do not try
to undo the user's settings, that would just be maddening. */
if (strcmp (rs->buf, "OK") != 0)
warning (_("Remote refused setting permissions with: %s"), rs->buf);
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
}
/* This type describes each known response to the qSupported
packet. */
struct protocol_feature
{
/* The name of this protocol feature. */
const char *name;
/* The default for this protocol feature. */
enum packet_support default_support;
/* The function to call when this feature is reported, or after
qSupported processing if the feature is not supported.
The first argument points to this structure. The second
argument indicates whether the packet requested support be
enabled, disabled, or probed (or the default, if this function
is being called at the end of processing and this feature was
not reported). The third argument may be NULL; if not NULL, it
is a NUL-terminated string taken from the packet following
this feature's name and an equals sign. */
void (*func) (const struct protocol_feature *, enum packet_support,
const char *);
/* The corresponding packet for this feature. Only used if
FUNC is remote_supported_packet. */
int packet;
};
static void
remote_supported_packet (const struct protocol_feature *feature,
enum packet_support support,
const char *argument)
{
if (argument)
{
warning (_("Remote qSupported response supplied an unexpected value for"
" \"%s\"."), feature->name);
return;
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
remote_protocol_packets[feature->packet].support = support;
}
static void
remote_packet_size (const struct protocol_feature *feature,
enum packet_support support, const char *value)
{
struct remote_state *rs = get_remote_state ();
int packet_size;
char *value_end;
if (support != PACKET_ENABLE)
return;
if (value == NULL || *value == '\0')
{
warning (_("Remote target reported \"%s\" without a size."),
feature->name);
return;
}
errno = 0;
packet_size = strtol (value, &value_end, 16);
if (errno != 0 || *value_end != '\0' || packet_size < 0)
{
warning (_("Remote target reported \"%s\" with a bad size: \"%s\"."),
feature->name, value);
return;
}
if (packet_size > MAX_REMOTE_PACKET_SIZE)
{
warning (_("limiting remote suggested packet size (%d bytes) to %d"),
packet_size, MAX_REMOTE_PACKET_SIZE);
packet_size = MAX_REMOTE_PACKET_SIZE;
}
/* Record the new maximum packet size. */
rs->explicit_packet_size = packet_size;
}
static const struct protocol_feature remote_protocol_features[] = {
{ "PacketSize", PACKET_DISABLE, remote_packet_size, -1 },
{ "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet,
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
PACKET_qXfer_auxv },
{ "qXfer:exec-file:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_exec_file },
XML feature description support. * NEWS: Mention target descriptions, "set tdesc filename", "unset tdesc filename", "show tdesc filename", and qXfer:features:read. * arch-utils.c (choose_architecture_for_target): New function. (gdbarch_info_fill): Call it. * target-descriptions.c (struct property): Make members non-const. (struct target_desc): Add arch member. (target_description_filename): New variable. (target_find_description): Try via XML first. (tdesc_architecture): New. (free_target_description, make_cleanup_free_target_description): New. (set_tdesc_property): Call xstrdup. (set_tdesc_architecture, tdesc_set_cmdlist, tdesc_show_cmdlist) (tdesc_unset_cmdlist, unset_tdesc_cmd, unset_tdesc_filename_cmd) (set_tdesc_cmd, show_tdesc_cmd, set_tdesc_filename_cmd) (show_tdesc_filename_cmd, _initialize_target_descriptions): New. * target-descriptions.h (tdesc_architecture) (make_cleanup_free_target_description, set_tdesc_architecture): New prototypes. * Makefile.in (SFILES): Add xml-tdesc.c. (COMMON_OBS): Add xml-tdesc.o. (target-descriptions.o): Update. (xml-tdesc.o): New rule. * xml-tdesc.c, xml-tdesc.h: New files. * remote.c (PACKET_qXfer_features): New enum. (remote_protocol_features): Add qXfer:features:read. (remote_xfer_partial): Handle TARGET_OBJECT_AVAILABLE_FEATURES. (_initialize_remote): Register qXfer:features:read. * target.h (enum target_object): Add TARGET_OBJECT_AVAILABLE_FEATURES. * features/gdb-target.dtd: New file. * linux-i386-low.c (the_low_target): Set arch_string. * linux-x86-64-low.c (the_low_target): Likewise. * linux-low.c (linux_arch_string): New. (linux_target_ops): Add it. * linux-low.h (struct linux_target_ops): Add arch_string. * server.c (write_qxfer_response): Use const void * for DATA. (get_features_xml): New. (handle_query): Handle qXfer:features:read. Report it for qSupported. * target.h (struct target_ops): Add arch_string method. * gdb.texinfo (Target Descriptions): New section. (General Query Packets): Add QPassSignals anchor. Mention qXfer:features:read under qSupported. Expand mentions of qXfer:memory-map:read and QPassSignals. Document qXfer:features:read.
2007-01-09 23:55:10 +01:00
{ "qXfer:features:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_features },
{ "qXfer:libraries:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_libraries },
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{ "qXfer:libraries-svr4:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_libraries_svr4 },
{ "augmented-libraries-svr4-read", PACKET_DISABLE,
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
remote_supported_packet, PACKET_augmented_libraries_svr4_read_feature },
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
{ "qXfer:memory-map:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_memory_map },
{ "qXfer:spu:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_spu_read },
{ "qXfer:spu:write", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_spu_write },
{ "qXfer:osdata:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_osdata },
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
{ "qXfer:threads:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_threads },
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
{ "qXfer:traceframe-info:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_traceframe_info },
{ "QPassSignals", PACKET_DISABLE, remote_supported_packet,
PACKET_QPassSignals },
{ "QProgramSignals", PACKET_DISABLE, remote_supported_packet,
PACKET_QProgramSignals },
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
{ "QStartNoAckMode", PACKET_DISABLE, remote_supported_packet,
PACKET_QStartNoAckMode },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "multiprocess", PACKET_DISABLE, remote_supported_packet,
PACKET_multiprocess_feature },
{ "QNonStop", PACKET_DISABLE, remote_supported_packet, PACKET_QNonStop },
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
{ "qXfer:siginfo:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_siginfo_read },
{ "qXfer:siginfo:write", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_siginfo_write },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "ConditionalTracepoints", PACKET_DISABLE, remote_supported_packet,
PACKET_ConditionalTracepoints },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "ConditionalBreakpoints", PACKET_DISABLE, remote_supported_packet,
PACKET_ConditionalBreakpoints },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "BreakpointCommands", PACKET_DISABLE, remote_supported_packet,
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
PACKET_BreakpointCommands },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "FastTracepoints", PACKET_DISABLE, remote_supported_packet,
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
PACKET_FastTracepoints },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "StaticTracepoints", PACKET_DISABLE, remote_supported_packet,
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
PACKET_StaticTracepoints },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{"InstallInTrace", PACKET_DISABLE, remote_supported_packet,
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
PACKET_InstallInTrace},
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "DisconnectedTracing", PACKET_DISABLE, remote_supported_packet,
PACKET_DisconnectedTracing_feature },
{ "ReverseContinue", PACKET_DISABLE, remote_supported_packet,
PACKET_bc },
{ "ReverseStep", PACKET_DISABLE, remote_supported_packet,
PACKET_bs },
{ "TracepointSource", PACKET_DISABLE, remote_supported_packet,
PACKET_TracepointSource },
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
{ "QAllow", PACKET_DISABLE, remote_supported_packet,
PACKET_QAllow },
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "EnableDisableTracepoints", PACKET_DISABLE, remote_supported_packet,
PACKET_EnableDisableTracepoints_feature },
{ "qXfer:fdpic:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_fdpic },
{ "qXfer:uib:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_uib },
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
{ "QDisableRandomization", PACKET_DISABLE, remote_supported_packet,
PACKET_QDisableRandomization },
{ "QAgent", PACKET_DISABLE, remote_supported_packet, PACKET_QAgent},
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
{ "QTBuffer:size", PACKET_DISABLE,
remote_supported_packet, PACKET_QTBuffer_size},
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
{ "tracenz", PACKET_DISABLE, remote_supported_packet, PACKET_tracenz_feature },
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{ "Qbtrace:off", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_off },
{ "Qbtrace:bts", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_bts },
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
{ "Qbtrace:pt", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_pt },
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{ "qXfer:btrace:read", PACKET_DISABLE, remote_supported_packet,
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
PACKET_qXfer_btrace },
{ "qXfer:btrace-conf:read", PACKET_DISABLE, remote_supported_packet,
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
PACKET_qXfer_btrace_conf },
{ "Qbtrace-conf:bts:size", PACKET_DISABLE, remote_supported_packet,
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
PACKET_Qbtrace_conf_bts_size },
{ "swbreak", PACKET_DISABLE, remote_supported_packet, PACKET_swbreak_feature },
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
{ "hwbreak", PACKET_DISABLE, remote_supported_packet, PACKET_hwbreak_feature },
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
{ "fork-events", PACKET_DISABLE, remote_supported_packet,
PACKET_fork_event_feature },
{ "vfork-events", PACKET_DISABLE, remote_supported_packet,
PACKET_vfork_event_feature },
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
{ "Qbtrace-conf:pt:size", PACKET_DISABLE, remote_supported_packet,
PACKET_Qbtrace_conf_pt_size }
};
static char *remote_support_xml;
/* Register string appended to "xmlRegisters=" in qSupported query. */
void
register_remote_support_xml (const char *xml)
{
#if defined(HAVE_LIBEXPAT)
if (remote_support_xml == NULL)
remote_support_xml = concat ("xmlRegisters=", xml, (char *) NULL);
else
{
char *copy = xstrdup (remote_support_xml + 13);
char *p = strtok (copy, ",");
do
{
if (strcmp (p, xml) == 0)
{
/* already there */
xfree (copy);
return;
}
}
while ((p = strtok (NULL, ",")) != NULL);
xfree (copy);
remote_support_xml = reconcat (remote_support_xml,
remote_support_xml, ",", xml,
(char *) NULL);
}
#endif
}
static char *
remote_query_supported_append (char *msg, const char *append)
{
if (msg)
return reconcat (msg, msg, ";", append, (char *) NULL);
else
return xstrdup (append);
}
static void
remote_query_supported (void)
{
struct remote_state *rs = get_remote_state ();
char *next;
int i;
unsigned char seen [ARRAY_SIZE (remote_protocol_features)];
/* The packet support flags are handled differently for this packet
than for most others. We treat an error, a disabled packet, and
an empty response identically: any features which must be reported
to be used will be automatically disabled. An empty buffer
accomplishes this, since that is also the representation for a list
containing no features. */
rs->buf[0] = 0;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qSupported) != PACKET_DISABLE)
{
char *q = NULL;
struct cleanup *old_chain = make_cleanup (free_current_contents, &q);
q = remote_query_supported_append (q, "multiprocess+");
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
if (packet_set_cmd_state (PACKET_swbreak_feature) != AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "swbreak+");
if (packet_set_cmd_state (PACKET_hwbreak_feature) != AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "hwbreak+");
if (remote_support_xml)
q = remote_query_supported_append (q, remote_support_xml);
q = remote_query_supported_append (q, "qRelocInsn+");
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
if (rs->extended)
{
if (packet_set_cmd_state (PACKET_fork_event_feature)
!= AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "fork-events+");
if (packet_set_cmd_state (PACKET_vfork_event_feature)
!= AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "vfork-events+");
}
q = reconcat (q, "qSupported:", q, (char *) NULL);
putpkt (q);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
do_cleanups (old_chain);
getpkt (&rs->buf, &rs->buf_size, 0);
/* If an error occured, warn, but do not return - just reset the
buffer to empty and go on to disable features. */
if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSupported])
== PACKET_ERROR)
{
warning (_("Remote failure reply: %s"), rs->buf);
rs->buf[0] = 0;
}
}
memset (seen, 0, sizeof (seen));
next = rs->buf;
while (*next)
{
enum packet_support is_supported;
char *p, *end, *name_end, *value;
/* First separate out this item from the rest of the packet. If
there's another item after this, we overwrite the separator
(terminated strings are much easier to work with). */
p = next;
end = strchr (p, ';');
if (end == NULL)
{
end = p + strlen (p);
next = end;
}
else
{
*end = '\0';
next = end + 1;
if (end == p)
{
warning (_("empty item in \"qSupported\" response"));
continue;
}
}
name_end = strchr (p, '=');
if (name_end)
{
/* This is a name=value entry. */
is_supported = PACKET_ENABLE;
value = name_end + 1;
*name_end = '\0';
}
else
{
value = NULL;
switch (end[-1])
{
case '+':
is_supported = PACKET_ENABLE;
break;
case '-':
is_supported = PACKET_DISABLE;
break;
case '?':
is_supported = PACKET_SUPPORT_UNKNOWN;
break;
default:
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
warning (_("unrecognized item \"%s\" "
"in \"qSupported\" response"), p);
continue;
}
end[-1] = '\0';
}
for (i = 0; i < ARRAY_SIZE (remote_protocol_features); i++)
if (strcmp (remote_protocol_features[i].name, p) == 0)
{
const struct protocol_feature *feature;
seen[i] = 1;
feature = &remote_protocol_features[i];
feature->func (feature, is_supported, value);
break;
}
}
/* If we increased the packet size, make sure to increase the global
buffer size also. We delay this until after parsing the entire
qSupported packet, because this is the same buffer we were
parsing. */
if (rs->buf_size < rs->explicit_packet_size)
{
rs->buf_size = rs->explicit_packet_size;
rs->buf = xrealloc (rs->buf, rs->buf_size);
}
/* Handle the defaults for unmentioned features. */
for (i = 0; i < ARRAY_SIZE (remote_protocol_features); i++)
if (!seen[i])
{
const struct protocol_feature *feature;
feature = &remote_protocol_features[i];
feature->func (feature, feature->default_support, NULL);
}
}
/* Remove any of the remote.c targets from target stack. Upper targets depend
on it so remove them first. */
static void
remote_unpush_target (void)
{
pop_all_targets_above (process_stratum - 1);
}
static void
remote_open_1 (const char *name, int from_tty,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
struct target_ops *target, int extended_p)
{
struct remote_state *rs = get_remote_state ();
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
if (name == 0)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("To open a remote debug connection, you need to specify what\n"
2001-11-19 21:18:32 +01:00
"serial device is attached to the remote system\n"
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
"(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.)."));
/* See FIXME above. */
if (!target_async_permitted)
wait_forever_enabled_p = 1;
1999-09-28 23:55:21 +02:00
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* If we're connected to a running target, target_preopen will kill it.
Ask this question first, before target_preopen has a chance to kill
anything. */
if (rs->remote_desc != NULL && !have_inferiors ())
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
if (from_tty
&& !query (_("Already connected to a remote target. Disconnect? ")))
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
error (_("Still connected."));
}
/* Here the possibly existing remote target gets unpushed. */
target_preopen (from_tty);
/* Make sure we send the passed signals list the next time we resume. */
xfree (rs->last_pass_packet);
rs->last_pass_packet = NULL;
/* Make sure we send the program signals list the next time we
resume. */
xfree (rs->last_program_signals_packet);
rs->last_program_signals_packet = NULL;
remote_fileio_reset ();
reopen_exec_file ();
reread_symbols ();
rs->remote_desc = remote_serial_open (name);
if (!rs->remote_desc)
perror_with_name (name);
if (baud_rate != -1)
{
if (serial_setbaudrate (rs->remote_desc, baud_rate))
{
/* The requested speed could not be set. Error out to
top level after closing remote_desc. Take care to
set remote_desc to NULL to avoid closing remote_desc
more than once. */
serial_close (rs->remote_desc);
rs->remote_desc = NULL;
perror_with_name (name);
}
}
GDB: Add set/show serial parity command. The "set serial parity" command allows the user to control which parity to use when communicating over a serial connection, rather than having the parity hardcoded to none. gdb/ChangeLog: * NEWS: Mention set/show serial parity command. * monitor.c (monitor_open): Call serial_setparity. * remote.c (remote_open_1): Likewise. * ser-base.c (ser_base_serparity): New function. * ser-base.h (ser_base_setparity): Add declaration. * ser-go32.c (dos_ops): Set "setparity" field. * ser-mingw.c (ser_windows_raw): Do not set state.fParity and state.Parity. (ser_windows_setparity): New function. (hardwire_ops): Add ser_windows_setparity. (tty_ops): Add NULL for setparity field. (pipe_ops): Add ser_base_setparity. (tcp_ops): Likewise. * ser-pipe.c (pipe_ops): Likewise. * ser-tcp.c (tcp_ops): Likewise. * ser-unix.c (hardwire_setparity): Add declaration. (hardwire_raw): Don't reset PARENB flag. (hardwire_setparity): New function. (hardwire_ops): Add hardwire_setparity. * serial.c (serial_setparity): New function. (serial_parity): New global. (parity_none, parity_odd, parity_even, parity_enums, parity): New static globals. (set_parity): New function. (_initialize_serial): Add set/show serial parity commands. * serial.h (GDBPARITY_NONE): Define. (GDBPARITY_ODD): Define. (GDBPARITY_EVEN): Define. (serial_setparity) Add declaration. (struct serial_ops): Add setparity field. * target.h (serial_parity): Add declaration. gdb/doc/ChangeLog: * gdb.texinfo (Remote configuration): Document "set/show serial parity" command.
2015-03-23 22:15:42 +01:00
serial_setparity (rs->remote_desc, serial_parity);
serial_raw (rs->remote_desc);
/* If there is something sitting in the buffer we might take it as a
response to a command, which would be bad. */
serial_flush_input (rs->remote_desc);
if (from_tty)
{
puts_filtered ("Remote debugging using ");
puts_filtered (name);
puts_filtered ("\n");
}
push_target (target); /* Switch to using remote target now. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Register extra event sources in the event loop. */
remote_async_inferior_event_token
= create_async_event_handler (remote_async_inferior_event_handler,
NULL);
rs->notif_state = remote_notif_state_allocate ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Reset the target state; these things will be queried either by
remote_query_supported or as they are needed. */
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
reset_all_packet_configs_support ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
rs->cached_wait_status = 0;
rs->explicit_packet_size = 0;
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
rs->noack_mode = 0;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
rs->extended = extended_p;
rs->waiting_for_stop_reply = 0;
rs->ctrlc_pending_p = 0;
rs->general_thread = not_sent_ptid;
rs->continue_thread = not_sent_ptid;
rs->remote_traceframe_number = -1;
/* Probe for ability to use "ThreadInfo" query, as required. */
rs->use_threadinfo_query = 1;
rs->use_threadextra_query = 1;
if (target_async_permitted)
{
/* With this target we start out by owning the terminal. */
remote_async_terminal_ours_p = 1;
/* FIXME: cagney/1999-09-23: During the initial connection it is
assumed that the target is already ready and able to respond to
requests. Unfortunately remote_start_remote() eventually calls
wait_for_inferior() with no timeout. wait_forever_enabled_p gets
around this. Eventually a mechanism that allows
wait_for_inferior() to expect/get timeouts will be
implemented. */
wait_forever_enabled_p = 0;
}
/* First delete any symbols previously loaded from shared libraries. */
no_shared_libraries (NULL, 0);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Start afresh. */
init_thread_list ();
/* Start the remote connection. If error() or QUIT, discard this
target (we'd otherwise be in an inconsistent state) and then
propogate the error on up the exception chain. This ensures that
the caller doesn't stumble along blindly assuming that the
function succeeded. The CLI doesn't have this problem but other
UI's, such as MI do.
FIXME: cagney/2002-05-19: Instead of re-throwing the exception,
this function should return an error indication letting the
caller restore the previous state. Unfortunately the command
``target remote'' is directly wired to this function making that
impossible. On a positive note, the CLI side of this problem has
been fixed - the function set_cmd_context() makes it possible for
all the ``target ....'' commands to share a common callback
function. See cli-dump.c. */
{
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
TRY
{
remote_start_remote (from_tty, target, extended_p);
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
CATCH (ex, RETURN_MASK_ALL)
{
/* Pop the partially set up target - unless something else did
already before throwing the exception. */
if (rs->remote_desc != NULL)
remote_unpush_target ();
if (target_async_permitted)
wait_forever_enabled_p = 1;
throw_exception (ex);
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
END_CATCH
}
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
remote_btrace_reset ();
if (target_async_permitted)
wait_forever_enabled_p = 1;
1999-07-05 19:58:44 +02:00
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Detach the specified process. */
static void
remote_detach_pid (int pid)
{
struct remote_state *rs = get_remote_state ();
if (remote_multi_process_p (rs))
xsnprintf (rs->buf, get_remote_packet_size (), "D;%x", pid);
else
strcpy (rs->buf, "D");
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == 'O' && rs->buf[1] == 'K')
;
else if (rs->buf[0] == '\0')
error (_("Remote doesn't know how to detach"));
else
error (_("Can't detach process."));
}
/* This detaches a program to which we previously attached, using
inferior_ptid to identify the process. After this is done, GDB
can be used to debug some other program. We better not have left
any breakpoints in the target program or it'll die when it hits
one. */
static void
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
remote_detach_1 (const char *args, int from_tty)
{
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
int pid = ptid_get_pid (inferior_ptid);
struct remote_state *rs = get_remote_state ();
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
struct thread_info *tp = find_thread_ptid (inferior_ptid);
int is_fork_parent;
if (args)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Argument given to \"detach\" when remotely debugging."));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
if (!target_has_execution)
error (_("No process to detach from."));
if (from_tty)
{
char *exec_file = get_exec_file (0);
if (exec_file == NULL)
exec_file = "";
printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
/* Tell the remote target to detach. */
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
remote_detach_pid (pid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
if (from_tty && !rs->extended)
puts_filtered (_("Ending remote debugging.\n"));
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Check to see if we are detaching a fork parent. Note that if we
are detaching a fork child, tp == NULL. */
is_fork_parent = (tp != NULL
&& tp->pending_follow.kind == TARGET_WAITKIND_FORKED);
/* If doing detach-on-fork, we don't mourn, because that will delete
breakpoints that should be available for the followed inferior. */
if (!is_fork_parent)
target_mourn_inferior ();
else
{
inferior_ptid = null_ptid;
detach_inferior (pid);
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
static void
constify to_detach This patch constifies the target_ops method to_detach. This is a small cleanup, but also, I think, a bug-prevention fix, since gdb already acts as if the "args" argument here was const. In particular, top.c:quit_force calls kill_or_detach via iterate_over_inferiors. kill_or_detach calls target_detach, passing the same argument each time. So, if one of these methods was not const-correct, then kill_or_detach would change its behavior in a strange way. I could not build every target I modified in this patch. I've inspected them all by hand, though. Many targets do not use the "args" parameter; a couple pass it to atoi; and a few pass it on to the to_detach method of the target beneath. The only code that required a real change was in linux-nat.c, and that only needed the introduction of a temporary variable for const-correctness. 2013-11-08 Tom Tromey <tromey@redhat.com> * aix-thread.c (aix_thread_detach): Update. * corelow.c (core_detach): Update. * darwin-nat.c (darwin_detach): Update. * dec-thread.c (dec_thread_detach): Update. * gnu-nat.c (gnu_detach): Update. * go32-nat.c (go32_detach): Update. * inf-ptrace.c (inf_ptrace_detach): Update. * inf-ttrace.c (inf_ttrace_detach): Update. * linux-fork.c (linux_fork_detach): Update. * linux-fork.h (linux_fork_detach): Update. * linux-nat.c (linux_nat_detach): Update. Introduce "tem" local for const-correctness. * linux-thread-db.c (thread_db_detach): Update. * monitor.c (monitor_detach): Update. * nto-procfs.c (procfs_detach): Update. * procfs.c (procfs_detach): Update. * record.c (record_detach): Update. * record.h (record_detach): Update. * remote-m32r-sdi.c (m32r_detach): Update. * remote-mips.c (mips_detach): Update. * remote-sim.c (gdbsim_detach): Update. * remote.c (remote_detach_1, remote_detach) (extended_remote_detach): Update. * sol-thread.c (sol_thread_detach): Update. * target.c (target_detach): Make "args" const. (init_dummy_target): Update. * target.h (struct target_ops) <to_detach>: Make argument const. (target_detach): Likewise. * windows-nat.c (windows_detach): Update.
2013-03-19 16:23:17 +01:00
remote_detach (struct target_ops *ops, const char *args, int from_tty)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
remote_detach_1 (args, from_tty);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
static void
constify to_detach This patch constifies the target_ops method to_detach. This is a small cleanup, but also, I think, a bug-prevention fix, since gdb already acts as if the "args" argument here was const. In particular, top.c:quit_force calls kill_or_detach via iterate_over_inferiors. kill_or_detach calls target_detach, passing the same argument each time. So, if one of these methods was not const-correct, then kill_or_detach would change its behavior in a strange way. I could not build every target I modified in this patch. I've inspected them all by hand, though. Many targets do not use the "args" parameter; a couple pass it to atoi; and a few pass it on to the to_detach method of the target beneath. The only code that required a real change was in linux-nat.c, and that only needed the introduction of a temporary variable for const-correctness. 2013-11-08 Tom Tromey <tromey@redhat.com> * aix-thread.c (aix_thread_detach): Update. * corelow.c (core_detach): Update. * darwin-nat.c (darwin_detach): Update. * dec-thread.c (dec_thread_detach): Update. * gnu-nat.c (gnu_detach): Update. * go32-nat.c (go32_detach): Update. * inf-ptrace.c (inf_ptrace_detach): Update. * inf-ttrace.c (inf_ttrace_detach): Update. * linux-fork.c (linux_fork_detach): Update. * linux-fork.h (linux_fork_detach): Update. * linux-nat.c (linux_nat_detach): Update. Introduce "tem" local for const-correctness. * linux-thread-db.c (thread_db_detach): Update. * monitor.c (monitor_detach): Update. * nto-procfs.c (procfs_detach): Update. * procfs.c (procfs_detach): Update. * record.c (record_detach): Update. * record.h (record_detach): Update. * remote-m32r-sdi.c (m32r_detach): Update. * remote-mips.c (mips_detach): Update. * remote-sim.c (gdbsim_detach): Update. * remote.c (remote_detach_1, remote_detach) (extended_remote_detach): Update. * sol-thread.c (sol_thread_detach): Update. * target.c (target_detach): Make "args" const. (init_dummy_target): Update. * target.h (struct target_ops) <to_detach>: Make argument const. (target_detach): Likewise. * windows-nat.c (windows_detach): Update.
2013-03-19 16:23:17 +01:00
extended_remote_detach (struct target_ops *ops, const char *args, int from_tty)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
remote_detach_1 (args, from_tty);
}
/* Target follow-fork function for remote targets. On entry, and
at return, the current inferior is the fork parent.
Note that although this is currently only used for extended-remote,
it is named remote_follow_fork in anticipation of using it for the
remote target as well. */
static int
remote_follow_fork (struct target_ops *ops, int follow_child,
int detach_fork)
{
struct remote_state *rs = get_remote_state ();
2015-05-12 18:52:45 +02:00
enum target_waitkind kind = inferior_thread ()->pending_follow.kind;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
2015-05-12 18:52:45 +02:00
if ((kind == TARGET_WAITKIND_FORKED && remote_fork_event_p (rs))
|| (kind == TARGET_WAITKIND_VFORKED && remote_vfork_event_p (rs)))
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
{
/* When following the parent and detaching the child, we detach
the child here. For the case of following the child and
detaching the parent, the detach is done in the target-
independent follow fork code in infrun.c. We can't use
target_detach when detaching an unfollowed child because
the client side doesn't know anything about the child. */
if (detach_fork && !follow_child)
{
/* Detach the fork child. */
ptid_t child_ptid;
pid_t child_pid;
child_ptid = inferior_thread ()->pending_follow.value.related_pid;
child_pid = ptid_get_pid (child_ptid);
remote_detach_pid (child_pid);
detach_inferior (child_pid);
}
}
return 0;
}
/* Same as remote_detach, but don't send the "D" packet; just disconnect. */
1999-07-05 19:58:44 +02:00
static void
remote_disconnect (struct target_ops *target, const char *args, int from_tty)
1999-07-05 19:58:44 +02:00
{
if (args)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
error (_("Argument given to \"disconnect\" when remotely debugging."));
1999-07-05 19:58:44 +02:00
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Make sure we unpush even the extended remote targets; mourn
won't do it. So call remote_mourn directly instead of
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
target_mourn_inferior. */
remote_mourn (target);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
1999-07-05 19:58:44 +02:00
if (from_tty)
puts_filtered ("Ending remote debugging.\n");
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Attach to the process specified by ARGS. If FROM_TTY is non-zero,
be chatty about it. */
static void
extended_remote_attach (struct target_ops *target, const char *args,
int from_tty)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
struct remote_state *rs = get_remote_state ();
int pid;
char *wait_status = NULL;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
pid = parse_pid_to_attach (args);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Remote PID can be freely equal to getpid, do not check it here the same
way as in other targets. */
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vAttach) == PACKET_DISABLE)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
error (_("This target does not support attaching to a process"));
if (from_tty)
{
char *exec_file = get_exec_file (0);
if (exec_file)
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
target_pid_to_str (pid_to_ptid (pid)));
else
printf_unfiltered (_("Attaching to %s\n"),
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
xsnprintf (rs->buf, get_remote_packet_size (), "vAttach;%x", pid);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_ok (rs->buf,
&remote_protocol_packets[PACKET_vAttach]))
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
case PACKET_OK:
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (!non_stop)
{
/* Save the reply for later. */
wait_status = alloca (strlen (rs->buf) + 1);
strcpy (wait_status, rs->buf);
}
else if (strcmp (rs->buf, "OK") != 0)
error (_("Attaching to %s failed with: %s"),
target_pid_to_str (pid_to_ptid (pid)),
rs->buf);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
break;
case PACKET_UNKNOWN:
error (_("This target does not support attaching to a process"));
default:
error (_("Attaching to %s failed"),
target_pid_to_str (pid_to_ptid (pid)));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
Access executable from remote system when first inferior appears This commit modifies remote_add_inferior to take an extra argument try_open_exec. If this is nonzero, remote_add_inferior will attempt to open this inferior's executable as the main executable if no main executable is open already. Callers are updated appropriately. With this commit, remote debugging can now be initiated using only a "target remote" or "target extended-remote" command; no "set sysroot" or "file" commands are required, e.g. bash$ gdb -q (gdb) target remote | gdbserver - /bin/sh Remote debugging using | gdbserver - /bin/sh Process /bin/sh created; pid = 32166 stdin/stdout redirected Remote debugging using stdio Reading symbols from target:/bin/bash... One testcase required updating as a result of this commit. The test checked that GDB's "info files" command does not crash if no main executable is open, and relied on GDB's inability to access the main executable over the remote protocol. The test was updated to inhibit this new behavior. gdb/ChangeLog: * remote.c (remote_add_inferior): New argument try_open_exec. If nonzero, attempt to open the inferior's executable file as the main executable if no main executable is open already. All callers updated. * NEWS: Mention that GDB now supports automatic location and retrieval of executable + files from remote targets. gdb/doc/ChangeLog: * gdb.texinfo (Connecting to a Remote Target): Mention that GDB can access program files from remote targets that support qXfer:exec-file:read and Host I/O packets. gdb/testsuite/ChangeLog: * gdb.server/server-exec-info.exp: Inhibit GDB from accessing the main executable over the remote protocol.
2015-04-17 10:47:30 +02:00
set_current_inferior (remote_add_inferior (0, pid, 1, 0));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
inferior_ptid = pid_to_ptid (pid);
if (non_stop)
{
struct thread_info *thread;
/* Get list of threads. */
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
remote_update_thread_list (target);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
thread = first_thread_of_process (pid);
if (thread)
inferior_ptid = thread->ptid;
else
inferior_ptid = pid_to_ptid (pid);
/* Invalidate our notion of the remote current thread. */
record_currthread (rs, minus_one_ptid);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
{
/* Now, if we have thread information, update inferior_ptid. */
inferior_ptid = remote_current_thread (inferior_ptid);
/* Add the main thread to the thread list. */
add_thread_silent (inferior_ptid);
}
/* Next, if the target can specify a description, read it. We do
this before anything involving memory or registers. */
target_find_description ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (!non_stop)
{
/* Use the previously fetched status. */
gdb_assert (wait_status != NULL);
if (target_can_async_p ())
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct notif_event *reply
= remote_notif_parse (&notif_client_stop, wait_status);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
push_stop_reply ((struct stop_reply *) reply);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
target_async (1);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
else
{
gdb_assert (wait_status != NULL);
strcpy (rs->buf, wait_status);
rs->cached_wait_status = 1;
}
}
else
gdb_assert (wait_status == NULL);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
/* Implementation of the to_post_attach method. */
static void
extended_remote_post_attach (struct target_ops *ops, int pid)
{
/* In certain cases GDB might not have had the chance to start
symbol lookup up until now. This could happen if the debugged
binary is not using shared libraries, the vsyscall page is not
present (on Linux) and the binary itself hadn't changed since the
debugging process was started. */
if (symfile_objfile != NULL)
remote_check_symbols();
}
/* Check for the availability of vCont. This function should also check
the response. */
static void
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
remote_vcont_probe (struct remote_state *rs)
{
char *buf;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
strcpy (rs->buf, "vCont?");
putpkt (rs->buf);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
buf = rs->buf;
/* Make sure that the features we assume are supported. */
if (startswith (buf, "vCont"))
{
char *p = &buf[5];
int support_s, support_S, support_c, support_C;
support_s = 0;
support_S = 0;
support_c = 0;
support_C = 0;
rs->supports_vCont.t = 0;
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
rs->supports_vCont.r = 0;
while (p && *p == ';')
{
p++;
if (*p == 's' && (*(p + 1) == ';' || *(p + 1) == 0))
support_s = 1;
else if (*p == 'S' && (*(p + 1) == ';' || *(p + 1) == 0))
support_S = 1;
else if (*p == 'c' && (*(p + 1) == ';' || *(p + 1) == 0))
support_c = 1;
else if (*p == 'C' && (*(p + 1) == ';' || *(p + 1) == 0))
support_C = 1;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else if (*p == 't' && (*(p + 1) == ';' || *(p + 1) == 0))
rs->supports_vCont.t = 1;
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
else if (*p == 'r' && (*(p + 1) == ';' || *(p + 1) == 0))
rs->supports_vCont.r = 1;
p = strchr (p, ';');
}
/* If s, S, c, and C are not all supported, we can't use vCont. Clearing
BUF will make packet_ok disable the packet. */
if (!support_s || !support_S || !support_c || !support_C)
buf[0] = 0;
}
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
packet_ok (buf, &remote_protocol_packets[PACKET_vCont]);
}
/* Helper function for building "vCont" resumptions. Write a
resumption to P. ENDP points to one-passed-the-end of the buffer
we're allowed to write to. Returns BUF+CHARACTERS_WRITTEN. The
thread to be resumed is PTID; STEP and SIGGNAL indicate whether the
resumed thread should be single-stepped and/or signalled. If PTID
equals minus_one_ptid, then all threads are resumed; if PTID
represents a process, then all threads of the process are resumed;
the thread to be stepped and/or signalled is given in the global
INFERIOR_PTID. */
static char *
append_resumption (char *p, char *endp,
ptid_t ptid, int step, enum gdb_signal siggnal)
{
struct remote_state *rs = get_remote_state ();
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
if (step && siggnal != GDB_SIGNAL_0)
p += xsnprintf (p, endp - p, ";S%02x", siggnal);
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
else if (step
/* GDB is willing to range step. */
&& use_range_stepping
/* Target supports range stepping. */
&& rs->supports_vCont.r
/* We don't currently support range stepping multiple
threads with a wildcard (though the protocol allows it,
so stubs shouldn't make an active effort to forbid
it). */
&& !(remote_multi_process_p (rs) && ptid_is_pid (ptid)))
{
struct thread_info *tp;
if (ptid_equal (ptid, minus_one_ptid))
{
/* If we don't know about the target thread's tid, then
we're resuming magic_null_ptid (see caller). */
tp = find_thread_ptid (magic_null_ptid);
}
else
tp = find_thread_ptid (ptid);
gdb_assert (tp != NULL);
if (tp->control.may_range_step)
{
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
p += xsnprintf (p, endp - p, ";r%s,%s",
phex_nz (tp->control.step_range_start,
addr_size),
phex_nz (tp->control.step_range_end,
addr_size));
}
else
p += xsnprintf (p, endp - p, ";s");
}
else if (step)
p += xsnprintf (p, endp - p, ";s");
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
else if (siggnal != GDB_SIGNAL_0)
p += xsnprintf (p, endp - p, ";C%02x", siggnal);
else
p += xsnprintf (p, endp - p, ";c");
if (remote_multi_process_p (rs) && ptid_is_pid (ptid))
{
ptid_t nptid;
/* All (-1) threads of process. */
nptid = ptid_build (ptid_get_pid (ptid), -1, 0);
p += xsnprintf (p, endp - p, ":");
p = write_ptid (p, endp, nptid);
}
else if (!ptid_equal (ptid, minus_one_ptid))
{
p += xsnprintf (p, endp - p, ":");
p = write_ptid (p, endp, ptid);
}
return p;
}
/* Append a vCont continue-with-signal action for threads that have a
non-zero stop signal. */
static char *
append_pending_thread_resumptions (char *p, char *endp, ptid_t ptid)
{
struct thread_info *thread;
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (thread)
if (ptid_match (thread->ptid, ptid)
&& !ptid_equal (inferior_ptid, thread->ptid)
Always pass signals to the right thread Currently, GDB can pass a signal to the wrong thread in several different but related scenarios. E.g., if thread 1 stops for signal SIGFOO, the user switches to thread 2, and then issues "continue", SIGFOO is actually delivered to thread 2, not thread 1. This obviously messes up programs that use pthread_kill to send signals to specific threads. This has been a known issue for a long while. Back in 2008 when I made stop_signal be per-thread (2020b7ab), I kept the behavior -- see code in 'proceed' being removed -- wanting to come back to it later. The time has finally come now. The patch fixes this -- on resumption, intercepted signals are always delivered to the thread that had intercepted them. Another example: if thread 1 stops for a breakpoint, the user switches to thread 2, and then issues "signal SIGFOO", SIGFOO is actually delivered to thread 1, not thread 2, because 'proceed' first switches to thread 1 to step over its breakpoint... If the user deletes the breakpoint before issuing "signal FOO", then the signal is delivered to thread 2 (the current thread). "signal SIGFOO" can be used for two things: inject a signal in the program while the program/thread had stopped for none, bypassing "handle nopass"; or changing/suppressing a signal the program had stopped for. These scenarios are really two faces of the same coin, and GDB can't really guess what the user is trying to do. GDB might have intercepted signals in more than one thread even (see the new signal-command-multiple-signals-pending.exp test). At least in the inject case, it's obviously clear to me that the user means to deliver the signal to the currently selected thread, so best is to make the command's behavior consistent and easy to explain. Then, if the user is trying to suppress/change a signal the program had stopped for instead of injecting a new signal, but, the user had changed threads meanwhile, then she will be surprised that with: (gdb) continue Thread 1 stopped for signal SIGFOO. (gdb) thread 2 (gdb) signal SIGBAR ... GDB actually delivers SIGFOO to thread 1, and SIGBAR to thread 2 (with scheduler-locking off, which is the default, because then "signal" or any other resumption command resumes all threads). So the patch makes GDB detect that, and ask for confirmation: (gdb) thread 1 [Switching to thread 1 (Thread 10979)] (gdb) signal SIGUSR2 Note: Thread 3 previously stopped with signal SIGUSR2, User defined signal 2. Thread 2 previously stopped with signal SIGUSR1, User defined signal 1. Continuing thread 1 (the current thread) with specified signal will still deliver the signals noted above to their respective threads. Continue anyway? (y or n) All these scenarios are covered by the new tests. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2014-07-25 Pedro Alves <palves@redhat.com> * NEWS: Mention signal passing and "signal" command changes. * gdbthread.h (struct thread_suspend_state) <stop_signal>: Extend comment. * breakpoint.c (until_break_command): Adjust clear_proceed_status call. * infcall.c (run_inferior_call): Adjust clear_proceed_status call. * infcmd.c (proceed_thread_callback, continue_1, step_once) (jump_command): Adjust clear_proceed_status call. (signal_command): Warn if other thread that are resumed have signals that will be delivered. Adjust clear_proceed_status call. (until_next_command, finish_command) (proceed_after_attach_callback, attach_command_post_wait) (attach_command): Adjust clear_proceed_status call. * infrun.c (proceed_after_vfork_done): Likewise. (proceed_after_attach_callback): Adjust comment. (clear_proceed_status_thread): Clear stop_signal if not in pass state. (clear_proceed_status_callback): Delete. (clear_proceed_status): New 'step' parameter. Only clear the proceed status of threads the command being prepared is about to resume. (proceed): If passed in an explicit signal, override stop_signal with it. Don't pass the last stop signal to the thread we're resuming. (init_wait_for_inferior): Adjust clear_proceed_status call. (switch_back_to_stepped_thread): Clear the signal if it should not be passed. * infrun.h (clear_proceed_status): New 'step' parameter. (user_visible_resume_ptid): Add comment. * linux-nat.c (linux_nat_resume_callback): Don't check whether the signal is in pass state. * remote.c (append_pending_thread_resumptions): Likewise. * mi/mi-main.c (proceed_thread): Adjust clear_proceed_status call. gdb/doc/ 2014-07-25 Pedro Alves <palves@redhat.com> Eli Zaretskii <eliz@gnu.org> * gdb.texinfo (Signaling) <signal command>: Explain what happens with multi-threaded programs. gdb/testsuite/ 2014-07-25 Pedro Alves <palves@redhat.com> * gdb.threads/signal-command-handle-nopass.c: New file. * gdb.threads/signal-command-handle-nopass.exp: New file. * gdb.threads/signal-command-multiple-signals-pending.c: New file. * gdb.threads/signal-command-multiple-signals-pending.exp: New file. * gdb.threads/signal-delivered-right-thread.c: New file. * gdb.threads/signal-delivered-right-thread.exp: New file.
2014-07-25 17:57:31 +02:00
&& thread->suspend.stop_signal != GDB_SIGNAL_0)
{
p = append_resumption (p, endp, thread->ptid,
0, thread->suspend.stop_signal);
thread->suspend.stop_signal = GDB_SIGNAL_0;
}
return p;
}
/* Resume the remote inferior by using a "vCont" packet. The thread
to be resumed is PTID; STEP and SIGGNAL indicate whether the
resumed thread should be single-stepped and/or signalled. If PTID
equals minus_one_ptid, then all threads are resumed; the thread to
be stepped and/or signalled is given in the global INFERIOR_PTID.
This function returns non-zero iff it resumes the inferior.
This function issues a strict subset of all possible vCont commands at the
moment. */
static int
remote_vcont_resume (ptid_t ptid, int step, enum gdb_signal siggnal)
{
struct remote_state *rs = get_remote_state ();
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
char *p;
char *endp;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
remote_vcont_probe (rs);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vCont) == PACKET_DISABLE)
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
return 0;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
p = rs->buf;
endp = rs->buf + get_remote_packet_size ();
/* If we could generate a wider range of packets, we'd have to worry
about overflowing BUF. Should there be a generic
"multi-part-packet" packet? */
p += xsnprintf (p, endp - p, "vCont");
if (ptid_equal (ptid, magic_null_ptid))
{
/* MAGIC_NULL_PTID means that we don't have any active threads,
so we don't have any TID numbers the inferior will
understand. Make sure to only send forms that do not specify
a TID. */
append_resumption (p, endp, minus_one_ptid, step, siggnal);
}
else if (ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
{
/* Resume all threads (of all processes, or of a single
process), with preference for INFERIOR_PTID. This assumes
inferior_ptid belongs to the set of all threads we are about
to resume. */
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
if (step || siggnal != GDB_SIGNAL_0)
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
{
/* Step inferior_ptid, with or without signal. */
p = append_resumption (p, endp, inferior_ptid, step, siggnal);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
/* Also pass down any pending signaled resumption for other
threads not the current. */
p = append_pending_thread_resumptions (p, endp, ptid);
/* And continue others without a signal. */
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
append_resumption (p, endp, ptid, /*step=*/ 0, GDB_SIGNAL_0);
}
else
{
/* Scheduler locking; resume only PTID. */
append_resumption (p, endp, ptid, step, siggnal);
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
gdb_assert (strlen (rs->buf) < get_remote_packet_size ());
putpkt (rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (non_stop)
{
/* In non-stop, the stub replies to vCont with "OK". The stop
reply will be reported asynchronously by means of a `%Stop'
notification. */
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") != 0)
error (_("Unexpected vCont reply in non-stop mode: %s"), rs->buf);
}
return 1;
}
1999-07-05 19:58:44 +02:00
/* Tell the remote machine to resume. */
1999-07-05 19:58:44 +02:00
static void
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
remote_resume (struct target_ops *ops,
ptid_t ptid, int step, enum gdb_signal siggnal)
1999-07-05 19:58:44 +02:00
{
struct remote_state *rs = get_remote_state ();
char *buf;
1999-07-05 19:58:44 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* In all-stop, we can't mark REMOTE_ASYNC_GET_PENDING_EVENTS_TOKEN
(explained in remote-notif.c:handle_notification) so
remote_notif_process is not called. We need find a place where
it is safe to start a 'vNotif' sequence. It is good to do it
before resuming inferior, because inferior was stopped and no RSP
traffic at that moment. */
if (!non_stop)
remote_notif_process (rs->notif_state, &notif_client_stop);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
rs->last_sent_signal = siggnal;
rs->last_sent_step = step;
1999-07-05 19:58:44 +02:00
/* The vCont packet doesn't need to specify threads via Hc. */
/* No reverse support (yet) for vCont. */
if (execution_direction != EXEC_REVERSE)
if (remote_vcont_resume (ptid, step, siggnal))
goto done;
/* All other supported resume packets do use Hc, so set the continue
thread. */
if (ptid_equal (ptid, minus_one_ptid))
set_continue_thread (any_thread_ptid);
else
set_continue_thread (ptid);
buf = rs->buf;
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
if (execution_direction == EXEC_REVERSE)
{
/* We don't pass signals to the target in reverse exec mode. */
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
if (info_verbose && siggnal != GDB_SIGNAL_0)
warning (_(" - Can't pass signal %d to target in reverse: ignored."),
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
siggnal);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (step && packet_support (PACKET_bs) == PACKET_DISABLE)
error (_("Remote reverse-step not supported."));
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (!step && packet_support (PACKET_bc) == PACKET_DISABLE)
2009-09-11 00:47:56 +02:00
error (_("Remote reverse-continue not supported."));
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
strcpy (buf, step ? "bs" : "bc");
}
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
else if (siggnal != GDB_SIGNAL_0)
1999-07-05 19:58:44 +02:00
{
buf[0] = step ? 'S' : 'C';
1999-07-07 22:19:36 +02:00
buf[1] = tohex (((int) siggnal >> 4) & 0xf);
buf[2] = tohex (((int) siggnal) & 0xf);
1999-07-05 19:58:44 +02:00
buf[3] = '\0';
}
else
1999-07-07 22:19:36 +02:00
strcpy (buf, step ? "s" : "c");
putpkt (buf);
1999-07-05 19:58:44 +02:00
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
done:
1999-10-06 01:13:56 +02:00
/* We are about to start executing the inferior, let's register it
with the event loop. NOTE: this is the one place where all the
execution commands end up. We could alternatively do this in each
of the execution commands in infcmd.c. */
1999-10-06 01:13:56 +02:00
/* FIXME: ezannoni 1999-09-28: We may need to move this out of here
into infcmd.c in order to allow inferior function calls to work
NOT asynchronously. */
if (target_can_async_p ())
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
target_async (1);
/* We've just told the target to resume. The remote server will
wait for the inferior to stop, and then send a stop reply. In
the mean time, we can't start another command/query ourselves
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
because the stub wouldn't be ready to process it. This applies
only to the base all-stop protocol, however. In non-stop (which
only supports vCont), the stub replies with an "OK", and is
immediate able to process further serial input. */
if (!non_stop)
rs->waiting_for_stop_reply = 1;
1999-07-05 19:58:44 +02:00
}
1999-07-05 19:58:44 +02:00
/* Set up the signal handler for SIGINT, while the target is
executing, ovewriting the 'regular' SIGINT signal handler. */
1999-07-05 19:58:44 +02:00
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_initialize_sigint_signal_handler (void)
1999-07-05 19:58:44 +02:00
{
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
signal (SIGINT, async_handle_remote_sigint);
1999-07-05 19:58:44 +02:00
}
/* Signal handler for SIGINT, while the target is executing. */
1999-07-05 19:58:44 +02:00
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_handle_remote_sigint (int sig)
1999-07-05 19:58:44 +02:00
{
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
signal (sig, async_handle_remote_sigint_twice);
/* Note we need to go through gdb_call_async_signal_handler in order
to wake up the event loop on Windows. */
gdb_call_async_signal_handler (async_sigint_remote_token, 0);
1999-07-05 19:58:44 +02:00
}
/* Signal handler for SIGINT, installed after SIGINT has already been
sent once. It will take effect the second time that the user sends
a ^C. */
1999-07-05 19:58:44 +02:00
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_handle_remote_sigint_twice (int sig)
1999-07-05 19:58:44 +02:00
{
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
signal (sig, async_handle_remote_sigint);
/* See note in async_handle_remote_sigint. */
gdb_call_async_signal_handler (async_sigint_remote_twice_token, 0);
1999-07-05 19:58:44 +02:00
}
1999-09-28 23:55:21 +02:00
/* Perform the real interruption of the target execution, in response
to a ^C. */
1999-07-07 22:19:36 +02:00
static void
2000-07-30 03:48:28 +02:00
async_remote_interrupt (gdb_client_data arg)
1999-07-05 19:58:44 +02:00
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "async_remote_interrupt called\n");
1999-07-05 19:58:44 +02:00
Non-stop inferior control. * infrun.c (resume): In non-stop mode, always resume just one thread. (proceed): Don't call prepare_to_proceed in non-stop mode. (fetch_inferior_event): In non-stop mode, switch context before handling the event. (error_is_running, ensure_not_running): New. (handle_inferior_event): In non-stop mode: Mark only the event thread as stopped. Require that the target module manages adding threads to the thread list. Assert that there isn't a deferred_step_ptid set. Don't switch to infwait_thread_hop_state. (normal_stop): Only mark not-running if inferior hasn't exited. In non-stop mode, only mark the event thread. * thread.c:Include "cli/cli-decode.h". (print_thread_info): Don't read from a running thread. Output "(running)" if thread is running. (switch_to_thread): Don't read stop_pc if thread is executing. (do_restore_current_thread_cleanup): Don't write to a running thread. (thread_apply_all_command): Don't read from a running thread. In non-stop mode, do a full context-switch instead of just switching threads. (thread_apply_command): In non-stop mode, do a full context-switch instead of just switching threads. (do_captured_thread_select): Likewise. Inform user if selected thread is running. (_initialize_thread): Mark "info threads" and "thread" and async_ok. * inf-loop.c (inferior_event_handler): In non-stop mode, don't unregister the target from the event loop. * infcmd.c (continue_command, step_1, jump_command) (signal_command): Ensure the selected thread isn't running. (interrupt_target_command): In non-stop mode, interrupt only the selected thread. * inferior.h (error_is_running, ensure_not_running): Declare. * target.h (struct target_ops): Add ptid argument to the to_stop member. (target_stop): Add ptid_t argument. * target.c (update_current_target): Add ptid argument to to_stop's type. (debug_to_stop): Add ptid_t argument. (debug_to_rcmd): Set to_stop_ptid. * remote.c (remote_stop): Add ptid_t argument. (async_remote_interrupt): Add inferior_ptid to target_stop. * inf-ptrace.c (inf_ptrace_stop): Add ptid argument. * Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 00:42:43 +02:00
target_stop (inferior_ptid);
1999-07-05 19:58:44 +02:00
}
/* Perform interrupt, if the first attempt did not succeed. Just give
up on the target alltogether. */
static void
2000-07-30 03:48:28 +02:00
async_remote_interrupt_twice (gdb_client_data arg)
1999-07-05 19:58:44 +02:00
{
1999-10-12 06:37:53 +02:00
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "async_remote_interrupt_twice called\n");
interrupt_query ();
1999-07-05 19:58:44 +02:00
}
/* Reinstall the usual SIGINT handlers, after the target has
stopped. */
1999-09-28 23:55:21 +02:00
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_cleanup_sigint_signal_handler (void *dummy)
1999-07-05 19:58:44 +02:00
{
signal (SIGINT, handle_sigint);
}
/* Send ^C to target to halt it. Target will respond, and send us a
packet. */
static void (*ofunc) (int);
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
/* The command line interface's interrupt routine. This function is installed
as a signal handler for SIGINT. The first time a user requests an
interrupt, we call remote_interrupt to send a break or ^C. If there is no
1999-04-26 20:34:20 +02:00
response from the target (it didn't stop when the user requested it),
we ask the user if he'd like to detach from the target. */
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
sync_remote_interrupt (int signo)
{
/* If this doesn't work, try more severe steps. */
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
signal (signo, sync_remote_interrupt_twice);
1999-04-26 20:34:20 +02:00
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
gdb_call_async_signal_handler (async_sigint_remote_token, 1);
1999-04-26 20:34:20 +02:00
}
/* The user typed ^C twice. */
static void
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
sync_remote_interrupt_twice (int signo)
1999-04-26 20:34:20 +02:00
{
signal (signo, ofunc);
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
gdb_call_async_signal_handler (async_sigint_remote_twice_token, 1);
signal (signo, sync_remote_interrupt);
}
1999-04-26 20:34:20 +02:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Non-stop version of target_stop. Uses `vCont;t' to stop a remote
thread, all threads of a remote process, or all threads of all
processes. */
static void
remote_stop_ns (ptid_t ptid)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
char *endp = rs->buf + get_remote_packet_size ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
remote_vcont_probe (rs);
if (!rs->supports_vCont.t)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
error (_("Remote server does not support stopping threads"));
if (ptid_equal (ptid, minus_one_ptid)
|| (!remote_multi_process_p (rs) && ptid_is_pid (ptid)))
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
p += xsnprintf (p, endp - p, "vCont;t");
else
{
ptid_t nptid;
p += xsnprintf (p, endp - p, "vCont;t:");
if (ptid_is_pid (ptid))
/* All (-1) threads of process. */
nptid = ptid_build (ptid_get_pid (ptid), -1, 0);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
{
/* Small optimization: if we already have a stop reply for
this thread, no use in telling the stub we want this
stopped. */
if (peek_stop_reply (ptid))
return;
nptid = ptid;
}
write_ptid (p, endp, nptid);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* In non-stop, we get an immediate OK reply. The stop reply will
come in asynchronously by notification. */
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") != 0)
error (_("Stopping %s failed: %s"), target_pid_to_str (ptid), rs->buf);
}
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
/* All-stop version of target_interrupt. Sends a break or a ^C to
interrupt the remote target. It is undefined which thread of which
process reports the interrupt. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
remote_interrupt_as (ptid_t ptid)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
struct remote_state *rs = get_remote_state ();
rs->ctrlc_pending_p = 1;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If the inferior is stopped already, but the core didn't know
about it yet, just ignore the request. The cached wait status
will be collected in remote_wait. */
if (rs->cached_wait_status)
return;
/* Send interrupt_sequence to remote target. */
send_interrupt_sequence ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
/* Implement the to_stop function for the remote targets. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
remote_stop (struct target_ops *self, ptid_t ptid)
{
1999-04-26 20:34:20 +02:00
if (remote_debug)
1999-06-14 20:08:47 +02:00
fprintf_unfiltered (gdb_stdlog, "remote_stop called\n");
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (non_stop)
remote_stop_ns (ptid);
else
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
{
/* We don't currently have a way to transparently pause the
remote target in all-stop mode. Interrupt it instead. */
remote_interrupt_as (ptid);
}
}
/* Implement the to_interrupt function for the remote targets. */
static void
remote_interrupt (struct target_ops *self, ptid_t ptid)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
if (non_stop)
{
/* We don't currently have a way to ^C the remote target in
non-stop mode. Stop it (with no signal) instead. */
remote_stop_ns (ptid);
}
else
remote_interrupt_as (ptid);
}
/* Ask the user what to do when an interrupt is received. */
static void
2000-07-30 03:48:28 +02:00
interrupt_query (void)
{
target_terminal_ours ();
if (target_is_async_p ())
{
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
signal (SIGINT, handle_sigint);
quit ();
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
{
if (query (_("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? ")))
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
remote_unpush_target ();
quit ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
}
target_terminal_inferior ();
}
1999-09-28 23:55:21 +02:00
/* Enable/disable target terminal ownership. Most targets can use
terminal groups to control terminal ownership. Remote targets are
different in that explicit transfer of ownership to/from GDB/target
is required. */
1999-09-28 23:55:21 +02:00
static void
remote_terminal_inferior (struct target_ops *self)
1999-09-28 23:55:21 +02:00
{
if (!target_async_permitted)
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
/* Nothing to do. */
return;
/* FIXME: cagney/1999-09-27: Make calls to target_terminal_*()
idempotent. The event-loop GDB talking to an asynchronous target
with a synchronous command calls this function from both
event-top.c and infrun.c/infcmd.c. Once GDB stops trying to
transfer the terminal to the target when it shouldn't this guard
can go away. */
1999-09-28 23:55:21 +02:00
if (!remote_async_terminal_ours_p)
return;
delete_file_handler (input_fd);
remote_async_terminal_ours_p = 0;
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_initialize_sigint_signal_handler ();
1999-09-28 23:55:21 +02:00
/* NOTE: At this point we could also register our selves as the
recipient of all input. Any characters typed could then be
passed on down to the target. */
1999-09-28 23:55:21 +02:00
}
static void
remote_terminal_ours (struct target_ops *self)
1999-09-28 23:55:21 +02:00
{
if (!target_async_permitted)
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
/* Nothing to do. */
return;
/* See FIXME in remote_terminal_inferior. */
1999-09-28 23:55:21 +02:00
if (remote_async_terminal_ours_p)
return;
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_cleanup_sigint_signal_handler (NULL);
1999-09-28 23:55:21 +02:00
add_file_handler (input_fd, stdin_event_handler, 0);
remote_async_terminal_ours_p = 1;
}
static void
1999-10-19 04:47:02 +02:00
remote_console_output (char *msg)
{
char *p;
1999-07-07 22:19:36 +02:00
for (p = msg; p[0] && p[1]; p += 2)
{
char tb[2];
char c = fromhex (p[0]) * 16 + fromhex (p[1]);
tb[0] = c;
tb[1] = 0;
1999-07-05 19:58:44 +02:00
fputs_unfiltered (tb, gdb_stdtarg);
}
gdb_flush (gdb_stdtarg);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
typedef struct cached_reg
{
int num;
gdb_byte data[MAX_REGISTER_SIZE];
} cached_reg_t;
DEF_VEC_O(cached_reg_t);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
typedef struct stop_reply
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct notif_event base;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* The identifier of the thread about this event */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
ptid_t ptid;
2013-10-11 05:01:09 +02:00
/* The remote state this event is associated with. When the remote
connection, represented by a remote_state object, is closed,
all the associated stop_reply events should be released. */
struct remote_state *rs;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
struct target_waitstatus ws;
/* Expedited registers. This makes remote debugging a bit more
efficient for those targets that provide critical registers as
part of their normal status mechanism (as another roundtrip to
fetch them is avoided). */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
VEC(cached_reg_t) *regcache;
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
enum target_stop_reason stop_reason;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
CORE_ADDR watch_data_address;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
int core;
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
} *stop_reply_p;
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
DECLARE_QUEUE_P (stop_reply_p);
DEFINE_QUEUE_P (stop_reply_p);
/* The list of already fetched and acknowledged stop events. This
queue is used for notification Stop, and other notifications
don't need queue for their events, because the notification events
of Stop can't be consumed immediately, so that events should be
queued first, and be consumed by remote_wait_{ns,as} one per
time. Other notifications can consume their events immediately,
so queue is not needed for them. */
static QUEUE (stop_reply_p) *stop_reply_queue;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
stop_reply_xfree (struct stop_reply *r)
{
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
notif_event_xfree ((struct notif_event *) r);
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
static void
remote_notif_stop_parse (struct notif_client *self, char *buf,
struct notif_event *event)
{
remote_parse_stop_reply (buf, (struct stop_reply *) event);
}
static void
remote_notif_stop_ack (struct notif_client *self, char *buf,
struct notif_event *event)
{
struct stop_reply *stop_reply = (struct stop_reply *) event;
/* acknowledge */
putpkt ((char *) self->ack_command);
if (stop_reply->ws.kind == TARGET_WAITKIND_IGNORE)
/* We got an unknown stop reply. */
error (_("Unknown stop reply"));
push_stop_reply (stop_reply);
}
static int
remote_notif_stop_can_get_pending_events (struct notif_client *self)
{
/* We can't get pending events in remote_notif_process for
notification stop, and we have to do this in remote_wait_ns
instead. If we fetch all queued events from stub, remote stub
may exit and we have no chance to process them back in
remote_wait_ns. */
mark_async_event_handler (remote_async_inferior_event_token);
return 0;
}
static void
stop_reply_dtr (struct notif_event *event)
{
struct stop_reply *r = (struct stop_reply *) event;
VEC_free (cached_reg_t, r->regcache);
}
static struct notif_event *
remote_notif_stop_alloc_reply (void)
{
struct notif_event *r
replace XMALLOC with XNEW This replaces XMALLOC with XNEW, and removes XMALLOC. The only non-mechanical bit here was remembering to edit gdbarch.sh. 2014-01-13 Tom Tromey <tromey@redhat.com> * defs.h (XMALLOC): Remove. * avr-tdep.c (avr_gdbarch_init): Use XNEW, not XMALLOC. * bfin-tdep.c (bfin_gdbarch_init): Likewise. * cli-out.c (struct ui_out *): Likewise. * cli/cli-dump.c (add_dump_command): Likewise. (add_dump_command): Likewise. * complaints.c (get_complaints): Likewise. (find_complaint): Likewise. * dwarf2-frame.c (execute_cfa_program): Likewise. * dwarf2read.c (abbrev_table_read_table): Likewise. * gdbarch.sh: Likewise. * gdbarch.c: Rebuild. * inf-ttrace.c (inf_ttrace_add_page): Likewise. * interps.c (interp_new): Likewise. * lm32-tdep.c (lm32_gdbarch_init): Likewise. * m32r-tdep.c (m32r_gdbarch_init): Likewise. * mi/mi-console.c (mi_console_file_new): Likewise. * mi/mi-interp.c (mi_interpreter_init): Likewise. * mi/mi-out.c (mi_out_new): Likewise. * mi/mi-parse.c (mi_parse): Likewise. * microblaze-tdep.c (microblaze_gdbarch_init): Likewise. * moxie-tdep.c (moxie_gdbarch_init): Likewise. * observer.c (xalloc_observer_list_node): Likewise. * regcache.c (regcache_xmalloc_1): Likewise. * reggroups.c (reggroup_new): Likewise. (_initialize_reggroup): Likewise. * registry.c (register_data_with_cleanup): Likewise. * remote.c (remote_notif_stop_alloc_reply): Likewise. * ser-base.c (serial_ttystate): Likewise. * ser-mingw.c (make_pipe_state): Likewise. * ser-pipe.c (pipe_open): Likewise. * serial.c (serial_open): Likewise. * sh64-tdep.c (sh64_gdbarch_init): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_add_content_elements): Likewise. * tui/tui-file.c (tui_file_new): Likewise. * tui/tui-out.c (tui_out_new): Likewise. * ui-file.c (mem_file_new): Likewise. * ui-out.c (push_level): Likewise. (make_cleanup_ui_out_end): Likewise. (append_header_to_list): Likewise. (ui_out_new): Likewise. * user-regs.c (user_reg_add_builtin): Likewise.
2013-12-28 23:31:23 +01:00
= (struct notif_event *) XNEW (struct stop_reply);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
r->dtr = stop_reply_dtr;
return r;
}
/* A client of notification Stop. */
struct notif_client notif_client_stop =
{
"Stop",
"vStopped",
remote_notif_stop_parse,
remote_notif_stop_ack,
remote_notif_stop_can_get_pending_events,
remote_notif_stop_alloc_reply,
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
REMOTE_NOTIF_STOP,
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
};
/* A parameter to pass data in and out. */
struct queue_iter_param
{
void *input;
struct stop_reply *output;
};
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
/* Determine if THREAD is a pending fork parent thread. ARG contains
the pid of the process that owns the threads we want to check, or
-1 if we want to check all threads. */
static int
is_pending_fork_parent (struct target_waitstatus *ws, int event_pid,
ptid_t thread_ptid)
{
if (ws->kind == TARGET_WAITKIND_FORKED
|| ws->kind == TARGET_WAITKIND_VFORKED)
{
if (event_pid == -1 || event_pid == ptid_get_pid (thread_ptid))
return 1;
}
return 0;
}
/* Check whether EVENT is a fork event, and if it is, remove the
fork child from the context list passed in DATA. */
static int
remove_child_of_pending_fork (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
stop_reply_p event,
void *data)
{
struct queue_iter_param *param = data;
struct threads_listing_context *context = param->input;
if (event->ws.kind == TARGET_WAITKIND_FORKED
|| event->ws.kind == TARGET_WAITKIND_VFORKED)
{
threads_listing_context_remove (&event->ws, context);
}
return 1;
}
/* If CONTEXT contains any fork child threads that have not been
reported yet, remove them from the CONTEXT list. If such a
thread exists it is because we are stopped at a fork catchpoint
and have not yet called follow_fork, which will set up the
host-side data structures for the new process. */
static void
remove_new_fork_children (struct threads_listing_context *context)
{
struct thread_info * thread;
int pid = -1;
struct notif_client *notif = &notif_client_stop;
struct queue_iter_param param;
/* For any threads stopped at a fork event, remove the corresponding
fork child threads from the CONTEXT list. */
ALL_NON_EXITED_THREADS (thread)
{
struct target_waitstatus *ws = &thread->pending_follow;
if (is_pending_fork_parent (ws, pid, thread->ptid))
{
threads_listing_context_remove (ws, context);
}
}
/* Check for any pending fork events (not reported or processed yet)
in process PID and remove those fork child threads from the
CONTEXT list as well. */
remote_notif_get_pending_events (notif);
param.input = context;
param.output = NULL;
QUEUE_iterate (stop_reply_p, stop_reply_queue,
remove_child_of_pending_fork, &param);
}
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
/* Remove stop replies in the queue if its pid is equal to the given
inferior's pid. */
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
static int
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
remove_stop_reply_for_inferior (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
stop_reply_p event,
void *data)
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
{
struct queue_iter_param *param = data;
struct inferior *inf = param->input;
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
if (ptid_get_pid (event->ptid) == inf->pid)
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
{
stop_reply_xfree (event);
QUEUE_remove_elem (stop_reply_p, q, iter);
}
return 1;
}
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
/* Discard all pending stop replies of inferior INF. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
discard_pending_stop_replies (struct inferior *inf)
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
int i;
struct queue_iter_param param;
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
struct stop_reply *reply;
struct remote_state *rs = get_remote_state ();
struct remote_notif_state *rns = rs->notif_state;
/* This function can be notified when an inferior exists. When the
target is not remote, the notification state is NULL. */
if (rs->remote_desc == NULL)
return;
reply = (struct stop_reply *) rns->pending_event[notif_client_stop.id];
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Discard the in-flight notification. */
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
if (reply != NULL && ptid_get_pid (reply->ptid) == inf->pid)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
stop_reply_xfree (reply);
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
rns->pending_event[notif_client_stop.id] = NULL;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
param.input = inf;
param.output = NULL;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Discard the stop replies we have already pulled with
vStopped. */
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
QUEUE_iterate (stop_reply_p, stop_reply_queue,
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
remove_stop_reply_for_inferior, &param);
}
/* If its remote state is equal to the given remote state,
remove EVENT from the stop reply queue. */
static int
remove_stop_reply_of_remote_state (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
stop_reply_p event,
void *data)
{
struct queue_iter_param *param = data;
struct remote_state *rs = param->input;
if (event->rs == rs)
{
stop_reply_xfree (event);
QUEUE_remove_elem (stop_reply_p, q, iter);
}
return 1;
}
/* Discard the stop replies for RS in stop_reply_queue. */
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
static void
discard_pending_stop_replies_in_queue (struct remote_state *rs)
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
{
struct queue_iter_param param;
param.input = rs;
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
param.output = NULL;
/* Discard the stop replies we have already pulled with
vStopped. */
QUEUE_iterate (stop_reply_p, stop_reply_queue,
remove_stop_reply_of_remote_state, &param);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* A parameter to pass data in and out. */
static int
remote_notif_remove_once_on_match (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
stop_reply_p event,
void *data)
{
struct queue_iter_param *param = data;
ptid_t *ptid = param->input;
if (ptid_match (event->ptid, *ptid))
{
param->output = event;
QUEUE_remove_elem (stop_reply_p, q, iter);
return 0;
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
return 1;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
1999-07-05 19:58:44 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* Remove the first reply in 'stop_reply_queue' which matches
PTID. */
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
static struct stop_reply *
remote_notif_remove_queued_reply (ptid_t ptid)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct queue_iter_param param;
param.input = &ptid;
param.output = NULL;
QUEUE_iterate (stop_reply_p, stop_reply_queue,
remote_notif_remove_once_on_match, &param);
if (notif_debug)
fprintf_unfiltered (gdb_stdlog,
"notif: discard queued event: 'Stop' in %s\n",
target_pid_to_str (ptid));
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
return param.output;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Look for a queued stop reply belonging to PTID. If one is found,
remove it from the queue, and return it. Returns NULL if none is
found. If there are still queued events left to process, tell the
event loop to get back to target_wait soon. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static struct stop_reply *
queued_stop_reply (ptid_t ptid)
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct stop_reply *r = remote_notif_remove_queued_reply (ptid);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
if (!QUEUE_is_empty (stop_reply_p, stop_reply_queue))
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* There's still at least an event left. */
mark_async_event_handler (remote_async_inferior_event_token);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
return r;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* Push a fully parsed stop reply in the stop reply queue. Since we
know that we now have at least one queued event left to pass to the
core side, tell the event loop to get back to target_wait soon. */
static void
push_stop_reply (struct stop_reply *new_event)
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
QUEUE_enque (stop_reply_p, stop_reply_queue, new_event);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
if (notif_debug)
fprintf_unfiltered (gdb_stdlog,
"notif: push 'Stop' %s to queue %d\n",
target_pid_to_str (new_event->ptid),
QUEUE_length (stop_reply_p,
stop_reply_queue));
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
mark_async_event_handler (remote_async_inferior_event_token);
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
static int
stop_reply_match_ptid_and_ws (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
struct stop_reply *event,
void *data)
{
ptid_t *ptid = data;
return !(ptid_equal (*ptid, event->ptid)
&& event->ws.kind == TARGET_WAITKIND_STOPPED);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Returns true if we have a stop reply for PTID. */
static int
peek_stop_reply (ptid_t ptid)
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
return !QUEUE_iterate (stop_reply_p, stop_reply_queue,
stop_reply_match_ptid_and_ws, &ptid);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* Skip PACKET until the next semi-colon (or end of string). */
static char *
skip_to_semicolon (char *p)
{
while (*p != '\0' && *p != ';')
p++;
return p;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Parse the stop reply in BUF. Either the function succeeds, and the
result is stored in EVENT, or throws an error. */
static void
remote_parse_stop_reply (char *buf, struct stop_reply *event)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
ULONGEST addr;
char *p;
event->ptid = null_ptid;
event->rs = get_remote_state ();
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event->ws.kind = TARGET_WAITKIND_IGNORE;
event->ws.value.integer = 0;
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
event->stop_reason = TARGET_STOPPED_BY_NO_REASON;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event->regcache = NULL;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
event->core = -1;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
switch (buf[0])
{
case 'T': /* Status with PC, SP, FP, ... */
/* Expedited reply, containing Signal, {regno, reg} repeat. */
/* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
ss = signal number
n... = register number
r... = register contents
*/
p = &buf[3]; /* after Txx */
while (*p)
{
char *p1;
int fieldsize;
1999-07-05 19:58:44 +02:00
p1 = strchr (p, ':');
if (p1 == NULL)
error (_("Malformed packet(a) (missing colon): %s\n\
Packet: '%s'\n"),
p, buf);
if (p == p1)
error (_("Malformed packet(a) (missing register number): %s\n\
Packet: '%s'\n"),
p, buf);
/* Some "registers" are actually extended stop information.
Note if you're adding a new entry here: GDB 7.9 and
earlier assume that all register "numbers" that start
with an hex digit are real register numbers. Make sure
the server only sends such a packet if it knows the
client understands it. */
if (strncmp (p, "thread", p1 - p) == 0)
event->ptid = read_ptid (++p1, &p);
else if ((strncmp (p, "watch", p1 - p) == 0)
|| (strncmp (p, "rwatch", p1 - p) == 0)
|| (strncmp (p, "awatch", p1 - p) == 0))
{
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
event->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
p = unpack_varlen_hex (++p1, &addr);
event->watch_data_address = (CORE_ADDR) addr;
}
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
else if (strncmp (p, "swbreak", p1 - p) == 0)
{
event->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
/* Make sure the stub doesn't forget to indicate support
with qSupported. */
if (packet_support (PACKET_swbreak_feature) != PACKET_ENABLE)
error (_("Unexpected swbreak stop reason"));
/* The value part is documented as "must be empty",
though we ignore it, in case we ever decide to make
use of it in a backward compatible way. */
p = skip_to_semicolon (p1 + 1);
}
else if (strncmp (p, "hwbreak", p1 - p) == 0)
{
event->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
/* Make sure the stub doesn't forget to indicate support
with qSupported. */
if (packet_support (PACKET_hwbreak_feature) != PACKET_ENABLE)
error (_("Unexpected hwbreak stop reason"));
/* See above. */
p = skip_to_semicolon (p1 + 1);
}
else if (strncmp (p, "library", p1 - p) == 0)
{
event->ws.kind = TARGET_WAITKIND_LOADED;
p = skip_to_semicolon (p1 + 1);
}
else if (strncmp (p, "replaylog", p1 - p) == 0)
{
event->ws.kind = TARGET_WAITKIND_NO_HISTORY;
/* p1 will indicate "begin" or "end", but it makes
no difference for now, so ignore it. */
p = skip_to_semicolon (p1 + 1);
}
else if (strncmp (p, "core", p1 - p) == 0)
{
ULONGEST c;
p = unpack_varlen_hex (++p1, &c);
event->core = c;
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
else if (strncmp (p, "fork", p1 - p) == 0)
{
event->ws.value.related_pid = read_ptid (++p1, &p);
event->ws.kind = TARGET_WAITKIND_FORKED;
}
2015-05-12 18:52:45 +02:00
else if (strncmp (p, "vfork", p1 - p) == 0)
{
event->ws.value.related_pid = read_ptid (++p1, &p);
event->ws.kind = TARGET_WAITKIND_VFORKED;
}
else if (strncmp (p, "vforkdone", p1 - p) == 0)
{
event->ws.kind = TARGET_WAITKIND_VFORK_DONE;
p = skip_to_semicolon (p1 + 1);
}
else
{
ULONGEST pnum;
char *p_temp;
/* Maybe a real ``P'' register number. */
p_temp = unpack_varlen_hex (p, &pnum);
/* If the first invalid character is the colon, we got a
register number. Otherwise, it's an unknown stop
reason. */
if (p_temp == p1)
{
struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum);
cached_reg_t cached_reg;
1999-07-05 19:58:44 +02:00
if (reg == NULL)
error (_("Remote sent bad register number %s: %s\n\
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
Packet: '%s'\n"),
hex_string (pnum), p, buf);
cached_reg.num = reg->regnum;
p = p1 + 1;
fieldsize = hex2bin (p, cached_reg.data,
register_size (target_gdbarch (),
reg->regnum));
p += 2 * fieldsize;
if (fieldsize < register_size (target_gdbarch (),
reg->regnum))
warning (_("Remote reply is too short: %s"), buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
VEC_safe_push (cached_reg_t, event->regcache, &cached_reg);
}
else
{
/* Not a number. Silently skip unknown optional
info. */
p = skip_to_semicolon (p1 + 1);
}
}
if (*p != ';')
error (_("Remote register badly formatted: %s\nhere: %s"),
buf, p);
++p;
}
if (event->ws.kind != TARGET_WAITKIND_IGNORE)
break;
/* fall through */
case 'S': /* Old style status, just signal only. */
{
int sig;
event->ws.kind = TARGET_WAITKIND_STOPPED;
sig = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
if (GDB_SIGNAL_FIRST <= sig && sig < GDB_SIGNAL_LAST)
event->ws.value.sig = (enum gdb_signal) sig;
else
event->ws.value.sig = GDB_SIGNAL_UNKNOWN;
}
break;
case 'W': /* Target exited. */
case 'X':
{
char *p;
int pid;
ULONGEST value;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* GDB used to accept only 2 hex chars here. Stubs should
only send more if they detect GDB supports multi-process
support. */
p = unpack_varlen_hex (&buf[1], &value);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (buf[0] == 'W')
{
/* The remote process exited. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event->ws.kind = TARGET_WAITKIND_EXITED;
event->ws.value.integer = value;
}
else
{
/* The remote process exited with a signal. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event->ws.kind = TARGET_WAITKIND_SIGNALLED;
if (GDB_SIGNAL_FIRST <= value && value < GDB_SIGNAL_LAST)
event->ws.value.sig = (enum gdb_signal) value;
else
event->ws.value.sig = GDB_SIGNAL_UNKNOWN;
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
/* If no process is specified, assume inferior_ptid. */
pid = ptid_get_pid (inferior_ptid);
if (*p == '\0')
;
else if (*p == ';')
{
p++;
if (*p == '\0')
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
;
else if (startswith (p, "process:"))
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
{
ULONGEST upid;
p += sizeof ("process:") - 1;
unpack_varlen_hex (p, &upid);
pid = upid;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
else
error (_("unknown stop reply packet: %s"), buf);
1999-07-05 19:58:44 +02:00
}
else
error (_("unknown stop reply packet: %s"), buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event->ptid = pid_to_ptid (pid);
}
break;
}
if (non_stop && ptid_equal (event->ptid, null_ptid))
error (_("No process or thread specified in stop reply: %s"), buf);
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* When the stub wants to tell GDB about a new notification reply, it
sends a notification (%Stop, for example). Those can come it at
any time, hence, we have to make sure that any pending
putpkt/getpkt sequence we're making is finished, before querying
the stub for more events with the corresponding ack command
(vStopped, for example). E.g., if we started a vStopped sequence
immediately upon receiving the notification, something like this
could happen:
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
1.1) --> Hg 1
1.2) <-- OK
1.3) --> g
1.4) <-- %Stop
1.5) --> vStopped
1.6) <-- (registers reply to step #1.3)
Obviously, the reply in step #1.6 would be unexpected to a vStopped
query.
2013-02-15 04:37:12 +01:00
To solve this, whenever we parse a %Stop notification successfully,
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
we mark the REMOTE_ASYNC_GET_PENDING_EVENTS_TOKEN, and carry on
doing whatever we were doing:
2.1) --> Hg 1
2.2) <-- OK
2.3) --> g
2.4) <-- %Stop
<GDB marks the REMOTE_ASYNC_GET_PENDING_EVENTS_TOKEN>
2.5) <-- (registers reply to step #2.3)
Eventualy after step #2.5, we return to the event loop, which
notices there's an event on the
REMOTE_ASYNC_GET_PENDING_EVENTS_TOKEN event and calls the
associated callback --- the function below. At this point, we're
always safe to start a vStopped sequence. :
2.6) --> vStopped
2.7) <-- T05 thread:2
2.8) --> vStopped
2.9) --> OK
*/
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
void
remote_notif_get_pending_events (struct notif_client *nc)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
struct remote_state *rs = get_remote_state ();
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
if (rs->notif_state->pending_event[nc->id] != NULL)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
if (notif_debug)
fprintf_unfiltered (gdb_stdlog,
"notif: process: '%s' ack pending event\n",
nc->name);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* acknowledge */
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
nc->ack (nc, rs->buf, rs->notif_state->pending_event[nc->id]);
rs->notif_state->pending_event[nc->id] = NULL;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
while (1)
{
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") == 0)
break;
else
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
remote_notif_ack (nc, rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
}
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
else
{
if (notif_debug)
fprintf_unfiltered (gdb_stdlog,
"notif: process: '%s' no pending reply\n",
nc->name);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
/* Called when it is decided that STOP_REPLY holds the info of the
event that is to be returned to the core. This function always
destroys STOP_REPLY. */
static ptid_t
process_stop_reply (struct stop_reply *stop_reply,
struct target_waitstatus *status)
{
ptid_t ptid;
*status = stop_reply->ws;
ptid = stop_reply->ptid;
/* If no thread/process was reported by the stub, assume the current
inferior. */
if (ptid_equal (ptid, null_ptid))
ptid = inferior_ptid;
if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
struct remote_state *rs = get_remote_state ();
/* Expedited registers. */
if (stop_reply->regcache)
{
struct regcache *regcache
= get_thread_arch_regcache (ptid, target_gdbarch ());
cached_reg_t *reg;
int ix;
for (ix = 0;
VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg);
ix++)
regcache_raw_supply (regcache, reg->num, reg->data);
VEC_free (cached_reg_t, stop_reply->regcache);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
rs->stop_reason = stop_reply->stop_reason;
rs->remote_watch_data_address = stop_reply->watch_data_address;
remote_notice_new_inferior (ptid, 0);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
demand_private_info (ptid)->core = stop_reply->core;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
stop_reply_xfree (stop_reply);
return ptid;
}
/* The non-stop mode version of target_wait. */
static ptid_t
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
remote_wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
struct remote_state *rs = get_remote_state ();
struct stop_reply *stop_reply;
int ret;
int is_notif = 0;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If in non-stop mode, get out of getpkt even if a
notification is received. */
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
0 /* forever */, &is_notif);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
while (1)
{
if (ret != -1 && !is_notif)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
switch (rs->buf[0])
{
case 'E': /* Error of some sort. */
/* We're out of sync with the target now. Did it continue
or not? We can't tell which thread it was in non-stop,
so just ignore this. */
warning (_("Remote failure reply: %s"), rs->buf);
break;
case 'O': /* Console output. */
remote_console_output (rs->buf + 1);
break;
default:
warning (_("Invalid remote reply: %s"), rs->buf);
break;
}
/* Acknowledge a pending stop reply that may have arrived in the
mean time. */
Move pending_event to remote_notif_state. This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
2013-10-04 09:42:06 +02:00
if (rs->notif_state->pending_event[notif_client_stop.id] != NULL)
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
remote_notif_get_pending_events (&notif_client_stop);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If indeed we noticed a stop reply, we're done. */
stop_reply = queued_stop_reply (ptid);
if (stop_reply != NULL)
return process_stop_reply (stop_reply, status);
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
/* Still no event. If we're just polling for an event, then
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
return to the event loop. */
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
if (options & TARGET_WNOHANG)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid;
}
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
/* Otherwise do a blocking wait. */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
1 /* forever */, &is_notif);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
}
/* Wait until the remote machine stops, then return, storing status in
STATUS just as `wait' would. */
static ptid_t
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
struct remote_state *rs = get_remote_state ();
ptid_t event_ptid = null_ptid;
char *buf;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
struct stop_reply *stop_reply;
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
again:
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
status->kind = TARGET_WAITKIND_IGNORE;
status->value.integer = 0;
stop_reply = queued_stop_reply (ptid);
if (stop_reply != NULL)
return process_stop_reply (stop_reply, status);
if (rs->cached_wait_status)
/* Use the cached wait status, but only once. */
rs->cached_wait_status = 0;
else
{
int ret;
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
int is_notif;
int forever = ((options & TARGET_WNOHANG) == 0
&& wait_forever_enabled_p);
if (!rs->waiting_for_stop_reply)
{
status->kind = TARGET_WAITKIND_NO_RESUMED;
return minus_one_ptid;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (!target_is_async_p ())
{
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
ofunc = signal (SIGINT, sync_remote_interrupt);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If the user hit C-c before this packet, or between packets,
pretend that it was hit right here. */
if (check_quit_flag ())
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
clear_quit_flag ();
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
sync_remote_interrupt (SIGINT);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
}
/* FIXME: cagney/1999-09-27: If we're in async mode we should
_never_ wait for ever -> test on target_is_async_p().
However, before we do that we need to ensure that the caller
knows how to take the target into/out of async mode. */
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
forever, &is_notif);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
if (!target_is_async_p ())
signal (SIGINT, ofunc);
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
/* GDB gets a notification. Return to core as this event is
not interesting. */
if (ret != -1 && is_notif)
return minus_one_ptid;
if (ret == -1 && (options & TARGET_WNOHANG) != 0)
return minus_one_ptid;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
buf = rs->buf;
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
rs->stop_reason = TARGET_STOPPED_BY_NO_REASON;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* We got something. */
rs->waiting_for_stop_reply = 0;
/* Assume that the target has acknowledged Ctrl-C unless we receive
an 'F' or 'O' packet. */
if (buf[0] != 'F' && buf[0] != 'O')
rs->ctrlc_pending_p = 0;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
switch (buf[0])
{
case 'E': /* Error of some sort. */
/* We're out of sync with the target now. Did it continue or
not? Not is more likely, so report a stop. */
warning (_("Remote failure reply: %s"), buf);
status->kind = TARGET_WAITKIND_STOPPED;
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
status->value.sig = GDB_SIGNAL_0;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
break;
case 'F': /* File-I/O request. */
remote_fileio_request (buf, rs->ctrlc_pending_p);
rs->ctrlc_pending_p = 0;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
break;
case 'T': case 'S': case 'X': case 'W':
{
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
struct stop_reply *stop_reply
= (struct stop_reply *) remote_notif_parse (&notif_client_stop,
rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
event_ptid = process_stop_reply (stop_reply, status);
break;
}
case 'O': /* Console output. */
remote_console_output (buf + 1);
/* The target didn't really stop; keep waiting. */
rs->waiting_for_stop_reply = 1;
break;
case '\0':
if (rs->last_sent_signal != GDB_SIGNAL_0)
{
/* Zero length reply means that we tried 'S' or 'C' and the
remote system doesn't support it. */
target_terminal_ours_for_output ();
printf_filtered
("Can't send signals to this remote system. %s not sent.\n",
gdb_signal_to_name (rs->last_sent_signal));
rs->last_sent_signal = GDB_SIGNAL_0;
target_terminal_inferior ();
strcpy ((char *) buf, rs->last_sent_step ? "s" : "c");
putpkt ((char *) buf);
/* We just told the target to resume, so a stop reply is in
order. */
rs->waiting_for_stop_reply = 1;
break;
1999-07-05 19:58:44 +02:00
}
/* else fallthrough */
default:
warning (_("Invalid remote reply: %s"), buf);
/* Keep waiting. */
rs->waiting_for_stop_reply = 1;
break;
1999-07-05 19:58:44 +02:00
}
if (status->kind == TARGET_WAITKIND_IGNORE)
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
{
/* Nothing interesting happened. If we're doing a non-blocking
poll, we're done. Otherwise, go back to waiting. */
if (options & TARGET_WNOHANG)
return minus_one_ptid;
else
goto again;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED)
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
{
if (!ptid_equal (event_ptid, null_ptid))
record_currthread (rs, event_ptid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
else
event_ptid = inferior_ptid;
1999-07-05 19:58:44 +02:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
/* A process exit. Invalidate our notion of current thread. */
record_currthread (rs, minus_one_ptid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
return event_ptid;
1999-07-05 19:58:44 +02:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Wait until the remote machine stops, then return, storing status in
STATUS just as `wait' would. */
static ptid_t
* linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
remote_wait (struct target_ops *ops,
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
ptid_t ptid, struct target_waitstatus *status, int options)
{
ptid_t event_ptid;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (non_stop)
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
event_ptid = remote_wait_ns (ptid, status, options);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
event_ptid = remote_wait_as (ptid, status, options);
if (target_is_async_p ())
{
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If there are are events left in the queue tell the event loop
to return here. */
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
if (!QUEUE_is_empty (stop_reply_p, stop_reply_queue))
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
mark_async_event_handler (remote_async_inferior_event_token);
}
return event_ptid;
}
/* Fetch a single register using a 'p' packet. */
static int
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
fetch_register_using_p (struct regcache *regcache, struct packet_reg *reg)
{
struct remote_state *rs = get_remote_state ();
char *buf, *p;
char regp[MAX_REGISTER_SIZE];
int i;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_p) == PACKET_DISABLE)
return 0;
if (reg->pnum == -1)
return 0;
p = rs->buf;
*p++ = 'p';
p += hexnumstr (p, reg->pnum);
*p++ = '\0';
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
buf = rs->buf;
switch (packet_ok (buf, &remote_protocol_packets[PACKET_p]))
{
case PACKET_OK:
break;
case PACKET_UNKNOWN:
return 0;
case PACKET_ERROR:
error (_("Could not fetch register \"%s\"; remote failure reply '%s'"),
gdbarch_register_name (get_regcache_arch (regcache),
reg->regnum),
buf);
}
/* If this register is unfetchable, tell the regcache. */
if (buf[0] == 'x')
{
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, reg->regnum, NULL);
return 1;
}
/* Otherwise, parse and supply the value. */
p = buf;
i = 0;
while (p[0] != 0)
{
if (p[1] == 0)
error (_("fetch_register_using_p: early buf termination"));
regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
p += 2;
}
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, reg->regnum, regp);
return 1;
}
/* Fetch the registers included in the target's 'g' packet. */
static int
send_g_packet (void)
{
struct remote_state *rs = get_remote_state ();
int buf_len;
xsnprintf (rs->buf, get_remote_packet_size (), "g");
remote_send (&rs->buf, &rs->buf_size);
/* We can get out of synch in various cases. If the first character
in the buffer is not a hex character, assume that has happened
and try to fetch another packet to read. */
while ((rs->buf[0] < '0' || rs->buf[0] > '9')
&& (rs->buf[0] < 'A' || rs->buf[0] > 'F')
&& (rs->buf[0] < 'a' || rs->buf[0] > 'f')
&& rs->buf[0] != 'x') /* New: unavailable register value. */
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"Bad register packet; fetching a new packet\n");
getpkt (&rs->buf, &rs->buf_size, 0);
}
buf_len = strlen (rs->buf);
/* Sanity check the received packet. */
if (buf_len % 2 != 0)
error (_("Remote 'g' packet reply is of odd length: %s"), rs->buf);
return buf_len / 2;
}
static void
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
process_g_packet (struct regcache *regcache)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
int i, buf_len;
char *p;
char *regs;
buf_len = strlen (rs->buf);
/* Further sanity checks, with knowledge of the architecture. */
if (buf_len > 2 * rsa->sizeof_g_packet)
error (_("Remote 'g' packet reply is too long: %s"), rs->buf);
/* Save the size of the packet sent to us by the target. It is used
as a heuristic when determining the max size of packets that the
target can safely receive. */
if (rsa->actual_register_packet_size == 0)
rsa->actual_register_packet_size = buf_len;
/* If this is smaller than we guessed the 'g' packet would be,
update our records. A 'g' reply that doesn't include a register's
value implies either that the register is not available, or that
the 'p' packet must be used. */
if (buf_len < 2 * rsa->sizeof_g_packet)
{
rsa->sizeof_g_packet = buf_len / 2;
for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
{
if (rsa->regs[i].pnum == -1)
continue;
if (rsa->regs[i].offset >= rsa->sizeof_g_packet)
rsa->regs[i].in_g_packet = 0;
else
rsa->regs[i].in_g_packet = 1;
}
}
regs = alloca (rsa->sizeof_g_packet);
/* Unimplemented registers read as all bits zero. */
memset (regs, 0, rsa->sizeof_g_packet);
/* Reply describes registers byte by byte, each byte encoded as two
hex characters. Suck them all up, then supply them to the
register cacheing/storage mechanism. */
p = rs->buf;
for (i = 0; i < rsa->sizeof_g_packet; i++)
{
if (p[0] == 0 || p[1] == 0)
/* This shouldn't happen - we adjusted sizeof_g_packet above. */
internal_error (__FILE__, __LINE__,
_("unexpected end of 'g' packet reply"));
if (p[0] == 'x' && p[1] == 'x')
1999-07-07 22:19:36 +02:00
regs[i] = 0; /* 'x' */
else
regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
p += 2;
}
for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
{
struct packet_reg *r = &rsa->regs[i];
if (r->in_g_packet)
{
if (r->offset * 2 >= strlen (rs->buf))
/* This shouldn't happen - we adjusted in_g_packet above. */
internal_error (__FILE__, __LINE__,
_("unexpected end of 'g' packet reply"));
else if (rs->buf[r->offset * 2] == 'x')
{
gdb_assert (r->offset * 2 < strlen (rs->buf));
/* The register isn't available, mark it as such (at
the same time setting the value to zero). */
regcache_raw_supply (regcache, r->regnum, NULL);
}
else
regcache_raw_supply (regcache, r->regnum,
regs + r->offset);
}
}
}
static void
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
fetch_registers_using_g (struct regcache *regcache)
{
send_g_packet ();
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
process_g_packet (regcache);
}
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
/* Make the remote selected traceframe match GDB's selected
traceframe. */
static void
set_remote_traceframe (void)
{
int newnum;
struct remote_state *rs = get_remote_state ();
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
if (rs->remote_traceframe_number == get_traceframe_number ())
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
return;
/* Avoid recursion, remote_trace_find calls us again. */
rs->remote_traceframe_number = get_traceframe_number ();
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
newnum = target_trace_find (tfind_number,
get_traceframe_number (), 0, 0, NULL);
/* Should not happen. If it does, all bets are off. */
if (newnum != get_traceframe_number ())
warning (_("could not set remote traceframe"));
}
static void
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
remote_fetch_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
set_remote_traceframe ();
set_general_thread (inferior_ptid);
if (regnum >= 0)
{
struct packet_reg *reg = packet_reg_from_regnum (rsa, regnum);
gdb_assert (reg != NULL);
/* If this register might be in the 'g' packet, try that first -
we are likely to read more than one register. If this is the
first 'g' packet, we might be overly optimistic about its
contents, so fall back to 'p'. */
if (reg->in_g_packet)
{
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
fetch_registers_using_g (regcache);
if (reg->in_g_packet)
return;
}
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
if (fetch_register_using_p (regcache, reg))
return;
/* This register is not available. */
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, reg->regnum, NULL);
return;
}
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
fetch_registers_using_g (regcache);
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (!rsa->regs[i].in_g_packet)
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
if (!fetch_register_using_p (regcache, &rsa->regs[i]))
{
/* This register is not available. */
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, i, NULL);
}
}
/* Prepare to store registers. Since we may send them all (using a
'G' request), we have to read out the ones we don't want to change
first. */
1999-07-07 22:19:36 +02:00
static void
remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
gdb_byte buf[MAX_REGISTER_SIZE];
/* Make sure the entire registers array is valid. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_support (PACKET_P))
1999-07-27 02:51:29 +02:00
{
case PACKET_DISABLE:
case PACKET_SUPPORT_UNKNOWN:
/* Make sure all the necessary registers are cached. */
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (rsa->regs[i].in_g_packet)
regcache_raw_read (regcache, rsa->regs[i].regnum, buf);
1999-07-27 02:51:29 +02:00
break;
case PACKET_ENABLE:
break;
}
}
/* Helper: Attempt to store REGNUM using the P packet. Return fail IFF
packet was not recognized. */
1999-07-27 02:51:29 +02:00
static int
store_register_using_P (const struct regcache *regcache,
struct packet_reg *reg)
1999-07-27 02:51:29 +02:00
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct remote_state *rs = get_remote_state ();
1999-07-27 02:51:29 +02:00
/* Try storing a single register. */
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *buf = rs->buf;
gdb_byte regp[MAX_REGISTER_SIZE];
1999-07-27 02:51:29 +02:00
char *p;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_P) == PACKET_DISABLE)
return 0;
if (reg->pnum == -1)
return 0;
xsnprintf (buf, get_remote_packet_size (), "P%s=", phex_nz (reg->pnum, 0));
1999-07-27 02:51:29 +02:00
p = buf + strlen (buf);
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_collect (regcache, reg->regnum, regp);
bin2hex (regp, p, register_size (gdbarch, reg->regnum));
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-07-27 02:51:29 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_P]))
{
case PACKET_OK:
return 1;
case PACKET_ERROR:
error (_("Could not write register \"%s\"; remote failure reply '%s'"),
gdbarch_register_name (gdbarch, reg->regnum), rs->buf);
case PACKET_UNKNOWN:
return 0;
default:
internal_error (__FILE__, __LINE__, _("Bad result from packet_ok"));
}
}
/* Store register REGNUM, or all registers if REGNUM == -1, from the
contents of the register cache buffer. FIXME: ignores errors. */
static void
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
store_registers_using_G (const struct regcache *regcache)
{
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
gdb_byte *regs;
char *p;
/* Extract all the registers in the regcache copying them into a
local buffer. */
{
int i;
regs = alloca (rsa->sizeof_g_packet);
memset (regs, 0, rsa->sizeof_g_packet);
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
{
struct packet_reg *r = &rsa->regs[i];
if (r->in_g_packet)
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_collect (regcache, r->regnum, regs + r->offset);
}
}
/* Command describes registers byte by byte,
each byte encoded as two hex characters. */
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
p = rs->buf;
*p++ = 'G';
/* remote_prepare_to_store insures that rsa->sizeof_g_packet gets
updated. */
bin2hex (regs, p, rsa->sizeof_g_packet);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (packet_check_result (rs->buf) == PACKET_ERROR)
error (_("Could not write registers; remote failure reply '%s'"),
rs->buf);
}
/* Store register REGNUM, or all registers if REGNUM == -1, from the contents
of the register cache buffer. FIXME: ignores errors. */
static void
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
remote_store_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
set_remote_traceframe ();
set_general_thread (inferior_ptid);
if (regnum >= 0)
{
struct packet_reg *reg = packet_reg_from_regnum (rsa, regnum);
gdb_assert (reg != NULL);
/* Always prefer to store registers using the 'P' packet if
possible; we often change only a small number of registers.
Sometimes we change a larger number; we'd need help from a
higher layer to know to use 'G'. */
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
if (store_register_using_P (regcache, reg))
return;
/* For now, don't complain if we have no way to write the
register. GDB loses track of unavailable registers too
easily. Some day, this may be an error. We don't have
any way to read the register, either... */
if (!reg->in_g_packet)
return;
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
store_registers_using_G (regcache);
return;
}
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
store_registers_using_G (regcache);
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (!rsa->regs[i].in_g_packet)
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
if (!store_register_using_P (regcache, &rsa->regs[i]))
/* See above for why we do not issue an error here. */
continue;
}
/* Return the number of hex digits in num. */
static int
2000-07-30 03:48:28 +02:00
hexnumlen (ULONGEST num)
{
int i;
for (i = 0; num != 0; i++)
num >>= 4;
return max (i, 1);
}
1999-10-12 06:37:53 +02:00
/* Set BUF to the minimum number of hex digits representing NUM. */
static int
2000-07-30 03:48:28 +02:00
hexnumstr (char *buf, ULONGEST num)
{
int len = hexnumlen (num);
1999-10-12 06:37:53 +02:00
return hexnumnstr (buf, num, len);
}
1999-10-12 06:37:53 +02:00
/* Set BUF to the hex digits representing NUM, padded to WIDTH characters. */
1999-10-12 06:37:53 +02:00
static int
2000-07-30 03:48:28 +02:00
hexnumnstr (char *buf, ULONGEST num, int width)
1999-10-12 06:37:53 +02:00
{
int i;
buf[width] = '\0';
for (i = width - 1; i >= 0; i--)
{
1999-07-07 22:19:36 +02:00
buf[i] = "0123456789abcdef"[(num & 0xf)];
num >>= 4;
}
1999-10-12 06:37:53 +02:00
return width;
}
/* Mask all but the least significant REMOTE_ADDRESS_SIZE bits. */
static CORE_ADDR
2000-07-30 03:48:28 +02:00
remote_address_masked (CORE_ADDR addr)
{
unsigned int address_size = remote_address_size;
/* If "remoteaddresssize" was not set, default to target address size. */
if (!address_size)
address_size = gdbarch_addr_bit (target_gdbarch ());
if (address_size > 0
&& address_size < (sizeof (ULONGEST) * 8))
{
/* Only create a mask when that mask can safely be constructed
in a ULONGEST variable. */
ULONGEST mask = 1;
mask = (mask << address_size) - 1;
addr &= mask;
}
return addr;
}
/* Determine whether the remote target supports binary downloading.
This is accomplished by sending a no-op memory write of zero length
to the target at the specified address. It does not suffice to send
the whole packet, since many stubs strip the eighth bit and
subsequently compute a wrong checksum, which causes real havoc with
remote_write_bytes.
1999-04-26 20:34:20 +02:00
1999-08-09 23:36:23 +02:00
NOTE: This can still lose if the serial line is not eight-bit
clean. In cases like this, the user should clear "remote
X-packet". */
1999-08-09 23:36:23 +02:00
static void
2000-07-30 03:48:28 +02:00
check_binary_download (CORE_ADDR addr)
{
struct remote_state *rs = get_remote_state ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_support (PACKET_X))
{
1999-08-09 23:36:23 +02:00
case PACKET_DISABLE:
break;
case PACKET_ENABLE:
break;
case PACKET_SUPPORT_UNKNOWN:
{
char *p;
p = rs->buf;
1999-08-09 23:36:23 +02:00
*p++ = 'X';
p += hexnumstr (p, (ULONGEST) addr);
*p++ = ',';
p += hexnumstr (p, (ULONGEST) 0);
*p++ = ':';
*p = '\0';
putpkt_binary (rs->buf, (int) (p - rs->buf));
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == '\0')
1999-08-09 23:36:23 +02:00
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
"binary downloading NOT "
"supported by target\n");
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
remote_protocol_packets[PACKET_X].support = PACKET_DISABLE;
1999-08-09 23:36:23 +02:00
}
else
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"binary downloading supported by target\n");
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
remote_protocol_packets[PACKET_X].support = PACKET_ENABLE;
1999-08-09 23:36:23 +02:00
}
break;
}
}
}
/* Helper function to resize the payload in order to try to get a good
alignment. We try to write an amount of data such that the next write will
start on an address aligned on REMOTE_ALIGN_WRITES. */
static int
align_for_efficient_write (int todo, CORE_ADDR memaddr)
{
return ((memaddr + todo) & ~(REMOTE_ALIGN_WRITES - 1)) - memaddr;
}
/* Write memory data directly to the remote machine.
This does not inform the data cache; the data cache uses this.
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
HEADER is the starting part of the packet.
MEMADDR is the address in the remote memory space.
MYADDR is the address of the buffer in our space.
LEN_UNITS is the number of addressable units to write.
UNIT_SIZE is the length in bytes of an addressable unit.
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
PACKET_FORMAT should be either 'X' or 'M', and indicates if we
should send data as binary ('X'), or hex-encoded ('M').
The function creates packet of the form
<HEADER><ADDRESS>,<LENGTH>:<DATA>
where encoding of <DATA> is terminated by PACKET_FORMAT.
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
If USE_LENGTH is 0, then the <LENGTH> field and the preceding comma
are omitted.
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
Return the transferred status, error or OK (an
'enum target_xfer_status' value). Save the number of addressable units
transferred in *XFERED_LEN_UNITS. Only transfer a single packet.
On a platform with an addressable memory size of 2 bytes (UNIT_SIZE == 2), an
exchange between gdb and the stub could look like (?? in place of the
checksum):
-> $m1000,4#??
<- aaaabbbbccccdddd
-> $M1000,3:eeeeffffeeee#??
<- OK
-> $m1000,4#??
<- eeeeffffeeeedddd */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
const gdb_byte *myaddr, ULONGEST len_units,
int unit_size, ULONGEST *xfered_len_units,
char packet_format, int use_length)
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
struct remote_state *rs = get_remote_state ();
char *p;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
char *plen = NULL;
int plenlen = 0;
int todo_units;
int units_written;
int payload_capacity_bytes;
int payload_length_bytes;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (packet_format != 'X' && packet_format != 'M')
internal_error (__FILE__, __LINE__,
_("remote_write_bytes_aux: bad packet format"));
if (len_units == 0)
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return TARGET_XFER_EOF;
payload_capacity_bytes = get_memory_write_packet_size ();
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* The packet buffer will be large enough for the payload;
get_memory_packet_size ensures this. */
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
rs->buf[0] = '\0';
/* Compute the size of the actual payload by subtracting out the
packet header and footer overhead: "$M<memaddr>,<len>:...#nn". */
payload_capacity_bytes -= strlen ("$,:#NN");
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (!use_length)
/* The comma won't be used. */
payload_capacity_bytes += 1;
payload_capacity_bytes -= strlen (header);
payload_capacity_bytes -= hexnumlen (memaddr);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
/* Construct the packet excluding the data: "<header><memaddr>,<len>:". */
1999-10-19 04:47:02 +02:00
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
strcat (rs->buf, header);
p = rs->buf + strlen (header);
/* Compute a best guess of the number of bytes actually transfered. */
if (packet_format == 'X')
{
/* Best guess at number of bytes that will fit. */
todo_units = min (len_units, payload_capacity_bytes / unit_size);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (use_length)
payload_capacity_bytes -= hexnumlen (todo_units);
todo_units = min (todo_units, payload_capacity_bytes / unit_size);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
}
else
{
/* Number of bytes that will fit. */
todo_units = min (len_units, (payload_capacity_bytes / unit_size) / 2);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (use_length)
payload_capacity_bytes -= hexnumlen (todo_units);
todo_units = min (todo_units, (payload_capacity_bytes / unit_size) / 2);
1999-10-19 04:47:02 +02:00
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (todo_units <= 0)
internal_error (__FILE__, __LINE__,
2011-11-14 Stan Shebs <stan@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> * NEWS: Document shorter fast tracepoints and qTMinFTPILen packet. * i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for the minimum instruction size for fast tracepoints. * target.h (struct target_ops): Add new method to_get_min_fast_tracepoint_insn_len. (target_get_min_fast_tracepoint_insn_len): New. * target.c (update_current_target): Set up new target operation. * remote.c (remote_write_bytes_aux): Fix typo. (remote_get_min_fast_tracepoint_insn_len): New. (init_remote_ops): Initialize new field. * gdb.texinfo (Create and Delete Tracepoints): Describe what is needed to get shorter fast tracepoints. (Tracepoint Packets): Document new qTMinFTPILen packet. * linux-x86-low.c (small_jump_insn): New. (i386_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message, build a trampoline and issue a small jump instruction to it. (x86_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message. (x86_get_min_fast_tracepoint_insn_len): New. (the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len. * linux-low.h (struct linux_target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new operation. * linux-low.c (linux_install_fast_tracepoint_jump_pad): Add arguments. (linux_get_min_fast_tracepoint_insn_len): New function. (linux_target_op): Add new operation. * tracepoint.c (gdb_trampoline_buffer): New IPA variable. (gdb_trampoline_buffer_end): Ditto. (gdb_trampoline_buffer_error): Ditto. (struct ipa_sym_addresses): Add fields for new IPA variables. (symbol_list): Add entries for new IPA variables. (struct tracepoint): Add fields to hold the address range of the trampoline used by the tracepoint. (trampoline_buffer_head): New static variable. (trampoline_buffer_tail): Ditto. (claim_trampoline_space): New function. (have_fast_tracepoint_trampoline_buffer): New function. (clone_fast_tracepoint): Fill in trampoline fields of tracepoint structure. (install_fast_tracepoint): Ditto, also add error buffer argument. (cmd_qtminftpilen): New function. (handle_tracepoint_query): Add response to qTMinFTPILen packet. (fast_tracepoint_from_trampoline_address): New function. (fast_tracepoint_collecting): Handle trampoline as part of jump pad space. (set_trampoline_buffer_space): New function. (initialize_tracepoint): Initialize new IPA variables. * target.h (struct target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new get_min_fast_tracepoint_insn_len operation. (target_get_min_fast_tracepoint_insn_len): New. (install_fast_tracepoint_jump_pad): Add arguments. * server.h (IPA_BUFSIZ): Define. * linux-i386-ipa.c: Include extra header files. (initialize_fast_tracepoint_trampoline_buffer): New function. (initialize_low_tracepoint): Call it. * server.h (set_trampoline_buffer_space): Declare. (claim_trampoline_space): Ditto. (have_fast_tracepoint_trampoline_buffer): Ditto. * gdb.trace/ftrace.c: New. * gdb.trace/ftrace.exp: New.
2011-11-14 21:07:25 +01:00
_("minimum packet size too small to write data"));
/* If we already need another packet, then try to align the end
of this packet to a useful boundary. */
if (todo_units > 2 * REMOTE_ALIGN_WRITES && todo_units < len_units)
todo_units = align_for_efficient_write (todo_units, memaddr);
/* Append "<memaddr>". */
1999-10-19 04:47:02 +02:00
memaddr = remote_address_masked (memaddr);
p += hexnumstr (p, (ULONGEST) memaddr);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (use_length)
{
/* Append ",". */
*p++ = ',';
/* Append the length and retain its location and size. It may need to be
adjusted once the packet body has been created. */
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
plen = p;
plenlen = hexnumstr (p, (ULONGEST) todo_units);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
p += plenlen;
}
/* Append ":". */
1999-10-19 04:47:02 +02:00
*p++ = ':';
*p = '\0';
/* Append the packet body. */
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (packet_format == 'X')
1999-10-19 04:47:02 +02:00
{
/* Binary mode. Send target system values byte by byte, in
increasing byte addresses. Only escape certain critical
characters. */
payload_length_bytes =
remote_escape_output (myaddr, todo_units, unit_size, (gdb_byte *) p,
&units_written, payload_capacity_bytes);
/* If not all TODO units fit, then we'll need another packet. Make
a second try to keep the end of the packet aligned. Don't do
this if the packet is tiny. */
if (units_written < todo_units && units_written > 2 * REMOTE_ALIGN_WRITES)
{
int new_todo_units;
new_todo_units = align_for_efficient_write (units_written, memaddr);
if (new_todo_units != units_written)
payload_length_bytes =
remote_escape_output (myaddr, new_todo_units, unit_size,
(gdb_byte *) p, &units_written,
payload_capacity_bytes);
}
p += payload_length_bytes;
if (use_length && units_written < todo_units)
{
/* Escape chars have filled up the buffer prematurely,
and we have actually sent fewer units than planned.
1999-10-19 04:47:02 +02:00
Fix-up the length field of the packet. Use the same
number of characters as before. */
plen += hexnumnstr (plen, (ULONGEST) units_written,
plenlen);
1999-10-19 04:47:02 +02:00
*plen = ':'; /* overwrite \0 from hexnumnstr() */
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
}
else
{
1999-10-19 04:47:02 +02:00
/* Normal mode: Send target system values byte by byte, in
increasing byte addresses. Each byte is encoded as a two hex
value. */
p += 2 * bin2hex (myaddr, p, todo_units * unit_size);
units_written = todo_units;
}
putpkt_binary (rs->buf, (int) (p - rs->buf));
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == 'E')
return TARGET_XFER_E_IO;
/* Return UNITS_WRITTEN, not TODO_UNITS, in case escape chars caused us to
send fewer units than we'd planned. */
*xfered_len_units = (ULONGEST) units_written;
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return TARGET_XFER_OK;
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
/* Write memory data directly to the remote machine.
This does not inform the data cache; the data cache uses this.
MEMADDR is the address in the remote memory space.
MYADDR is the address of the buffer in our space.
LEN is the number of bytes.
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
Return the transferred status, error or OK (an
'enum target_xfer_status' value). Save the number of bytes
transferred in *XFERED_LEN. Only transfer a single packet. */
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len,
int unit_size, ULONGEST *xfered_len)
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
{
char *packet_format = 0;
/* Check whether the target supports binary download. */
check_binary_download (memaddr);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_support (PACKET_X))
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
{
case PACKET_ENABLE:
packet_format = "X";
break;
case PACKET_DISABLE:
packet_format = "M";
break;
case PACKET_SUPPORT_UNKNOWN:
internal_error (__FILE__, __LINE__,
_("remote_write_bytes: bad internal state"));
default:
internal_error (__FILE__, __LINE__, _("bad switch"));
}
return remote_write_bytes_aux (packet_format,
memaddr, myaddr, len, unit_size, xfered_len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
packet_format[0], 1);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
}
/* Read memory data directly from the remote machine.
This does not use the data cache; the data cache uses this.
MEMADDR is the address in the remote memory space.
MYADDR is the address of the buffer in our space.
LEN_UNITS is the number of addressable memory units to read..
UNIT_SIZE is the length in bytes of an addressable unit.
Return the transferred status, error or OK (an
'enum target_xfer_status' value). Save the number of bytes
transferred in *XFERED_LEN_UNITS.
See the comment of remote_write_bytes_aux for an example of
memory read/write exchange between gdb and the stub. */
static enum target_xfer_status
remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len_units,
int unit_size, ULONGEST *xfered_len_units)
{
struct remote_state *rs = get_remote_state ();
int buf_size_bytes; /* Max size of packet output buffer. */
char *p;
int todo_units;
int decoded_bytes;
buf_size_bytes = get_memory_read_packet_size ();
/* The packet buffer will be large enough for the payload;
get_memory_packet_size ensures this. */
/* Number of units that will fit. */
todo_units = min (len_units, (buf_size_bytes / unit_size) / 2);
/* Construct "m"<memaddr>","<len>". */
memaddr = remote_address_masked (memaddr);
p = rs->buf;
*p++ = 'm';
p += hexnumstr (p, (ULONGEST) memaddr);
*p++ = ',';
p += hexnumstr (p, (ULONGEST) todo_units);
*p = '\0';
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == 'E'
&& isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
&& rs->buf[3] == '\0')
return TARGET_XFER_E_IO;
/* Reply describes memory byte by byte, each byte encoded as two hex
characters. */
p = rs->buf;
decoded_bytes = hex2bin (p, myaddr, todo_units * unit_size);
/* Return what we have. Let higher layers handle partial reads. */
*xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
return TARGET_XFER_OK;
}
/* Using the set of read-only target sections of remote, read live
read-only memory.
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
For interface/parameters/return description see target.h,
to_xfer_partial. */
static enum target_xfer_status
remote_xfer_live_readonly_partial (struct target_ops *ops, gdb_byte *readbuf,
ULONGEST memaddr, ULONGEST len,
int unit_size, ULONGEST *xfered_len)
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
{
struct target_section *secp;
struct target_section_table *table;
secp = target_section_by_addr (ops, memaddr);
if (secp != NULL
&& (bfd_get_section_flags (secp->the_bfd_section->owner,
secp->the_bfd_section)
& SEC_READONLY))
{
struct target_section *p;
ULONGEST memend = memaddr + len;
table = target_get_section_table (ops);
for (p = table->sections; p < table->sections_end; p++)
{
if (memaddr >= p->addr)
{
if (memend <= p->endaddr)
{
/* Entire transfer is within this section. */
return remote_read_bytes_1 (memaddr, readbuf, len, unit_size,
xfered_len);
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
}
else if (memaddr >= p->endaddr)
{
/* This section ends before the transfer starts. */
continue;
}
else
{
/* This section overlaps the transfer. Just do half. */
len = p->endaddr - memaddr;
return remote_read_bytes_1 (memaddr, readbuf, len, unit_size,
xfered_len);
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
}
}
}
}
return TARGET_XFER_EOF;
}
/* Similar to remote_read_bytes_1, but it reads from the remote stub
first if the requested memory is unavailable in traceframe.
Otherwise, fall back to remote_read_bytes_1. */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
gdb_byte *myaddr, ULONGEST len, int unit_size,
ULONGEST *xfered_len)
{
if (len == 0)
return TARGET_XFER_EOF;
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
if (get_traceframe_number () != -1)
{
VEC(mem_range_s) *available;
/* If we fail to get the set of available memory, then the
target does not support querying traceframe info, and so we
attempt reading from the traceframe anyway (assuming the
target implements the old QTro packet then). */
if (traceframe_available_memory (&available, memaddr, len))
{
struct cleanup *old_chain;
old_chain = make_cleanup (VEC_cleanup(mem_range_s), &available);
if (VEC_empty (mem_range_s, available)
|| VEC_index (mem_range_s, available, 0)->start != memaddr)
{
enum target_xfer_status res;
/* Don't read into the traceframe's available
memory. */
if (!VEC_empty (mem_range_s, available))
{
LONGEST oldlen = len;
len = VEC_index (mem_range_s, available, 0)->start - memaddr;
gdb_assert (len <= oldlen);
}
do_cleanups (old_chain);
/* This goes through the topmost target again. */
res = remote_xfer_live_readonly_partial (ops, myaddr, memaddr,
len, unit_size, xfered_len);
Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets As a follow-up to [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html this patch moves traceframe_available_memory down to the target side. After this patch, the gdb core code is cleaner, and code on handling unavailable memory is moved to remote/tfile/ctf targets. In details, this patch moves traceframe_available_memory code from memory_xfer_partial_1 to remote target only, so remote target still uses traceframe_info mechanism to check unavailable memory, and use remote_ops to read them from read-only sections. We don't use traceframe_info mechanism for tfile and ctf target, because it is fast to iterate all traceframes from trace file, so the summary information got from traceframe_info is not necessary. This patch also moves two functions to remote.c from target.c, because they are only used in remote.c. I'll clean them up in another patch. gdb: 2014-03-22 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Check the return value of exec_read_partial_read_only, if it is not TARGET_XFER_OK, return TARGET_XFER_UNAVAILABLE. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * target.c (target_read_live_memory): Move it to remote.c. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial_1): Move some code to remote_read_bytes. * remote.c (target_read_live_memory): Moved from target.c. (memory_xfer_live_readonly_partial): Likewise. (remote_read_bytes): New, factored out from memory_xfer_partial_1.
2014-03-11 03:47:48 +01:00
if (res == TARGET_XFER_OK)
return TARGET_XFER_OK;
else
{
/* No use trying further, we know some memory starting
at MEMADDR isn't available. */
*xfered_len = len;
return TARGET_XFER_UNAVAILABLE;
}
}
/* Don't try to read more than how much is available, in
case the target implements the deprecated QTro packet to
cater for older GDBs (the target's knowledge of read-only
sections may be outdated by now). */
len = VEC_index (mem_range_s, available, 0)->length;
do_cleanups (old_chain);
}
}
return remote_read_bytes_1 (memaddr, myaddr, len, unit_size, xfered_len);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
/* Sends a packet with content determined by the printf format string
FORMAT and the remaining arguments, then gets the reply. Returns
whether the packet was a success, a failure, or unknown. */
static enum packet_result remote_send_printf (const char *format, ...)
ATTRIBUTE_PRINTF (1, 2);
2008-02-21 Pedro Alves <pedro@codesorcery.com> Silence a few -Wmissing-prototypes warnings. PR build/9877: * amd64-nat.c: Include "amd64-nat.h". * fork-child.c (_initialize_fork_child): Ditto. * gcore.c (_initialize_gcore): Ditto. * inf-ptrace.c: Include "inf-ptrace.h". (inf_ptrace_store_registers): Make it static. * linux-nat.c (linux_nat_terminal_ours): Make it static. (_initialize_linux_nat): Declare before definition. * linux-tdep.c: Include "linux-tdep.h". * linux-thread-db.c (_initialize_thread_db): Declare before definition. * proc-service.c (_initialize_proc_service): Ditto. * remote.c (remote_send_printf): Make it static. * solib.c: Include "solib.h". * symfile-mem.c (_initialize_symfile_mem): Declare before definition. * ada-lang.c (ada_la_decode, ada_match_name) (ada_suppress_symbol_printing, ada_is_array_type) (ada_value_ptr_subscript, ada_array_length) (ada_to_static_fixed_value): Make them static. (_initialize_ada_language): Declare before definition. * ada-tasks.c (ada_get_task_number, ada_get_environment_task) (ada_task_list_changed, ada_new_objfile_observer): Make them static. (_initialize_tasks): Declare before definition. * addrmap.c (_initialize_addrmap): Declare before definition. * auxv.c (default_auxv_parse): Make it static. * bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make them static. * breakpoint.c (remove_sal): Add line break. (expand_line_sal_maybe): Make it static. * cp-name-parser.y: Include "cp-support.h". * cp-valprint.c (cp_find_class_member): Make it static. * eval.c (value_f90_subarray): Ditto. * exceptions.c (print_any_exception): Ditto. * findcmd.c (_initialize_mem_search): Declare before definition. * frame.c (frame_observer_target_changed): Make it static. * gnu-v3-abi.c (gnuv3_find_method_in): Make it static. * inf-child.c: Include "inf-child.h". * inferior.h (valid_inferior_id): Rename to ... (valid_gdb_inferior_id): ... this. * infrun.c (infrun_thread_stop_requested, siginfo_make_value): Make them static. * jv-lang.c (java_language_arch_info): Make it static. * m2-typeprint.c (m2_get_discrete_bounds): Ditto. * osdata.c (info_osdata_command): Make it static. * regcache.c (regcache_observer_target_changed): Make it static. * reverse.c (_initialize_reverse): Declare before definition. * stabsread.c (cleanup_undefined_types_noname) (cleanup_undefined_types_1): Make them static. * symfile.c (place_section): Make it static. * symtab.c (find_pc_sect_psymtab_closer): Make it static. * target-descriptions.c (_initialize_target_descriptions): Declare before definition. * target.c (default_get_ada_task_ptid, find_default_can_async_p) (find_default_is_async_p, find_default_supports_non_stop): Make them static. (target_supports_non_stop): Add prototype. (dummy_pid_to_str): Make it static. * utils.c (_initialize_utils): Declare before definition. * ada-exp.y (_initialize_ada_exp): Declare before definition. * solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype. * target.h (struct target_ops): Add a prototype to the to_can_execute_reverse callback. * macroscope.c (_initialize_macroscope): Declare before definition. * cp-namespace.c (_initialize_cp_namespace): Declare before definition. * python/python.c (_initialize_python): Declare before definition. * tui/tui-command.c: Include "tui/tui-command.h". * tui/tui-data.c (init_content_element, init_win_info): Make them static. * tui/tui-disasm.c: Include "tui/tui-disasm.h". * tui/tui-interp.c (_initialize_tui_interp): Declare before definition. * tui/tui-layout.c: Include "tui/tui-layout.h". (_initialize_tui_layout): Declare before definition. * tui/tui-regs.c: Include "tui/tui-regs.h". (tui_display_reg_element_at_line): Make it static. (_initialize_tui_regs): Declare before definition. * tui/tui-stack.c (_initialize_tui_stack): Declare before definition. * tui/tui-win.c: Include "tui/tui-win.h". (_initialize_tui_win): Declare before definition. (tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH. * tui/tui-win.h (tui_sigwinch_handler): Delete declaration. (tui_get_cmd_list): Add a prototype. * tui/tui-windata.c: Include tui-windata.h. * tui/tui-wingeneral.c (box_win): Make it static. * cli/cli-logging.c (show_logging_command): Make it static. (_initialize_cli_logging): Declare before definition. * mi/mi-common.c (_initialize_gdb_mi_common): Declare before definition.
2009-02-21 17:14:50 +01:00
static enum packet_result
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_send_printf (const char *format, ...)
{
struct remote_state *rs = get_remote_state ();
int max_size = get_remote_packet_size ();
va_list ap;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
va_start (ap, format);
rs->buf[0] = '\0';
if (vsnprintf (rs->buf, max_size, format, ap) >= max_size)
internal_error (__FILE__, __LINE__, _("Too long remote packet."));
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
if (putpkt (rs->buf) < 0)
error (_("Communication problem with target."));
rs->buf[0] = '\0';
getpkt (&rs->buf, &rs->buf_size, 0);
return packet_check_result (rs->buf);
}
static void
restore_remote_timeout (void *p)
{
int value = *(int *)p;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_timeout = value;
}
/* Flash writing can take quite some time. We'll set
effectively infinite timeout for flash operations.
In future, we'll need to decide on a better approach. */
static const int remote_flash_timeout = 1000;
static void
remote_flash_erase (struct target_ops *ops,
ULONGEST address, LONGEST length)
{
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
int saved_remote_timeout = remote_timeout;
enum packet_result ret;
struct cleanup *back_to = make_cleanup (restore_remote_timeout,
&saved_remote_timeout);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_timeout = remote_flash_timeout;
ret = remote_send_printf ("vFlashErase:%s,%s",
* defs.h (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter. * utils.c (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter, use it instead of current_gdbarch. * ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter. * ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter, use it instead of current_gdbarch. Update calls to ui_out_field_core_addr to pass architecture: * ada-lang.c (print_one_exception): Update. * breakpoint.c (print_one_breakpoint_location, print_one_exception_catchpoint): Update. * disasm.c (dump_insns): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * mi/mi-main.c (mi_cmd_data_read_memory): Update. * mi/mi-symbol-cmds.c: Include "objfiles.h". (mi_cmd_symbol_list_lines): Update. * stack.c (print_frame_info, print_frame): Update. Update callers of paddress to pass architecture: * ada-tasks.c (info_task): Update. * ada-valprint.c (ada_val_print_1): Update. * annotate.c (annotate_source, annotate_frame_begin): Update. * breakpoint.c (insert_bp_location, describe_other_breakpoints, mention): Update. * cli/cli-cmds.c (edit_command, list_command, print_disassembly): Update. * corefile.c (memory_error): Update. * c-valprint.c (print_function_pointer_address, c_val_print): Update. * disasm.c (dis_asm_print_address): Update. * exec.c (print_section_info): Update. * f-valprint.c (f_val_print): Update. * infcmd.c: Include "arch-utils.h". (jump_command, program_info): Update. * linux-fork.c: Include "arch-utils.h". (info_forks_command): Update. * m2-valprint.c (print_function_pointer_address, print_unpacked_pointer, print_variable_at_address, m2_val_print): Update. * m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command): Update. * printcmd.c (print_address, print_address_demangle, address_info): Update. * p-valprint.c (pascal_val_print): Update. * source.c: Include "arch-utils.h". (line_info): Update. * stack.c (frame_info, print_block_frame_labels): Update. * symfile.c (add_symbol_file_command, list_overlays_command): Update. * symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1, print_symbol, print_partial_symbols, maintenance_info_psymtabs, maintenance_check_symtabs): Update. * symtab.c (find_pc_sect_symtab): Update. * target.c (deprecated_debug_xfer_memory): Update. * tracepoint.c (scope_info): Update. * tui/tui-stack.c (tui_make_status_line): Update. * valprint.c (val_print_string): Update. Update callers of paddr_nz to use paddress instead (keeping user-visible output identical): * alpha-tdep.c (alpha_heuristic_proc_start): Update. * amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn, amd64_displaced_step_fixup): Update. * arch-utils.c (simple_displaced_step_copy_insn): Update. * auxv.c (fprint_target_auxv): Update. * breakpoint.c (insert_single_step_breakpoint): Update. * buildsym.c (finish_block): Update. * cli/cli-dump.c (restore_section_callback): Update. * fbsd-nat.c (fbsd_find_memory_regions): Update. * frame.c (frame_unwind_register_value): Update. * gcore.c (gcore_create_callback): Update. * hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm, i386_process_record): Update. * ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id, ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id, ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update. * infrun.c (displaced_step_prepare, displaced_step_fixup, handle_inferior_event, insert_step_resume_breakpoint_at_sal, insert_longjmp_resume_breakpoint): Update. * linux-nat.c (linux_nat_find_memory_regions): Update. * linux-record.c (record_linux_system_call): Update. * mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call): Update. * monitor.c (monitor_error, monitor_remove_breakpoint): Update. * record.c (record_arch_list_add_mem, record_wait, record_xfer_partial): Update. * remote-mips.c (mips_fetch_word, mips_check_lsi_error, mips_common_breakpoint): Update. * remote-sim.c (gdbsim_xfer_inferior_memory): Update. * rs6000-tdep.c (ppc_displaced_step_fixup): Update. * solib-som.c (som_current_sos): Update. * symfile.c (load_progress, generic_load): Update. * symfile-mem.c (add_vsyscall_page): Update. * valops.c (value_fetch_lazy): Update. * windows-tdep.c (windows_xfer_shared_library): Update. Update callers of paddr_nz to use paddress instead (changing user-visible output to make it more correct): * dwarf2loc.c (locexpr_describe_location): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint, ia64_memory_remove_breakpoint): Update. * jv-valprint.c (java_value_print): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. * monitor.c (monitor_read_memory): Update. Update callers of paddr to use paddress instead (changing user-visible output to make it more correct): * arm-tdep.c (arm_push_dummy_call): Update. * breakpoint.c (insert_bp_location, create_thread_event_breakpoint, create_breakpoint): Update. * darwin-nat-info.c (darwin_debug_regions): Update. * dcache.c (dcache_info): Update. * dsrec.c (load_srec, make_srec): Update. * dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program, dwarf2_frame_cache): Update. * gcore.c (gcore_copy_callback): Update. * gnu-nat.c (gnu_xfer_memory): Update. * mips-linux-nat.c (mips_show_dr): Update. * monitor.c (monitor_write_memory, monitor_insert_breakpoint, monitor_remove_breakpoint): Update. * remote.c (compare_sections_command): Update. * remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint, m32r_remove_breakpoint, m32r_insert_watchpoint, m32r_remove_watchpoint): Update. * sol-thread.c (info_cb): Update. * symfile.c (load_progress): Update. Update callers of paddress or paddr_nz to use hex_string instead (changes output of internal/error/debug messages only): * dwarf2read.c (dump_die_shallow): Update. * frame.c (fprint_field, fprint_frame, frame_pc_unwind, get_frame_func, create_new_frame): Update. * hppa-tdep.c (find_unwind_entry, unwind_command): Update. * ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x, ia64_get_dyn_info_list): Update. * maint.c (maintenance_translate_address): Update. * mi/mi-cmd-var.c (mi_cmd_var_create): Update. * target.c (target_flash_erase): Update. Update callers of paddr/paddr_nz to use phex/phex_nz instead, using an appropriate address size. Remove use of strlen_paddr. * exec.c (exec_files_info): Update. * i386-nat.c (i386_show_dr): Update. * remote.c (remote_flash_erase): Update. * m32r-rom.c (m32r_load_section): Update. * monitor.c (monitor_vsprintf, monitor_store_register): Update. * remote.c (remote_check_symbols, remote_search_memory): Update. * remote-mips.c (mips_request, mips_common_breakpoint): Update. * scm-valprint.c (scm_ipruk, scm_scmval_print): Update. * sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs, sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs, sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs, sh_dsp_show_regs): Update. * xcoffsolib.c (sharedlibrary_command): Update. * maint.c (maint_print_section_info): Add ADDR_SIZE parameter. Use hex_string_custom instead of paddr. (print_bfd_section_info): Pass address size. (print_objfile_section_info): Likewise. * annotate.h (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * annotate.c (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * source.c (identify_source_line): Update call to annotate_source. * stack.c (print_frame_info, print_frame): Update call to annotate_frame_begin. * breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter. (create_breakpoint, create_ada_exception_breakpoint): Update call. * stack.c (print_block_frame_labels): Add GDBARCH parameter. (print_frame_label_vars): Update call. * symmisc.c (print_partial_symbols): Add GDBARCH parameter. (dump_psymtab): Update call to print_partial_symbols. (struct print_symbol_args): Add GDBARCH member. (dump_symtab_1): Set print_symbol_args architecture member. (print_symbol): Use it. * windows-tdep.h (windows_xfer_shared_library): Add GDBARCH parameter. * windows-tdep.c (windows_xfer_shared_library): Likewise. * i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member. (core_process_module_section): Pass architecture from cpms_data to windows_xfer_shared_library. (windows_core_xfer_shared_libraries): Initialize cmps_data architecture member. * windows-nat.c (windows_xfer_shared_libraries): Pass architecture to windows_xfer_shared_library. * defs.h (print_address): Add GDBARCH parameter. * printcmd.c (print_address): Add GDBARCH parameter. (print_scalar_formatted, do_examine): Update call. * findcmd.c (find_command): Update call. * tracepoint.c: Include "arch-utils.h". (trace_find_line_command): Update call. * tui/tui-disasm.c (tui_disassemble): Update call. * value.h (print_address_demangle): Add GDBARCH parameter. * printcmd.c (print_address_demangle): Add GDBARCH parameter. * c-valprint.c (print_function_pointer_address, c_val_print): Update call. * f-valprint.c (f_val_print): Update call. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update call. * jv-valprint.c (java_val_print): Update call. * m2-valprint.c (print_function_pointer_address, m2_val_print): Update call. * p-valprint.c (pascal_val_print): Update call. * disasm.c (gdb_disassemble_info): Install architecture into di.application_data field. testsuite/ChangeLog: * gdb.threads/tls-shared.exp: Update to locexpr_describe_location change to prefix TLS offset in hex with 0x. doc/ChangeLog: * gdbint.texinfo (Item Output Functions): Update signature for ui_out_field_core_addr.
2009-07-02 19:21:10 +02:00
phex (address, addr_size),
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
phex (length, 4));
switch (ret)
{
case PACKET_UNKNOWN:
error (_("Remote target does not support flash erase"));
case PACKET_ERROR:
error (_("Error erasing flash with vFlashErase packet"));
default:
break;
}
do_cleanups (back_to);
}
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
remote_flash_write (struct target_ops *ops, ULONGEST address,
ULONGEST length, ULONGEST *xfered_len,
const gdb_byte *data)
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
{
int saved_remote_timeout = remote_timeout;
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
enum target_xfer_status ret;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
struct cleanup *back_to = make_cleanup (restore_remote_timeout,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
&saved_remote_timeout);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_timeout = remote_flash_timeout;
ret = remote_write_bytes_aux ("vFlashWrite:", address, data, length, 1,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,'X', 0);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
do_cleanups (back_to);
return ret;
}
static void
remote_flash_done (struct target_ops *ops)
{
int saved_remote_timeout = remote_timeout;
int ret;
struct cleanup *back_to = make_cleanup (restore_remote_timeout,
&saved_remote_timeout);
remote_timeout = remote_flash_timeout;
ret = remote_send_printf ("vFlashDone");
do_cleanups (back_to);
switch (ret)
{
case PACKET_UNKNOWN:
error (_("Remote target does not support vFlashDone"));
case PACKET_ERROR:
error (_("Error finishing flash operation"));
default:
break;
}
}
static void
2000-07-30 03:48:28 +02:00
remote_files_info (struct target_ops *ignore)
{
puts_filtered ("Debugging a target over a serial line.\n");
}
/* Stuff for dealing with the packets which are part of this protocol.
See comment at top of file for details. */
/* Close/unpush the remote target, and throw a TARGET_CLOSE_ERROR
error to higher layers. Called when a serial error is detected.
The exception message is STRING, followed by a colon and a blank,
the system error message for errno at function entry and final dot
for output compatibility with throw_perror_with_name. */
static void
unpush_and_perror (const char *string)
{
int saved_errno = errno;
remote_unpush_target ();
throw_error (TARGET_CLOSE_ERROR, "%s: %s.", string,
safe_strerror (saved_errno));
}
/* Read a single character from the remote end. */
static int
2000-07-30 03:48:28 +02:00
readchar (int timeout)
{
int ch;
struct remote_state *rs = get_remote_state ();
ch = serial_readchar (rs->remote_desc, timeout);
1999-10-06 01:13:56 +02:00
if (ch >= 0)
return ch;
1999-10-06 01:13:56 +02:00
switch ((enum serial_rc) ch)
{
case SERIAL_EOF:
remote_unpush_target ();
throw_error (TARGET_CLOSE_ERROR, _("Remote connection closed"));
1999-10-06 01:13:56 +02:00
/* no return */
case SERIAL_ERROR:
unpush_and_perror (_("Remote communication error. "
"Target disconnected."));
1999-10-06 01:13:56 +02:00
/* no return */
case SERIAL_TIMEOUT:
1999-10-06 01:13:56 +02:00
break;
}
1999-10-06 01:13:56 +02:00
return ch;
}
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
/* Wrapper for serial_write that closes the target and throws if
writing fails. */
static void
remote_serial_write (const char *str, int len)
{
struct remote_state *rs = get_remote_state ();
if (serial_write (rs->remote_desc, str, len))
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
{
unpush_and_perror (_("Remote communication error. "
"Target disconnected."));
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
}
}
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Send the command in *BUF to the remote machine, and read the reply
into *BUF. Report an error if we get an error reply. Resize
*BUF using xrealloc if necessary to hold the result, and update
*SIZEOF_BUF. */
static void
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
remote_send (char **buf,
long *sizeof_buf)
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (*buf);
1999-12-07 04:56:43 +01:00
getpkt (buf, sizeof_buf, 0);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
if ((*buf)[0] == 'E')
error (_("Remote failure reply: %s"), *buf);
}
/* Return a pointer to an xmalloc'ed string representing an escaped
version of BUF, of len N. E.g. \n is converted to \\n, \t to \\t,
etc. The caller is responsible for releasing the returned
memory. */
static char *
escape_buffer (const char *buf, int n)
{
struct cleanup *old_chain;
struct ui_file *stb;
char *str;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
PR mi/15806: Fix quoting of async events Original patch: https://sourceware.org/ml/gdb-patches/2014-04/msg00552.html New in v2: * In remote.c:escape_buffer, pass '\\' to fputstrn_unfiltered/printchar to make sure backslashes are escaped in remote debug output. * Updated function documentation for printchar. See updated ChangeLog below. -------------------- The quoting in whatever goes in the event_channel of MI is little bit broken. Link for the lazy: https://sourceware.org/bugzilla/show_bug.cgi?id=15806 Here is an example of a =library-loaded event with an ill-named directory, /tmp/how"are\you (the problem is present with every directory on Windows since it uses backslashes as a path separator). The result will be the following: =library-loaded,id="/tmp/how"are\\you/libexpat.so.1",... The " between 'how' and 'are' should be escaped. Another bad behavior is double escaping in =breakpoint-created, for example: =breakpoint-created,bkpt={...,fullname="/tmp/how\\"are\\\\you/test.c",...} The two backslashes before 'how' should be one and the four before 'you' should be two. The reason for this is that when sending something to an MI console, escaping can take place at two different moments (the actual escaping work is always done in the printchar function): 1. When generating the content, if ui_out_field_* functions are used. Here, fields are automatically quoted with " and properly escaped. At least mi_field_string does it, not sure about mi_field_fmt, I need to investigate further. 2. When gdb_flush is called, to send the data in the buffer of the console to the actual output (stdout). At this point, mi_console_raw_packet takes the whole string in the buffer, quotes it, and escapes all occurences of the quoting character and backslashes. The event_channel does not specify a quoting character, so quotes are not escaped here, only backslashes. The problem with =library-loaded is that it does use fprintf_unfiltered, which doesn't do escaping (so, no #1). When gdb_flush is called, backslashes are escaped (#2). The problem with =breakpoint-created is that it first uses ui_out_field_* functions to generate its output, so backslashes and quotes are escaped there (#1). backslashes are escaped again in #2, leading to an overdose of backslashes. In retrospect, there is no way escaping can be done reliably in mi_console_raw_packet for data that is already formatted, such as event_channel. At this point, there is no way to differentiate quotes that delimit field values from those that should be escaped. In the case of other MI consoles, it is ok since mi_console_raw_packet receives one big string that should be quoted and escaped as a whole. So, first part of the fix: for the MI channels that specify no quoting character, no escaping at all should be done in mi_console_raw_packet (that's the change in printchar, thanks to Yuanhui Zhang for this). For those channels, whoever generates the content is responsible for proper quoting and escaping. This will fix the =breakpoint-created kind of problem. Second part of the fix is to make =library-loaded generate content that is properly escaped. For this, we use ui_out_field_* functions, instead of one big fprintf_unfiltered. =library-unloaded suffered from the same problem so it is modified as well. There might be other events that need fixing too, but that's all I found with a quick scan. Those that use fprintf_unfiltered but whose sole variable data is a %d are not critical, since it won't generate a " or a \. Finally, a test has been fixed, as it was expecting an erroneous output. Otherwise, all other tests that were previously passing still pass (x86-64 linux). gdb/ChangeLog: 2014-06-02 Simon Marchi <simon.marchi@ericsson.com> PR mi/15806 * utils.c (printchar): Don't escape at all if quoter is NUL. Update function documentation to clarify effect of parameter QUOTER. * remote.c (escape_buffer): Pass '\\' as the quoter to fputstrn_unfiltered. * mi/mi-interp.c (mi_solib_loaded): Use ui_out_field_* functions to generate the output. (mi_solib_unloaded): Same. gdb/testsuite/ChangeLog: 2014-06-02 Simon Marchi <simon.marchi@ericsson.com> * gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Fix erroneous dprintf expected input.
2014-06-02 23:10:36 +02:00
fputstrn_unfiltered (buf, n, '\\', stb);
str = ui_file_xstrdup (stb, NULL);
do_cleanups (old_chain);
return str;
}
/* Display a null-terminated packet on stdout, for debugging, using C
string notation. */
static void
print_packet (const char *buf)
{
puts_filtered ("\"");
1999-07-12 13:15:22 +02:00
fputstr_filtered (buf, '"', gdb_stdout);
puts_filtered ("\"");
}
int
putpkt (const char *buf)
{
return putpkt_binary (buf, strlen (buf));
}
/* Send a packet to the remote machine, with error checking. The data
of the packet is in BUF. The string in BUF can be at most
get_remote_packet_size () - 5 to account for the $, # and checksum,
and for a possible /0 if we are debugging (remote_debug) and want
to print the sent packet as a string. */
static int
putpkt_binary (const char *buf, int cnt)
{
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
struct remote_state *rs = get_remote_state ();
int i;
unsigned char csum = 0;
1999-11-09 02:23:30 +01:00
char *buf2 = alloca (cnt + 6);
1999-06-28 18:06:02 +02:00
int ch;
int tcount = 0;
char *p;
char *message;
/* Catch cases like trying to read memory or listing threads while
we're waiting for a stop reply. The remote server wouldn't be
ready to handle this request, so we'd hang and timeout. We don't
have to worry about this in synchronous mode, because in that
case it's not possible to issue a command while the target is
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
running. This is not a problem in non-stop mode, because in that
case, the stub is always ready to process serial input. */
if (!non_stop && target_is_async_p () && rs->waiting_for_stop_reply)
{
error (_("Cannot execute this command while the target is running.\n"
"Use the \"interrupt\" command to stop the target\n"
"and then try again."));
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* We're sending out a new packet. Make sure we don't look at a
stale cached response. */
rs->cached_wait_status = 0;
/* Copy the packet into buffer BUF2, encapsulating it
and giving it a checksum. */
p = buf2;
*p++ = '$';
for (i = 0; i < cnt; i++)
{
csum += buf[i];
*p++ = buf[i];
}
*p++ = '#';
*p++ = tohex ((csum >> 4) & 0xf);
*p++ = tohex (csum & 0xf);
/* Send it over and over until we get a positive ack. */
while (1)
{
int started_error_output = 0;
if (remote_debug)
{
struct cleanup *old_chain;
char *str;
*p = '\0';
str = escape_buffer (buf2, p - buf2);
old_chain = make_cleanup (xfree, str);
fprintf_unfiltered (gdb_stdlog, "Sending packet: %s...", str);
1999-06-14 20:08:47 +02:00
gdb_flush (gdb_stdlog);
do_cleanups (old_chain);
}
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write (buf2, p - buf2);
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
/* If this is a no acks version of the remote protocol, send the
packet and move on. */
if (rs->noack_mode)
break;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Read until either a timeout occurs (-2) or '+' is read.
Handle any notification that arrives in the mean time. */
while (1)
{
ch = readchar (remote_timeout);
1999-07-07 22:19:36 +02:00
if (remote_debug)
{
switch (ch)
{
case '+':
2000-02-09 03:51:55 +01:00
case '-':
case SERIAL_TIMEOUT:
case '$':
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
case '%':
if (started_error_output)
{
putchar_unfiltered ('\n');
started_error_output = 0;
}
}
}
switch (ch)
{
case '+':
if (remote_debug)
1999-06-14 20:08:47 +02:00
fprintf_unfiltered (gdb_stdlog, "Ack\n");
return 1;
2000-02-09 03:51:55 +01:00
case '-':
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "Nak\n");
/* FALLTHROUGH */
case SERIAL_TIMEOUT:
1999-07-07 22:19:36 +02:00
tcount++;
if (tcount > 3)
return 0;
break; /* Retransmit buffer. */
case '$':
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"Packet instead of Ack, ignoring it\n");
/* It's probably an old response sent because an ACK
was lost. Gobble up the packet and ack it so it
doesn't get retransmitted when we resend this
packet. */
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
skip_frame ();
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("+", 1);
continue; /* Now, go look for +. */
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
case '%':
{
int val;
/* If we got a notification, handle it, and go back to looking
for an ack. */
/* We've found the start of a notification. Now
collect the data. */
val = read_frame (&rs->buf, &rs->buf_size);
if (val >= 0)
{
if (remote_debug)
{
struct cleanup *old_chain;
char *str;
str = escape_buffer (rs->buf, val);
old_chain = make_cleanup (xfree, str);
fprintf_unfiltered (gdb_stdlog,
" Notification received: %s\n",
str);
do_cleanups (old_chain);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
handle_notification (rs->notif_state, rs->buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* We're in sync now, rewait for the ack. */
tcount = 0;
}
else
{
if (remote_debug)
{
if (!started_error_output)
{
started_error_output = 1;
fprintf_unfiltered (gdb_stdlog, "putpkt: Junk: ");
}
fputc_unfiltered (ch & 0177, gdb_stdlog);
fprintf_unfiltered (gdb_stdlog, "%s", rs->buf);
}
}
continue;
}
/* fall-through */
default:
if (remote_debug)
{
if (!started_error_output)
{
started_error_output = 1;
1999-06-14 20:08:47 +02:00
fprintf_unfiltered (gdb_stdlog, "putpkt: Junk: ");
}
1999-06-14 20:08:47 +02:00
fputc_unfiltered (ch & 0177, gdb_stdlog);
}
continue;
}
break; /* Here to retransmit. */
}
#if 0
/* This is wrong. If doing a long backtrace, the user should be
1999-07-07 22:19:36 +02:00
able to get out next time we call QUIT, without anything as
violent as interrupt_query. If we want to provide a way out of
here without getting to the next QUIT, it should be based on
hitting ^C twice as in remote_wait. */
if (quit_flag)
{
quit_flag = 0;
interrupt_query ();
}
#endif
}
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
return 0;
}
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Come here after finding the start of a frame when we expected an
ack. Do our best to discard the rest of this packet. */
static void
skip_frame (void)
{
int c;
while (1)
{
c = readchar (remote_timeout);
switch (c)
{
case SERIAL_TIMEOUT:
/* Nothing we can do. */
return;
case '#':
/* Discard the two bytes of checksum and stop. */
c = readchar (remote_timeout);
if (c >= 0)
c = readchar (remote_timeout);
return;
case '*': /* Run length encoding. */
/* Discard the repeat count. */
c = readchar (remote_timeout);
if (c < 0)
return;
break;
default:
/* A regular character. */
break;
}
}
}
/* Come here after finding the start of the frame. Collect the rest
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
into *BUF, verifying the checksum, length, and handling run-length
compression. NUL terminate the buffer. If there is not enough room,
expand *BUF using xrealloc.
1999-12-07 04:56:43 +01:00
Returns -1 on error, number of characters in buffer (ignoring the
trailing NULL) on success. (could be extended to return one of the
SERIAL status indications). */
1999-12-07 04:56:43 +01:00
static long
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
read_frame (char **buf_p,
long *sizeof_buf)
{
unsigned char csum;
1999-12-07 04:56:43 +01:00
long bc;
int c;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *buf = *buf_p;
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
struct remote_state *rs = get_remote_state ();
csum = 0;
1999-12-07 04:56:43 +01:00
bc = 0;
while (1)
{
c = readchar (remote_timeout);
switch (c)
{
case SERIAL_TIMEOUT:
if (remote_debug)
1999-06-14 20:08:47 +02:00
fputs_filtered ("Timeout in mid-packet, retrying\n", gdb_stdlog);
1999-12-07 04:56:43 +01:00
return -1;
case '$':
if (remote_debug)
1999-06-14 20:08:47 +02:00
fputs_filtered ("Saw new packet start in middle of old one\n",
gdb_stdlog);
return -1; /* Start a new packet, count retries. */
case '#':
{
unsigned char pktcsum;
int check_0 = 0;
int check_1 = 0;
1999-12-07 04:56:43 +01:00
buf[bc] = '\0';
check_0 = readchar (remote_timeout);
if (check_0 >= 0)
check_1 = readchar (remote_timeout);
if (check_0 == SERIAL_TIMEOUT || check_1 == SERIAL_TIMEOUT)
{
if (remote_debug)
fputs_filtered ("Timeout in checksum, retrying\n",
gdb_stdlog);
return -1;
}
else if (check_0 < 0 || check_1 < 0)
{
if (remote_debug)
fputs_filtered ("Communication error in checksum\n",
gdb_stdlog);
return -1;
}
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
/* Don't recompute the checksum; with no ack packets we
don't have any way to indicate a packet retransmission
is necessary. */
if (rs->noack_mode)
return bc;
pktcsum = (fromhex (check_0) << 4) | fromhex (check_1);
if (csum == pktcsum)
1999-12-07 04:56:43 +01:00
return bc;
1999-07-07 22:19:36 +02:00
if (remote_debug)
{
struct cleanup *old_chain;
char *str;
str = escape_buffer (buf, bc);
old_chain = make_cleanup (xfree, str);
fprintf_unfiltered (gdb_stdlog,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
"Bad checksum, sentsum=0x%x, "
"csum=0x%x, buf=%s\n",
pktcsum, csum, str);
do_cleanups (old_chain);
}
1999-12-07 04:56:43 +01:00
/* Number of characters in buffer ignoring trailing
NULL. */
1999-12-07 04:56:43 +01:00
return -1;
}
case '*': /* Run length encoding. */
1999-09-22 05:28:34 +02:00
{
int repeat;
csum += c;
c = readchar (remote_timeout);
csum += c;
repeat = c - ' ' + 3; /* Compute repeat count. */
/* The character before ``*'' is repeated. */
1999-12-07 04:56:43 +01:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
if (repeat > 0 && repeat <= 255 && bc > 0)
1999-09-22 05:28:34 +02:00
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
if (bc + repeat - 1 >= *sizeof_buf - 1)
{
/* Make some more room in the buffer. */
*sizeof_buf += repeat;
*buf_p = xrealloc (*buf_p, *sizeof_buf);
buf = *buf_p;
}
1999-12-07 04:56:43 +01:00
memset (&buf[bc], buf[bc - 1], repeat);
bc += repeat;
1999-09-22 05:28:34 +02:00
continue;
}
1999-12-07 04:56:43 +01:00
buf[bc] = '\0';
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
printf_filtered (_("Invalid run length encoding: %s\n"), buf);
1999-12-07 04:56:43 +01:00
return -1;
1999-09-22 05:28:34 +02:00
}
default:
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
if (bc >= *sizeof_buf - 1)
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
/* Make some more room in the buffer. */
*sizeof_buf *= 2;
*buf_p = xrealloc (*buf_p, *sizeof_buf);
buf = *buf_p;
}
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
buf[bc++] = c;
csum += c;
continue;
}
}
}
/* Read a packet from the remote machine, with error checking, and
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
store it in *BUF. Resize *BUF using xrealloc if necessary to hold
the result, and update *SIZEOF_BUF. If FOREVER, wait forever
rather than timing out; this is used (in synchronous mode) to wait
for a target that is is executing user code to stop. */
2000-02-02 01:21:19 +01:00
/* FIXME: ezannoni 2000-02-01 this wrapper is necessary so that we
don't have to change all the calls to getpkt to deal with the
return value, because at the moment I don't know what the right
thing to do it for those. */
void
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (char **buf,
long *sizeof_buf,
1999-12-07 04:56:43 +01:00
int forever)
2000-02-02 01:21:19 +01:00
{
int timed_out;
timed_out = getpkt_sane (buf, sizeof_buf, forever);
}
/* Read a packet from the remote machine, with error checking, and
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
store it in *BUF. Resize *BUF using xrealloc if necessary to hold
the result, and update *SIZEOF_BUF. If FOREVER, wait forever
rather than timing out; this is used (in synchronous mode) to wait
for a target that is is executing user code to stop. If FOREVER ==
0, this function is allowed to time out gracefully and return an
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
indication of this to the caller. Otherwise return the number of
bytes read. If EXPECTING_NOTIF, consider receiving a notification
enough reason to return to the caller. *IS_NOTIF is an output
boolean that indicates whether *BUF holds a notification or not
(a regular packet). */
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
* arch-utils.c (#include "gdbthread.h"): Removed. (#include "symfile.h"): Removed. (XMALLOC): Removed unused macro. * breakpoint.c (tbreak_command): Removed local declaration. (awatch_command, do_enable_breakpoint, set_breakpoint_count): Remove duplicate declarations. (bpstat_should_step, bpstat_have_active_hw_watchpoints) (remove_solib_event_breakpoints): Fix indentation botch. * c-typeprint.c (#include "command.h"): Removed. (#include "gdbcmd.h"): Removed. * ch-exp.c (ch_terminal_match_float_literal, parse_expr) (parse_primval, parse_untyped_expr, parse_opt_untyped_expr): Removed duplicate declarations. * ch-typeprint.c (#include "command.h"): Removed. (#include "gdbcmd.h"): Removed. * corefile.c (#include "frame.h"): Removed (#include "symfile.h"): Removed. (#include "language.h"): Removed. * dbxread.c (#include "command.h"): Removed. * environ.c (#include "gdbcore.h"): Removed. * event-loop.c (#include "top.h"): Removed. * f-typeprint.c (#include "command.h"): Removed. (#include "gdbcmd.h"): Removed. (#include "language.h"): Removed. (#include "typeprint.h"): Removed. (#include "frame.h"): Removed. * gdbtypes.h (print_type_scalar): Removed declaration. * infcmd.c (#include "completer.h"): Removed. * language.c (#include "frame.h"): Removed. * m2-typeprint.c (#include "command.h"): Removed. (#include "gdbcmd.h"): Removed. (#include "language.h"): Removed. * m2-valprint.c (#include "valprint.h"): Removed. * p-typeprint.c (#include "command.h"): Removed. (#include "gdbcmd.h"): Removed. * p-valprint.c (#include "typeprint.h"): Removed. * parse.c (#include "linespec.h"): Removed. * regcache.c (#include "frame.h"): Removed. * remote.c (#include "frame.h"): Removed. (getpkt_sane): Make static. * source.c (#include "completer.h"): Removed. * stack.c (#include "symfile.h"): Removed. (#include "objfiles.h"): Removed. * symfile.c (#include "completer.h"): Removed. * tracepoint.c (#include "completer.h"): Removed. * values.c (#include "frame.h"): Removed. * varobj.c (#include "valprint.h"): Removed. * wrapper.c (#include "frame.h"): Removed. * memattr.c (create_mem_region): Removed unused variable. * remote-nrom.c: Removed spurious semicolon after init_nrom_ops. -------------------------------------------------------------------
2001-03-27 22:36:24 +02:00
static int
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
int expecting_notif, int *is_notif)
{
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
struct remote_state *rs = get_remote_state ();
int c;
int tries;
int timeout;
int val = -1;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* We're reading a new response. Make sure we don't look at a
previously cached response. */
rs->cached_wait_status = 0;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
strcpy (*buf, "timeout");
if (forever)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
timeout = watchdog > 0 ? watchdog : -1;
else if (expecting_notif)
timeout = 0; /* There should already be a char in the buffer. If
not, bail out. */
else
timeout = remote_timeout;
#define MAX_TRIES 3
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Process any number of notifications, and then return when
we get a packet. */
for (;;)
{
/* If we get a timeout or bad checksum, retry up to MAX_TRIES
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
times. */
for (tries = 1; tries <= MAX_TRIES; tries++)
{
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* This can loop forever if the remote side sends us
characters continuously, but if it pauses, we'll get
SERIAL_TIMEOUT from readchar because of timeout. Then
we'll count that as a retry.
Note that even when forever is set, we will only wait
forever prior to the start of a packet. After that, we
expect characters to arrive at a brisk pace. They should
show up within remote_timeout intervals. */
do
c = readchar (timeout);
while (c != SERIAL_TIMEOUT && c != '$' && c != '%');
if (c == SERIAL_TIMEOUT)
{
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (expecting_notif)
return -1; /* Don't complain, it's normal to not get
anything in this case. */
if (forever) /* Watchdog went off? Kill the target. */
{
1999-10-06 01:13:56 +02:00
QUIT;
remote_unpush_target ();
throw_error (TARGET_CLOSE_ERROR,
_("Watchdog timeout has expired. "
"Target detached."));
}
if (remote_debug)
1999-06-14 20:08:47 +02:00
fputs_filtered ("Timed out.\n", gdb_stdlog);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
else
{
/* We've found the start of a packet or notification.
Now collect the data. */
val = read_frame (buf, sizeof_buf);
if (val >= 0)
break;
}
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("-", 1);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (tries > MAX_TRIES)
{
/* We have tried hard enough, and just can't receive the
packet/notification. Give up. */
printf_unfiltered (_("Ignoring packet error, continuing...\n"));
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Skip the ack char if we're in no-ack mode. */
if (!rs->noack_mode)
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("+", 1);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
return -1;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If we got an ordinary packet, return that to our caller. */
if (c == '$')
{
if (remote_debug)
1999-07-12 13:15:22 +02:00
{
struct cleanup *old_chain;
char *str;
str = escape_buffer (*buf, val);
old_chain = make_cleanup (xfree, str);
fprintf_unfiltered (gdb_stdlog, "Packet received: %s\n", str);
do_cleanups (old_chain);
1999-07-12 13:15:22 +02:00
}
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
/* Skip the ack char if we're in no-ack mode. */
if (!rs->noack_mode)
unpush the remote target if serial_write fails. PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
2013-04-02 15:51:07 +02:00
remote_serial_write ("+", 1);
if (is_notif != NULL)
*is_notif = 0;
return val;
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* If we got a notification, handle it, and go back to looking
for a packet. */
else
{
gdb_assert (c == '%');
if (remote_debug)
{
struct cleanup *old_chain;
char *str;
str = escape_buffer (*buf, val);
old_chain = make_cleanup (xfree, str);
fprintf_unfiltered (gdb_stdlog,
" Notification received: %s\n",
str);
do_cleanups (old_chain);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
if (is_notif != NULL)
*is_notif = 1;
handle_notification (rs->notif_state, *buf);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
/* Notifications require no acknowledgement. */
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
if (expecting_notif)
return val;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
}
}
static int
getpkt_sane (char **buf, long *sizeof_buf, int forever)
{
return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 0, NULL);
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
}
static int
getpkt_or_notif_sane (char **buf, long *sizeof_buf, int forever,
int *is_notif)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 1,
is_notif);
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
/* Check whether EVENT is a fork event for the process specified
by the pid passed in DATA, and if it is, kill the fork child. */
static int
kill_child_of_pending_fork (QUEUE (stop_reply_p) *q,
QUEUE_ITER (stop_reply_p) *iter,
stop_reply_p event,
void *data)
{
struct queue_iter_param *param = data;
int parent_pid = *(int *) param->input;
if (is_pending_fork_parent (&event->ws, parent_pid, event->ptid))
{
struct remote_state *rs = get_remote_state ();
int child_pid = ptid_get_pid (event->ws.value.related_pid);
int res;
res = remote_vkill (child_pid, rs);
if (res != 0)
error (_("Can't kill fork child process %d"), child_pid);
}
return 1;
}
/* Kill any new fork children of process PID that haven't been
processed by follow_fork. */
static void
kill_new_fork_children (int pid, struct remote_state *rs)
{
struct thread_info *thread;
struct notif_client *notif = &notif_client_stop;
struct queue_iter_param param;
/* Kill the fork child threads of any threads in process PID
that are stopped at a fork event. */
ALL_NON_EXITED_THREADS (thread)
{
struct target_waitstatus *ws = &thread->pending_follow;
if (is_pending_fork_parent (ws, pid, thread->ptid))
{
struct remote_state *rs = get_remote_state ();
int child_pid = ptid_get_pid (ws->value.related_pid);
int res;
res = remote_vkill (child_pid, rs);
if (res != 0)
error (_("Can't kill fork child process %d"), child_pid);
}
}
/* Check for any pending fork events (not reported or processed yet)
in process PID and kill those fork child threads as well. */
remote_notif_get_pending_events (notif);
param.input = &pid;
param.output = NULL;
QUEUE_iterate (stop_reply_p, stop_reply_queue,
kill_child_of_pending_fork, &param);
}
static void
remote_kill (struct target_ops *ops)
1999-07-05 19:58:44 +02:00
{
Handle 'k' packet TARGET_CLOSE_ERROR gracefully. Remote servers may cut the connection abruptly since they are not required to reply to a 'k' (Kill) packet sent from GDB. This patch addresses any issues arising from such scenario, which leads to a GDB internal error due to an attempt to pop the target more than once. With the patch, this failure is handled gracefully. Here's the GDB backtrace Maciej got running the testsuite against QEMU. Full paths edited out for brevity. #0 0x55573430 in __kernel_vsyscall () #1 0x557a2951 in raise () from /lib32/libc.so.6 #2 0x557a5d82 in abort () from /lib32/libc.so.6 #3 0x0826e2e4 in dump_core () at .../gdb/utils.c:635 #4 0x0826e5b6 in internal_vproblem (problem=0x85200c0, file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:804 #5 0x0826e5fb in internal_verror ( file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:820 #6 0x0826e633 in internal_error ( file=0x8416be8 ".../gdb/target.c", line=2861, string=0x84174ac "could not find a target to follow mourn inferior") at .../gdb/utils.c:830 #7 0x081b4ad0 in target_mourn_inferior () at .../gdb/target.c:2861 #8 0x08082283 in remote_kill (ops=0x85245e0) at .../gdb/remote.c:7840 #9 0x081b06d1 in target_kill () at .../gdb/target.c:486 #10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0) at .../gdb/target.c:2570 #11 0x08290cfc in iterate_over_inferiors ( callback=0x81b42af <dispose_inferior>, data=0x0) at .../gdb/inferior.c:396 #12 0x081b435a in target_preopen (from_tty=1) at .../gdb/target.c:2591 #13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1, target=0x85245e0, extended_p=0) at .../gdb/remote.c:4292 #14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/remote.c:3655 #15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:107 #16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:1882 #17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1) at .../gdb/top.c:467 #18 0x08193f2d in command_handler (command=0xa5538a8 "") at .../gdb/event-top.c:435 #19 0x08194463 in command_line_handler ( rl=0xa778198 "target remote localhost:1237") at .../gdb/event-top.c:633 #20 0x082ba92b in rl_callback_read_char () at .../readline/callback.c:220 #21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0) at .../gdb/event-top.c:164 #22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0) at .../gdb/event-top.c:375 #23 0x08192f29 in handle_file_event (data=...) at .../gdb/event-loop.c:768 #24 0x0819266a in process_event () at .../gdb/event-loop.c:342 #25 0x08192708 in gdb_do_one_event () at .../gdb/event-loop.c:394 #26 0x08192781 in start_event_loop () at .../gdb/event-loop.c:431 #27 0x08193b08 in cli_command_loop (data=0x0) at .../gdb/event-top.c:179 #28 0x0818bc26 in current_interp_command_loop () at .../gdb/interps.c:327 #29 0x0818c4e5 in captured_command_loop (data=0x0) at .../gdb/main.c:267 #30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>, func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #31 0x0818d736 in captured_main (data=0xffa47f10) at .../gdb/main.c:1067 #32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>, func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #33 0x0818d76c in gdb_main (args=0xffa47f10) at .../gdb/main.c:1076 #34 0x0804dd1b in main (argc=5, argv=0xffa47fd4) at .../gdb/gdb.c:34 The corresponding gdb.log excerpt: (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9) cont Continuing. Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44 44 } (gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9 print flags $10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'} (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc) delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break2 Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48. (gdb) entering gdb_reload target remote localhost:1235 A program is being debugged already. Kill it? (y or n) y Remote connection closed .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ^Ccontinue Please answer y or n. .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Resyncing due to internal error. n .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y Command aborted. (gdb) print/x flags $11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1 cont The program is not being run. (gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running) print/x flags $12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2 delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break3 Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52. (gdb) entering gdb_reload target remote localhost:1236 Remote debugging using localhost:1236 Reading symbols from .../lib/ld-linux.so.3...done. Loaded symbols for .../lib/ld-linux.so.3 0x41001b80 in _start () from .../lib/ld-linux.so.3 (gdb) continue Continuing. Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52 52 } (gdb) print flags $13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'} (gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges gdb/ 2013-12-02 Pedro Alves <pedro@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> * remote.c (putpkt_for_catch_errors): Remove function. (remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet gracefully.
2013-11-30 19:22:49 +01:00
/* Catch errors so the user can quit from gdb even when we
aren't on speaking terms with the remote system. */
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
TRY
Handle 'k' packet TARGET_CLOSE_ERROR gracefully. Remote servers may cut the connection abruptly since they are not required to reply to a 'k' (Kill) packet sent from GDB. This patch addresses any issues arising from such scenario, which leads to a GDB internal error due to an attempt to pop the target more than once. With the patch, this failure is handled gracefully. Here's the GDB backtrace Maciej got running the testsuite against QEMU. Full paths edited out for brevity. #0 0x55573430 in __kernel_vsyscall () #1 0x557a2951 in raise () from /lib32/libc.so.6 #2 0x557a5d82 in abort () from /lib32/libc.so.6 #3 0x0826e2e4 in dump_core () at .../gdb/utils.c:635 #4 0x0826e5b6 in internal_vproblem (problem=0x85200c0, file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:804 #5 0x0826e5fb in internal_verror ( file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:820 #6 0x0826e633 in internal_error ( file=0x8416be8 ".../gdb/target.c", line=2861, string=0x84174ac "could not find a target to follow mourn inferior") at .../gdb/utils.c:830 #7 0x081b4ad0 in target_mourn_inferior () at .../gdb/target.c:2861 #8 0x08082283 in remote_kill (ops=0x85245e0) at .../gdb/remote.c:7840 #9 0x081b06d1 in target_kill () at .../gdb/target.c:486 #10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0) at .../gdb/target.c:2570 #11 0x08290cfc in iterate_over_inferiors ( callback=0x81b42af <dispose_inferior>, data=0x0) at .../gdb/inferior.c:396 #12 0x081b435a in target_preopen (from_tty=1) at .../gdb/target.c:2591 #13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1, target=0x85245e0, extended_p=0) at .../gdb/remote.c:4292 #14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/remote.c:3655 #15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:107 #16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:1882 #17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1) at .../gdb/top.c:467 #18 0x08193f2d in command_handler (command=0xa5538a8 "") at .../gdb/event-top.c:435 #19 0x08194463 in command_line_handler ( rl=0xa778198 "target remote localhost:1237") at .../gdb/event-top.c:633 #20 0x082ba92b in rl_callback_read_char () at .../readline/callback.c:220 #21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0) at .../gdb/event-top.c:164 #22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0) at .../gdb/event-top.c:375 #23 0x08192f29 in handle_file_event (data=...) at .../gdb/event-loop.c:768 #24 0x0819266a in process_event () at .../gdb/event-loop.c:342 #25 0x08192708 in gdb_do_one_event () at .../gdb/event-loop.c:394 #26 0x08192781 in start_event_loop () at .../gdb/event-loop.c:431 #27 0x08193b08 in cli_command_loop (data=0x0) at .../gdb/event-top.c:179 #28 0x0818bc26 in current_interp_command_loop () at .../gdb/interps.c:327 #29 0x0818c4e5 in captured_command_loop (data=0x0) at .../gdb/main.c:267 #30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>, func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #31 0x0818d736 in captured_main (data=0xffa47f10) at .../gdb/main.c:1067 #32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>, func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #33 0x0818d76c in gdb_main (args=0xffa47f10) at .../gdb/main.c:1076 #34 0x0804dd1b in main (argc=5, argv=0xffa47fd4) at .../gdb/gdb.c:34 The corresponding gdb.log excerpt: (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9) cont Continuing. Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44 44 } (gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9 print flags $10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'} (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc) delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break2 Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48. (gdb) entering gdb_reload target remote localhost:1235 A program is being debugged already. Kill it? (y or n) y Remote connection closed .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ^Ccontinue Please answer y or n. .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Resyncing due to internal error. n .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y Command aborted. (gdb) print/x flags $11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1 cont The program is not being run. (gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running) print/x flags $12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2 delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break3 Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52. (gdb) entering gdb_reload target remote localhost:1236 Remote debugging using localhost:1236 Reading symbols from .../lib/ld-linux.so.3...done. Loaded symbols for .../lib/ld-linux.so.3 0x41001b80 in _start () from .../lib/ld-linux.so.3 (gdb) continue Continuing. Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52 52 } (gdb) print flags $13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'} (gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges gdb/ 2013-12-02 Pedro Alves <pedro@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> * remote.c (putpkt_for_catch_errors): Remove function. (remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet gracefully.
2013-11-30 19:22:49 +01:00
{
putpkt ("k");
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
CATCH (ex, RETURN_MASK_ERROR)
Handle 'k' packet TARGET_CLOSE_ERROR gracefully. Remote servers may cut the connection abruptly since they are not required to reply to a 'k' (Kill) packet sent from GDB. This patch addresses any issues arising from such scenario, which leads to a GDB internal error due to an attempt to pop the target more than once. With the patch, this failure is handled gracefully. Here's the GDB backtrace Maciej got running the testsuite against QEMU. Full paths edited out for brevity. #0 0x55573430 in __kernel_vsyscall () #1 0x557a2951 in raise () from /lib32/libc.so.6 #2 0x557a5d82 in abort () from /lib32/libc.so.6 #3 0x0826e2e4 in dump_core () at .../gdb/utils.c:635 #4 0x0826e5b6 in internal_vproblem (problem=0x85200c0, file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:804 #5 0x0826e5fb in internal_verror ( file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:820 #6 0x0826e633 in internal_error ( file=0x8416be8 ".../gdb/target.c", line=2861, string=0x84174ac "could not find a target to follow mourn inferior") at .../gdb/utils.c:830 #7 0x081b4ad0 in target_mourn_inferior () at .../gdb/target.c:2861 #8 0x08082283 in remote_kill (ops=0x85245e0) at .../gdb/remote.c:7840 #9 0x081b06d1 in target_kill () at .../gdb/target.c:486 #10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0) at .../gdb/target.c:2570 #11 0x08290cfc in iterate_over_inferiors ( callback=0x81b42af <dispose_inferior>, data=0x0) at .../gdb/inferior.c:396 #12 0x081b435a in target_preopen (from_tty=1) at .../gdb/target.c:2591 #13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1, target=0x85245e0, extended_p=0) at .../gdb/remote.c:4292 #14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/remote.c:3655 #15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:107 #16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:1882 #17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1) at .../gdb/top.c:467 #18 0x08193f2d in command_handler (command=0xa5538a8 "") at .../gdb/event-top.c:435 #19 0x08194463 in command_line_handler ( rl=0xa778198 "target remote localhost:1237") at .../gdb/event-top.c:633 #20 0x082ba92b in rl_callback_read_char () at .../readline/callback.c:220 #21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0) at .../gdb/event-top.c:164 #22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0) at .../gdb/event-top.c:375 #23 0x08192f29 in handle_file_event (data=...) at .../gdb/event-loop.c:768 #24 0x0819266a in process_event () at .../gdb/event-loop.c:342 #25 0x08192708 in gdb_do_one_event () at .../gdb/event-loop.c:394 #26 0x08192781 in start_event_loop () at .../gdb/event-loop.c:431 #27 0x08193b08 in cli_command_loop (data=0x0) at .../gdb/event-top.c:179 #28 0x0818bc26 in current_interp_command_loop () at .../gdb/interps.c:327 #29 0x0818c4e5 in captured_command_loop (data=0x0) at .../gdb/main.c:267 #30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>, func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #31 0x0818d736 in captured_main (data=0xffa47f10) at .../gdb/main.c:1067 #32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>, func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #33 0x0818d76c in gdb_main (args=0xffa47f10) at .../gdb/main.c:1076 #34 0x0804dd1b in main (argc=5, argv=0xffa47fd4) at .../gdb/gdb.c:34 The corresponding gdb.log excerpt: (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9) cont Continuing. Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44 44 } (gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9 print flags $10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'} (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc) delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break2 Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48. (gdb) entering gdb_reload target remote localhost:1235 A program is being debugged already. Kill it? (y or n) y Remote connection closed .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ^Ccontinue Please answer y or n. .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Resyncing due to internal error. n .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y Command aborted. (gdb) print/x flags $11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1 cont The program is not being run. (gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running) print/x flags $12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2 delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break3 Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52. (gdb) entering gdb_reload target remote localhost:1236 Remote debugging using localhost:1236 Reading symbols from .../lib/ld-linux.so.3...done. Loaded symbols for .../lib/ld-linux.so.3 0x41001b80 in _start () from .../lib/ld-linux.so.3 (gdb) continue Continuing. Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52 52 } (gdb) print flags $13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'} (gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges gdb/ 2013-12-02 Pedro Alves <pedro@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> * remote.c (putpkt_for_catch_errors): Remove function. (remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet gracefully.
2013-11-30 19:22:49 +01:00
{
if (ex.error == TARGET_CLOSE_ERROR)
{
/* If we got an (EOF) error that caused the target
to go away, then we're done, that's what we wanted.
"k" is susceptible to cause a premature EOF, given
that the remote server isn't actually required to
reply to "k", and it can happen that it doesn't
even get to reply ACK to the "k". */
return;
}
/* Otherwise, something went wrong. We didn't actually kill
the target. Just propagate the exception, and let the
user or higher layers decide what to do. */
throw_exception (ex);
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
END_CATCH
1999-07-05 19:58:44 +02:00
Handle 'k' packet TARGET_CLOSE_ERROR gracefully. Remote servers may cut the connection abruptly since they are not required to reply to a 'k' (Kill) packet sent from GDB. This patch addresses any issues arising from such scenario, which leads to a GDB internal error due to an attempt to pop the target more than once. With the patch, this failure is handled gracefully. Here's the GDB backtrace Maciej got running the testsuite against QEMU. Full paths edited out for brevity. #0 0x55573430 in __kernel_vsyscall () #1 0x557a2951 in raise () from /lib32/libc.so.6 #2 0x557a5d82 in abort () from /lib32/libc.so.6 #3 0x0826e2e4 in dump_core () at .../gdb/utils.c:635 #4 0x0826e5b6 in internal_vproblem (problem=0x85200c0, file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:804 #5 0x0826e5fb in internal_verror ( file=0x8416be8 ".../gdb/target.c", line=2861, fmt=0x84174ac "could not find a target to follow mourn inferior", ap=0xffa4796c "\f") at .../gdb/utils.c:820 #6 0x0826e633 in internal_error ( file=0x8416be8 ".../gdb/target.c", line=2861, string=0x84174ac "could not find a target to follow mourn inferior") at .../gdb/utils.c:830 #7 0x081b4ad0 in target_mourn_inferior () at .../gdb/target.c:2861 #8 0x08082283 in remote_kill (ops=0x85245e0) at .../gdb/remote.c:7840 #9 0x081b06d1 in target_kill () at .../gdb/target.c:486 #10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0) at .../gdb/target.c:2570 #11 0x08290cfc in iterate_over_inferiors ( callback=0x81b42af <dispose_inferior>, data=0x0) at .../gdb/inferior.c:396 #12 0x081b435a in target_preopen (from_tty=1) at .../gdb/target.c:2591 #13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1, target=0x85245e0, extended_p=0) at .../gdb/remote.c:4292 #14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/remote.c:3655 #15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:107 #16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237", from_tty=1) at .../gdb/cli/cli-decode.c:1882 #17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1) at .../gdb/top.c:467 #18 0x08193f2d in command_handler (command=0xa5538a8 "") at .../gdb/event-top.c:435 #19 0x08194463 in command_line_handler ( rl=0xa778198 "target remote localhost:1237") at .../gdb/event-top.c:633 #20 0x082ba92b in rl_callback_read_char () at .../readline/callback.c:220 #21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0) at .../gdb/event-top.c:164 #22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0) at .../gdb/event-top.c:375 #23 0x08192f29 in handle_file_event (data=...) at .../gdb/event-loop.c:768 #24 0x0819266a in process_event () at .../gdb/event-loop.c:342 #25 0x08192708 in gdb_do_one_event () at .../gdb/event-loop.c:394 #26 0x08192781 in start_event_loop () at .../gdb/event-loop.c:431 #27 0x08193b08 in cli_command_loop (data=0x0) at .../gdb/event-top.c:179 #28 0x0818bc26 in current_interp_command_loop () at .../gdb/interps.c:327 #29 0x0818c4e5 in captured_command_loop (data=0x0) at .../gdb/main.c:267 #30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>, func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #31 0x0818d736 in captured_main (data=0xffa47f10) at .../gdb/main.c:1067 #32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>, func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL) at .../gdb/exceptions.c:524 #33 0x0818d76c in gdb_main (args=0xffa47f10) at .../gdb/main.c:1076 #34 0x0804dd1b in main (argc=5, argv=0xffa47fd4) at .../gdb/gdb.c:34 The corresponding gdb.log excerpt: (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9) cont Continuing. Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44 44 } (gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9 print flags $10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'} (gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc) delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break2 Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48. (gdb) entering gdb_reload target remote localhost:1235 A program is being debugged already. Kill it? (y or n) y Remote connection closed .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ^Ccontinue Please answer y or n. .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Resyncing due to internal error. n .../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y Command aborted. (gdb) print/x flags $11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1 cont The program is not being run. (gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running) print/x flags $12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0} (gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2 delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break break3 Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52. (gdb) entering gdb_reload target remote localhost:1236 Remote debugging using localhost:1236 Reading symbols from .../lib/ld-linux.so.3...done. Loaded symbols for .../lib/ld-linux.so.3 0x41001b80 in _start () from .../lib/ld-linux.so.3 (gdb) continue Continuing. Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52 52 } (gdb) print flags $13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'} (gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges gdb/ 2013-12-02 Pedro Alves <pedro@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> * remote.c (putpkt_for_catch_errors): Remove function. (remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet gracefully.
2013-11-30 19:22:49 +01:00
/* We've killed the remote end, we get to mourn it. Since this is
target remote, single-process, mourning the inferior also
unpushes remote_ops. */
1999-07-05 19:58:44 +02:00
target_mourn_inferior ();
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
static int
remote_vkill (int pid, struct remote_state *rs)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vKill) == PACKET_DISABLE)
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
return -1;
/* Tell the remote target to detach. */
xsnprintf (rs->buf, get_remote_packet_size (), "vKill;%x", pid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_ok (rs->buf,
&remote_protocol_packets[PACKET_vKill]))
{
case PACKET_OK:
return 0;
case PACKET_ERROR:
return 1;
case PACKET_UNKNOWN:
return -1;
default:
internal_error (__FILE__, __LINE__, _("Bad result from packet_ok"));
}
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
static void
extended_remote_kill (struct target_ops *ops)
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
{
int res;
int pid = ptid_get_pid (inferior_ptid);
struct remote_state *rs = get_remote_state ();
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
/* If we're stopped while forking and we haven't followed yet, kill the
child task. We need to do this before killing the parent task
because if this is a vfork then the parent will be sleeping. */
kill_new_fork_children (pid, rs);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
res = remote_vkill (pid, rs);
if (res == -1 && !(rs->extended && remote_multi_process_p (rs)))
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
{
/* Don't try 'k' on a multi-process aware stub -- it has no way
to specify the pid. */
putpkt ("k");
#if 0
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] != 'O' || rs->buf[0] != 'K')
res = 1;
#else
/* Don't wait for it to die. I'm not really sure it matters whether
we do or not. For the existing stubs, kill is a noop. */
res = 0;
#endif
}
if (res != 0)
error (_("Can't kill process"));
target_mourn_inferior ();
}
static void
remote_mourn (struct target_ops *target)
{
unpush_target (target);
/* remote_close takes care of doing most of the clean up. */
generic_mourn_inferior ();
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
static void
extended_remote_mourn (struct target_ops *target)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
struct remote_state *rs = get_remote_state ();
/* In case we got here due to an error, but we're going to stay
connected. */
rs->waiting_for_stop_reply = 0;
/* If the current general thread belonged to the process we just
detached from or has exited, the remote side current general
thread becomes undefined. Considering a case like this:
- We just got here due to a detach.
- The process that we're detaching from happens to immediately
report a global breakpoint being hit in non-stop mode, in the
same thread we had selected before.
- GDB attaches to this process again.
- This event happens to be the next event we handle.
GDB would consider that the current general thread didn't need to
be set on the stub side (with Hg), since for all it knew,
GENERAL_THREAD hadn't changed.
Notice that although in all-stop mode, the remote server always
sets the current thread to the thread reporting the stop event,
that doesn't happen in non-stop mode; in non-stop, the stub *must
not* change the current thread when reporting a breakpoint hit,
due to the decoupling of event reporting and event handling.
To keep things simple, we always invalidate our notion of the
current thread. */
record_currthread (rs, minus_one_ptid);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Unlike "target remote", we do not want to unpush the target; then
the next time the user says "run", we won't be connected. */
/* Call common code to mark the inferior as not running. */
generic_mourn_inferior ();
2009-03-25 22:42:35 +01:00
if (!have_inferiors ())
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
if (!remote_multi_process_p (rs))
{
/* Check whether the target is running now - some remote stubs
automatically restart after kill. */
putpkt ("?");
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] == 'S' || rs->buf[0] == 'T')
{
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
/* Assume that the target has been restarted. Set
inferior_ptid so that bits of core GDB realizes
there's something here, e.g., so that the user can
say "kill" again. */
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
inferior_ptid = magic_null_ptid;
}
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
}
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
static int
extended_remote_supports_disable_randomization (struct target_ops *self)
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_QDisableRandomization) == PACKET_ENABLE;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
}
static void
extended_remote_disable_randomization (int val)
{
struct remote_state *rs = get_remote_state ();
char *reply;
xsnprintf (rs->buf, get_remote_packet_size (), "QDisableRandomization:%x",
val);
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
error (_("Target does not support QDisableRandomization."));
if (strcmp (reply, "OK") != 0)
error (_("Bogus QDisableRandomization reply from target: %s"), reply);
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
static int
extended_remote_run (char *args)
{
struct remote_state *rs = get_remote_state ();
int len;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* If the user has disabled vRun support, or we have detected that
support is not available, do not try it. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vRun) == PACKET_DISABLE)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
return -1;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
strcpy (rs->buf, "vRun;");
len = strlen (rs->buf);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
if (strlen (remote_exec_file) * 2 + len >= get_remote_packet_size ())
error (_("Remote file name too long for run packet"));
len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->buf + len,
strlen (remote_exec_file));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
gdb_assert (args != NULL);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
if (*args)
{
struct cleanup *back_to;
int i;
char **argv;
argv = gdb_buildargv (args);
back_to = make_cleanup_freeargv (argv);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
for (i = 0; argv[i] != NULL; i++)
{
if (strlen (argv[i]) * 2 + 1 + len >= get_remote_packet_size ())
error (_("Argument list too long for run packet"));
rs->buf[len++] = ';';
len += 2 * bin2hex ((gdb_byte *) argv[i], rs->buf + len,
strlen (argv[i]));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
do_cleanups (back_to);
}
rs->buf[len++] = '\0';
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vRun]))
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
case PACKET_OK:
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
/* We have a wait response. All is well. */
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
return 0;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
case PACKET_UNKNOWN:
return -1;
case PACKET_ERROR:
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
if (remote_exec_file[0] == '\0')
error (_("Running the default executable on the remote target failed; "
"try \"set remote exec-file\"?"));
else
error (_("Running \"%s\" on the remote target failed"),
remote_exec_file);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
default:
gdb_assert_not_reached (_("bad switch"));
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
}
}
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* In the extended protocol we want to be able to do things like
"run" and have them basically work as expected. So we need
a special create_inferior function. We support changing the
executable file and the command line arguments, but not the
environment. */
1999-07-05 19:58:44 +02:00
static void
extended_remote_create_inferior (struct target_ops *ops,
char *exec_file, char *args,
char **env, int from_tty)
1999-07-05 19:58:44 +02:00
{
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
int run_worked;
char *stop_reply;
struct remote_state *rs = get_remote_state ();
1999-07-05 19:58:44 +02:00
/* If running asynchronously, register the target file descriptor
with the event loop. */
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
if (target_can_async_p ())
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
target_async (1);
1999-07-05 19:58:44 +02:00
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
/* Disable address space randomization if requested (and supported). */
if (extended_remote_supports_disable_randomization (ops))
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
extended_remote_disable_randomization (disable_randomization);
1999-07-05 19:58:44 +02:00
/* Now restart the remote server. */
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
run_worked = extended_remote_run (args) != -1;
if (!run_worked)
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
{
/* vRun was not supported. Fail if we need it to do what the
user requested. */
if (remote_exec_file[0])
error (_("Remote target does not support \"set remote exec-file\""));
if (args[0])
error (_("Remote target does not support \"set args\" or run <ARGS>"));
1999-07-05 19:58:44 +02:00
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Fall back to "R". */
extended_remote_restart ();
}
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
if (!have_inferiors ())
{
/* Clean up from the last time we ran, before we mark the target
running again. This will mark breakpoints uninserted, and
get_offsets may insert breakpoints. */
init_thread_list ();
init_wait_for_inferior ();
}
Fix GDB internal error against targets that return a thread in T stop replies but don't support qC. Yao writes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; Sending packet: $Hc-1#09...Packet received: E01 Sending packet: $qC#b4...Packet received: Sending packet: $qAttached:a410#bf...Packet received: E01 Packet qAttached (query-attached) is supported warning: Remote failure reply: E01 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Right after the initial connection, we query the target for its state, with the ? packet. We store the resulting wait status / stop reply aside, and query the target for the current thread, using qC, which fails, so we fake a ptid for the target's thread. We then later, after the initial setup, end up consuming that set-aside wait status, parsing the T stop reply, which contains a "thread" "register" (which was the thread the target would have replied to qC). We get into trouble because the ptid in that stop reply doesn't match our faked up ptid in the initial setup, although the target threads are the same... So we had the T stop reply handy all along. We might as well extract the thread's ptid from it, and avoid all the resulting issues. qC is also used after vRun, in order to discover the new process'es main thread. But, vRun's reply is also a wait status, just like '?''s, which is quite convenient. This means that if we have a "Txx thread: ptid" reply, then we don't really need qC. The patch makes GDB look in the T reply first, and if not found, try with qC. The packet handling seems to have been added in gdb-4.18 (1999), and I see that in that same release, "Txx thread: ptid" didn't exist yet, which probably explains why nobody though of doing this before. Regression tested against a gdbserver with qC disabled (and then enabled), on x86_64 Fedora 17. 2013-01-25 Pedro Alves <palves@redhat.com> * remote.c (stop_reply_extract_thread): New. (add_current_inferior_and_thread): New parameter 'wait_status'. Handle it. (remote_start_remote): Pass wait status to add_current_inferior_and_thread. (extended_remote_run): Update comment. (extended_remote_create_inferior_1): Pass wait status to add_current_inferior_and_thread.
2013-01-25 18:25:59 +01:00
/* vRun's success return is a stop reply. */
stop_reply = run_worked ? rs->buf : NULL;
add_current_inferior_and_thread (stop_reply);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* Get updated offsets, if the stub uses qOffsets. */
get_offsets ();
}
1999-07-07 22:19:36 +02:00
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
/* Given a location's target info BP_TGT and the packet buffer BUF, output
the list of conditions (in agent expression bytecode format), if any, the
target needs to evaluate. The output is placed into the packet buffer
started from BUF and ended at BUF_END. */
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
static int
remote_add_target_side_condition (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt, char *buf,
char *buf_end)
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
{
struct agent_expr *aexpr = NULL;
int i, ix;
char *pkt;
char *buf_start = buf;
if (VEC_empty (agent_expr_p, bp_tgt->conditions))
return 0;
buf += strlen (buf);
xsnprintf (buf, buf_end - buf, "%s", ";");
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
buf++;
/* Send conditions to the target and free the vector. */
for (ix = 0;
VEC_iterate (agent_expr_p, bp_tgt->conditions, ix, aexpr);
ix++)
{
xsnprintf (buf, buf_end - buf, "X%x,", aexpr->len);
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
buf += strlen (buf);
for (i = 0; i < aexpr->len; ++i)
buf = pack_hex_byte (buf, aexpr->buf[i]);
*buf = '\0';
}
return 0;
}
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
static void
remote_add_target_side_commands (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt, char *buf)
{
struct agent_expr *aexpr = NULL;
int i, ix;
if (VEC_empty (agent_expr_p, bp_tgt->tcommands))
return;
buf += strlen (buf);
sprintf (buf, ";cmds:%x,", bp_tgt->persist);
buf += strlen (buf);
/* Concatenate all the agent expressions that are commands into the
cmds parameter. */
for (ix = 0;
VEC_iterate (agent_expr_p, bp_tgt->tcommands, ix, aexpr);
ix++)
{
sprintf (buf, "X%x,", aexpr->len);
buf += strlen (buf);
for (i = 0; i < aexpr->len; ++i)
buf = pack_hex_byte (buf, aexpr->buf[i]);
*buf = '\0';
}
}
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
/* Insert a breakpoint. On targets that have software breakpoint
support, we ask the remote target to do the work; on targets
which don't, we insert a traditional memory breakpoint. */
static int
target, breakpoint: allow insert/remove breakpoint to be forwarded 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * target.h (target_ops) <to_insert_breakpoint> <to_remove_breakpoint>: Add target_ops parameter. (forward_target_insert_breakpoint): New. (forward_target_remove_breakpoint): New. (memory_remove_breakpoint, memory_insert_breakpoint): Add target_ops parameter. * target.c (target_insert_breakpoint): Split into this and ... (forward_target_insert_breakpoint): ... this. (target_remove_breakpoint): Split into this and ... (forward_target_remove_breakpoint): ... this. (debug_to_insert_breakpoint): Add target_ops parameter. Call forward_target_insert_breakpoint. (debug_to_remove_breakpoint): Add target_ops parameter. Call forward_target_remove_breakpoint. (update_current_target): Do not inherit or default to_insert_breakpoint and to_remove_breakpoint. * corelow.c (ignore): Add target_ops parameter. * exec.c (ignore): Add target_ops parameter. * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): Add target_ops parameter. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Add target_ops parameter. * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint): Add target_ops parameter. * record-full.c (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint) (tmp_to_remove_breakpoint, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint): Add target_ops parameter. Update users. (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_remove_breakpoint_ops) (tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New. (record_full_open): Initialize tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops, record_full_beneath_to_insert_breakpoint_ops, and record_full_beneath_to_remove_breakpoint_ops. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Add target_ops parameter. * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint): Add target_ops parameter. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Add target_ops parameter.
2013-12-17 10:49:03 +01:00
remote_insert_breakpoint (struct target_ops *ops,
struct gdbarch *gdbarch,
* breakpoint.h (struct breakpoint): New member GDBARCH. * breakpoint.c: Include "arch-utils.h". (set_raw_breakpoint_without_location): Add GDBARCH parameter. Use it to set breakpoint architecture. (set_raw_breakpoint): Add GDBARCH parameter. (create_internal_breakpoint): Likewise. (create_catchpoint): Likewise. (create_fork_vfork_event_catchpoint): Likewise. (create_breakpoint): Likewise. (create_breakpoints): Likewise. (break_command_really): Likewise. (create_ada_exception_breakpoint): Likewise. Update local callers to pass architecture: (create_internal_breakpoint): Update. (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_thread_event_breakpoint): Update. (create_solib_event_breakpoint): Update. (create_catchpoint): Update. (create_fork_vfork_event_catchpoint): Update. (set_momentary_breakpoint): Update. (clone_momentary_breakpoint): Update. (create_breakpoint): Update. (create_breakpoints): Update. (break_command_really): Update. (break_command_1): Update. (set_breakpoint): Update. (watch_command_1): Update. (catch_fork_command_1): Update. (catch_exec_commnd_1): Update. (handle_gnu_v3_exceptions): Update. (create_ada_exception_breakpoint): Update. (catch_ada_exception_command): Update. (catch_assert_command): Update. (trace_command): Update. * breakpoint.h (struct bp_location): New member GDBARCH. * breakpoint.c (get_sal_arch): New function. (set_raw_breakpoint): Set location architecture. (add_location_to_breakpoint): Likewise. (clone_momentary_breakpoint): Likewise. (watch_command_1): Likewise. (update_watchpoint): Likewise. (bp_loc_is_permanent): Use location architecture instead of current_gdbarch. (adjust_breakpoint_address): Add GDBARCH parameter; use it instead of current_gdbarch. Update callers of adjust_breakpoint_address to pass breakpoint location architecture: (set_raw_breakpoint): Update. (watch_command_1): Update. * tracepoint.c: (collect_symbol): Add GDBARCH parameter, use instead of current_gdbarch. (add_local_symbols): Add GDBARCH parameter. Pass to collect_symbol. (encode_actions): Pass tracepoint architecture to add_local_symbols (encode_actions): Use tracepoint architecture instead of current_gdbarch. Pass it to add_local_symbols and collect_symbol. * breakpoint.h (struct breakpoint_ops): Replace last_addr parameter of print_one callback with last_loc. * breakpoint.c (print_one_breakpoint_location): Replace last_addr parameter with last_loc. (print_one_breakpoint): Likewise. (do_captured_breakpoint_query): Update call. (breakpoint_1): Pass last_loc instead of last_addr to print_one_breakpoint. Pass last location architecture instead of current_gdbarch to set_next_address. Update all implementations of the print_one callback: * breakpoint.c (print_one_catch_fork): Update. (print_one_catch_vfork): Update. (print_one_catch_exec): Update. (print_one_exception_catchpoint): Update. * ada-lang.c (print_one_exception): Update. (print_one_catch_exception): Update. (print_one_catch_exception_unhandled): Update. (print_one_catch_assert): Update. * breakpoint.c (print_one_breakpoint_location): Add PRINT_ADDRESS_BITS parameter. Use it instead of gdbarch_addr_bit (current_gdbarch). (print_one_breakpoint): Add PRINT_ADDRESS_BITS parameter and pass it to print_one_breakpoint_location. (breakpoint_address_bits): New function. (do_captured_breakpoint_query): Compute number of address bits to print and pass it to print_one_breakpoint. (breakpoint_1): Likewise. Use it instead of current_gdbarch. * breakpoint.h (create_thread_event_breakpoint): Add GDBARCH. * breakpoint.c (create_thread_event_breakpoint): Likewise. Update callers to create_thread_event_breakpoint: * aix-thread.c (pd_enable): Update. * linux-thread-db.c (enable_thread_event): Update. * breakpoint.h (create_solib_event_breakpoint): Add GDBARCH. * breakpoint.c (create_solib_event_breakpoint): Likewise. Update callers to create_solib_event_breakpoint: * solib-frv.c (enable_break, enable_break2): Update. * solib-pa64.c (pa64_solib_create_inferior_hook): Update. * solib-som.c (som_solib_create_inferior_hook): Update. * solib-darwin.c (darwin_solib_create_inferior_hook): Update. * solib-svr4.c (enable_break): Update. * breakpoint.h (insert_single_step_breakpoint): Add GDBARCH. * breakpoint.c (insert_single_step_breakpoint): Likewise. Update callers to insert_single_step_breakpoint: * alpha-tdep.c (alpha_software_single_step): Update. * arm-linux-tdep.c (arm_linux_software_single_step): Update. * arm-tdep.c (arm_software_single_step): Update. * cris-tdep.c (cris_software_single_step): Update. * rs6000-aix-tdep.c (rs6000_software_single_step): Update. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Update. * sparc-tdep.c (sparc_software_single_step): Update. * spu-tdep.c (spu_software_single_step): Update. * mips-tdep.c (deal_with_atomic_sequence): Add GDBARCH parameter. Pass it to insert_single_step_breakpoint. (mips_software_single_step): Pass architecture to deal_with_atomic_sequence and insert_single_step_breakpoint. * breakpoint.h (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. * breakpoint.c (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. Update callers to deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint: * breakpoint.c (single_step_gdbarch): New static variable. (insert_single_step_breakpoint): Pass GDBARCH parameter to deprecated_insert_raw_breakpoint. Store it in single_step_gdbarch. (remove_single_step_breakpoints): Pass architecture stored in single_step_gdbarch to deprecated_remove_raw_breakpoint. * rs6000-nat.c (exec_one_dummy_insn): Update. * solib-irix.c (enable_break, disable_break): Update. * procfs.c (procfs_mourn_inferior): Update. (remove_dbx_link_breakpoint): Update. * breakpoint.h (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. * breakpoint.c (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. Update callers to set_breakpoint, set_momentary_breakpoint and set_momentary_breakpoint_at_pc: * breakpoint.c (set_momentary_breakpoint_at_pc): Update. (until_break_command): Update. * infcall.c (call_function_by_hand): Update. * infcmd.c (finish_backward, finish_forward): Update. * infrun.c (insert_step_resume_breakpoint_at_sal): Add GDBARCH parameter. Pass it to set_momentary_breakpoint. (insert_longjmp_resume_breakpoint): Add GDBARCH parameter. Pass it to set_momentary_breakpoint_at_pc. (handle_inferior_event): Update. (insert_step_resume_breakpoint_at_frame): Update. (insert_step_resume_breakpoint_at_caller): Update.. * mi/mi-cmd-break.c: Include "arch-utils.h". (mi_cmd_break_insert): Update. * target.h (struct target_ops): Add GDBARCH parameter to to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint members. (target_insert_breakpoint, target_remove_breakpoint, target_insert_hw_breakpoint, target_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (memory_remove_breakpoint, memory_insert_breakpoint): Add GDBARCH parameter. * target.c (debug_to_insert_breakpoint, debug_to_remove_breakpoint, debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (update_current_target): Update function signature. * breakpoint.c (insert_bp_location, remove_breakpoint, deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint): Pass architecture to target_ routines. Update all implementations of the target breakpoint routines to take GDBARCH parameter and use it instead of GDBARCH as appropriate: * corelow.c (ignore): Update. * exec.c (ignore): Update. * mem-break.c (memory_insert_breakpoint): Update. (memory_remove_breakpoint): Update. * monitor.c (monitor_insert_breakpoint): Update. (monitor_remove_breakpoint): Update. * record.c (record_insert_breakpoint): Update. (record_beneath_to_insert_breakpoint): Update. (record_remove_breakpoint): Update. (record_beneath_to_remove_breakpoint): Update. * remote.c (remote_insert_breakpoint): Update. (remote_remove_breakpoint): Update. (remote_insert_hw_breakpoint): Update. (remote_remove_hw_breakpoint): Update. * remote-m32r-sdi.c (m32r_insert_breakpoint): Update. (m32r_remove_breakpoint): Update. * remote-mips.c (mips_insert_breakpoint): Update. (mips_remove_breakpoint): Update. * i386-nat.c (i386_insert_hw_breakpoint): Update. (i386_remove_hw_breakpoint): Update. * nto-procfs.c (procfs_insert_breakpoint): Update. (procfs_remove_breakpoint): Update. (procfs_insert_hw_breakpoint): Update. (procfs_remove_hw_breakpoint): Update. doc/ChangeLog: * gdbint.texi (Examples of Use of @code{ui_out} functions): Update example code extrated from breakpoint.c.
2009-07-02 19:12:28 +02:00
struct bp_target_info *bp_tgt)
{
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
If it succeeds, then set the support to PACKET_ENABLE. If it
fails, and the user has explicitly requested the Z support then
report an error, otherwise, mark it disabled and go on. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z0) != PACKET_DISABLE)
1999-08-09 23:36:23 +02:00
{
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
CORE_ADDR addr = bp_tgt->reqstd_address;
struct remote_state *rs;
char *p, *endbuf;
int bpsize;
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
struct condition_list *cond = NULL;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize);
rs = get_remote_state ();
p = rs->buf;
endbuf = rs->buf + get_remote_packet_size ();
1999-08-09 23:36:23 +02:00
*(p++) = 'Z';
*(p++) = '0';
*(p++) = ',';
addr = (ULONGEST) remote_address_masked (addr);
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
p += hexnumstr (p, addr);
xsnprintf (p, endbuf - p, ",%d", bpsize);
if (remote_supports_cond_breakpoints (ops))
remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
if (remote_can_run_breakpoint_commands (ops))
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
remote_add_target_side_commands (gdbarch, bp_tgt, p);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0]))
1999-08-09 23:36:23 +02:00
{
case PACKET_ERROR:
return -1;
case PACKET_OK:
bp_tgt->placed_address = addr;
bp_tgt->placed_size = bpsize;
return 0;
case PACKET_UNKNOWN:
break;
1999-08-09 23:36:23 +02:00
}
}
Handle the case of a remote target supporting target side commands, but not on software breakpoints. Although we can tell upfront whether a remote target supports target side commands, we can only tell whether the target supports that in combination with a given breakpoint kind (software, hardware, watchpoints, etc.) when we go and try to insert such a breakpoint kind the first time. It's not desirable to make remote_insert_breakpoint simply return -1 in this case, because if the breakpoint was set in a shared library, insert_bp_location will assume that the breakpoint insertion failed because the library wasn't mapped in. insert_bp_location already handles errors/exceptions thrown from the target_insert_xxx methods, exactly so the backend can tell the user the detailed reason the insertion of hw breakpoints failed. But, in the case of software breakpoints, it discards the detailed error message. So the patch makes insert_bp_location use the error's message for SW breakpoints too, and, introduces a NOT_SUPPORTED_ERROR error code so that insert_bp_location doesn't confuse the error for failure due to a shared library disappearing. The result is: (gdb) c Warning: Cannot insert breakpoint 2: Target doesn't support breakpoints that have target side commands. 2014-01-09 Pedro Alves <palves@redhat.com> Hui Zhu <hui@codesourcery.com> PR gdb/16101 * breakpoint.c (insert_bp_location): Rename hw_bp_err_string to bp_err_string. Don't mark the location shlib_disabled if the error thrown wasn't a generic or memory error. Catch errors thrown while inserting breakpoints in overlayed code. Output error message of software breakpoints. * remote.c (remote_insert_breakpoint): If this breakpoint has target-side commands but this stub doesn't support Z0 packets, throw NOT_SUPPORTED_ERROR error. * exceptions.h (enum errors) <NOT_SUPPORTED_ERROR>: New error. * target.h (target_insert_breakpoint): Extend comment. (target_insert_hw_breakpoint): Add comment.
2014-01-09 19:33:45 +01:00
/* If this breakpoint has target-side commands but this stub doesn't
support Z0 packets, throw error. */
if (!VEC_empty (agent_expr_p, bp_tgt->tcommands))
throw_error (NOT_SUPPORTED_ERROR, _("\
Target doesn't support breakpoints that have target side commands."));
target, breakpoint: allow insert/remove breakpoint to be forwarded 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * target.h (target_ops) <to_insert_breakpoint> <to_remove_breakpoint>: Add target_ops parameter. (forward_target_insert_breakpoint): New. (forward_target_remove_breakpoint): New. (memory_remove_breakpoint, memory_insert_breakpoint): Add target_ops parameter. * target.c (target_insert_breakpoint): Split into this and ... (forward_target_insert_breakpoint): ... this. (target_remove_breakpoint): Split into this and ... (forward_target_remove_breakpoint): ... this. (debug_to_insert_breakpoint): Add target_ops parameter. Call forward_target_insert_breakpoint. (debug_to_remove_breakpoint): Add target_ops parameter. Call forward_target_remove_breakpoint. (update_current_target): Do not inherit or default to_insert_breakpoint and to_remove_breakpoint. * corelow.c (ignore): Add target_ops parameter. * exec.c (ignore): Add target_ops parameter. * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): Add target_ops parameter. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Add target_ops parameter. * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint): Add target_ops parameter. * record-full.c (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint) (tmp_to_remove_breakpoint, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint): Add target_ops parameter. Update users. (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_remove_breakpoint_ops) (tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New. (record_full_open): Initialize tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops, record_full_beneath_to_insert_breakpoint_ops, and record_full_beneath_to_remove_breakpoint_ops. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Add target_ops parameter. * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint): Add target_ops parameter. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Add target_ops parameter.
2013-12-17 10:49:03 +01:00
return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
}
static int
target, breakpoint: allow insert/remove breakpoint to be forwarded 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * target.h (target_ops) <to_insert_breakpoint> <to_remove_breakpoint>: Add target_ops parameter. (forward_target_insert_breakpoint): New. (forward_target_remove_breakpoint): New. (memory_remove_breakpoint, memory_insert_breakpoint): Add target_ops parameter. * target.c (target_insert_breakpoint): Split into this and ... (forward_target_insert_breakpoint): ... this. (target_remove_breakpoint): Split into this and ... (forward_target_remove_breakpoint): ... this. (debug_to_insert_breakpoint): Add target_ops parameter. Call forward_target_insert_breakpoint. (debug_to_remove_breakpoint): Add target_ops parameter. Call forward_target_remove_breakpoint. (update_current_target): Do not inherit or default to_insert_breakpoint and to_remove_breakpoint. * corelow.c (ignore): Add target_ops parameter. * exec.c (ignore): Add target_ops parameter. * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): Add target_ops parameter. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Add target_ops parameter. * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint): Add target_ops parameter. * record-full.c (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint) (tmp_to_remove_breakpoint, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint): Add target_ops parameter. Update users. (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_remove_breakpoint_ops) (tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New. (record_full_open): Initialize tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops, record_full_beneath_to_insert_breakpoint_ops, and record_full_beneath_to_remove_breakpoint_ops. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Add target_ops parameter. * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint): Add target_ops parameter. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Add target_ops parameter.
2013-12-17 10:49:03 +01:00
remote_remove_breakpoint (struct target_ops *ops,
struct gdbarch *gdbarch,
* breakpoint.h (struct breakpoint): New member GDBARCH. * breakpoint.c: Include "arch-utils.h". (set_raw_breakpoint_without_location): Add GDBARCH parameter. Use it to set breakpoint architecture. (set_raw_breakpoint): Add GDBARCH parameter. (create_internal_breakpoint): Likewise. (create_catchpoint): Likewise. (create_fork_vfork_event_catchpoint): Likewise. (create_breakpoint): Likewise. (create_breakpoints): Likewise. (break_command_really): Likewise. (create_ada_exception_breakpoint): Likewise. Update local callers to pass architecture: (create_internal_breakpoint): Update. (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_thread_event_breakpoint): Update. (create_solib_event_breakpoint): Update. (create_catchpoint): Update. (create_fork_vfork_event_catchpoint): Update. (set_momentary_breakpoint): Update. (clone_momentary_breakpoint): Update. (create_breakpoint): Update. (create_breakpoints): Update. (break_command_really): Update. (break_command_1): Update. (set_breakpoint): Update. (watch_command_1): Update. (catch_fork_command_1): Update. (catch_exec_commnd_1): Update. (handle_gnu_v3_exceptions): Update. (create_ada_exception_breakpoint): Update. (catch_ada_exception_command): Update. (catch_assert_command): Update. (trace_command): Update. * breakpoint.h (struct bp_location): New member GDBARCH. * breakpoint.c (get_sal_arch): New function. (set_raw_breakpoint): Set location architecture. (add_location_to_breakpoint): Likewise. (clone_momentary_breakpoint): Likewise. (watch_command_1): Likewise. (update_watchpoint): Likewise. (bp_loc_is_permanent): Use location architecture instead of current_gdbarch. (adjust_breakpoint_address): Add GDBARCH parameter; use it instead of current_gdbarch. Update callers of adjust_breakpoint_address to pass breakpoint location architecture: (set_raw_breakpoint): Update. (watch_command_1): Update. * tracepoint.c: (collect_symbol): Add GDBARCH parameter, use instead of current_gdbarch. (add_local_symbols): Add GDBARCH parameter. Pass to collect_symbol. (encode_actions): Pass tracepoint architecture to add_local_symbols (encode_actions): Use tracepoint architecture instead of current_gdbarch. Pass it to add_local_symbols and collect_symbol. * breakpoint.h (struct breakpoint_ops): Replace last_addr parameter of print_one callback with last_loc. * breakpoint.c (print_one_breakpoint_location): Replace last_addr parameter with last_loc. (print_one_breakpoint): Likewise. (do_captured_breakpoint_query): Update call. (breakpoint_1): Pass last_loc instead of last_addr to print_one_breakpoint. Pass last location architecture instead of current_gdbarch to set_next_address. Update all implementations of the print_one callback: * breakpoint.c (print_one_catch_fork): Update. (print_one_catch_vfork): Update. (print_one_catch_exec): Update. (print_one_exception_catchpoint): Update. * ada-lang.c (print_one_exception): Update. (print_one_catch_exception): Update. (print_one_catch_exception_unhandled): Update. (print_one_catch_assert): Update. * breakpoint.c (print_one_breakpoint_location): Add PRINT_ADDRESS_BITS parameter. Use it instead of gdbarch_addr_bit (current_gdbarch). (print_one_breakpoint): Add PRINT_ADDRESS_BITS parameter and pass it to print_one_breakpoint_location. (breakpoint_address_bits): New function. (do_captured_breakpoint_query): Compute number of address bits to print and pass it to print_one_breakpoint. (breakpoint_1): Likewise. Use it instead of current_gdbarch. * breakpoint.h (create_thread_event_breakpoint): Add GDBARCH. * breakpoint.c (create_thread_event_breakpoint): Likewise. Update callers to create_thread_event_breakpoint: * aix-thread.c (pd_enable): Update. * linux-thread-db.c (enable_thread_event): Update. * breakpoint.h (create_solib_event_breakpoint): Add GDBARCH. * breakpoint.c (create_solib_event_breakpoint): Likewise. Update callers to create_solib_event_breakpoint: * solib-frv.c (enable_break, enable_break2): Update. * solib-pa64.c (pa64_solib_create_inferior_hook): Update. * solib-som.c (som_solib_create_inferior_hook): Update. * solib-darwin.c (darwin_solib_create_inferior_hook): Update. * solib-svr4.c (enable_break): Update. * breakpoint.h (insert_single_step_breakpoint): Add GDBARCH. * breakpoint.c (insert_single_step_breakpoint): Likewise. Update callers to insert_single_step_breakpoint: * alpha-tdep.c (alpha_software_single_step): Update. * arm-linux-tdep.c (arm_linux_software_single_step): Update. * arm-tdep.c (arm_software_single_step): Update. * cris-tdep.c (cris_software_single_step): Update. * rs6000-aix-tdep.c (rs6000_software_single_step): Update. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Update. * sparc-tdep.c (sparc_software_single_step): Update. * spu-tdep.c (spu_software_single_step): Update. * mips-tdep.c (deal_with_atomic_sequence): Add GDBARCH parameter. Pass it to insert_single_step_breakpoint. (mips_software_single_step): Pass architecture to deal_with_atomic_sequence and insert_single_step_breakpoint. * breakpoint.h (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. * breakpoint.c (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. Update callers to deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint: * breakpoint.c (single_step_gdbarch): New static variable. (insert_single_step_breakpoint): Pass GDBARCH parameter to deprecated_insert_raw_breakpoint. Store it in single_step_gdbarch. (remove_single_step_breakpoints): Pass architecture stored in single_step_gdbarch to deprecated_remove_raw_breakpoint. * rs6000-nat.c (exec_one_dummy_insn): Update. * solib-irix.c (enable_break, disable_break): Update. * procfs.c (procfs_mourn_inferior): Update. (remove_dbx_link_breakpoint): Update. * breakpoint.h (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. * breakpoint.c (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. Update callers to set_breakpoint, set_momentary_breakpoint and set_momentary_breakpoint_at_pc: * breakpoint.c (set_momentary_breakpoint_at_pc): Update. (until_break_command): Update. * infcall.c (call_function_by_hand): Update. * infcmd.c (finish_backward, finish_forward): Update. * infrun.c (insert_step_resume_breakpoint_at_sal): Add GDBARCH parameter. Pass it to set_momentary_breakpoint. (insert_longjmp_resume_breakpoint): Add GDBARCH parameter. Pass it to set_momentary_breakpoint_at_pc. (handle_inferior_event): Update. (insert_step_resume_breakpoint_at_frame): Update. (insert_step_resume_breakpoint_at_caller): Update.. * mi/mi-cmd-break.c: Include "arch-utils.h". (mi_cmd_break_insert): Update. * target.h (struct target_ops): Add GDBARCH parameter to to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint members. (target_insert_breakpoint, target_remove_breakpoint, target_insert_hw_breakpoint, target_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (memory_remove_breakpoint, memory_insert_breakpoint): Add GDBARCH parameter. * target.c (debug_to_insert_breakpoint, debug_to_remove_breakpoint, debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (update_current_target): Update function signature. * breakpoint.c (insert_bp_location, remove_breakpoint, deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint): Pass architecture to target_ routines. Update all implementations of the target breakpoint routines to take GDBARCH parameter and use it instead of GDBARCH as appropriate: * corelow.c (ignore): Update. * exec.c (ignore): Update. * mem-break.c (memory_insert_breakpoint): Update. (memory_remove_breakpoint): Update. * monitor.c (monitor_insert_breakpoint): Update. (monitor_remove_breakpoint): Update. * record.c (record_insert_breakpoint): Update. (record_beneath_to_insert_breakpoint): Update. (record_remove_breakpoint): Update. (record_beneath_to_remove_breakpoint): Update. * remote.c (remote_insert_breakpoint): Update. (remote_remove_breakpoint): Update. (remote_insert_hw_breakpoint): Update. (remote_remove_hw_breakpoint): Update. * remote-m32r-sdi.c (m32r_insert_breakpoint): Update. (m32r_remove_breakpoint): Update. * remote-mips.c (mips_insert_breakpoint): Update. (mips_remove_breakpoint): Update. * i386-nat.c (i386_insert_hw_breakpoint): Update. (i386_remove_hw_breakpoint): Update. * nto-procfs.c (procfs_insert_breakpoint): Update. (procfs_remove_breakpoint): Update. (procfs_insert_hw_breakpoint): Update. (procfs_remove_hw_breakpoint): Update. doc/ChangeLog: * gdbint.texi (Examples of Use of @code{ui_out} functions): Update example code extrated from breakpoint.c.
2009-07-02 19:12:28 +02:00
struct bp_target_info *bp_tgt)
{
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
CORE_ADDR addr = bp_tgt->placed_address;
struct remote_state *rs = get_remote_state ();
1999-08-09 23:36:23 +02:00
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z0) != PACKET_DISABLE)
1999-08-09 23:36:23 +02:00
{
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *p = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
1999-08-09 23:36:23 +02:00
*(p++) = 'z';
*(p++) = '0';
*(p++) = ',';
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
p += hexnumstr (p, addr);
xsnprintf (p, endbuf - p, ",%d", bp_tgt->placed_size);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
return (rs->buf[0] == 'E');
1999-08-09 23:36:23 +02:00
}
target, breakpoint: allow insert/remove breakpoint to be forwarded 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * target.h (target_ops) <to_insert_breakpoint> <to_remove_breakpoint>: Add target_ops parameter. (forward_target_insert_breakpoint): New. (forward_target_remove_breakpoint): New. (memory_remove_breakpoint, memory_insert_breakpoint): Add target_ops parameter. * target.c (target_insert_breakpoint): Split into this and ... (forward_target_insert_breakpoint): ... this. (target_remove_breakpoint): Split into this and ... (forward_target_remove_breakpoint): ... this. (debug_to_insert_breakpoint): Add target_ops parameter. Call forward_target_insert_breakpoint. (debug_to_remove_breakpoint): Add target_ops parameter. Call forward_target_remove_breakpoint. (update_current_target): Do not inherit or default to_insert_breakpoint and to_remove_breakpoint. * corelow.c (ignore): Add target_ops parameter. * exec.c (ignore): Add target_ops parameter. * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): Add target_ops parameter. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Add target_ops parameter. * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint): Add target_ops parameter. * record-full.c (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint) (tmp_to_remove_breakpoint, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint): Add target_ops parameter. Update users. (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_remove_breakpoint_ops) (tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New. (record_full_open): Initialize tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops, record_full_beneath_to_insert_breakpoint_ops, and record_full_beneath_to_remove_breakpoint_ops. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Add target_ops parameter. * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint): Add target_ops parameter. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Add target_ops parameter.
2013-12-17 10:49:03 +01:00
return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
}
Mostly trivial enum fixes This is a patch I extracted from Pedro's C++ branch. It contains the most trivial enum fixes, where an integer type/value was used instead of the appropriate enum type/value. It fixes many C++ errors, since in C++ you can't mix integers and enums implicitely. Regardless of the C++ conversion, I think this is a good cleanup to make use of the appropriate enum types. Regression-tested on native x86_64. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Use enum type or value instead of integer. (aarch64_linux_insert_watchpoint): Likewise. (aarch64_linux_remove_watchpoint): Likewise. * ada-lang.c (ada_op_print_tab): Likewise. * amd64-linux-tdep.c (amd64_canonicalize_syscall): Likewise. (amd64_linux_syscall_record_common): Likewise. * arch-utils.c (target_byte_order_user): Likewise. (default_byte_order): Likewise. * arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Likewise. (arm_linux_get_hwbp_type): Likewise. (arm_linux_hw_watchpoint_initialize): Likewise. (arm_linux_insert_watchpoint): Likewise. * arm-linux-tdep.c (arm_canonicalize_syscall): Likewise. (arm_linux_syscall_record): Likewise. * breakpoint.c (update_watchpoint): Likewise. (breakpoint_here_p): Likewise. (bpstat_print): Likewise. (enable_breakpoint_disp): Likewise. * c-lang.c (c_op_print_tab): Likewise. * cli/cli-decode.c (add_info_alias): Likewise. * d-lang.c (d_op_print_tab): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * f-exp.y (dot_ops): Likewise. (f77_keywords): Likewise. * f-lang.c (f_op_print_tab): Likewise. * go-lang.c (go_op_print_tab): Likewise. * guile/scm-breakpoint.c (gdbscm_make_breakpoint): Likewise. * guile/scm-cmd.c (gdbscm_make_command): Likewise. * guile/scm-param.c (gdbscm_make_parameter): Likewise. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Likewise. * guile/scm-string.c (struct scm_to_stringn_data): Likewise. (struct scm_from_stringn_data): Likewise. * i386-linux-tdep.c (i386_canonicalize_syscall): Likewise. * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise. (ia64_linux_remove_watchpoint): Likewise. (ia64_linux_can_use_hw_breakpoint): Likewise. * infrun.c (print_stop_event): Likewise. * jv-lang.c (java_op_print_tab): Likewise. * linux-nat.c (linux_proc_xfer_partial): Likewise. * linux-nat.h (struct lwp_info): Likewise. * linux-thread-db.c (enable_thread_event): Likewise. * m2-lang.c (m2_op_print_tab): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise. (mi_cmd_stack_list_variables): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * mi/mi-out.c (mi_table_begin): Likewise. (mi_table_header): Likewise. * mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Likewise. (mips_linux_insert_watchpoint): Likewise. (mips_linux_remove_watchpoint): Likewise. * nat/mips-linux-watch.c (mips_linux_watch_type_to_irw): Likewise. * nat/mips-linux-watch.h (struct mips_watchpoint): Likewise. (mips_linux_watch_type_to_irw): Likewise. * nto-procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_hw_watchpoint): Likewise. (procfs_can_use_hw_breakpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. * p-lang.c (pascal_op_print_tab): Likewise. * ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppu2spu_unwind_register): Likewise. * ppc-sysv-tdep.c (get_decimal_float_return_value): Likewise. * procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_watchpoint): Likewise. (procfs_remove_watchpoint): Likewise. * psymtab.c (recursively_search_psymtabs): Likewise. * remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Likewise. (m32r_insert_watchpoint): Likewise. * remote-mips.c (mips_can_use_watchpoint): Likewise. (mips_insert_watchpoint): Likewise. (mips_remove_watchpoint): Likewise. * remote.c (watchpoint_to_Z_packet): Likewise. (remote_insert_watchpoint): Likewise. (remote_remove_watchpoint): Likewise. (remote_check_watch_resources): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. (s390_remove_watchpoint): Likewise. (s390_can_use_hw_breakpoint): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * spu-linux-nat.c (spu_can_use_hw_breakpoint): Likewise. * target.h (struct target_ops): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue): Likewise. * ui-out.c (struct ui_out_hdr): Likewise. (append_header_to_list): Likewise. (get_next_header): Likewise. (verify_field): Likewise. (ui_out_begin): Likewise. (ui_out_field_int): Likewise. (ui_out_field_fmt_int): Likewise. (ui_out_field_skip): Likewise. (ui_out_field_string): Likewise. (ui_out_field_fmt): Likewise. * varobj.c (new_variable): Likewise. * x86-nat.c (x86_insert_watchpoint): Likewise. (x86_remove_watchpoint): Likewise. (x86_can_use_hw_breakpoint): Likewise. * xtensa-tdep.h (struct gdbarch_tdep): Likewise. * inflow.c (enum gdb_has_a_terminal_flag_enum): Add name to previously anonymous enumeration type.. * linux-record.h (enum gdb_syscall): Add gdb_sys_no_syscall value. * target-debug.h (target_debug_print_enum_target_hw_bp_type): New. (target_debug_print_enum_bptype): New. * target-delegates.c: Regenerate.
2015-07-31 19:19:53 +02:00
static enum Z_packet_type
watchpoint_to_Z_packet (int type)
{
switch (type)
{
case hw_write:
return Z_PACKET_WRITE_WP;
break;
case hw_read:
return Z_PACKET_READ_WP;
break;
case hw_access:
return Z_PACKET_ACCESS_WP;
break;
default:
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("hw_bp_to_z: bad watchpoint type %d"), type);
}
}
static int
Mostly trivial enum fixes This is a patch I extracted from Pedro's C++ branch. It contains the most trivial enum fixes, where an integer type/value was used instead of the appropriate enum type/value. It fixes many C++ errors, since in C++ you can't mix integers and enums implicitely. Regardless of the C++ conversion, I think this is a good cleanup to make use of the appropriate enum types. Regression-tested on native x86_64. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Use enum type or value instead of integer. (aarch64_linux_insert_watchpoint): Likewise. (aarch64_linux_remove_watchpoint): Likewise. * ada-lang.c (ada_op_print_tab): Likewise. * amd64-linux-tdep.c (amd64_canonicalize_syscall): Likewise. (amd64_linux_syscall_record_common): Likewise. * arch-utils.c (target_byte_order_user): Likewise. (default_byte_order): Likewise. * arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Likewise. (arm_linux_get_hwbp_type): Likewise. (arm_linux_hw_watchpoint_initialize): Likewise. (arm_linux_insert_watchpoint): Likewise. * arm-linux-tdep.c (arm_canonicalize_syscall): Likewise. (arm_linux_syscall_record): Likewise. * breakpoint.c (update_watchpoint): Likewise. (breakpoint_here_p): Likewise. (bpstat_print): Likewise. (enable_breakpoint_disp): Likewise. * c-lang.c (c_op_print_tab): Likewise. * cli/cli-decode.c (add_info_alias): Likewise. * d-lang.c (d_op_print_tab): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * f-exp.y (dot_ops): Likewise. (f77_keywords): Likewise. * f-lang.c (f_op_print_tab): Likewise. * go-lang.c (go_op_print_tab): Likewise. * guile/scm-breakpoint.c (gdbscm_make_breakpoint): Likewise. * guile/scm-cmd.c (gdbscm_make_command): Likewise. * guile/scm-param.c (gdbscm_make_parameter): Likewise. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Likewise. * guile/scm-string.c (struct scm_to_stringn_data): Likewise. (struct scm_from_stringn_data): Likewise. * i386-linux-tdep.c (i386_canonicalize_syscall): Likewise. * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise. (ia64_linux_remove_watchpoint): Likewise. (ia64_linux_can_use_hw_breakpoint): Likewise. * infrun.c (print_stop_event): Likewise. * jv-lang.c (java_op_print_tab): Likewise. * linux-nat.c (linux_proc_xfer_partial): Likewise. * linux-nat.h (struct lwp_info): Likewise. * linux-thread-db.c (enable_thread_event): Likewise. * m2-lang.c (m2_op_print_tab): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise. (mi_cmd_stack_list_variables): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * mi/mi-out.c (mi_table_begin): Likewise. (mi_table_header): Likewise. * mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Likewise. (mips_linux_insert_watchpoint): Likewise. (mips_linux_remove_watchpoint): Likewise. * nat/mips-linux-watch.c (mips_linux_watch_type_to_irw): Likewise. * nat/mips-linux-watch.h (struct mips_watchpoint): Likewise. (mips_linux_watch_type_to_irw): Likewise. * nto-procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_hw_watchpoint): Likewise. (procfs_can_use_hw_breakpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. * p-lang.c (pascal_op_print_tab): Likewise. * ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppu2spu_unwind_register): Likewise. * ppc-sysv-tdep.c (get_decimal_float_return_value): Likewise. * procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_watchpoint): Likewise. (procfs_remove_watchpoint): Likewise. * psymtab.c (recursively_search_psymtabs): Likewise. * remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Likewise. (m32r_insert_watchpoint): Likewise. * remote-mips.c (mips_can_use_watchpoint): Likewise. (mips_insert_watchpoint): Likewise. (mips_remove_watchpoint): Likewise. * remote.c (watchpoint_to_Z_packet): Likewise. (remote_insert_watchpoint): Likewise. (remote_remove_watchpoint): Likewise. (remote_check_watch_resources): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. (s390_remove_watchpoint): Likewise. (s390_can_use_hw_breakpoint): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * spu-linux-nat.c (spu_can_use_hw_breakpoint): Likewise. * target.h (struct target_ops): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue): Likewise. * ui-out.c (struct ui_out_hdr): Likewise. (append_header_to_list): Likewise. (get_next_header): Likewise. (verify_field): Likewise. (ui_out_begin): Likewise. (ui_out_field_int): Likewise. (ui_out_field_fmt_int): Likewise. (ui_out_field_skip): Likewise. (ui_out_field_string): Likewise. (ui_out_field_fmt): Likewise. * varobj.c (new_variable): Likewise. * x86-nat.c (x86_insert_watchpoint): Likewise. (x86_remove_watchpoint): Likewise. (x86_can_use_hw_breakpoint): Likewise. * xtensa-tdep.h (struct gdbarch_tdep): Likewise. * inflow.c (enum gdb_has_a_terminal_flag_enum): Add name to previously anonymous enumeration type.. * linux-record.h (enum gdb_syscall): Add gdb_sys_no_syscall value. * target-debug.h (target_debug_print_enum_target_hw_bp_type): New. (target_debug_print_enum_bptype): New. * target-delegates.c: Regenerate.
2015-07-31 19:19:53 +02:00
remote_insert_watchpoint (struct target_ops *self, CORE_ADDR addr, int len,
enum target_hw_bp_type type, struct expression *cond)
1999-08-09 23:36:23 +02:00
{
struct remote_state *rs = get_remote_state ();
char *endbuf = rs->buf + get_remote_packet_size ();
1999-10-26 05:43:48 +02:00
char *p;
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
1999-08-09 23:36:23 +02:00
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
return 1;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
xsnprintf (rs->buf, endbuf - rs->buf, "Z%x,", packet);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
p = strchr (rs->buf, '\0');
1999-08-09 23:36:23 +02:00
addr = remote_address_masked (addr);
p += hexnumstr (p, (ULONGEST) addr);
xsnprintf (p, endbuf - p, ",%x", len);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet]))
{
case PACKET_ERROR:
return -1;
case PACKET_UNKNOWN:
return 1;
case PACKET_OK:
return 0;
}
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("remote_insert_watchpoint: reached end of function"));
1999-08-09 23:36:23 +02:00
}
static int
remote_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr,
CORE_ADDR start, int length)
{
CORE_ADDR diff = remote_address_masked (addr - start);
return diff < length;
}
static int
Mostly trivial enum fixes This is a patch I extracted from Pedro's C++ branch. It contains the most trivial enum fixes, where an integer type/value was used instead of the appropriate enum type/value. It fixes many C++ errors, since in C++ you can't mix integers and enums implicitely. Regardless of the C++ conversion, I think this is a good cleanup to make use of the appropriate enum types. Regression-tested on native x86_64. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Use enum type or value instead of integer. (aarch64_linux_insert_watchpoint): Likewise. (aarch64_linux_remove_watchpoint): Likewise. * ada-lang.c (ada_op_print_tab): Likewise. * amd64-linux-tdep.c (amd64_canonicalize_syscall): Likewise. (amd64_linux_syscall_record_common): Likewise. * arch-utils.c (target_byte_order_user): Likewise. (default_byte_order): Likewise. * arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Likewise. (arm_linux_get_hwbp_type): Likewise. (arm_linux_hw_watchpoint_initialize): Likewise. (arm_linux_insert_watchpoint): Likewise. * arm-linux-tdep.c (arm_canonicalize_syscall): Likewise. (arm_linux_syscall_record): Likewise. * breakpoint.c (update_watchpoint): Likewise. (breakpoint_here_p): Likewise. (bpstat_print): Likewise. (enable_breakpoint_disp): Likewise. * c-lang.c (c_op_print_tab): Likewise. * cli/cli-decode.c (add_info_alias): Likewise. * d-lang.c (d_op_print_tab): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * f-exp.y (dot_ops): Likewise. (f77_keywords): Likewise. * f-lang.c (f_op_print_tab): Likewise. * go-lang.c (go_op_print_tab): Likewise. * guile/scm-breakpoint.c (gdbscm_make_breakpoint): Likewise. * guile/scm-cmd.c (gdbscm_make_command): Likewise. * guile/scm-param.c (gdbscm_make_parameter): Likewise. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Likewise. * guile/scm-string.c (struct scm_to_stringn_data): Likewise. (struct scm_from_stringn_data): Likewise. * i386-linux-tdep.c (i386_canonicalize_syscall): Likewise. * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise. (ia64_linux_remove_watchpoint): Likewise. (ia64_linux_can_use_hw_breakpoint): Likewise. * infrun.c (print_stop_event): Likewise. * jv-lang.c (java_op_print_tab): Likewise. * linux-nat.c (linux_proc_xfer_partial): Likewise. * linux-nat.h (struct lwp_info): Likewise. * linux-thread-db.c (enable_thread_event): Likewise. * m2-lang.c (m2_op_print_tab): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise. (mi_cmd_stack_list_variables): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * mi/mi-out.c (mi_table_begin): Likewise. (mi_table_header): Likewise. * mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Likewise. (mips_linux_insert_watchpoint): Likewise. (mips_linux_remove_watchpoint): Likewise. * nat/mips-linux-watch.c (mips_linux_watch_type_to_irw): Likewise. * nat/mips-linux-watch.h (struct mips_watchpoint): Likewise. (mips_linux_watch_type_to_irw): Likewise. * nto-procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_hw_watchpoint): Likewise. (procfs_can_use_hw_breakpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. * p-lang.c (pascal_op_print_tab): Likewise. * ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppu2spu_unwind_register): Likewise. * ppc-sysv-tdep.c (get_decimal_float_return_value): Likewise. * procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_watchpoint): Likewise. (procfs_remove_watchpoint): Likewise. * psymtab.c (recursively_search_psymtabs): Likewise. * remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Likewise. (m32r_insert_watchpoint): Likewise. * remote-mips.c (mips_can_use_watchpoint): Likewise. (mips_insert_watchpoint): Likewise. (mips_remove_watchpoint): Likewise. * remote.c (watchpoint_to_Z_packet): Likewise. (remote_insert_watchpoint): Likewise. (remote_remove_watchpoint): Likewise. (remote_check_watch_resources): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. (s390_remove_watchpoint): Likewise. (s390_can_use_hw_breakpoint): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * spu-linux-nat.c (spu_can_use_hw_breakpoint): Likewise. * target.h (struct target_ops): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue): Likewise. * ui-out.c (struct ui_out_hdr): Likewise. (append_header_to_list): Likewise. (get_next_header): Likewise. (verify_field): Likewise. (ui_out_begin): Likewise. (ui_out_field_int): Likewise. (ui_out_field_fmt_int): Likewise. (ui_out_field_skip): Likewise. (ui_out_field_string): Likewise. (ui_out_field_fmt): Likewise. * varobj.c (new_variable): Likewise. * x86-nat.c (x86_insert_watchpoint): Likewise. (x86_remove_watchpoint): Likewise. (x86_can_use_hw_breakpoint): Likewise. * xtensa-tdep.h (struct gdbarch_tdep): Likewise. * inflow.c (enum gdb_has_a_terminal_flag_enum): Add name to previously anonymous enumeration type.. * linux-record.h (enum gdb_syscall): Add gdb_sys_no_syscall value. * target-debug.h (target_debug_print_enum_target_hw_bp_type): New. (target_debug_print_enum_bptype): New. * target-delegates.c: Regenerate.
2015-07-31 19:19:53 +02:00
remote_remove_watchpoint (struct target_ops *self, CORE_ADDR addr, int len,
enum target_hw_bp_type type, struct expression *cond)
1999-08-09 23:36:23 +02:00
{
struct remote_state *rs = get_remote_state ();
char *endbuf = rs->buf + get_remote_packet_size ();
1999-10-26 05:43:48 +02:00
char *p;
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
return -1;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
xsnprintf (rs->buf, endbuf - rs->buf, "z%x,", packet);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
p = strchr (rs->buf, '\0');
1999-08-09 23:36:23 +02:00
addr = remote_address_masked (addr);
p += hexnumstr (p, (ULONGEST) addr);
xsnprintf (p, endbuf - p, ",%x", len);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet]))
{
case PACKET_ERROR:
case PACKET_UNKNOWN:
return -1;
case PACKET_OK:
return 0;
}
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("remote_remove_watchpoint: reached end of function"));
1999-08-09 23:36:23 +02:00
}
int remote_hw_watchpoint_limit = -1;
int remote_hw_watchpoint_length_limit = -1;
int remote_hw_breakpoint_limit = -1;
static int
remote_region_ok_for_hw_watchpoint (struct target_ops *self,
CORE_ADDR addr, int len)
{
if (remote_hw_watchpoint_length_limit == 0)
return 0;
else if (remote_hw_watchpoint_length_limit < 0)
return 1;
else if (len <= remote_hw_watchpoint_length_limit)
return 1;
else
return 0;
}
2003-06-08 Andrew Cagney <cagney@redhat.com> * acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen from GCC's acinclude.m4. * configure.in: Check for getopt's delcaration. * aclocal.m4, config.in, configure: Re-generate. * main.c (error_init): Delete declaration. * defs.h (error_init): Declare. * rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static. (rs6000_convert_from_func_ptr_addr): Make static. (_initialize_rs6000_tdep): Add declaration. * cli/cli-cmds.c (dont_repeat): Delete declaration. (show_commands, set_verbose, show_history): Delete declaration. * top.h (set_verbose): Add declaration. (show_history, set_history, show_commands): Add declaration. (do_restore_instream_cleanup): Add declaration. * objc-lang.c (specialcmp): Make static. (print_object_command): Make static. (find_objc_msgsend): Make static. (find_objc_msgcall_submethod_helper): Make static. (find_objc_msgcall_submethod): Make static. (_initialize_objc_language): Add declaration. (find_implementation_from_class): Make static. (find_implementation): Make static. * objc-exp.y (yylex): Delete lookup_struct_typedef declaration. * objc-lang.h (lookup_struct_typedef): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-script.c (clear_hook_in_cleanup): Make static. (do_restore_user_call_depth): Make static. (do_restore_instream_cleanup): Delete declaration. (dont_repeat): Delete declaration. * cli/cli-decode.c (add_abbrev_cmd): Delete function. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * hpacc-abi.c (_initialize_hpacc_abi): Add declaration. * gnu-v3-abi.c (gnuv3_baseclass_offset): Make static. (_initialize_gnu_v3_abi): Add declaration. * gnu-v2-abi.c (gnuv2_value_rtti_type): Make static. (_initialize_gnu_v2_abi): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * doublest.c (floatformat_from_length): Make static. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (create_sentinel_frame): Make static. (_initialize_frame): Add declaration. * top.c (do_catch_errors): Make static. (gdb_rl_operate_and_get_next_completion): Make static. * typeprint.c: Include "typeprint.h". * sentinel-frame.c (sentinel_frame_prev_register): Make static. (sentinel_frame_this_id): Make static. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * ui-out.c (make_cleanup_ui_out_begin_end): Delete function. * dwarf2-frame.c (dwarf2_frame_cache): Make static. * p-exp.y (push_current_type, pop_current_type): ISO C declaration. * dwarf2expr.h (dwarf_expr_context): ISO C declaration. * maint.c (maintenance_print_architecture): Make static. * signals/signals.c (_initialize_signals): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * jv-exp.y (push_variable): ISO C definition. (push_qualified_expression_name): Ditto. * memattr.c (_initialize_mem): Add declaration. * remote.c (remote_check_watch_resources): Make static. (remote_stopped_by_watchpoint): Make static. (remote_stopped_data_address): Make static. * d10v-tdep.c (nr_dmap_regs): Make static. (a0_regnum): Make static. (d10v_frame_unwind_cache): Make static. (d10v_frame_p): Make static. * osabi.c (show_osabi): Make static. (_initialize_gdb_osabi): Add extern declaration. * gdbtypes.c (make_qualified_type): Make static. (safe_parse_type): Make static. * macrocmd.c (_initialize_macrocmd): Add extern declaration. * macrotab.c (macro_bcache_free): Make static. * interps.c (interp_set_quiet): Make static. (interpreter_exec_cmd): Make static. * stack.h (select_frame_command): New file. * stack.c: Include "stack.h". (select_frame_command_wrapper): Delete function. (select_frame_command): Make global. * infcall.c: Include "infcall.h". * linespec.c: Include "linespec.h". * symfile.c (sections_overlap): Make static. * cp-support.h (cp_initialize_namespace): ISO C declaration. * charset.c (_initialize_charset): Add missing prototype. * regcache.c (init_legacy_regcache_descr): Make static. (do_regcache_xfree): Make static. (regcache_xfer_part): Make static. (_initialize_regcache): Add missing prototype. * breakpoint.c (parse_breakpoint_sals): Make static. (breakpoint_sals_to_pc): Make static. * interps.h (clear_interpreter_hooks): ISO C declaration. * Makefile.in (stack_h): Define. (stack.o, typeprint.o, mi-main.o): Update dependencies. (mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies. Index: mi/ChangeLog 2003-06-08 Andrew Cagney <cagney@redhat.com> * mi-parse.c (_initialize_mi_parse): Delete function. * mi-main.c: Include "mi-main.h". * mi-interp.c (_initialize_mi_interp): Add declaration. * mi-cmd-stack.c: Include "stack.h". (select_frame_command_wrapper): Delete extern declaration. (mi_cmd_stack_select_frame): Replace select_frame_command_wrapper with select_frame_command.
2003-06-08 20:27:14 +02:00
static int
remote_check_watch_resources (struct target_ops *self,
Mostly trivial enum fixes This is a patch I extracted from Pedro's C++ branch. It contains the most trivial enum fixes, where an integer type/value was used instead of the appropriate enum type/value. It fixes many C++ errors, since in C++ you can't mix integers and enums implicitely. Regardless of the C++ conversion, I think this is a good cleanup to make use of the appropriate enum types. Regression-tested on native x86_64. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Use enum type or value instead of integer. (aarch64_linux_insert_watchpoint): Likewise. (aarch64_linux_remove_watchpoint): Likewise. * ada-lang.c (ada_op_print_tab): Likewise. * amd64-linux-tdep.c (amd64_canonicalize_syscall): Likewise. (amd64_linux_syscall_record_common): Likewise. * arch-utils.c (target_byte_order_user): Likewise. (default_byte_order): Likewise. * arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Likewise. (arm_linux_get_hwbp_type): Likewise. (arm_linux_hw_watchpoint_initialize): Likewise. (arm_linux_insert_watchpoint): Likewise. * arm-linux-tdep.c (arm_canonicalize_syscall): Likewise. (arm_linux_syscall_record): Likewise. * breakpoint.c (update_watchpoint): Likewise. (breakpoint_here_p): Likewise. (bpstat_print): Likewise. (enable_breakpoint_disp): Likewise. * c-lang.c (c_op_print_tab): Likewise. * cli/cli-decode.c (add_info_alias): Likewise. * d-lang.c (d_op_print_tab): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * f-exp.y (dot_ops): Likewise. (f77_keywords): Likewise. * f-lang.c (f_op_print_tab): Likewise. * go-lang.c (go_op_print_tab): Likewise. * guile/scm-breakpoint.c (gdbscm_make_breakpoint): Likewise. * guile/scm-cmd.c (gdbscm_make_command): Likewise. * guile/scm-param.c (gdbscm_make_parameter): Likewise. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Likewise. * guile/scm-string.c (struct scm_to_stringn_data): Likewise. (struct scm_from_stringn_data): Likewise. * i386-linux-tdep.c (i386_canonicalize_syscall): Likewise. * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise. (ia64_linux_remove_watchpoint): Likewise. (ia64_linux_can_use_hw_breakpoint): Likewise. * infrun.c (print_stop_event): Likewise. * jv-lang.c (java_op_print_tab): Likewise. * linux-nat.c (linux_proc_xfer_partial): Likewise. * linux-nat.h (struct lwp_info): Likewise. * linux-thread-db.c (enable_thread_event): Likewise. * m2-lang.c (m2_op_print_tab): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise. (mi_cmd_stack_list_variables): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * mi/mi-out.c (mi_table_begin): Likewise. (mi_table_header): Likewise. * mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Likewise. (mips_linux_insert_watchpoint): Likewise. (mips_linux_remove_watchpoint): Likewise. * nat/mips-linux-watch.c (mips_linux_watch_type_to_irw): Likewise. * nat/mips-linux-watch.h (struct mips_watchpoint): Likewise. (mips_linux_watch_type_to_irw): Likewise. * nto-procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_hw_watchpoint): Likewise. (procfs_can_use_hw_breakpoint): Likewise. (procfs_remove_hw_watchpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. * p-lang.c (pascal_op_print_tab): Likewise. * ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppu2spu_unwind_register): Likewise. * ppc-sysv-tdep.c (get_decimal_float_return_value): Likewise. * procfs.c (procfs_can_use_hw_breakpoint): Likewise. (procfs_insert_watchpoint): Likewise. (procfs_remove_watchpoint): Likewise. * psymtab.c (recursively_search_psymtabs): Likewise. * remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Likewise. (m32r_insert_watchpoint): Likewise. * remote-mips.c (mips_can_use_watchpoint): Likewise. (mips_insert_watchpoint): Likewise. (mips_remove_watchpoint): Likewise. * remote.c (watchpoint_to_Z_packet): Likewise. (remote_insert_watchpoint): Likewise. (remote_remove_watchpoint): Likewise. (remote_check_watch_resources): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. (s390_remove_watchpoint): Likewise. (s390_can_use_hw_breakpoint): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * spu-linux-nat.c (spu_can_use_hw_breakpoint): Likewise. * target.h (struct target_ops): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue): Likewise. * ui-out.c (struct ui_out_hdr): Likewise. (append_header_to_list): Likewise. (get_next_header): Likewise. (verify_field): Likewise. (ui_out_begin): Likewise. (ui_out_field_int): Likewise. (ui_out_field_fmt_int): Likewise. (ui_out_field_skip): Likewise. (ui_out_field_string): Likewise. (ui_out_field_fmt): Likewise. * varobj.c (new_variable): Likewise. * x86-nat.c (x86_insert_watchpoint): Likewise. (x86_remove_watchpoint): Likewise. (x86_can_use_hw_breakpoint): Likewise. * xtensa-tdep.h (struct gdbarch_tdep): Likewise. * inflow.c (enum gdb_has_a_terminal_flag_enum): Add name to previously anonymous enumeration type.. * linux-record.h (enum gdb_syscall): Add gdb_sys_no_syscall value. * target-debug.h (target_debug_print_enum_target_hw_bp_type): New. (target_debug_print_enum_bptype): New. * target-delegates.c: Regenerate.
2015-07-31 19:19:53 +02:00
enum bptype type, int cnt, int ot)
1999-08-09 23:36:23 +02:00
{
if (type == bp_hardware_breakpoint)
{
if (remote_hw_breakpoint_limit == 0)
return 0;
else if (remote_hw_breakpoint_limit < 0)
return 1;
else if (cnt <= remote_hw_breakpoint_limit)
return 1;
}
else
{
if (remote_hw_watchpoint_limit == 0)
return 0;
else if (remote_hw_watchpoint_limit < 0)
return 1;
else if (ot)
return -1;
else if (cnt <= remote_hw_watchpoint_limit)
return 1;
}
return -1;
}
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
/* The to_stopped_by_sw_breakpoint method of target remote. */
static int
remote_stopped_by_sw_breakpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
return rs->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT;
}
/* The to_supports_stopped_by_sw_breakpoint method of target
remote. */
static int
remote_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
return (packet_support (PACKET_swbreak_feature) == PACKET_ENABLE);
}
/* The to_stopped_by_hw_breakpoint method of target remote. */
static int
remote_stopped_by_hw_breakpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
return rs->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT;
}
/* The to_supports_stopped_by_hw_breakpoint method of target
remote. */
static int
remote_supports_stopped_by_hw_breakpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
return (packet_support (PACKET_hwbreak_feature) == PACKET_ENABLE);
}
2003-06-08 Andrew Cagney <cagney@redhat.com> * acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen from GCC's acinclude.m4. * configure.in: Check for getopt's delcaration. * aclocal.m4, config.in, configure: Re-generate. * main.c (error_init): Delete declaration. * defs.h (error_init): Declare. * rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static. (rs6000_convert_from_func_ptr_addr): Make static. (_initialize_rs6000_tdep): Add declaration. * cli/cli-cmds.c (dont_repeat): Delete declaration. (show_commands, set_verbose, show_history): Delete declaration. * top.h (set_verbose): Add declaration. (show_history, set_history, show_commands): Add declaration. (do_restore_instream_cleanup): Add declaration. * objc-lang.c (specialcmp): Make static. (print_object_command): Make static. (find_objc_msgsend): Make static. (find_objc_msgcall_submethod_helper): Make static. (find_objc_msgcall_submethod): Make static. (_initialize_objc_language): Add declaration. (find_implementation_from_class): Make static. (find_implementation): Make static. * objc-exp.y (yylex): Delete lookup_struct_typedef declaration. * objc-lang.h (lookup_struct_typedef): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-script.c (clear_hook_in_cleanup): Make static. (do_restore_user_call_depth): Make static. (do_restore_instream_cleanup): Delete declaration. (dont_repeat): Delete declaration. * cli/cli-decode.c (add_abbrev_cmd): Delete function. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * hpacc-abi.c (_initialize_hpacc_abi): Add declaration. * gnu-v3-abi.c (gnuv3_baseclass_offset): Make static. (_initialize_gnu_v3_abi): Add declaration. * gnu-v2-abi.c (gnuv2_value_rtti_type): Make static. (_initialize_gnu_v2_abi): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * doublest.c (floatformat_from_length): Make static. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (create_sentinel_frame): Make static. (_initialize_frame): Add declaration. * top.c (do_catch_errors): Make static. (gdb_rl_operate_and_get_next_completion): Make static. * typeprint.c: Include "typeprint.h". * sentinel-frame.c (sentinel_frame_prev_register): Make static. (sentinel_frame_this_id): Make static. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * ui-out.c (make_cleanup_ui_out_begin_end): Delete function. * dwarf2-frame.c (dwarf2_frame_cache): Make static. * p-exp.y (push_current_type, pop_current_type): ISO C declaration. * dwarf2expr.h (dwarf_expr_context): ISO C declaration. * maint.c (maintenance_print_architecture): Make static. * signals/signals.c (_initialize_signals): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * jv-exp.y (push_variable): ISO C definition. (push_qualified_expression_name): Ditto. * memattr.c (_initialize_mem): Add declaration. * remote.c (remote_check_watch_resources): Make static. (remote_stopped_by_watchpoint): Make static. (remote_stopped_data_address): Make static. * d10v-tdep.c (nr_dmap_regs): Make static. (a0_regnum): Make static. (d10v_frame_unwind_cache): Make static. (d10v_frame_p): Make static. * osabi.c (show_osabi): Make static. (_initialize_gdb_osabi): Add extern declaration. * gdbtypes.c (make_qualified_type): Make static. (safe_parse_type): Make static. * macrocmd.c (_initialize_macrocmd): Add extern declaration. * macrotab.c (macro_bcache_free): Make static. * interps.c (interp_set_quiet): Make static. (interpreter_exec_cmd): Make static. * stack.h (select_frame_command): New file. * stack.c: Include "stack.h". (select_frame_command_wrapper): Delete function. (select_frame_command): Make global. * infcall.c: Include "infcall.h". * linespec.c: Include "linespec.h". * symfile.c (sections_overlap): Make static. * cp-support.h (cp_initialize_namespace): ISO C declaration. * charset.c (_initialize_charset): Add missing prototype. * regcache.c (init_legacy_regcache_descr): Make static. (do_regcache_xfree): Make static. (regcache_xfer_part): Make static. (_initialize_regcache): Add missing prototype. * breakpoint.c (parse_breakpoint_sals): Make static. (breakpoint_sals_to_pc): Make static. * interps.h (clear_interpreter_hooks): ISO C declaration. * Makefile.in (stack_h): Define. (stack.o, typeprint.o, mi-main.o): Update dependencies. (mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies. Index: mi/ChangeLog 2003-06-08 Andrew Cagney <cagney@redhat.com> * mi-parse.c (_initialize_mi_parse): Delete function. * mi-main.c: Include "mi-main.h". * mi-interp.c (_initialize_mi_interp): Add declaration. * mi-cmd-stack.c: Include "stack.h". (select_frame_command_wrapper): Delete extern declaration. (mi_cmd_stack_select_frame): Replace select_frame_command_wrapper with select_frame_command.
2003-06-08 20:27:14 +02:00
static int
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
remote_stopped_by_watchpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
return rs->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
static int
remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
{
struct remote_state *rs = get_remote_state ();
int rc = 0;
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
if (remote_stopped_by_watchpoint (target))
{
*addr_p = rs->remote_watch_data_address;
rc = 1;
}
return rc;
}
static int
remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
* breakpoint.h (struct breakpoint): New member GDBARCH. * breakpoint.c: Include "arch-utils.h". (set_raw_breakpoint_without_location): Add GDBARCH parameter. Use it to set breakpoint architecture. (set_raw_breakpoint): Add GDBARCH parameter. (create_internal_breakpoint): Likewise. (create_catchpoint): Likewise. (create_fork_vfork_event_catchpoint): Likewise. (create_breakpoint): Likewise. (create_breakpoints): Likewise. (break_command_really): Likewise. (create_ada_exception_breakpoint): Likewise. Update local callers to pass architecture: (create_internal_breakpoint): Update. (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_thread_event_breakpoint): Update. (create_solib_event_breakpoint): Update. (create_catchpoint): Update. (create_fork_vfork_event_catchpoint): Update. (set_momentary_breakpoint): Update. (clone_momentary_breakpoint): Update. (create_breakpoint): Update. (create_breakpoints): Update. (break_command_really): Update. (break_command_1): Update. (set_breakpoint): Update. (watch_command_1): Update. (catch_fork_command_1): Update. (catch_exec_commnd_1): Update. (handle_gnu_v3_exceptions): Update. (create_ada_exception_breakpoint): Update. (catch_ada_exception_command): Update. (catch_assert_command): Update. (trace_command): Update. * breakpoint.h (struct bp_location): New member GDBARCH. * breakpoint.c (get_sal_arch): New function. (set_raw_breakpoint): Set location architecture. (add_location_to_breakpoint): Likewise. (clone_momentary_breakpoint): Likewise. (watch_command_1): Likewise. (update_watchpoint): Likewise. (bp_loc_is_permanent): Use location architecture instead of current_gdbarch. (adjust_breakpoint_address): Add GDBARCH parameter; use it instead of current_gdbarch. Update callers of adjust_breakpoint_address to pass breakpoint location architecture: (set_raw_breakpoint): Update. (watch_command_1): Update. * tracepoint.c: (collect_symbol): Add GDBARCH parameter, use instead of current_gdbarch. (add_local_symbols): Add GDBARCH parameter. Pass to collect_symbol. (encode_actions): Pass tracepoint architecture to add_local_symbols (encode_actions): Use tracepoint architecture instead of current_gdbarch. Pass it to add_local_symbols and collect_symbol. * breakpoint.h (struct breakpoint_ops): Replace last_addr parameter of print_one callback with last_loc. * breakpoint.c (print_one_breakpoint_location): Replace last_addr parameter with last_loc. (print_one_breakpoint): Likewise. (do_captured_breakpoint_query): Update call. (breakpoint_1): Pass last_loc instead of last_addr to print_one_breakpoint. Pass last location architecture instead of current_gdbarch to set_next_address. Update all implementations of the print_one callback: * breakpoint.c (print_one_catch_fork): Update. (print_one_catch_vfork): Update. (print_one_catch_exec): Update. (print_one_exception_catchpoint): Update. * ada-lang.c (print_one_exception): Update. (print_one_catch_exception): Update. (print_one_catch_exception_unhandled): Update. (print_one_catch_assert): Update. * breakpoint.c (print_one_breakpoint_location): Add PRINT_ADDRESS_BITS parameter. Use it instead of gdbarch_addr_bit (current_gdbarch). (print_one_breakpoint): Add PRINT_ADDRESS_BITS parameter and pass it to print_one_breakpoint_location. (breakpoint_address_bits): New function. (do_captured_breakpoint_query): Compute number of address bits to print and pass it to print_one_breakpoint. (breakpoint_1): Likewise. Use it instead of current_gdbarch. * breakpoint.h (create_thread_event_breakpoint): Add GDBARCH. * breakpoint.c (create_thread_event_breakpoint): Likewise. Update callers to create_thread_event_breakpoint: * aix-thread.c (pd_enable): Update. * linux-thread-db.c (enable_thread_event): Update. * breakpoint.h (create_solib_event_breakpoint): Add GDBARCH. * breakpoint.c (create_solib_event_breakpoint): Likewise. Update callers to create_solib_event_breakpoint: * solib-frv.c (enable_break, enable_break2): Update. * solib-pa64.c (pa64_solib_create_inferior_hook): Update. * solib-som.c (som_solib_create_inferior_hook): Update. * solib-darwin.c (darwin_solib_create_inferior_hook): Update. * solib-svr4.c (enable_break): Update. * breakpoint.h (insert_single_step_breakpoint): Add GDBARCH. * breakpoint.c (insert_single_step_breakpoint): Likewise. Update callers to insert_single_step_breakpoint: * alpha-tdep.c (alpha_software_single_step): Update. * arm-linux-tdep.c (arm_linux_software_single_step): Update. * arm-tdep.c (arm_software_single_step): Update. * cris-tdep.c (cris_software_single_step): Update. * rs6000-aix-tdep.c (rs6000_software_single_step): Update. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Update. * sparc-tdep.c (sparc_software_single_step): Update. * spu-tdep.c (spu_software_single_step): Update. * mips-tdep.c (deal_with_atomic_sequence): Add GDBARCH parameter. Pass it to insert_single_step_breakpoint. (mips_software_single_step): Pass architecture to deal_with_atomic_sequence and insert_single_step_breakpoint. * breakpoint.h (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. * breakpoint.c (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. Update callers to deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint: * breakpoint.c (single_step_gdbarch): New static variable. (insert_single_step_breakpoint): Pass GDBARCH parameter to deprecated_insert_raw_breakpoint. Store it in single_step_gdbarch. (remove_single_step_breakpoints): Pass architecture stored in single_step_gdbarch to deprecated_remove_raw_breakpoint. * rs6000-nat.c (exec_one_dummy_insn): Update. * solib-irix.c (enable_break, disable_break): Update. * procfs.c (procfs_mourn_inferior): Update. (remove_dbx_link_breakpoint): Update. * breakpoint.h (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. * breakpoint.c (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. Update callers to set_breakpoint, set_momentary_breakpoint and set_momentary_breakpoint_at_pc: * breakpoint.c (set_momentary_breakpoint_at_pc): Update. (until_break_command): Update. * infcall.c (call_function_by_hand): Update. * infcmd.c (finish_backward, finish_forward): Update. * infrun.c (insert_step_resume_breakpoint_at_sal): Add GDBARCH parameter. Pass it to set_momentary_breakpoint. (insert_longjmp_resume_breakpoint): Add GDBARCH parameter. Pass it to set_momentary_breakpoint_at_pc. (handle_inferior_event): Update. (insert_step_resume_breakpoint_at_frame): Update. (insert_step_resume_breakpoint_at_caller): Update.. * mi/mi-cmd-break.c: Include "arch-utils.h". (mi_cmd_break_insert): Update. * target.h (struct target_ops): Add GDBARCH parameter to to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint members. (target_insert_breakpoint, target_remove_breakpoint, target_insert_hw_breakpoint, target_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (memory_remove_breakpoint, memory_insert_breakpoint): Add GDBARCH parameter. * target.c (debug_to_insert_breakpoint, debug_to_remove_breakpoint, debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (update_current_target): Update function signature. * breakpoint.c (insert_bp_location, remove_breakpoint, deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint): Pass architecture to target_ routines. Update all implementations of the target breakpoint routines to take GDBARCH parameter and use it instead of GDBARCH as appropriate: * corelow.c (ignore): Update. * exec.c (ignore): Update. * mem-break.c (memory_insert_breakpoint): Update. (memory_remove_breakpoint): Update. * monitor.c (monitor_insert_breakpoint): Update. (monitor_remove_breakpoint): Update. * record.c (record_insert_breakpoint): Update. (record_beneath_to_insert_breakpoint): Update. (record_remove_breakpoint): Update. (record_beneath_to_remove_breakpoint): Update. * remote.c (remote_insert_breakpoint): Update. (remote_remove_breakpoint): Update. (remote_insert_hw_breakpoint): Update. (remote_remove_hw_breakpoint): Update. * remote-m32r-sdi.c (m32r_insert_breakpoint): Update. (m32r_remove_breakpoint): Update. * remote-mips.c (mips_insert_breakpoint): Update. (mips_remove_breakpoint): Update. * i386-nat.c (i386_insert_hw_breakpoint): Update. (i386_remove_hw_breakpoint): Update. * nto-procfs.c (procfs_insert_breakpoint): Update. (procfs_remove_breakpoint): Update. (procfs_insert_hw_breakpoint): Update. (procfs_remove_hw_breakpoint): Update. doc/ChangeLog: * gdbint.texi (Examples of Use of @code{ui_out} functions): Update example code extrated from breakpoint.c.
2009-07-02 19:12:28 +02:00
struct bp_target_info *bp_tgt)
{
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
CORE_ADDR addr = bp_tgt->reqstd_address;
struct remote_state *rs;
char *p, *endbuf;
char *message;
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
int bpsize;
/* The length field should be set to the size of a breakpoint
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
instruction, even though we aren't inserting one ourselves. */
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z1) == PACKET_DISABLE)
return -1;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
rs = get_remote_state ();
p = rs->buf;
endbuf = rs->buf + get_remote_packet_size ();
1999-08-09 23:36:23 +02:00
*(p++) = 'Z';
*(p++) = '1';
*(p++) = ',';
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
addr = remote_address_masked (addr);
1999-08-09 23:36:23 +02:00
p += hexnumstr (p, (ULONGEST) addr);
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
xsnprintf (p, endbuf - p, ",%x", bpsize);
1999-08-09 23:36:23 +02:00
if (remote_supports_cond_breakpoints (self))
remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
if (remote_can_run_breakpoint_commands (self))
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
remote_add_target_side_commands (gdbarch, bp_tgt, p);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1]))
{
case PACKET_ERROR:
if (rs->buf[1] == '.')
{
message = strchr (rs->buf + 2, '.');
if (message)
error (_("Remote failure reply: %s"), message + 1);
}
return -1;
case PACKET_UNKNOWN:
return -1;
case PACKET_OK:
Avoid software breakpoint's instruction shadow inconsistency This change: commit b775012e845380ed4c7421a1b87caf7bfae39f5f Author: Luis Machado <luisgpm@br.ibm.com> Date: Fri Feb 24 15:10:59 2012 +0000 2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. [...] changed the way breakpoints are inserted and removed such that `insert_bp_location' can now be called with the breakpoint being handled already in place, while previously the call was only ever made for breakpoints that have not been put in place. This in turn caused an issue for software breakpoints and targets for which a breakpoint's `placed_address' may not be the same as the original requested address. The issue is `insert_bp_location' overwrites the previously adjusted value in `placed_address' with the original address, that is only replaced back with the correct adjusted address later on when `gdbarch_breakpoint_from_pc' is called. Meanwhile there's a window where the value in `placed_address' does not correspond to data stored in `shadow_contents', leading to incorrect instruction bytes being supplied when `one_breakpoint_xfer_memory' is called to supply the instruction overlaid by the breakpoint. And this is exactly what happens on the MIPS target with software breakpoints placed in microMIPS code. In this case not only `placed_address' is not the original address because of the ISA bit, but `mips_breakpoint_from_pc' has to read the original instruction to determine which one of the two software breakpoint instruction encodings to choose as well. The 16-bit encoding is used to replace 16-bit instructions and similarly the 32-bit one is used with 32-bit instructions, to satisfy branch delay slot size requirements. The mismatch between `placed_address' and the address data in `shadow_contents' has been obtained from leads to the wrong encoding being used in some cases, which in the case of a 32-bit software breakpoint instruction replacing a 16-bit instruction causes corruption to the adjacent following instruction and leads the debug session astray if execution reaches there e.g. with a jump. To address this problem I made the change below, that adds a `reqstd_address' field to `struct bp_target_info' and leaves `placed_address' unchanged once it has been set. This ensures data in `shadow_contents' is always consistent with `placed_address'. This approach also has this good side effect that all the places that examine the breakpoint's address see a consistent value, either `reqstd_address' or `placed_address', as required. Currently some places see either the original or the adjusted address in `placed_address', depending on whether they have been called before `gdbarch_remote_breakpoint_from_pc' or afterwards. This is in particular true for subsequent calls to `gdbarch_remote_breakpoint_from_pc' itself, e.g. from `one_breakpoint_xfer_memory'. This is also important for places like `find_single_step_breakpoint' where a breakpoint's address is compared to the raw value of $pc. * breakpoint.h (bp_target_info): Add `reqstd_address' member, update comments. * breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address' for the breakpoint's address. Don't preinitialize `placed_size'. (insert_bp_location): Set `reqstd_address' rather than `placed_address'. (bp_target_info_copy_insertion_state): Also copy `placed_address'. (bkpt_insert_location): Use `reqstd_address' for the breakpoint's address. (bkpt_remove_location): Likewise. (deprecated_insert_raw_breakpoint): Likewise. (deprecated_remove_raw_breakpoint): Likewise. (find_single_step_breakpoint): Likewise. * mem-break.c (default_memory_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. Don't set `placed_address' or `placed_size' if breakpoint contents couldn't have been determined. * remote.c (remote_insert_breakpoint): Use `reqstd_address' for the breakpoint's address. (remote_insert_hw_breakpoint): Likewise. Don't set `placed_address' or `placed_size' if breakpoint couldn't have been set. * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use `reqstd_address' for the breakpoint's address. * arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise. * ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise. * microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint): Likewise. * nto-procfs.c (procfs_insert_breakpoint): Likewise. (procfs_insert_hw_breakpoint): Likewise. * ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint): Likewise. * x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 13:44:58 +02:00
bp_tgt->placed_address = addr;
bp_tgt->placed_size = bpsize;
return 0;
}
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("remote_insert_hw_breakpoint: reached end of function"));
1999-08-09 23:36:23 +02:00
}
static int
remote_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
* breakpoint.h (struct breakpoint): New member GDBARCH. * breakpoint.c: Include "arch-utils.h". (set_raw_breakpoint_without_location): Add GDBARCH parameter. Use it to set breakpoint architecture. (set_raw_breakpoint): Add GDBARCH parameter. (create_internal_breakpoint): Likewise. (create_catchpoint): Likewise. (create_fork_vfork_event_catchpoint): Likewise. (create_breakpoint): Likewise. (create_breakpoints): Likewise. (break_command_really): Likewise. (create_ada_exception_breakpoint): Likewise. Update local callers to pass architecture: (create_internal_breakpoint): Update. (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_thread_event_breakpoint): Update. (create_solib_event_breakpoint): Update. (create_catchpoint): Update. (create_fork_vfork_event_catchpoint): Update. (set_momentary_breakpoint): Update. (clone_momentary_breakpoint): Update. (create_breakpoint): Update. (create_breakpoints): Update. (break_command_really): Update. (break_command_1): Update. (set_breakpoint): Update. (watch_command_1): Update. (catch_fork_command_1): Update. (catch_exec_commnd_1): Update. (handle_gnu_v3_exceptions): Update. (create_ada_exception_breakpoint): Update. (catch_ada_exception_command): Update. (catch_assert_command): Update. (trace_command): Update. * breakpoint.h (struct bp_location): New member GDBARCH. * breakpoint.c (get_sal_arch): New function. (set_raw_breakpoint): Set location architecture. (add_location_to_breakpoint): Likewise. (clone_momentary_breakpoint): Likewise. (watch_command_1): Likewise. (update_watchpoint): Likewise. (bp_loc_is_permanent): Use location architecture instead of current_gdbarch. (adjust_breakpoint_address): Add GDBARCH parameter; use it instead of current_gdbarch. Update callers of adjust_breakpoint_address to pass breakpoint location architecture: (set_raw_breakpoint): Update. (watch_command_1): Update. * tracepoint.c: (collect_symbol): Add GDBARCH parameter, use instead of current_gdbarch. (add_local_symbols): Add GDBARCH parameter. Pass to collect_symbol. (encode_actions): Pass tracepoint architecture to add_local_symbols (encode_actions): Use tracepoint architecture instead of current_gdbarch. Pass it to add_local_symbols and collect_symbol. * breakpoint.h (struct breakpoint_ops): Replace last_addr parameter of print_one callback with last_loc. * breakpoint.c (print_one_breakpoint_location): Replace last_addr parameter with last_loc. (print_one_breakpoint): Likewise. (do_captured_breakpoint_query): Update call. (breakpoint_1): Pass last_loc instead of last_addr to print_one_breakpoint. Pass last location architecture instead of current_gdbarch to set_next_address. Update all implementations of the print_one callback: * breakpoint.c (print_one_catch_fork): Update. (print_one_catch_vfork): Update. (print_one_catch_exec): Update. (print_one_exception_catchpoint): Update. * ada-lang.c (print_one_exception): Update. (print_one_catch_exception): Update. (print_one_catch_exception_unhandled): Update. (print_one_catch_assert): Update. * breakpoint.c (print_one_breakpoint_location): Add PRINT_ADDRESS_BITS parameter. Use it instead of gdbarch_addr_bit (current_gdbarch). (print_one_breakpoint): Add PRINT_ADDRESS_BITS parameter and pass it to print_one_breakpoint_location. (breakpoint_address_bits): New function. (do_captured_breakpoint_query): Compute number of address bits to print and pass it to print_one_breakpoint. (breakpoint_1): Likewise. Use it instead of current_gdbarch. * breakpoint.h (create_thread_event_breakpoint): Add GDBARCH. * breakpoint.c (create_thread_event_breakpoint): Likewise. Update callers to create_thread_event_breakpoint: * aix-thread.c (pd_enable): Update. * linux-thread-db.c (enable_thread_event): Update. * breakpoint.h (create_solib_event_breakpoint): Add GDBARCH. * breakpoint.c (create_solib_event_breakpoint): Likewise. Update callers to create_solib_event_breakpoint: * solib-frv.c (enable_break, enable_break2): Update. * solib-pa64.c (pa64_solib_create_inferior_hook): Update. * solib-som.c (som_solib_create_inferior_hook): Update. * solib-darwin.c (darwin_solib_create_inferior_hook): Update. * solib-svr4.c (enable_break): Update. * breakpoint.h (insert_single_step_breakpoint): Add GDBARCH. * breakpoint.c (insert_single_step_breakpoint): Likewise. Update callers to insert_single_step_breakpoint: * alpha-tdep.c (alpha_software_single_step): Update. * arm-linux-tdep.c (arm_linux_software_single_step): Update. * arm-tdep.c (arm_software_single_step): Update. * cris-tdep.c (cris_software_single_step): Update. * rs6000-aix-tdep.c (rs6000_software_single_step): Update. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Update. * sparc-tdep.c (sparc_software_single_step): Update. * spu-tdep.c (spu_software_single_step): Update. * mips-tdep.c (deal_with_atomic_sequence): Add GDBARCH parameter. Pass it to insert_single_step_breakpoint. (mips_software_single_step): Pass architecture to deal_with_atomic_sequence and insert_single_step_breakpoint. * breakpoint.h (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. * breakpoint.c (deprecated_insert_raw_breakpoint): Add GDBARCH. (deprecated_remove_raw_breakpoint): Likewise. Update callers to deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint: * breakpoint.c (single_step_gdbarch): New static variable. (insert_single_step_breakpoint): Pass GDBARCH parameter to deprecated_insert_raw_breakpoint. Store it in single_step_gdbarch. (remove_single_step_breakpoints): Pass architecture stored in single_step_gdbarch to deprecated_remove_raw_breakpoint. * rs6000-nat.c (exec_one_dummy_insn): Update. * solib-irix.c (enable_break, disable_break): Update. * procfs.c (procfs_mourn_inferior): Update. (remove_dbx_link_breakpoint): Update. * breakpoint.h (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. * breakpoint.c (set_breakpoint): Add GDBARCH parameter. (set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise. Update callers to set_breakpoint, set_momentary_breakpoint and set_momentary_breakpoint_at_pc: * breakpoint.c (set_momentary_breakpoint_at_pc): Update. (until_break_command): Update. * infcall.c (call_function_by_hand): Update. * infcmd.c (finish_backward, finish_forward): Update. * infrun.c (insert_step_resume_breakpoint_at_sal): Add GDBARCH parameter. Pass it to set_momentary_breakpoint. (insert_longjmp_resume_breakpoint): Add GDBARCH parameter. Pass it to set_momentary_breakpoint_at_pc. (handle_inferior_event): Update. (insert_step_resume_breakpoint_at_frame): Update. (insert_step_resume_breakpoint_at_caller): Update.. * mi/mi-cmd-break.c: Include "arch-utils.h". (mi_cmd_break_insert): Update. * target.h (struct target_ops): Add GDBARCH parameter to to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint members. (target_insert_breakpoint, target_remove_breakpoint, target_insert_hw_breakpoint, target_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (memory_remove_breakpoint, memory_insert_breakpoint): Add GDBARCH parameter. * target.c (debug_to_insert_breakpoint, debug_to_remove_breakpoint, debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Add GDBARCH parameter, pass to target routine. (update_current_target): Update function signature. * breakpoint.c (insert_bp_location, remove_breakpoint, deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint): Pass architecture to target_ routines. Update all implementations of the target breakpoint routines to take GDBARCH parameter and use it instead of GDBARCH as appropriate: * corelow.c (ignore): Update. * exec.c (ignore): Update. * mem-break.c (memory_insert_breakpoint): Update. (memory_remove_breakpoint): Update. * monitor.c (monitor_insert_breakpoint): Update. (monitor_remove_breakpoint): Update. * record.c (record_insert_breakpoint): Update. (record_beneath_to_insert_breakpoint): Update. (record_remove_breakpoint): Update. (record_beneath_to_remove_breakpoint): Update. * remote.c (remote_insert_breakpoint): Update. (remote_remove_breakpoint): Update. (remote_insert_hw_breakpoint): Update. (remote_remove_hw_breakpoint): Update. * remote-m32r-sdi.c (m32r_insert_breakpoint): Update. (m32r_remove_breakpoint): Update. * remote-mips.c (mips_insert_breakpoint): Update. (mips_remove_breakpoint): Update. * i386-nat.c (i386_insert_hw_breakpoint): Update. (i386_remove_hw_breakpoint): Update. * nto-procfs.c (procfs_insert_breakpoint): Update. (procfs_remove_breakpoint): Update. (procfs_insert_hw_breakpoint): Update. (procfs_remove_hw_breakpoint): Update. doc/ChangeLog: * gdbint.texi (Examples of Use of @code{ui_out} functions): Update example code extrated from breakpoint.c.
2009-07-02 19:12:28 +02:00
struct bp_target_info *bp_tgt)
1999-08-09 23:36:23 +02:00
{
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
CORE_ADDR addr;
struct remote_state *rs = get_remote_state ();
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *p = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Z1) == PACKET_DISABLE)
return -1;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process, if
necessary. */
if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
set_general_process ();
1999-08-09 23:36:23 +02:00
*(p++) = 'z';
*(p++) = '1';
*(p++) = ',';
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
addr = remote_address_masked (bp_tgt->placed_address);
1999-08-09 23:36:23 +02:00
p += hexnumstr (p, (ULONGEST) addr);
xsnprintf (p, endbuf - p, ",%x", bp_tgt->placed_size);
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1]))
{
case PACKET_ERROR:
case PACKET_UNKNOWN:
return -1;
case PACKET_OK:
return 0;
}
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("remote_remove_hw_breakpoint: reached end of function"));
1999-08-09 23:36:23 +02:00
}
/* Verify memory using the "qCRC:" request. */
static int
remote_verify_memory (struct target_ops *ops,
const gdb_byte *data, CORE_ADDR lma, ULONGEST size)
{
struct remote_state *rs = get_remote_state ();
unsigned long host_crc, target_crc;
char *tmp;
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
/* It doesn't make sense to use qCRC if the remote target is
connected but not running. */
if (target_has_execution && packet_support (PACKET_qCRC) != PACKET_DISABLE)
{
enum packet_result result;
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
/* Make sure the remote is pointing at the right process. */
set_general_process ();
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
/* FIXME: assumes lma can fit into long. */
xsnprintf (rs->buf, get_remote_packet_size (), "qCRC:%lx,%lx",
(long) lma, (long) size);
putpkt (rs->buf);
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
/* Be clever; compute the host_crc before waiting for target
reply. */
host_crc = xcrc32 (data, size, 0xffffffff);
getpkt (&rs->buf, &rs->buf_size, 0);
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
result = packet_ok (rs->buf,
&remote_protocol_packets[PACKET_qCRC]);
if (result == PACKET_ERROR)
return -1;
else if (result == PACKET_OK)
{
for (target_crc = 0, tmp = &rs->buf[1]; *tmp; tmp++)
target_crc = target_crc * 16 + fromhex (*tmp);
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
return (host_crc == target_crc);
}
}
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
return simple_verify_memory (ops, data, lma, size);
}
/* compare-sections command
With no arguments, compares each loadable section in the exec bfd
with the same memory range on the target, and reports mismatches.
Useful for verifying the image on the target against the exec file. */
1999-10-26 05:43:48 +02:00
static void
2000-07-30 03:48:28 +02:00
compare_sections_command (char *args, int from_tty)
{
asection *s;
struct cleanup *old_chain;
-Wpointer-sign: char -> gdb_byte. -Wpointer-sign catches all these cases across the codebase that should be using gdb_byte for raw target bytes. I think these are all obvious, hence I've collapsed into a single patch. gdb/ 2013-04-19 Pedro Alves <palves@redhat.com> * aarch64-tdep.c (aarch64_default_breakpoint): Change type to gdb_byte[]. (aarch64_breakpoint_from_pc): Change return type to gdb_byte *. * ada-lang.c (ada_value_assign): Use gdb_byte. * alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[]. (alphanbsd_sigtramp_offset): Use gdb_byte. * arm-linux-tdep.c (arm_linux_arm_le_breakpoint) (arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint) (eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint) (arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint) (arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[]. * arm-tdep.c (arm_stub_unwind_sniffer) (arm_displaced_init_closure): Use gdb_byte. (arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint) (arm_default_thumb_le_breakpoint) (arm_default_thumb_be_breakpoint): Change type to gdb_byte[]. * arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint, thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *. * arm-wince-tdep.c (arm_wince_le_breakpoint) (arm_wince_thumb_le_breakpoint): Change type to gdb_byte[]. * armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint) (arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint) (arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[]. * armobsd-tdep.c (arm_obsd_thumb_le_breakpoint) (arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[]. * cris-tdep.c (push_stack_item, cris_push_dummy_call) (cris_store_return_value, cris_extract_return_value): Use gdb_byte. (constraint): Change type of parameter to char * from signed char*. Use gdb_byte. * dwarf2loc.c (read_pieced_value, write_pieced_value): Change type of local buffer to gdb_byte *. * dwarf2read.c (read_index_from_section): Use gdb_byte. (create_dwp_hash_table): Change type of locals to gdb_byte *. (add_address_entry): Change type of local buffer to gdb_byte[]. * frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr) (frv_push_dummy_call): Use gdb_byte. * hppa-hpux-tdep.c (hppa_hpux_push_dummy_code) (hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide) (hppa_hpux_supply_save_state): Use gdb_byte. * hppa-tdep.c (hppa32_push_dummy_call) (hppa64_convert_code_addr_to_fptr): Use gdb_byte. * ia64-tdep.c (extract_bit_field, replace_bit_field) (slotN_contents, replace_slotN_contents): Change type of parameter to gdb_byte *. (fetch_instruction, ia64_pseudo_register_write) (ia64_register_to_value, ia64_value_to_register) (ia64_extract_return_value, ia64_store_return_value) (ia64_push_dummy_call): Use gdb_byte. * m32c-tdep.c (m32c_return_value): Remove cast. * m68hc11-tdep.c (m68hc11_pseudo_register_write) (m68hc11_push_dummy_call, m68hc11_store_return_value): Use gdb_byte. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte. * mn10300-tdep.c (mn10300_store_return_value) (mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use gdb_byte. * moxie-tdep.c (moxie_process_readu): Use gdb_byte. (moxie_process_record): Remove casts. * ppc-ravenscar-thread.c (supply_register_at_address) (ppc_ravenscar_generic_store_registers): Use gdb_byte. * ravenscar-thread.c (get_running_thread_id): Use gdb_byte. * remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte. * remote-mips.c (mips_xfer_memory): Use gdb_byte. * remote.c (compare_sections_command): Use gdb_byte. * score-tdep.c (score7_free_memblock): Change type of parameter to gdb_byte *. * sh-tdep.c (sh_justify_value_in_reg): Change return type to gdb_byte *. Use gdb_byte. (sh_push_dummy_call_fpu): Use gdb_byte. (sh_extract_return_value_nofpu, sh_extract_return_value_fpu) (sh_store_return_value_nofpu, sh_store_return_value_fpu) (sh_register_convert_to_virtual, sh_register_convert_to_raw): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte. * sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte. (sh64_store_return_value, sh64_register_convert_to_virtual): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh64_pseudo_register_write): Use gdb_byte. * solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'. * solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte buffer. (irix_current_sos): Use gdb_byte. * solib-som.c (som_current_sos): Use gdb_byte. * sparc-ravenscar-thread.c (supply_register_at_address) (sparc_ravenscar_generic_store_registers): Use gdb_byte. * spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'. * spu-tdep.c (spu_get_overlay_table): Use gdb_byte. * tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to 'gdb_byte *'. * tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to 'gdb_byte *'. * tracepoint.c (tfile_fetch_registers): Use gdb_byte. * xstormy16-tdep.c (xstormy16_extract_return_value) (xstormy16_store_return_value): Change parameter type to 'gdb_byte *'. Adjust. (xstormy16_push_dummy_call): Use gdb_byte. * xtensa-tdep.c (xtensa_scan_prologue, call0_ret) (call0_analyze_prologue, execute_code): Use gdb_byte.
2013-04-19 17:09:46 +02:00
gdb_byte *sectdata;
const char *sectname;
bfd_size_type size;
bfd_vma lma;
int matched = 0;
int mismatched = 0;
int res;
int read_only = 0;
if (!exec_bfd)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("command cannot be used without an exec file"));
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process. */
set_general_process ();
if (args != NULL && strcmp (args, "-r") == 0)
{
read_only = 1;
args = NULL;
}
1999-07-07 22:19:36 +02:00
for (s = exec_bfd->sections; s; s = s->next)
{
if (!(s->flags & SEC_LOAD))
continue; /* Skip non-loadable section. */
if (read_only && (s->flags & SEC_READONLY) == 0)
continue; /* Skip writeable sections */
size = bfd_get_section_size (s);
if (size == 0)
continue; /* Skip zero-length section. */
sectname = bfd_get_section_name (exec_bfd, s);
if (args && strcmp (args, sectname) != 0)
continue; /* Not the section selected by user. */
matched = 1; /* Do this section. */
lma = s->lma;
sectdata = xmalloc (size);
2000-12-15 02:01:51 +01:00
old_chain = make_cleanup (xfree, sectdata);
bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
res = target_verify_memory (sectdata, lma, size);
if (res == -1)
* defs.h (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter. * utils.c (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter, use it instead of current_gdbarch. * ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter. * ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter, use it instead of current_gdbarch. Update calls to ui_out_field_core_addr to pass architecture: * ada-lang.c (print_one_exception): Update. * breakpoint.c (print_one_breakpoint_location, print_one_exception_catchpoint): Update. * disasm.c (dump_insns): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * mi/mi-main.c (mi_cmd_data_read_memory): Update. * mi/mi-symbol-cmds.c: Include "objfiles.h". (mi_cmd_symbol_list_lines): Update. * stack.c (print_frame_info, print_frame): Update. Update callers of paddress to pass architecture: * ada-tasks.c (info_task): Update. * ada-valprint.c (ada_val_print_1): Update. * annotate.c (annotate_source, annotate_frame_begin): Update. * breakpoint.c (insert_bp_location, describe_other_breakpoints, mention): Update. * cli/cli-cmds.c (edit_command, list_command, print_disassembly): Update. * corefile.c (memory_error): Update. * c-valprint.c (print_function_pointer_address, c_val_print): Update. * disasm.c (dis_asm_print_address): Update. * exec.c (print_section_info): Update. * f-valprint.c (f_val_print): Update. * infcmd.c: Include "arch-utils.h". (jump_command, program_info): Update. * linux-fork.c: Include "arch-utils.h". (info_forks_command): Update. * m2-valprint.c (print_function_pointer_address, print_unpacked_pointer, print_variable_at_address, m2_val_print): Update. * m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command): Update. * printcmd.c (print_address, print_address_demangle, address_info): Update. * p-valprint.c (pascal_val_print): Update. * source.c: Include "arch-utils.h". (line_info): Update. * stack.c (frame_info, print_block_frame_labels): Update. * symfile.c (add_symbol_file_command, list_overlays_command): Update. * symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1, print_symbol, print_partial_symbols, maintenance_info_psymtabs, maintenance_check_symtabs): Update. * symtab.c (find_pc_sect_symtab): Update. * target.c (deprecated_debug_xfer_memory): Update. * tracepoint.c (scope_info): Update. * tui/tui-stack.c (tui_make_status_line): Update. * valprint.c (val_print_string): Update. Update callers of paddr_nz to use paddress instead (keeping user-visible output identical): * alpha-tdep.c (alpha_heuristic_proc_start): Update. * amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn, amd64_displaced_step_fixup): Update. * arch-utils.c (simple_displaced_step_copy_insn): Update. * auxv.c (fprint_target_auxv): Update. * breakpoint.c (insert_single_step_breakpoint): Update. * buildsym.c (finish_block): Update. * cli/cli-dump.c (restore_section_callback): Update. * fbsd-nat.c (fbsd_find_memory_regions): Update. * frame.c (frame_unwind_register_value): Update. * gcore.c (gcore_create_callback): Update. * hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm, i386_process_record): Update. * ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id, ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id, ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update. * infrun.c (displaced_step_prepare, displaced_step_fixup, handle_inferior_event, insert_step_resume_breakpoint_at_sal, insert_longjmp_resume_breakpoint): Update. * linux-nat.c (linux_nat_find_memory_regions): Update. * linux-record.c (record_linux_system_call): Update. * mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call): Update. * monitor.c (monitor_error, monitor_remove_breakpoint): Update. * record.c (record_arch_list_add_mem, record_wait, record_xfer_partial): Update. * remote-mips.c (mips_fetch_word, mips_check_lsi_error, mips_common_breakpoint): Update. * remote-sim.c (gdbsim_xfer_inferior_memory): Update. * rs6000-tdep.c (ppc_displaced_step_fixup): Update. * solib-som.c (som_current_sos): Update. * symfile.c (load_progress, generic_load): Update. * symfile-mem.c (add_vsyscall_page): Update. * valops.c (value_fetch_lazy): Update. * windows-tdep.c (windows_xfer_shared_library): Update. Update callers of paddr_nz to use paddress instead (changing user-visible output to make it more correct): * dwarf2loc.c (locexpr_describe_location): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint, ia64_memory_remove_breakpoint): Update. * jv-valprint.c (java_value_print): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. * monitor.c (monitor_read_memory): Update. Update callers of paddr to use paddress instead (changing user-visible output to make it more correct): * arm-tdep.c (arm_push_dummy_call): Update. * breakpoint.c (insert_bp_location, create_thread_event_breakpoint, create_breakpoint): Update. * darwin-nat-info.c (darwin_debug_regions): Update. * dcache.c (dcache_info): Update. * dsrec.c (load_srec, make_srec): Update. * dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program, dwarf2_frame_cache): Update. * gcore.c (gcore_copy_callback): Update. * gnu-nat.c (gnu_xfer_memory): Update. * mips-linux-nat.c (mips_show_dr): Update. * monitor.c (monitor_write_memory, monitor_insert_breakpoint, monitor_remove_breakpoint): Update. * remote.c (compare_sections_command): Update. * remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint, m32r_remove_breakpoint, m32r_insert_watchpoint, m32r_remove_watchpoint): Update. * sol-thread.c (info_cb): Update. * symfile.c (load_progress): Update. Update callers of paddress or paddr_nz to use hex_string instead (changes output of internal/error/debug messages only): * dwarf2read.c (dump_die_shallow): Update. * frame.c (fprint_field, fprint_frame, frame_pc_unwind, get_frame_func, create_new_frame): Update. * hppa-tdep.c (find_unwind_entry, unwind_command): Update. * ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x, ia64_get_dyn_info_list): Update. * maint.c (maintenance_translate_address): Update. * mi/mi-cmd-var.c (mi_cmd_var_create): Update. * target.c (target_flash_erase): Update. Update callers of paddr/paddr_nz to use phex/phex_nz instead, using an appropriate address size. Remove use of strlen_paddr. * exec.c (exec_files_info): Update. * i386-nat.c (i386_show_dr): Update. * remote.c (remote_flash_erase): Update. * m32r-rom.c (m32r_load_section): Update. * monitor.c (monitor_vsprintf, monitor_store_register): Update. * remote.c (remote_check_symbols, remote_search_memory): Update. * remote-mips.c (mips_request, mips_common_breakpoint): Update. * scm-valprint.c (scm_ipruk, scm_scmval_print): Update. * sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs, sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs, sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs, sh_dsp_show_regs): Update. * xcoffsolib.c (sharedlibrary_command): Update. * maint.c (maint_print_section_info): Add ADDR_SIZE parameter. Use hex_string_custom instead of paddr. (print_bfd_section_info): Pass address size. (print_objfile_section_info): Likewise. * annotate.h (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * annotate.c (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * source.c (identify_source_line): Update call to annotate_source. * stack.c (print_frame_info, print_frame): Update call to annotate_frame_begin. * breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter. (create_breakpoint, create_ada_exception_breakpoint): Update call. * stack.c (print_block_frame_labels): Add GDBARCH parameter. (print_frame_label_vars): Update call. * symmisc.c (print_partial_symbols): Add GDBARCH parameter. (dump_psymtab): Update call to print_partial_symbols. (struct print_symbol_args): Add GDBARCH member. (dump_symtab_1): Set print_symbol_args architecture member. (print_symbol): Use it. * windows-tdep.h (windows_xfer_shared_library): Add GDBARCH parameter. * windows-tdep.c (windows_xfer_shared_library): Likewise. * i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member. (core_process_module_section): Pass architecture from cpms_data to windows_xfer_shared_library. (windows_core_xfer_shared_libraries): Initialize cmps_data architecture member. * windows-nat.c (windows_xfer_shared_libraries): Pass architecture to windows_xfer_shared_library. * defs.h (print_address): Add GDBARCH parameter. * printcmd.c (print_address): Add GDBARCH parameter. (print_scalar_formatted, do_examine): Update call. * findcmd.c (find_command): Update call. * tracepoint.c: Include "arch-utils.h". (trace_find_line_command): Update call. * tui/tui-disasm.c (tui_disassemble): Update call. * value.h (print_address_demangle): Add GDBARCH parameter. * printcmd.c (print_address_demangle): Add GDBARCH parameter. * c-valprint.c (print_function_pointer_address, c_val_print): Update call. * f-valprint.c (f_val_print): Update call. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update call. * jv-valprint.c (java_val_print): Update call. * m2-valprint.c (print_function_pointer_address, m2_val_print): Update call. * p-valprint.c (pascal_val_print): Update call. * disasm.c (gdb_disassemble_info): Install architecture into di.application_data field. testsuite/ChangeLog: * gdb.threads/tls-shared.exp: Update to locexpr_describe_location change to prefix TLS offset in hex with 0x. doc/ChangeLog: * gdbint.texinfo (Item Output Functions): Update signature for ui_out_field_core_addr.
2009-07-02 19:21:10 +02:00
error (_("target memory fault, section %s, range %s -- %s"), sectname,
paddress (target_gdbarch (), lma),
paddress (target_gdbarch (), lma + size));
* defs.h (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter. * utils.c (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter, use it instead of current_gdbarch. * ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter. * ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter, use it instead of current_gdbarch. Update calls to ui_out_field_core_addr to pass architecture: * ada-lang.c (print_one_exception): Update. * breakpoint.c (print_one_breakpoint_location, print_one_exception_catchpoint): Update. * disasm.c (dump_insns): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * mi/mi-main.c (mi_cmd_data_read_memory): Update. * mi/mi-symbol-cmds.c: Include "objfiles.h". (mi_cmd_symbol_list_lines): Update. * stack.c (print_frame_info, print_frame): Update. Update callers of paddress to pass architecture: * ada-tasks.c (info_task): Update. * ada-valprint.c (ada_val_print_1): Update. * annotate.c (annotate_source, annotate_frame_begin): Update. * breakpoint.c (insert_bp_location, describe_other_breakpoints, mention): Update. * cli/cli-cmds.c (edit_command, list_command, print_disassembly): Update. * corefile.c (memory_error): Update. * c-valprint.c (print_function_pointer_address, c_val_print): Update. * disasm.c (dis_asm_print_address): Update. * exec.c (print_section_info): Update. * f-valprint.c (f_val_print): Update. * infcmd.c: Include "arch-utils.h". (jump_command, program_info): Update. * linux-fork.c: Include "arch-utils.h". (info_forks_command): Update. * m2-valprint.c (print_function_pointer_address, print_unpacked_pointer, print_variable_at_address, m2_val_print): Update. * m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command): Update. * printcmd.c (print_address, print_address_demangle, address_info): Update. * p-valprint.c (pascal_val_print): Update. * source.c: Include "arch-utils.h". (line_info): Update. * stack.c (frame_info, print_block_frame_labels): Update. * symfile.c (add_symbol_file_command, list_overlays_command): Update. * symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1, print_symbol, print_partial_symbols, maintenance_info_psymtabs, maintenance_check_symtabs): Update. * symtab.c (find_pc_sect_symtab): Update. * target.c (deprecated_debug_xfer_memory): Update. * tracepoint.c (scope_info): Update. * tui/tui-stack.c (tui_make_status_line): Update. * valprint.c (val_print_string): Update. Update callers of paddr_nz to use paddress instead (keeping user-visible output identical): * alpha-tdep.c (alpha_heuristic_proc_start): Update. * amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn, amd64_displaced_step_fixup): Update. * arch-utils.c (simple_displaced_step_copy_insn): Update. * auxv.c (fprint_target_auxv): Update. * breakpoint.c (insert_single_step_breakpoint): Update. * buildsym.c (finish_block): Update. * cli/cli-dump.c (restore_section_callback): Update. * fbsd-nat.c (fbsd_find_memory_regions): Update. * frame.c (frame_unwind_register_value): Update. * gcore.c (gcore_create_callback): Update. * hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm, i386_process_record): Update. * ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id, ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id, ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update. * infrun.c (displaced_step_prepare, displaced_step_fixup, handle_inferior_event, insert_step_resume_breakpoint_at_sal, insert_longjmp_resume_breakpoint): Update. * linux-nat.c (linux_nat_find_memory_regions): Update. * linux-record.c (record_linux_system_call): Update. * mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call): Update. * monitor.c (monitor_error, monitor_remove_breakpoint): Update. * record.c (record_arch_list_add_mem, record_wait, record_xfer_partial): Update. * remote-mips.c (mips_fetch_word, mips_check_lsi_error, mips_common_breakpoint): Update. * remote-sim.c (gdbsim_xfer_inferior_memory): Update. * rs6000-tdep.c (ppc_displaced_step_fixup): Update. * solib-som.c (som_current_sos): Update. * symfile.c (load_progress, generic_load): Update. * symfile-mem.c (add_vsyscall_page): Update. * valops.c (value_fetch_lazy): Update. * windows-tdep.c (windows_xfer_shared_library): Update. Update callers of paddr_nz to use paddress instead (changing user-visible output to make it more correct): * dwarf2loc.c (locexpr_describe_location): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint, ia64_memory_remove_breakpoint): Update. * jv-valprint.c (java_value_print): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. * monitor.c (monitor_read_memory): Update. Update callers of paddr to use paddress instead (changing user-visible output to make it more correct): * arm-tdep.c (arm_push_dummy_call): Update. * breakpoint.c (insert_bp_location, create_thread_event_breakpoint, create_breakpoint): Update. * darwin-nat-info.c (darwin_debug_regions): Update. * dcache.c (dcache_info): Update. * dsrec.c (load_srec, make_srec): Update. * dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program, dwarf2_frame_cache): Update. * gcore.c (gcore_copy_callback): Update. * gnu-nat.c (gnu_xfer_memory): Update. * mips-linux-nat.c (mips_show_dr): Update. * monitor.c (monitor_write_memory, monitor_insert_breakpoint, monitor_remove_breakpoint): Update. * remote.c (compare_sections_command): Update. * remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint, m32r_remove_breakpoint, m32r_insert_watchpoint, m32r_remove_watchpoint): Update. * sol-thread.c (info_cb): Update. * symfile.c (load_progress): Update. Update callers of paddress or paddr_nz to use hex_string instead (changes output of internal/error/debug messages only): * dwarf2read.c (dump_die_shallow): Update. * frame.c (fprint_field, fprint_frame, frame_pc_unwind, get_frame_func, create_new_frame): Update. * hppa-tdep.c (find_unwind_entry, unwind_command): Update. * ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x, ia64_get_dyn_info_list): Update. * maint.c (maintenance_translate_address): Update. * mi/mi-cmd-var.c (mi_cmd_var_create): Update. * target.c (target_flash_erase): Update. Update callers of paddr/paddr_nz to use phex/phex_nz instead, using an appropriate address size. Remove use of strlen_paddr. * exec.c (exec_files_info): Update. * i386-nat.c (i386_show_dr): Update. * remote.c (remote_flash_erase): Update. * m32r-rom.c (m32r_load_section): Update. * monitor.c (monitor_vsprintf, monitor_store_register): Update. * remote.c (remote_check_symbols, remote_search_memory): Update. * remote-mips.c (mips_request, mips_common_breakpoint): Update. * scm-valprint.c (scm_ipruk, scm_scmval_print): Update. * sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs, sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs, sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs, sh_dsp_show_regs): Update. * xcoffsolib.c (sharedlibrary_command): Update. * maint.c (maint_print_section_info): Add ADDR_SIZE parameter. Use hex_string_custom instead of paddr. (print_bfd_section_info): Pass address size. (print_objfile_section_info): Likewise. * annotate.h (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * annotate.c (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * source.c (identify_source_line): Update call to annotate_source. * stack.c (print_frame_info, print_frame): Update call to annotate_frame_begin. * breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter. (create_breakpoint, create_ada_exception_breakpoint): Update call. * stack.c (print_block_frame_labels): Add GDBARCH parameter. (print_frame_label_vars): Update call. * symmisc.c (print_partial_symbols): Add GDBARCH parameter. (dump_psymtab): Update call to print_partial_symbols. (struct print_symbol_args): Add GDBARCH member. (dump_symtab_1): Set print_symbol_args architecture member. (print_symbol): Use it. * windows-tdep.h (windows_xfer_shared_library): Add GDBARCH parameter. * windows-tdep.c (windows_xfer_shared_library): Likewise. * i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member. (core_process_module_section): Pass architecture from cpms_data to windows_xfer_shared_library. (windows_core_xfer_shared_libraries): Initialize cmps_data architecture member. * windows-nat.c (windows_xfer_shared_libraries): Pass architecture to windows_xfer_shared_library. * defs.h (print_address): Add GDBARCH parameter. * printcmd.c (print_address): Add GDBARCH parameter. (print_scalar_formatted, do_examine): Update call. * findcmd.c (find_command): Update call. * tracepoint.c: Include "arch-utils.h". (trace_find_line_command): Update call. * tui/tui-disasm.c (tui_disassemble): Update call. * value.h (print_address_demangle): Add GDBARCH parameter. * printcmd.c (print_address_demangle): Add GDBARCH parameter. * c-valprint.c (print_function_pointer_address, c_val_print): Update call. * f-valprint.c (f_val_print): Update call. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update call. * jv-valprint.c (java_val_print): Update call. * m2-valprint.c (print_function_pointer_address, m2_val_print): Update call. * p-valprint.c (pascal_val_print): Update call. * disasm.c (gdb_disassemble_info): Install architecture into di.application_data field. testsuite/ChangeLog: * gdb.threads/tls-shared.exp: Update to locexpr_describe_location change to prefix TLS offset in hex with 0x. doc/ChangeLog: * gdbint.texinfo (Item Output Functions): Update signature for ui_out_field_core_addr.
2009-07-02 19:21:10 +02:00
printf_filtered ("Section %s, range %s -- %s: ", sectname,
paddress (target_gdbarch (), lma),
paddress (target_gdbarch (), lma + size));
if (res)
printf_filtered ("matched.\n");
else
1999-07-07 22:19:36 +02:00
{
printf_filtered ("MIS-MATCHED!\n");
mismatched++;
}
do_cleanups (old_chain);
}
if (mismatched > 0)
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
warning (_("One or more sections of the target image does not match\n\
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
the loaded file\n"));
if (args && !matched)
printf_filtered (_("No loaded section named '%s'.\n"), args);
}
/* Write LEN bytes from WRITEBUF into OBJECT_NAME/ANNEX at OFFSET
into remote target. The number of bytes written to the remote
target is returned, or -1 for error. */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
remote_write_qxfer (struct target_ops *ops, const char *object_name,
const char *annex, const gdb_byte *writebuf,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
ULONGEST offset, LONGEST len, ULONGEST *xfered_len,
struct packet_config *packet)
{
int i, buf_len;
ULONGEST n;
struct remote_state *rs = get_remote_state ();
int max_size = get_memory_write_packet_size ();
if (packet->support == PACKET_DISABLE)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
/* Insert header. */
i = snprintf (rs->buf, max_size,
"qXfer:%s:write:%s:%s:",
object_name, annex ? annex : "",
phex_nz (offset, sizeof offset));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
buf_len = remote_escape_output
(writebuf, len, 1, (gdb_byte *) rs->buf + i, &max_size, max_size);
if (putpkt_binary (rs->buf, i + buf_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
|| packet_ok (rs->buf, packet) != PACKET_OK)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
unpack_varlen_hex (rs->buf, &n);
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
*xfered_len = n;
return TARGET_XFER_OK;
}
/* Read OBJECT_NAME/ANNEX from the remote target using a qXfer packet.
Data at OFFSET, of up to LEN bytes, is read into READBUF; the
number of bytes read is returned, or 0 for EOF, or -1 for error.
The number of bytes read may be less than LEN without indicating an
EOF. PACKET is checked and updated to indicate whether the remote
target supports this object. */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
remote_read_qxfer (struct target_ops *ops, const char *object_name,
const char *annex,
gdb_byte *readbuf, ULONGEST offset, LONGEST len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
ULONGEST *xfered_len,
struct packet_config *packet)
{
struct remote_state *rs = get_remote_state ();
LONGEST i, n, packet_len;
if (packet->support == PACKET_DISABLE)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
/* Check whether we've cached an end-of-object packet that matches
this request. */
if (rs->finished_object)
{
if (strcmp (object_name, rs->finished_object) == 0
&& strcmp (annex ? annex : "", rs->finished_annex) == 0
&& offset == rs->finished_offset)
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return TARGET_XFER_EOF;
/* Otherwise, we're now reading something different. Discard
the cache. */
xfree (rs->finished_object);
xfree (rs->finished_annex);
rs->finished_object = NULL;
rs->finished_annex = NULL;
}
/* Request only enough to fit in a single packet. The actual data
may not, since we don't know how much of it will need to be escaped;
the target is free to respond with slightly less data. We subtract
five to account for the response type and the protocol frame. */
n = min (get_remote_packet_size () - 5, len);
snprintf (rs->buf, get_remote_packet_size () - 4, "qXfer:%s:read:%s:%s,%s",
object_name, annex ? annex : "",
phex_nz (offset, sizeof offset),
phex_nz (n, sizeof n));
i = putpkt (rs->buf);
if (i < 0)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
rs->buf[0] = '\0';
packet_len = getpkt_sane (&rs->buf, &rs->buf_size, 0);
if (packet_len < 0 || packet_ok (rs->buf, packet) != PACKET_OK)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
if (rs->buf[0] != 'l' && rs->buf[0] != 'm')
error (_("Unknown remote qXfer reply: %s"), rs->buf);
/* 'm' means there is (or at least might be) more data after this
batch. That does not make sense unless there's at least one byte
of data in this reply. */
if (rs->buf[0] == 'm' && packet_len == 1)
error (_("Remote qXfer reply contained no data."));
/* Got some data. */
i = remote_unescape_input ((gdb_byte *) rs->buf + 1,
packet_len - 1, readbuf, n);
/* 'l' is an EOF marker, possibly including a final block of data,
or possibly empty. If we have the final block of a non-empty
object, record this fact to bypass a subsequent partial read. */
if (rs->buf[0] == 'l' && offset + i > 0)
{
rs->finished_object = xstrdup (object_name);
rs->finished_annex = xstrdup (annex ? annex : "");
rs->finished_offset = offset + i;
}
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
if (i == 0)
return TARGET_XFER_EOF;
else
{
*xfered_len = i;
return TARGET_XFER_OK;
}
}
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
remote_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
{
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
struct remote_state *rs;
int i;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *p2;
char query_type;
int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
set_remote_traceframe ();
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
set_general_thread (inferior_ptid);
rs = get_remote_state ();
/* Handle memory using the standard memory routines. */
if (object == TARGET_OBJECT_MEMORY)
{
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
/* If the remote target is connected but not running, we should
pass this request down to a lower stratum (e.g. the executable
file). */
if (!target_has_execution)
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return TARGET_XFER_EOF;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
if (writebuf != NULL)
return remote_write_bytes (offset, writebuf, len, unit_size,
xfered_len);
else
return remote_read_bytes (ops, offset, readbuf, len, unit_size,
xfered_len);
}
/* Handle SPU memory using qxfer packets. */
if (object == TARGET_OBJECT_SPU)
{
if (readbuf)
return remote_read_qxfer (ops, "spu", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len, &remote_protocol_packets
[PACKET_qXfer_spu_read]);
else
return remote_write_qxfer (ops, "spu", annex, writebuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len, &remote_protocol_packets
[PACKET_qXfer_spu_write]);
}
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
/* Handle extra signal info using qxfer packets. */
if (object == TARGET_OBJECT_SIGNAL_INFO)
{
if (readbuf)
return remote_read_qxfer (ops, "siginfo", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len, &remote_protocol_packets
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
[PACKET_qXfer_siginfo_read]);
else
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
return remote_write_qxfer (ops, "siginfo", annex,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
writebuf, offset, len, xfered_len,
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
&remote_protocol_packets
[PACKET_qXfer_siginfo_write]);
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
if (object == TARGET_OBJECT_STATIC_TRACE_DATA)
{
if (readbuf)
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
return remote_read_qxfer (ops, "statictrace", annex,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
readbuf, offset, len, xfered_len,
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
&remote_protocol_packets
[PACKET_qXfer_statictrace_read]);
else
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
}
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
/* Only handle flash writes. */
if (writebuf != NULL)
{
LONGEST xfered;
switch (object)
{
case TARGET_OBJECT_FLASH:
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return remote_flash_write (ops, offset, len, xfered_len,
writebuf);
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
default:
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
}
}
/* Map pre-existing objects onto letters. DO NOT do this for new
objects!!! Instead specify new query packets. */
switch (object)
{
case TARGET_OBJECT_AVR:
query_type = 'R';
break;
case TARGET_OBJECT_AUXV:
gdb_assert (annex == NULL);
return remote_read_qxfer (ops, "auxv", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
&remote_protocol_packets[PACKET_qXfer_auxv]);
XML feature description support. * NEWS: Mention target descriptions, "set tdesc filename", "unset tdesc filename", "show tdesc filename", and qXfer:features:read. * arch-utils.c (choose_architecture_for_target): New function. (gdbarch_info_fill): Call it. * target-descriptions.c (struct property): Make members non-const. (struct target_desc): Add arch member. (target_description_filename): New variable. (target_find_description): Try via XML first. (tdesc_architecture): New. (free_target_description, make_cleanup_free_target_description): New. (set_tdesc_property): Call xstrdup. (set_tdesc_architecture, tdesc_set_cmdlist, tdesc_show_cmdlist) (tdesc_unset_cmdlist, unset_tdesc_cmd, unset_tdesc_filename_cmd) (set_tdesc_cmd, show_tdesc_cmd, set_tdesc_filename_cmd) (show_tdesc_filename_cmd, _initialize_target_descriptions): New. * target-descriptions.h (tdesc_architecture) (make_cleanup_free_target_description, set_tdesc_architecture): New prototypes. * Makefile.in (SFILES): Add xml-tdesc.c. (COMMON_OBS): Add xml-tdesc.o. (target-descriptions.o): Update. (xml-tdesc.o): New rule. * xml-tdesc.c, xml-tdesc.h: New files. * remote.c (PACKET_qXfer_features): New enum. (remote_protocol_features): Add qXfer:features:read. (remote_xfer_partial): Handle TARGET_OBJECT_AVAILABLE_FEATURES. (_initialize_remote): Register qXfer:features:read. * target.h (enum target_object): Add TARGET_OBJECT_AVAILABLE_FEATURES. * features/gdb-target.dtd: New file. * linux-i386-low.c (the_low_target): Set arch_string. * linux-x86-64-low.c (the_low_target): Likewise. * linux-low.c (linux_arch_string): New. (linux_target_ops): Add it. * linux-low.h (struct linux_target_ops): Add arch_string. * server.c (write_qxfer_response): Use const void * for DATA. (get_features_xml): New. (handle_query): Handle qXfer:features:read. Report it for qSupported. * target.h (struct target_ops): Add arch_string method. * gdb.texinfo (Target Descriptions): New section. (General Query Packets): Add QPassSignals anchor. Mention qXfer:features:read under qSupported. Expand mentions of qXfer:memory-map:read and QPassSignals. Document qXfer:features:read.
2007-01-09 23:55:10 +01:00
case TARGET_OBJECT_AVAILABLE_FEATURES:
return remote_read_qxfer
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
(ops, "features", annex, readbuf, offset, len, xfered_len,
XML feature description support. * NEWS: Mention target descriptions, "set tdesc filename", "unset tdesc filename", "show tdesc filename", and qXfer:features:read. * arch-utils.c (choose_architecture_for_target): New function. (gdbarch_info_fill): Call it. * target-descriptions.c (struct property): Make members non-const. (struct target_desc): Add arch member. (target_description_filename): New variable. (target_find_description): Try via XML first. (tdesc_architecture): New. (free_target_description, make_cleanup_free_target_description): New. (set_tdesc_property): Call xstrdup. (set_tdesc_architecture, tdesc_set_cmdlist, tdesc_show_cmdlist) (tdesc_unset_cmdlist, unset_tdesc_cmd, unset_tdesc_filename_cmd) (set_tdesc_cmd, show_tdesc_cmd, set_tdesc_filename_cmd) (show_tdesc_filename_cmd, _initialize_target_descriptions): New. * target-descriptions.h (tdesc_architecture) (make_cleanup_free_target_description, set_tdesc_architecture): New prototypes. * Makefile.in (SFILES): Add xml-tdesc.c. (COMMON_OBS): Add xml-tdesc.o. (target-descriptions.o): Update. (xml-tdesc.o): New rule. * xml-tdesc.c, xml-tdesc.h: New files. * remote.c (PACKET_qXfer_features): New enum. (remote_protocol_features): Add qXfer:features:read. (remote_xfer_partial): Handle TARGET_OBJECT_AVAILABLE_FEATURES. (_initialize_remote): Register qXfer:features:read. * target.h (enum target_object): Add TARGET_OBJECT_AVAILABLE_FEATURES. * features/gdb-target.dtd: New file. * linux-i386-low.c (the_low_target): Set arch_string. * linux-x86-64-low.c (the_low_target): Likewise. * linux-low.c (linux_arch_string): New. (linux_target_ops): Add it. * linux-low.h (struct linux_target_ops): Add arch_string. * server.c (write_qxfer_response): Use const void * for DATA. (get_features_xml): New. (handle_query): Handle qXfer:features:read. Report it for qSupported. * target.h (struct target_ops): Add arch_string method. * gdb.texinfo (Target Descriptions): New section. (General Query Packets): Add QPassSignals anchor. Mention qXfer:features:read under qSupported. Expand mentions of qXfer:memory-map:read and QPassSignals. Document qXfer:features:read.
2007-01-09 23:55:10 +01:00
&remote_protocol_packets[PACKET_qXfer_features]);
case TARGET_OBJECT_LIBRARIES:
return remote_read_qxfer
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
(ops, "libraries", annex, readbuf, offset, len, xfered_len,
&remote_protocol_packets[PACKET_qXfer_libraries]);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
case TARGET_OBJECT_LIBRARIES_SVR4:
return remote_read_qxfer
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
(ops, "libraries-svr4", annex, readbuf, offset, len, xfered_len,
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
&remote_protocol_packets[PACKET_qXfer_libraries_svr4]);
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
case TARGET_OBJECT_MEMORY_MAP:
gdb_assert (annex == NULL);
return remote_read_qxfer (ops, "memory-map", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
&remote_protocol_packets[PACKET_qXfer_memory_map]);
case TARGET_OBJECT_OSDATA:
/* Should only get here if we're connected. */
gdb_assert (rs->remote_desc);
return remote_read_qxfer
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
(ops, "osdata", annex, readbuf, offset, len, xfered_len,
&remote_protocol_packets[PACKET_qXfer_osdata]);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
case TARGET_OBJECT_THREADS:
gdb_assert (annex == NULL);
return remote_read_qxfer (ops, "threads", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
&remote_protocol_packets[PACKET_qXfer_threads]);
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
case TARGET_OBJECT_TRACEFRAME_INFO:
gdb_assert (annex == NULL);
return remote_read_qxfer
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
(ops, "traceframe-info", annex, readbuf, offset, len, xfered_len,
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
&remote_protocol_packets[PACKET_qXfer_traceframe_info]);
case TARGET_OBJECT_FDPIC:
return remote_read_qxfer (ops, "fdpic", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
&remote_protocol_packets[PACKET_qXfer_fdpic]);
case TARGET_OBJECT_OPENVMS_UIB:
return remote_read_qxfer (ops, "uib", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
&remote_protocol_packets[PACKET_qXfer_uib]);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
case TARGET_OBJECT_BTRACE:
return remote_read_qxfer (ops, "btrace", annex, readbuf, offset, len,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
xfered_len,
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
&remote_protocol_packets[PACKET_qXfer_btrace]);
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
case TARGET_OBJECT_BTRACE_CONF:
return remote_read_qxfer (ops, "btrace-conf", annex, readbuf, offset,
len, xfered_len,
&remote_protocol_packets[PACKET_qXfer_btrace_conf]);
case TARGET_OBJECT_EXEC_FILE:
return remote_read_qxfer (ops, "exec-file", annex, readbuf, offset,
len, xfered_len,
&remote_protocol_packets[PACKET_qXfer_exec_file]);
default:
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
}
/* Minimum outbuf size is get_remote_packet_size (). If LEN is not
large enough let the caller deal with it. */
if (len < get_remote_packet_size ())
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
len = get_remote_packet_size ();
/* Except for querying the minimum buffer size, target must be open. */
if (!rs->remote_desc)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("remote query is only available after target open"));
gdb_assert (annex != NULL);
gdb_assert (readbuf != NULL);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
p2 = rs->buf;
*p2++ = 'q';
*p2++ = query_type;
/* We used one buffer char for the remote protocol q command and
another for the query type. As the remote protocol encapsulation
uses 4 chars plus one extra in case we are debugging
(remote_debug), we have PBUFZIZ - 7 left to pack the query
string. */
i = 0;
while (annex[i] && (i < (get_remote_packet_size () - 8)))
{
/* Bad caller may have sent forbidden characters. */
gdb_assert (isprint (annex[i]) && annex[i] != '$' && annex[i] != '#');
*p2++ = annex[i];
i++;
}
*p2 = '\0';
gdb_assert (annex[i] == '\0');
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
i = putpkt (rs->buf);
1999-07-07 22:19:36 +02:00
if (i < 0)
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
strcpy ((char *) readbuf, rs->buf);
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
*xfered_len = strlen ((char *) readbuf);
return TARGET_XFER_OK;
}
static int
remote_search_memory (struct target_ops* ops,
CORE_ADDR start_addr, ULONGEST search_space_len,
const gdb_byte *pattern, ULONGEST pattern_len,
CORE_ADDR *found_addrp)
{
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
struct remote_state *rs = get_remote_state ();
int max_size = get_memory_write_packet_size ();
struct packet_config *packet =
&remote_protocol_packets[PACKET_qSearch_memory];
/* Number of packet bytes used to encode the pattern;
this could be more than PATTERN_LEN due to escape characters. */
int escaped_pattern_len;
/* Amount of pattern that was encodable in the packet. */
int used_pattern_len;
int i;
int found;
ULONGEST found_addr;
/* Don't go to the target if we don't have to.
This is done before checking packet->support to avoid the possibility that
a success for this edge case means the facility works in general. */
if (pattern_len > search_space_len)
return 0;
if (pattern_len == 0)
{
*found_addrp = start_addr;
return 1;
}
/* If we already know the packet isn't supported, fall back to the simple
way of searching memory. */
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_config_support (packet) == PACKET_DISABLE)
{
/* Target doesn't provided special support, fall back and use the
standard support (copy memory and do the search here). */
return simple_search_memory (ops, start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
[remote] Insert breakpoints in the right process. I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
2013-05-29 13:57:48 +02:00
/* Make sure the remote is pointing at the right process. */
set_general_process ();
/* Insert header. */
i = snprintf (rs->buf, max_size,
"qSearch:memory:%s;%s;",
* defs.h (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter. * utils.c (strlen_paddr, paddr, paddr_nz): Remove. (paddress): Add GDBARCH parameter, use it instead of current_gdbarch. * ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter. * ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter, use it instead of current_gdbarch. Update calls to ui_out_field_core_addr to pass architecture: * ada-lang.c (print_one_exception): Update. * breakpoint.c (print_one_breakpoint_location, print_one_exception_catchpoint): Update. * disasm.c (dump_insns): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * mi/mi-main.c (mi_cmd_data_read_memory): Update. * mi/mi-symbol-cmds.c: Include "objfiles.h". (mi_cmd_symbol_list_lines): Update. * stack.c (print_frame_info, print_frame): Update. Update callers of paddress to pass architecture: * ada-tasks.c (info_task): Update. * ada-valprint.c (ada_val_print_1): Update. * annotate.c (annotate_source, annotate_frame_begin): Update. * breakpoint.c (insert_bp_location, describe_other_breakpoints, mention): Update. * cli/cli-cmds.c (edit_command, list_command, print_disassembly): Update. * corefile.c (memory_error): Update. * c-valprint.c (print_function_pointer_address, c_val_print): Update. * disasm.c (dis_asm_print_address): Update. * exec.c (print_section_info): Update. * f-valprint.c (f_val_print): Update. * infcmd.c: Include "arch-utils.h". (jump_command, program_info): Update. * linux-fork.c: Include "arch-utils.h". (info_forks_command): Update. * m2-valprint.c (print_function_pointer_address, print_unpacked_pointer, print_variable_at_address, m2_val_print): Update. * m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command): Update. * printcmd.c (print_address, print_address_demangle, address_info): Update. * p-valprint.c (pascal_val_print): Update. * source.c: Include "arch-utils.h". (line_info): Update. * stack.c (frame_info, print_block_frame_labels): Update. * symfile.c (add_symbol_file_command, list_overlays_command): Update. * symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1, print_symbol, print_partial_symbols, maintenance_info_psymtabs, maintenance_check_symtabs): Update. * symtab.c (find_pc_sect_symtab): Update. * target.c (deprecated_debug_xfer_memory): Update. * tracepoint.c (scope_info): Update. * tui/tui-stack.c (tui_make_status_line): Update. * valprint.c (val_print_string): Update. Update callers of paddr_nz to use paddress instead (keeping user-visible output identical): * alpha-tdep.c (alpha_heuristic_proc_start): Update. * amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn, amd64_displaced_step_fixup): Update. * arch-utils.c (simple_displaced_step_copy_insn): Update. * auxv.c (fprint_target_auxv): Update. * breakpoint.c (insert_single_step_breakpoint): Update. * buildsym.c (finish_block): Update. * cli/cli-dump.c (restore_section_callback): Update. * fbsd-nat.c (fbsd_find_memory_regions): Update. * frame.c (frame_unwind_register_value): Update. * gcore.c (gcore_create_callback): Update. * hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm, i386_process_record): Update. * ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id, ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id, ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update. * infrun.c (displaced_step_prepare, displaced_step_fixup, handle_inferior_event, insert_step_resume_breakpoint_at_sal, insert_longjmp_resume_breakpoint): Update. * linux-nat.c (linux_nat_find_memory_regions): Update. * linux-record.c (record_linux_system_call): Update. * mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call): Update. * monitor.c (monitor_error, monitor_remove_breakpoint): Update. * record.c (record_arch_list_add_mem, record_wait, record_xfer_partial): Update. * remote-mips.c (mips_fetch_word, mips_check_lsi_error, mips_common_breakpoint): Update. * remote-sim.c (gdbsim_xfer_inferior_memory): Update. * rs6000-tdep.c (ppc_displaced_step_fixup): Update. * solib-som.c (som_current_sos): Update. * symfile.c (load_progress, generic_load): Update. * symfile-mem.c (add_vsyscall_page): Update. * valops.c (value_fetch_lazy): Update. * windows-tdep.c (windows_xfer_shared_library): Update. Update callers of paddr_nz to use paddress instead (changing user-visible output to make it more correct): * dwarf2loc.c (locexpr_describe_location): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint, ia64_memory_remove_breakpoint): Update. * jv-valprint.c (java_value_print): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. * monitor.c (monitor_read_memory): Update. Update callers of paddr to use paddress instead (changing user-visible output to make it more correct): * arm-tdep.c (arm_push_dummy_call): Update. * breakpoint.c (insert_bp_location, create_thread_event_breakpoint, create_breakpoint): Update. * darwin-nat-info.c (darwin_debug_regions): Update. * dcache.c (dcache_info): Update. * dsrec.c (load_srec, make_srec): Update. * dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program, dwarf2_frame_cache): Update. * gcore.c (gcore_copy_callback): Update. * gnu-nat.c (gnu_xfer_memory): Update. * mips-linux-nat.c (mips_show_dr): Update. * monitor.c (monitor_write_memory, monitor_insert_breakpoint, monitor_remove_breakpoint): Update. * remote.c (compare_sections_command): Update. * remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint, m32r_remove_breakpoint, m32r_insert_watchpoint, m32r_remove_watchpoint): Update. * sol-thread.c (info_cb): Update. * symfile.c (load_progress): Update. Update callers of paddress or paddr_nz to use hex_string instead (changes output of internal/error/debug messages only): * dwarf2read.c (dump_die_shallow): Update. * frame.c (fprint_field, fprint_frame, frame_pc_unwind, get_frame_func, create_new_frame): Update. * hppa-tdep.c (find_unwind_entry, unwind_command): Update. * ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x, ia64_get_dyn_info_list): Update. * maint.c (maintenance_translate_address): Update. * mi/mi-cmd-var.c (mi_cmd_var_create): Update. * target.c (target_flash_erase): Update. Update callers of paddr/paddr_nz to use phex/phex_nz instead, using an appropriate address size. Remove use of strlen_paddr. * exec.c (exec_files_info): Update. * i386-nat.c (i386_show_dr): Update. * remote.c (remote_flash_erase): Update. * m32r-rom.c (m32r_load_section): Update. * monitor.c (monitor_vsprintf, monitor_store_register): Update. * remote.c (remote_check_symbols, remote_search_memory): Update. * remote-mips.c (mips_request, mips_common_breakpoint): Update. * scm-valprint.c (scm_ipruk, scm_scmval_print): Update. * sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs, sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs, sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs, sh_dsp_show_regs): Update. * xcoffsolib.c (sharedlibrary_command): Update. * maint.c (maint_print_section_info): Add ADDR_SIZE parameter. Use hex_string_custom instead of paddr. (print_bfd_section_info): Pass address size. (print_objfile_section_info): Likewise. * annotate.h (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * annotate.c (annotate_source): Add GDBARCH parameter. (annotate_frame_begin): Likewise. * source.c (identify_source_line): Update call to annotate_source. * stack.c (print_frame_info, print_frame): Update call to annotate_frame_begin. * breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter. (create_breakpoint, create_ada_exception_breakpoint): Update call. * stack.c (print_block_frame_labels): Add GDBARCH parameter. (print_frame_label_vars): Update call. * symmisc.c (print_partial_symbols): Add GDBARCH parameter. (dump_psymtab): Update call to print_partial_symbols. (struct print_symbol_args): Add GDBARCH member. (dump_symtab_1): Set print_symbol_args architecture member. (print_symbol): Use it. * windows-tdep.h (windows_xfer_shared_library): Add GDBARCH parameter. * windows-tdep.c (windows_xfer_shared_library): Likewise. * i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member. (core_process_module_section): Pass architecture from cpms_data to windows_xfer_shared_library. (windows_core_xfer_shared_libraries): Initialize cmps_data architecture member. * windows-nat.c (windows_xfer_shared_libraries): Pass architecture to windows_xfer_shared_library. * defs.h (print_address): Add GDBARCH parameter. * printcmd.c (print_address): Add GDBARCH parameter. (print_scalar_formatted, do_examine): Update call. * findcmd.c (find_command): Update call. * tracepoint.c: Include "arch-utils.h". (trace_find_line_command): Update call. * tui/tui-disasm.c (tui_disassemble): Update call. * value.h (print_address_demangle): Add GDBARCH parameter. * printcmd.c (print_address_demangle): Add GDBARCH parameter. * c-valprint.c (print_function_pointer_address, c_val_print): Update call. * f-valprint.c (f_val_print): Update call. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update call. * jv-valprint.c (java_val_print): Update call. * m2-valprint.c (print_function_pointer_address, m2_val_print): Update call. * p-valprint.c (pascal_val_print): Update call. * disasm.c (gdb_disassemble_info): Install architecture into di.application_data field. testsuite/ChangeLog: * gdb.threads/tls-shared.exp: Update to locexpr_describe_location change to prefix TLS offset in hex with 0x. doc/ChangeLog: * gdbint.texinfo (Item Output Functions): Update signature for ui_out_field_core_addr.
2009-07-02 19:21:10 +02:00
phex_nz (start_addr, addr_size),
phex_nz (search_space_len, sizeof (search_space_len)));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
escaped_pattern_len =
remote_escape_output (pattern, pattern_len, 1, (gdb_byte *) rs->buf + i,
&used_pattern_len, max_size);
/* Bail if the pattern is too large. */
if (used_pattern_len != pattern_len)
error (_("Pattern is too large to transmit to remote target."));
if (putpkt_binary (rs->buf, i + escaped_pattern_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
|| packet_ok (rs->buf, packet) != PACKET_OK)
{
/* The request may not have worked because the command is not
supported. If so, fall back to the simple way. */
if (packet->support == PACKET_DISABLE)
{
return simple_search_memory (ops, start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
return -1;
}
if (rs->buf[0] == '0')
found = 0;
else if (rs->buf[0] == '1')
{
found = 1;
if (rs->buf[1] != ',')
error (_("Unknown qSearch:memory reply: %s"), rs->buf);
unpack_varlen_hex (rs->buf + 2, &found_addr);
*found_addrp = found_addr;
}
else
error (_("Unknown qSearch:memory reply: %s"), rs->buf);
return found;
}
1999-08-09 23:36:23 +02:00
static void
remote_rcmd (struct target_ops *self, const char *command,
2000-02-02 01:21:19 +01:00
struct ui_file *outbuf)
1999-08-09 23:36:23 +02:00
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
1999-08-09 23:36:23 +02:00
if (!rs->remote_desc)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("remote rcmd is only available after target open"));
1999-08-09 23:36:23 +02:00
/* Send a NULL command across as an empty command. */
1999-08-16 21:57:19 +02:00
if (command == NULL)
command = "";
/* The query prefix. */
strcpy (rs->buf, "qRcmd,");
p = strchr (rs->buf, '\0');
1999-08-09 23:36:23 +02:00
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
if ((strlen (rs->buf) + strlen (command) * 2 + 8/*misc*/)
> get_remote_packet_size ())
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("\"monitor\" command ``%s'' is too long."), command);
1999-08-09 23:36:23 +02:00
/* Encode the actual command. */
bin2hex ((const gdb_byte *) command, p, strlen (command));
1999-08-09 23:36:23 +02:00
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
if (putpkt (rs->buf) < 0)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Communication problem with target."));
1999-08-09 23:36:23 +02:00
/* get/display the response */
while (1)
{
char *buf;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* XXX - see also remote_get_noisy_reply(). */
QUIT; /* Allow user to bail out with ^C. */
rs->buf[0] = '\0';
if (getpkt_sane (&rs->buf, &rs->buf_size, 0) == -1)
{
/* Timeout. Continue to (try to) read responses.
This is better than stopping with an error, assuming the stub
is still executing the (long) monitor command.
If needed, the user can interrupt gdb using C-c, obtaining
an effect similar to stop on timeout. */
continue;
}
buf = rs->buf;
1999-08-09 23:36:23 +02:00
if (buf[0] == '\0')
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Target does not support this command."));
1999-08-09 23:36:23 +02:00
if (buf[0] == 'O' && buf[1] != 'K')
{
remote_console_output (buf + 1); /* 'O' message from stub. */
1999-08-09 23:36:23 +02:00
continue;
}
if (strcmp (buf, "OK") == 0)
break;
1999-08-16 21:57:19 +02:00
if (strlen (buf) == 3 && buf[0] == 'E'
&& isdigit (buf[1]) && isdigit (buf[2]))
{
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Protocol error with Rcmd"));
1999-08-16 21:57:19 +02:00
}
1999-08-09 23:36:23 +02:00
for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2)
{
char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
1999-08-09 23:36:23 +02:00
fputc_unfiltered (c, outbuf);
}
break;
}
}
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
static VEC(mem_region_s) *
remote_memory_map (struct target_ops *ops)
{
VEC(mem_region_s) *result = NULL;
char *text = target_read_stralloc (&current_target,
TARGET_OBJECT_MEMORY_MAP, NULL);
if (text)
{
struct cleanup *back_to = make_cleanup (xfree, text);
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
result = parse_memory_map (text);
do_cleanups (back_to);
}
return result;
}
static void
2000-07-30 03:48:28 +02:00
packet_command (char *args, int from_tty)
{
struct remote_state *rs = get_remote_state ();
if (!rs->remote_desc)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("command can only be used with remote target"));
1999-07-07 22:19:36 +02:00
if (!args)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("remote-packet command requires packet text as argument"));
puts_filtered ("sending: ");
print_packet (args);
puts_filtered ("\n");
putpkt (args);
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
getpkt (&rs->buf, &rs->buf_size, 0);
puts_filtered ("received: ");
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
print_packet (rs->buf);
puts_filtered ("\n");
}
#if 0
/* --------- UNIT_TEST for THREAD oriented PACKETS ------------------- */
2000-05-28 03:12:42 +02:00
static void display_thread_info (struct gdb_ext_thread_info *info);
2000-05-28 03:12:42 +02:00
static void threadset_test_cmd (char *cmd, int tty);
2000-05-28 03:12:42 +02:00
static void threadalive_test (char *cmd, int tty);
2000-05-28 03:12:42 +02:00
static void threadlist_test_cmd (char *cmd, int tty);
int get_and_display_threadinfo (threadref *ref);
2000-05-28 03:12:42 +02:00
static void threadinfo_test_cmd (char *cmd, int tty);
static int thread_display_step (threadref *ref, void *context);
2000-05-28 03:12:42 +02:00
static void threadlist_update_test_cmd (char *cmd, int tty);
2000-05-28 03:12:42 +02:00
static void init_remote_threadtests (void);
#define SAMPLE_THREAD 0x05060708 /* Truncated 64 bit threadid. */
static void
2000-07-30 03:48:28 +02:00
threadset_test_cmd (char *cmd, int tty)
{
int sample_thread = SAMPLE_THREAD;
printf_filtered (_("Remote threadset test\n"));
set_general_thread (sample_thread);
}
static void
2000-07-30 03:48:28 +02:00
threadalive_test (char *cmd, int tty)
{
int sample_thread = SAMPLE_THREAD;
int pid = ptid_get_pid (inferior_ptid);
ptid_t ptid = ptid_build (pid, sample_thread, 0);
if (remote_thread_alive (ptid))
printf_filtered ("PASS: Thread alive test\n");
else
printf_filtered ("FAIL: Thread alive test\n");
}
void output_threadid (char *title, threadref *ref);
void
2000-07-30 03:48:28 +02:00
output_threadid (char *title, threadref *ref)
{
char hexid[20];
pack_threadid (&hexid[0], ref); /* Convert threead id into hex. */
hexid[16] = 0;
printf_filtered ("%s %s\n", title, (&hexid[0]));
}
static void
2000-07-30 03:48:28 +02:00
threadlist_test_cmd (char *cmd, int tty)
{
int startflag = 1;
threadref nextthread;
int done, result_count;
threadref threadlist[3];
printf_filtered ("Remote Threadlist test\n");
if (!remote_get_threadlist (startflag, &nextthread, 3, &done,
&result_count, &threadlist[0]))
printf_filtered ("FAIL: threadlist test\n");
else
{
threadref *scan = threadlist;
threadref *limit = scan + result_count;
while (scan < limit)
output_threadid (" thread ", scan++);
}
}
void
2000-07-30 03:48:28 +02:00
display_thread_info (struct gdb_ext_thread_info *info)
{
output_threadid ("Threadid: ", &info->threadid);
printf_filtered ("Name: %s\n ", info->shortname);
printf_filtered ("State: %s\n", info->display);
printf_filtered ("other: %s\n\n", info->more_display);
}
int
2000-07-30 03:48:28 +02:00
get_and_display_threadinfo (threadref *ref)
{
int result;
int set;
struct gdb_ext_thread_info threadinfo;
set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
| TAG_MOREDISPLAY | TAG_DISPLAY;
if (0 != (result = remote_get_threadinfo (ref, set, &threadinfo)))
display_thread_info (&threadinfo);
return result;
}
static void
2000-07-30 03:48:28 +02:00
threadinfo_test_cmd (char *cmd, int tty)
{
int athread = SAMPLE_THREAD;
threadref thread;
int set;
int_to_threadref (&thread, athread);
printf_filtered ("Remote Threadinfo test\n");
if (!get_and_display_threadinfo (&thread))
printf_filtered ("FAIL cannot get thread info\n");
}
static int
2000-07-30 03:48:28 +02:00
thread_display_step (threadref *ref, void *context)
{
/* output_threadid(" threadstep ",ref); *//* simple test */
return get_and_display_threadinfo (ref);
}
static void
2000-07-30 03:48:28 +02:00
threadlist_update_test_cmd (char *cmd, int tty)
{
printf_filtered ("Remote Threadlist update test\n");
remote_threadlist_iterator (thread_display_step, 0, CRAZY_MAX_THREADS);
}
static void
init_remote_threadtests (void)
{
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
add_com ("tlist", class_obscure, threadlist_test_cmd,
_("Fetch and print the remote list of "
"thread identifiers, one pkt only"));
add_com ("tinfo", class_obscure, threadinfo_test_cmd,
_("Fetch and display info about one thread"));
add_com ("tset", class_obscure, threadset_test_cmd,
_("Test setting to a different thread"));
add_com ("tupd", class_obscure, threadlist_update_test_cmd,
_("Iterate through updating all remote thread info"));
add_com ("talive", class_obscure, threadalive_test,
_(" Remote thread alive test "));
}
#endif /* 0 */
/* Convert a thread ID to a string. Returns the string in a static
buffer. */
static char *
* linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
remote_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
static char buf[64];
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
struct remote_state *rs = get_remote_state ();
if (ptid_equal (ptid, null_ptid))
return normal_pid_to_str (ptid);
else if (ptid_is_pid (ptid))
{
/* Printing an inferior target id. */
/* When multi-process extensions are off, there's no way in the
remote protocol to know the remote process id, if there's any
at all. There's one exception --- when we're connected with
target extended-remote, and we manually attached to a process
with "attach PID". We don't record anywhere a flag that
allows us to distinguish that case from the case of
connecting with extended-remote and the stub already being
attached to a process, and reporting yes to qAttached, hence
no smart special casing here. */
if (!remote_multi_process_p (rs))
{
xsnprintf (buf, sizeof buf, "Remote target");
return buf;
}
return normal_pid_to_str (ptid);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
}
else
{
if (ptid_equal (magic_null_ptid, ptid))
xsnprintf (buf, sizeof buf, "Thread <main>");
else if (rs->extended && remote_multi_process_p (rs))
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
if (ptid_get_lwp (ptid) == 0)
return normal_pid_to_str (ptid);
else
xsnprintf (buf, sizeof buf, "Thread %d.%ld",
ptid_get_pid (ptid), ptid_get_lwp (ptid));
else
xsnprintf (buf, sizeof buf, "Thread %ld",
ptid_get_lwp (ptid));
return buf;
}
}
2005-04-15 21:58:59 +02:00
/* Get the address of the thread local variable in OBJFILE which is
stored at OFFSET within the thread local storage for thread PTID. */
static CORE_ADDR
* linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
remote_get_thread_local_address (struct target_ops *ops,
ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
2005-04-15 21:58:59 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qGetTLSAddr) != PACKET_DISABLE)
2005-04-15 21:58:59 +02:00
{
struct remote_state *rs = get_remote_state ();
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
char *p = rs->buf;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
char *endp = rs->buf + get_remote_packet_size ();
enum packet_result result;
2005-04-15 21:58:59 +02:00
strcpy (p, "qGetTLSAddr:");
p += strlen (p);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
p = write_ptid (p, endp, ptid);
2005-04-15 21:58:59 +02:00
*p++ = ',';
p += hexnumstr (p, offset);
*p++ = ',';
p += hexnumstr (p, lm);
*p++ = '\0';
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
result = packet_ok (rs->buf,
&remote_protocol_packets[PACKET_qGetTLSAddr]);
if (result == PACKET_OK)
2005-04-15 21:58:59 +02:00
{
ULONGEST result;
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
unpack_varlen_hex (rs->buf, &result);
2005-04-15 21:58:59 +02:00
return result;
}
else if (result == PACKET_UNKNOWN)
throw_error (TLS_GENERIC_ERROR,
_("Remote target doesn't support qGetTLSAddr packet"));
2005-04-15 21:58:59 +02:00
else
throw_error (TLS_GENERIC_ERROR,
_("Remote target failed to process qGetTLSAddr request"));
2005-04-15 21:58:59 +02:00
}
else
throw_error (TLS_GENERIC_ERROR,
_("TLS not supported or disabled on this target"));
2005-04-15 21:58:59 +02:00
/* Not reached. */
return 0;
}
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
/* Provide thread local base, i.e. Thread Information Block address.
Returns 1 if ptid is found and thread_local_base is non zero. */
2012-03-01 Pedro Alves <palves@redhat.com> * amd64-linux-tdep.c (amd64_linux_record_signal): Make static. * breakpoint.c (create_exception_master_breakpoint, trace_command) (ftrace_command, strace_command): Make static. * d-lang.c (_initialize_d_language): Declare. * dwarf2expr.c (_initialize_dwarf2expr): Declare. * dwarf2loc.c (_initialize_dwarf2loc): * dwarf2read.c (process_psymtab_comp_unit): Make static. * exec.c (exec_get_section_table): Make static. * i386-linux-tdep.c (i386_linux_record_signal): Make static. * infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static. * inferior.c (remove_inferior_command, add_inferior_command) (clone_inferior_command): Make static. * linux-nat.c (linux_nat_thread_address_space) (linux_nat_core_of_thread): Make static. * linux-tdep.c (_initialize_linux_tdep): Declare. * objc-lang.c (_initialize_objc_lang): Declare. * opencl-lang.c (builtin_opencl_type, opencl_language_arch_info): Make static. (_initialize_opencl_language): Declare. * record.c (_initialize_record): Declare. * remote.c (demand_private_info, remote_get_tib_address) (remote_supports_cond_tracepoints) (remote_supports_fast_tracepoints, remote_get_tracepoint_status): Make static. * skip.c (_initialize_step_skip): Declare. * symtab.c (skip_prologue_using_lineinfo): Make static. * tracepoint.c (delete_trace_state_variable) (trace_variable_command, delete_trace_variable_command) (get_uploaded_tsv, find_matching_tracepoint_location) (find_matching_tsv, create_tsv_from_upload, get_traceframe_info): Make static. * value.c (pack_unsigned_long): Make static. * varobj.c (varobj_ensure_python_env): Make static. * windows-tdep.c (_initialize_windows_tdep): Declare. * xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
static int
remote_get_tib_address (struct target_ops *self, ptid_t ptid, CORE_ADDR *addr)
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qGetTIBAddr) != PACKET_DISABLE)
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
char *endp = rs->buf + get_remote_packet_size ();
enum packet_result result;
strcpy (p, "qGetTIBAddr:");
p += strlen (p);
p = write_ptid (p, endp, ptid);
*p++ = '\0';
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
result = packet_ok (rs->buf,
&remote_protocol_packets[PACKET_qGetTIBAddr]);
if (result == PACKET_OK)
{
ULONGEST result;
unpack_varlen_hex (rs->buf, &result);
if (addr)
*addr = (CORE_ADDR) result;
return 1;
}
else if (result == PACKET_UNKNOWN)
error (_("Remote target doesn't support qGetTIBAddr packet"));
else
error (_("Remote target failed to process qGetTIBAddr request"));
}
else
error (_("qGetTIBAddr not supported or disabled on this target"));
/* Not reached. */
return 0;
}
/* Support for inferring a target description based on the current
architecture and the size of a 'g' packet. While the 'g' packet
can have any size (since optional registers can be left off the
end), some sizes are easily recognizable given knowledge of the
approximate architecture. */
struct remote_g_packet_guess
{
int bytes;
const struct target_desc *tdesc;
};
typedef struct remote_g_packet_guess remote_g_packet_guess_s;
DEF_VEC_O(remote_g_packet_guess_s);
struct remote_g_packet_data
{
VEC(remote_g_packet_guess_s) *guesses;
};
static struct gdbarch_data *remote_g_packet_data_handle;
static void *
remote_g_packet_data_init (struct obstack *obstack)
{
return OBSTACK_ZALLOC (obstack, struct remote_g_packet_data);
}
void
register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
const struct target_desc *tdesc)
{
struct remote_g_packet_data *data
= gdbarch_data (gdbarch, remote_g_packet_data_handle);
struct remote_g_packet_guess new_guess, *guess;
int ix;
gdb_assert (tdesc != NULL);
for (ix = 0;
VEC_iterate (remote_g_packet_guess_s, data->guesses, ix, guess);
ix++)
if (guess->bytes == bytes)
internal_error (__FILE__, __LINE__,
_("Duplicate g packet description added for size %d"),
bytes);
new_guess.bytes = bytes;
new_guess.tdesc = tdesc;
VEC_safe_push (remote_g_packet_guess_s, data->guesses, &new_guess);
}
/* Return 1 if remote_read_description would do anything on this target
and architecture, 0 otherwise. */
static int
remote_read_description_p (struct target_ops *target)
{
struct remote_g_packet_data *data
= gdbarch_data (target_gdbarch (), remote_g_packet_data_handle);
if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
return 1;
return 0;
}
static const struct target_desc *
remote_read_description (struct target_ops *target)
{
struct remote_g_packet_data *data
= gdbarch_data (target_gdbarch (), remote_g_packet_data_handle);
/* Do not try this during initial connection, when we do not know
whether there is a running but stopped thread. */
if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid))
return target->beneath->to_read_description (target->beneath);
if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
{
struct remote_g_packet_guess *guess;
int ix;
int bytes = send_g_packet ();
for (ix = 0;
VEC_iterate (remote_g_packet_guess_s, data->guesses, ix, guess);
ix++)
if (guess->bytes == bytes)
return guess->tdesc;
/* We discard the g packet. A minor optimization would be to
hold on to it, and fill the register cache once we have selected
an architecture, but it's too tricky to do safely. */
}
return target->beneath->to_read_description (target->beneath);
}
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
/* Remote file transfer support. This is host-initiated I/O, not
target-initiated; for target-initiated, see remote-fileio.c. */
/* If *LEFT is at least the length of STRING, copy STRING to
*BUFFER, update *BUFFER to point to the new end of the buffer, and
decrease *LEFT. Otherwise raise an error. */
static void
remote_buffer_add_string (char **buffer, int *left, char *string)
{
int len = strlen (string);
if (len > *left)
error (_("Packet too long for target."));
memcpy (*buffer, string, len);
*buffer += len;
*left -= len;
/* NUL-terminate the buffer as a convenience, if there is
room. */
if (*left)
**buffer = '\0';
}
/* If *LEFT is large enough, hex encode LEN bytes from BYTES into
*BUFFER, update *BUFFER to point to the new end of the buffer, and
decrease *LEFT. Otherwise raise an error. */
static void
remote_buffer_add_bytes (char **buffer, int *left, const gdb_byte *bytes,
int len)
{
if (2 * len > *left)
error (_("Packet too long for target."));
bin2hex (bytes, *buffer, len);
*buffer += 2 * len;
*left -= 2 * len;
/* NUL-terminate the buffer as a convenience, if there is
room. */
if (*left)
**buffer = '\0';
}
/* If *LEFT is large enough, convert VALUE to hex and add it to
*BUFFER, update *BUFFER to point to the new end of the buffer, and
decrease *LEFT. Otherwise raise an error. */
static void
remote_buffer_add_int (char **buffer, int *left, ULONGEST value)
{
int len = hexnumlen (value);
if (len > *left)
error (_("Packet too long for target."));
hexnumstr (*buffer, value);
*buffer += len;
*left -= len;
/* NUL-terminate the buffer as a convenience, if there is
room. */
if (*left)
**buffer = '\0';
}
/* Parse an I/O result packet from BUFFER. Set RETCODE to the return
value, *REMOTE_ERRNO to the remote error number or zero if none
was included, and *ATTACHMENT to point to the start of the annex
if any. The length of the packet isn't needed here; there may
be NUL bytes in BUFFER, but they will be after *ATTACHMENT.
Return 0 if the packet could be parsed, -1 if it could not. If
-1 is returned, the other variables may not be initialized. */
static int
remote_hostio_parse_result (char *buffer, int *retcode,
int *remote_errno, char **attachment)
{
char *p, *p2;
*remote_errno = 0;
*attachment = NULL;
if (buffer[0] != 'F')
return -1;
errno = 0;
*retcode = strtol (&buffer[1], &p, 16);
if (errno != 0 || p == &buffer[1])
return -1;
/* Check for ",errno". */
if (*p == ',')
{
errno = 0;
*remote_errno = strtol (p + 1, &p2, 16);
if (errno != 0 || p + 1 == p2)
return -1;
p = p2;
}
/* Check for ";attachment". If there is no attachment, the
packet should end here. */
if (*p == ';')
{
*attachment = p + 1;
return 0;
}
else if (*p == '\0')
return 0;
else
return -1;
}
/* Send a prepared I/O packet to the target and read its response.
The prepared packet is in the global RS->BUF before this function
is called, and the answer is there when we return.
COMMAND_BYTES is the length of the request to send, which may include
binary data. WHICH_PACKET is the packet configuration to check
before attempting a packet. If an error occurs, *REMOTE_ERRNO
is set to the error number and -1 is returned. Otherwise the value
returned by the function is returned.
ATTACHMENT and ATTACHMENT_LEN should be non-NULL if and only if an
attachment is expected; an error will be reported if there's a
mismatch. If one is found, *ATTACHMENT will be set to point into
the packet buffer and *ATTACHMENT_LEN will be set to the
attachment's length. */
static int
remote_hostio_send_command (int command_bytes, int which_packet,
int *remote_errno, char **attachment,
int *attachment_len)
{
struct remote_state *rs = get_remote_state ();
int ret, bytes_read;
char *attachment_tmp;
if (!rs->remote_desc
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
|| packet_support (which_packet) == PACKET_DISABLE)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
{
*remote_errno = FILEIO_ENOSYS;
return -1;
}
putpkt_binary (rs->buf, command_bytes);
bytes_read = getpkt_sane (&rs->buf, &rs->buf_size, 0);
/* If it timed out, something is wrong. Don't try to parse the
buffer. */
if (bytes_read < 0)
{
*remote_errno = FILEIO_EINVAL;
return -1;
}
switch (packet_ok (rs->buf, &remote_protocol_packets[which_packet]))
{
case PACKET_ERROR:
*remote_errno = FILEIO_EINVAL;
return -1;
case PACKET_UNKNOWN:
*remote_errno = FILEIO_ENOSYS;
return -1;
case PACKET_OK:
break;
}
if (remote_hostio_parse_result (rs->buf, &ret, remote_errno,
&attachment_tmp))
{
*remote_errno = FILEIO_EINVAL;
return -1;
}
/* Make sure we saw an attachment if and only if we expected one. */
if ((attachment_tmp == NULL && attachment != NULL)
|| (attachment_tmp != NULL && attachment == NULL))
{
*remote_errno = FILEIO_EINVAL;
return -1;
}
/* If an attachment was found, it must point into the packet buffer;
work out how many bytes there were. */
if (attachment_tmp != NULL)
{
*attachment = attachment_tmp;
*attachment_len = bytes_read - (*attachment - rs->buf);
}
return ret;
}
/* Set the filesystem remote_hostio functions that take FILENAME
arguments will use. Return 0 on success, or -1 if an error
occurs (and set *REMOTE_ERRNO). */
static int
remote_hostio_set_filesystem (struct inferior *inf, int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
int required_pid = (inf == NULL || inf->fake_pid_p) ? 0 : inf->pid;
char *p = rs->buf;
int left = get_remote_packet_size () - 1;
char arg[9];
int ret;
if (packet_support (PACKET_vFile_setfs) == PACKET_DISABLE)
return 0;
if (rs->fs_pid != -1 && required_pid == rs->fs_pid)
return 0;
remote_buffer_add_string (&p, &left, "vFile:setfs:");
xsnprintf (arg, sizeof (arg), "%x", required_pid);
remote_buffer_add_string (&p, &left, arg);
ret = remote_hostio_send_command (p - rs->buf, PACKET_vFile_setfs,
remote_errno, NULL, NULL);
if (packet_support (PACKET_vFile_setfs) == PACKET_DISABLE)
return 0;
if (ret == 0)
rs->fs_pid = required_pid;
return ret;
}
/* Implementation of to_fileio_open. */
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_hostio_open (struct target_ops *self,
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
struct inferior *inf, const char *filename,
int flags, int mode, int *remote_errno)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
int left = get_remote_packet_size () - 1;
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
return -1;
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
remote_buffer_add_string (&p, &left, "vFile:open:");
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
strlen (filename));
remote_buffer_add_string (&p, &left, ",");
remote_buffer_add_int (&p, &left, flags);
remote_buffer_add_string (&p, &left, ",");
remote_buffer_add_int (&p, &left, mode);
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_open,
remote_errno, NULL, NULL);
}
/* Implementation of to_fileio_pwrite. */
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_hostio_pwrite (struct target_ops *self,
int fd, const gdb_byte *write_buf, int len,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
ULONGEST offset, int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
int left = get_remote_packet_size ();
int out_len;
remote_buffer_add_string (&p, &left, "vFile:pwrite:");
remote_buffer_add_int (&p, &left, fd);
remote_buffer_add_string (&p, &left, ",");
remote_buffer_add_int (&p, &left, offset);
remote_buffer_add_string (&p, &left, ",");
p += remote_escape_output (write_buf, len, 1, (gdb_byte *) p, &out_len,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
get_remote_packet_size () - (p - rs->buf));
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_pwrite,
remote_errno, NULL, NULL);
}
/* Implementation of to_fileio_pread. */
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_hostio_pread (struct target_ops *self,
int fd, gdb_byte *read_buf, int len,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
ULONGEST offset, int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
char *attachment;
int left = get_remote_packet_size ();
int ret, attachment_len;
int read_len;
remote_buffer_add_string (&p, &left, "vFile:pread:");
remote_buffer_add_int (&p, &left, fd);
remote_buffer_add_string (&p, &left, ",");
remote_buffer_add_int (&p, &left, len);
remote_buffer_add_string (&p, &left, ",");
remote_buffer_add_int (&p, &left, offset);
ret = remote_hostio_send_command (p - rs->buf, PACKET_vFile_pread,
remote_errno, &attachment,
&attachment_len);
if (ret < 0)
return ret;
read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
read_buf, len);
if (read_len != ret)
error (_("Read returned %d, but %d bytes."), ret, (int) read_len);
return ret;
}
/* Implementation of to_fileio_close. */
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_hostio_close (struct target_ops *self, int fd, int *remote_errno)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
int left = get_remote_packet_size () - 1;
remote_buffer_add_string (&p, &left, "vFile:close:");
remote_buffer_add_int (&p, &left, fd);
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_close,
remote_errno, NULL, NULL);
}
/* Implementation of to_fileio_unlink. */
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_hostio_unlink (struct target_ops *self,
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
struct inferior *inf, const char *filename,
int *remote_errno)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
int left = get_remote_packet_size () - 1;
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
return -1;
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
remote_buffer_add_string (&p, &left, "vFile:unlink:");
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
strlen (filename));
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_unlink,
remote_errno, NULL, NULL);
}
/* Implementation of to_fileio_readlink. */
static char *
remote_hostio_readlink (struct target_ops *self,
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
struct inferior *inf, const char *filename,
int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
char *attachment;
int left = get_remote_packet_size ();
int len, attachment_len;
int read_len;
char *ret;
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
return NULL;
remote_buffer_add_string (&p, &left, "vFile:readlink:");
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
strlen (filename));
len = remote_hostio_send_command (p - rs->buf, PACKET_vFile_readlink,
remote_errno, &attachment,
&attachment_len);
if (len < 0)
return NULL;
ret = xmalloc (len + 1);
read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
(gdb_byte *) ret, len);
if (read_len != len)
error (_("Readlink returned %d, but %d bytes."), len, read_len);
ret[len] = '\0';
return ret;
}
/* Implementation of to_fileio_fstat. */
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
static int
remote_hostio_fstat (struct target_ops *self,
int fd, struct stat *st,
int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
int left = get_remote_packet_size ();
int attachment_len, ret;
char *attachment;
struct fio_stat fst;
int read_len;
remote_buffer_add_string (&p, &left, "vFile:fstat:");
remote_buffer_add_int (&p, &left, fd);
ret = remote_hostio_send_command (p - rs->buf, PACKET_vFile_fstat,
remote_errno, &attachment,
&attachment_len);
if (ret < 0)
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
{
if (*remote_errno != FILEIO_ENOSYS)
return ret;
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
/* Strictly we should return -1, ENOSYS here, but when
"set sysroot remote:" was implemented in August 2008
BFD's need for a stat function was sidestepped with
this hack. This was not remedied until March 2015
so we retain the previous behavior to avoid breaking
compatibility.
Note that the memset is a March 2015 addition; older
GDBs set st_size *and nothing else* so the structure
would have garbage in all other fields. This might
break something but retaining the previous behavior
here would be just too wrong. */
memset (st, 0, sizeof (struct stat));
st->st_size = INT_MAX;
return 0;
}
read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
(gdb_byte *) &fst, sizeof (fst));
if (read_len != ret)
error (_("vFile:fstat returned %d, but %d bytes."), ret, read_len);
if (read_len != sizeof (fst))
error (_("vFile:fstat returned %d bytes, but expecting %d."),
read_len, (int) sizeof (fst));
remote_fileio_to_host_stat (&fst, st);
return 0;
}
/* Implementation of to_filesystem_is_local. */
static int
remote_filesystem_is_local (struct target_ops *self)
{
/* Valgrind GDB presents itself as a remote target but works
on the local filesystem: it does not implement remote get
and users are not expected to set a sysroot. To handle
this case we treat the remote filesystem as local if the
sysroot is exactly TARGET_SYSROOT_PREFIX and if the stub
does not support vFile:open. */
if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) == 0)
{
enum packet_support ps = packet_support (PACKET_vFile_open);
if (ps == PACKET_SUPPORT_UNKNOWN)
{
int fd, remote_errno;
/* Try opening a file to probe support. The supplied
filename is irrelevant, we only care about whether
the stub recognizes the packet or not. */
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
fd = remote_hostio_open (self, NULL, "just probing",
FILEIO_O_RDONLY, 0700,
&remote_errno);
if (fd >= 0)
remote_hostio_close (self, fd, &remote_errno);
ps = packet_support (PACKET_vFile_open);
}
if (ps == PACKET_DISABLE)
{
static int warning_issued = 0;
if (!warning_issued)
{
warning (_("remote target does not support file"
" transfer, attempting to access files"
" from local filesystem."));
warning_issued = 1;
}
return 1;
}
}
return 0;
}
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
static int
remote_fileio_errno_to_host (int errnum)
{
switch (errnum)
{
case FILEIO_EPERM:
return EPERM;
case FILEIO_ENOENT:
return ENOENT;
case FILEIO_EINTR:
return EINTR;
case FILEIO_EIO:
return EIO;
case FILEIO_EBADF:
return EBADF;
case FILEIO_EACCES:
return EACCES;
case FILEIO_EFAULT:
return EFAULT;
case FILEIO_EBUSY:
return EBUSY;
case FILEIO_EEXIST:
return EEXIST;
case FILEIO_ENODEV:
return ENODEV;
case FILEIO_ENOTDIR:
return ENOTDIR;
case FILEIO_EISDIR:
return EISDIR;
case FILEIO_EINVAL:
return EINVAL;
case FILEIO_ENFILE:
return ENFILE;
case FILEIO_EMFILE:
return EMFILE;
case FILEIO_EFBIG:
return EFBIG;
case FILEIO_ENOSPC:
return ENOSPC;
case FILEIO_ESPIPE:
return ESPIPE;
case FILEIO_EROFS:
return EROFS;
case FILEIO_ENOSYS:
return ENOSYS;
case FILEIO_ENAMETOOLONG:
return ENAMETOOLONG;
}
return -1;
}
static char *
remote_hostio_error (int errnum)
{
int host_error = remote_fileio_errno_to_host (errnum);
if (host_error == -1)
error (_("Unknown remote I/O error %d"), errnum);
else
error (_("Remote I/O error: %s"), safe_strerror (host_error));
}
static void
remote_hostio_close_cleanup (void *opaque)
{
int fd = *(int *) opaque;
int remote_errno;
remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
}
void
remote_file_put (const char *local_file, const char *remote_file, int from_tty)
{
struct cleanup *back_to, *close_cleanup;
int retcode, fd, remote_errno, bytes, io_size;
FILE *file;
gdb_byte *buffer;
int bytes_in_buffer;
int saw_eof;
ULONGEST offset;
struct remote_state *rs = get_remote_state ();
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (!rs->remote_desc)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
error (_("command can only be used with remote target"));
PR gdb/7912: * Makefile.in (SFILES): Add filestuff.c (COMMON_OBS): Add filestuff.o. (filestuff.o): New target. * auto-load.c (auto_load_objfile_script_1): Use gdb_fopen_cloexec. * auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec. * cli/cli-cmds.c (shell_escape): Call close_most_fds. * cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec. * common/agent.c (gdb_connect_sync_socket): Use gdb_socket_cloexec. * common/filestuff.c: New file. * common/filestuff.h: New file. * common/linux-osdata.c (linux_common_core_of_thread) (command_from_pid, commandline_from_pid, print_source_lines) (linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use gdb_fopen_cloexec. * common/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_has_state): Use gdb_fopen_cloexec. * config.in, configure: Rebuild. * configure.ac: Don't check for sys/socket.h. Check for fdwalk, pipe2. * corelow.c (core_open): Use gdb_open_cloexec. * dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec. * fork-child.c (fork_inferior): Call close_most_fds. * gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec. * inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec. * linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals): Use gdb_fopen_cloexec. (linux_proc_xfer_partial, linux_proc_xfer_spu): Use gdb_open_cloexec. (linux_async_pipe): Use gdb_pipe_cloexec. * remote-fileio.c (remote_fileio_func_open): Use gdb_open_cloexec. * remote.c (remote_file_put, remote_file_get): Use gdb_fopen_cloexec. * ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec, close_most_fds. * ser-tcp.c (net_open): Use gdb_socket_cloexec. * ser-unix.c (hardwire_open): Use gdb_open_cloexec. * solib.c (solib_find): Use gdb_open_cloexec. * source.c (openp, find_and_open_source): Use gdb_open_cloexec. * tracepoint.c (tfile_start): Use gdb_fopen_cloexec. (tfile_open): Use gdb_open_cloexec. * tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec. * ui-file.c (gdb_fopen): Use gdb_fopen_cloexec. * xml-support.c (xml_fetch_content_from_file): Use gdb_fopen_cloexec. * main.c (captured_main): Call notice_open_fds. gdbserver * Makefile.in (SFILES): Add filestuff.c. (OBS): Add filestuff.o. (filestuff.o): New target. * config.in, configure: Rebuild. * configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
file = gdb_fopen_cloexec (local_file, "rb");
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (file == NULL)
perror_with_name (local_file);
back_to = make_cleanup_fclose (file);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
fd = remote_hostio_open (find_target_at (process_stratum), NULL,
remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
| FILEIO_O_TRUNC),
0700, &remote_errno);
if (fd == -1)
remote_hostio_error (remote_errno);
/* Send up to this many bytes at once. They won't all fit in the
remote packet limit, so we'll transfer slightly fewer. */
io_size = get_remote_packet_size ();
buffer = xmalloc (io_size);
make_cleanup (xfree, buffer);
close_cleanup = make_cleanup (remote_hostio_close_cleanup, &fd);
bytes_in_buffer = 0;
saw_eof = 0;
offset = 0;
while (bytes_in_buffer || !saw_eof)
{
if (!saw_eof)
{
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
bytes = fread (buffer + bytes_in_buffer, 1,
io_size - bytes_in_buffer,
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
file);
if (bytes == 0)
{
if (ferror (file))
error (_("Error reading %s."), local_file);
else
{
/* EOF. Unless there is something still in the
buffer from the last iteration, we are done. */
saw_eof = 1;
if (bytes_in_buffer == 0)
break;
}
}
}
else
bytes = 0;
bytes += bytes_in_buffer;
bytes_in_buffer = 0;
retcode = remote_hostio_pwrite (find_target_at (process_stratum),
fd, buffer, bytes,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
offset, &remote_errno);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (retcode < 0)
remote_hostio_error (remote_errno);
else if (retcode == 0)
error (_("Remote write of %d bytes returned 0!"), bytes);
else if (retcode < bytes)
{
/* Short write. Save the rest of the read data for the next
write. */
bytes_in_buffer = bytes - retcode;
memmove (buffer, buffer + retcode, bytes_in_buffer);
}
offset += retcode;
}
discard_cleanups (close_cleanup);
if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
remote_hostio_error (remote_errno);
if (from_tty)
printf_filtered (_("Successfully sent file \"%s\".\n"), local_file);
do_cleanups (back_to);
}
void
remote_file_get (const char *remote_file, const char *local_file, int from_tty)
{
struct cleanup *back_to, *close_cleanup;
int fd, remote_errno, bytes, io_size;
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
FILE *file;
gdb_byte *buffer;
ULONGEST offset;
struct remote_state *rs = get_remote_state ();
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (!rs->remote_desc)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
error (_("command can only be used with remote target"));
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
fd = remote_hostio_open (find_target_at (process_stratum), NULL,
remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (fd == -1)
remote_hostio_error (remote_errno);
PR gdb/7912: * Makefile.in (SFILES): Add filestuff.c (COMMON_OBS): Add filestuff.o. (filestuff.o): New target. * auto-load.c (auto_load_objfile_script_1): Use gdb_fopen_cloexec. * auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec. * cli/cli-cmds.c (shell_escape): Call close_most_fds. * cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec. * common/agent.c (gdb_connect_sync_socket): Use gdb_socket_cloexec. * common/filestuff.c: New file. * common/filestuff.h: New file. * common/linux-osdata.c (linux_common_core_of_thread) (command_from_pid, commandline_from_pid, print_source_lines) (linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use gdb_fopen_cloexec. * common/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_has_state): Use gdb_fopen_cloexec. * config.in, configure: Rebuild. * configure.ac: Don't check for sys/socket.h. Check for fdwalk, pipe2. * corelow.c (core_open): Use gdb_open_cloexec. * dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec. * fork-child.c (fork_inferior): Call close_most_fds. * gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec. * inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec. * linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals): Use gdb_fopen_cloexec. (linux_proc_xfer_partial, linux_proc_xfer_spu): Use gdb_open_cloexec. (linux_async_pipe): Use gdb_pipe_cloexec. * remote-fileio.c (remote_fileio_func_open): Use gdb_open_cloexec. * remote.c (remote_file_put, remote_file_get): Use gdb_fopen_cloexec. * ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec, close_most_fds. * ser-tcp.c (net_open): Use gdb_socket_cloexec. * ser-unix.c (hardwire_open): Use gdb_open_cloexec. * solib.c (solib_find): Use gdb_open_cloexec. * source.c (openp, find_and_open_source): Use gdb_open_cloexec. * tracepoint.c (tfile_start): Use gdb_fopen_cloexec. (tfile_open): Use gdb_open_cloexec. * tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec. * ui-file.c (gdb_fopen): Use gdb_fopen_cloexec. * xml-support.c (xml_fetch_content_from_file): Use gdb_fopen_cloexec. * main.c (captured_main): Call notice_open_fds. gdbserver * Makefile.in (SFILES): Add filestuff.c. (OBS): Add filestuff.o. (filestuff.o): New target. * config.in, configure: Rebuild. * configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
file = gdb_fopen_cloexec (local_file, "wb");
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (file == NULL)
perror_with_name (local_file);
back_to = make_cleanup_fclose (file);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
/* Send up to this many bytes at once. They won't all fit in the
remote packet limit, so we'll transfer slightly fewer. */
io_size = get_remote_packet_size ();
buffer = xmalloc (io_size);
make_cleanup (xfree, buffer);
close_cleanup = make_cleanup (remote_hostio_close_cleanup, &fd);
offset = 0;
while (1)
{
bytes = remote_hostio_pread (find_target_at (process_stratum),
fd, buffer, io_size, offset, &remote_errno);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (bytes == 0)
/* Success, but no bytes, means end-of-file. */
break;
if (bytes == -1)
remote_hostio_error (remote_errno);
offset += bytes;
bytes = fwrite (buffer, 1, bytes, file);
if (bytes == 0)
perror_with_name (local_file);
}
discard_cleanups (close_cleanup);
if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
remote_hostio_error (remote_errno);
if (from_tty)
printf_filtered (_("Successfully fetched file \"%s\".\n"), remote_file);
do_cleanups (back_to);
}
void
remote_file_delete (const char *remote_file, int from_tty)
{
int retcode, remote_errno;
struct remote_state *rs = get_remote_state ();
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (!rs->remote_desc)
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
error (_("command can only be used with remote target"));
retcode = remote_hostio_unlink (find_target_at (process_stratum),
Add "inferior" argument to some target_fileio functions This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
2015-06-10 15:28:43 +02:00
NULL, remote_file, &remote_errno);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
if (retcode == -1)
remote_hostio_error (remote_errno);
if (from_tty)
printf_filtered (_("Successfully deleted file \"%s\".\n"), remote_file);
}
static void
remote_put_command (char *args, int from_tty)
{
struct cleanup *back_to;
char **argv;
if (args == NULL)
error_no_arg (_("file to put"));
argv = gdb_buildargv (args);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
back_to = make_cleanup_freeargv (argv);
if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
error (_("Invalid parameters to remote put"));
remote_file_put (argv[0], argv[1], from_tty);
do_cleanups (back_to);
}
static void
remote_get_command (char *args, int from_tty)
{
struct cleanup *back_to;
char **argv;
if (args == NULL)
error_no_arg (_("file to get"));
argv = gdb_buildargv (args);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
back_to = make_cleanup_freeargv (argv);
if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
error (_("Invalid parameters to remote get"));
remote_file_get (argv[0], argv[1], from_tty);
do_cleanups (back_to);
}
static void
remote_delete_command (char *args, int from_tty)
{
struct cleanup *back_to;
char **argv;
if (args == NULL)
error_no_arg (_("file to delete"));
argv = gdb_buildargv (args);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
back_to = make_cleanup_freeargv (argv);
if (argv[0] == NULL || argv[1] != NULL)
error (_("Invalid parameters to remote delete"));
remote_file_delete (argv[0], from_tty);
do_cleanups (back_to);
}
static void
remote_command (char *args, int from_tty)
{
make calls to help_list use enumerator Currently there are many calls to help_list that pass the constant -1 as the "class" value. However, the parameter is declared as being of type enum command_class, and uses of the constant violate this abstraction. This patch fixes the error everywhere it occurs in the gdb sources. Tested by rebuilding. 2014-06-13 Tom Tromey <tromey@redhat.com> * cp-support.c (maint_cplus_command): Pass all_commands, not -1, to help_list. * guile/guile.c (info_guile_command): Pass all_commands, not -1, to help_list. * tui/tui-win.c (tui_command): Pass all_commands, not -1, to help_list. * tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to help_list.Pass all_commands, not -1, to help_list. * cli/cli-dump.c (dump_command, append_command) (srec_dump_command, ihex_dump_command, tekhex_dump_command) (binary_dump_command, binary_append_command): Pass all_commands, not -1, to help_list. * cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not -1, to help_list. * valprint.c (set_print, set_print_raw): Pass all_commands, not -1, to help_list. * typeprint.c (set_print_type): Pass all_commands, not -1, to help_list. * top.c (set_history): Pass all_commands, not -1, to help_list. * target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass all_commands, not -1, to help_list. * symfile.c (overlay_command): Pass all_commands, not -1, to help_list. * spu-tdep.c (info_spu_command): Pass all_commands, not -1, to help_list. * serial.c (serial_set_cmd): Pass all_commands, not -1, to help_list. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not -1, to help_list. * remote.c (remote_command, set_remote_cmd): Pass all_commands, not -1, to help_list. * ravenscar-thread.c (set_ravenscar_command): Pass all_commands, not -1, to help_list. * maint.c (maintenance_command, maintenance_info_command) (maintenance_print_command, maintenance_set_cmd): Pass all_commands, not -1, to help_list. * macrocmd.c (macro_command): Pass all_commands, not -1, to help_list. * language.c (set_check): Pass all_commands, not -1, to help_list. * infcmd.c (unset_command): Pass all_commands, not -1, to help_list. * frame.c (set_backtrace_cmd): Pass all_commands, not -1, to help_list. * dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to help_list. * dcache.c (set_dcache_command): Pass all_commands, not -1, to help_list. * breakpoint.c (save_command): Pass all_commands, not -1, to help_list. * ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass all_commands, not -1, to help_list.
2014-06-05 16:25:00 +02:00
help_list (remote_cmdlist, "remote ", all_commands, gdb_stdout);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
}
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
static int
remote_can_execute_reverse (struct target_ops *self)
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_bs) == PACKET_ENABLE
|| packet_support (PACKET_bc) == PACKET_ENABLE)
return 1;
else
return 0;
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static int
remote_supports_non_stop (struct target_ops *self)
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
{
return 1;
}
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
static int
remote_supports_disable_randomization (struct target_ops *self)
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
{
/* Only supported in extended mode. */
return 0;
}
static int
remote_supports_multi_process (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
/* Only extended-remote handles being attached to multiple
processes, even though plain remote can use the multi-process
thread id extensions, so that GDB knows the target process's
PID. */
return rs->extended && remote_multi_process_p (rs);
}
2012-03-01 Pedro Alves <palves@redhat.com> * amd64-linux-tdep.c (amd64_linux_record_signal): Make static. * breakpoint.c (create_exception_master_breakpoint, trace_command) (ftrace_command, strace_command): Make static. * d-lang.c (_initialize_d_language): Declare. * dwarf2expr.c (_initialize_dwarf2expr): Declare. * dwarf2loc.c (_initialize_dwarf2loc): * dwarf2read.c (process_psymtab_comp_unit): Make static. * exec.c (exec_get_section_table): Make static. * i386-linux-tdep.c (i386_linux_record_signal): Make static. * infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static. * inferior.c (remove_inferior_command, add_inferior_command) (clone_inferior_command): Make static. * linux-nat.c (linux_nat_thread_address_space) (linux_nat_core_of_thread): Make static. * linux-tdep.c (_initialize_linux_tdep): Declare. * objc-lang.c (_initialize_objc_lang): Declare. * opencl-lang.c (builtin_opencl_type, opencl_language_arch_info): Make static. (_initialize_opencl_language): Declare. * record.c (_initialize_record): Declare. * remote.c (demand_private_info, remote_get_tib_address) (remote_supports_cond_tracepoints) (remote_supports_fast_tracepoints, remote_get_tracepoint_status): Make static. * skip.c (_initialize_step_skip): Declare. * symtab.c (skip_prologue_using_lineinfo): Make static. * tracepoint.c (delete_trace_state_variable) (trace_variable_command, delete_trace_variable_command) (get_uploaded_tsv, find_matching_tracepoint_location) (find_matching_tsv, create_tsv_from_upload, get_traceframe_info): Make static. * value.c (pack_unsigned_long): Make static. * varobj.c (varobj_ensure_python_env): Make static. * windows-tdep.c (_initialize_windows_tdep): Declare. * xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
static int
remote_supports_cond_tracepoints (void)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_ConditionalTracepoints) == PACKET_ENABLE;
}
static int
remote_supports_cond_breakpoints (struct target_ops *self)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_ConditionalBreakpoints) == PACKET_ENABLE;
}
2012-03-01 Pedro Alves <palves@redhat.com> * amd64-linux-tdep.c (amd64_linux_record_signal): Make static. * breakpoint.c (create_exception_master_breakpoint, trace_command) (ftrace_command, strace_command): Make static. * d-lang.c (_initialize_d_language): Declare. * dwarf2expr.c (_initialize_dwarf2expr): Declare. * dwarf2loc.c (_initialize_dwarf2loc): * dwarf2read.c (process_psymtab_comp_unit): Make static. * exec.c (exec_get_section_table): Make static. * i386-linux-tdep.c (i386_linux_record_signal): Make static. * infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static. * inferior.c (remove_inferior_command, add_inferior_command) (clone_inferior_command): Make static. * linux-nat.c (linux_nat_thread_address_space) (linux_nat_core_of_thread): Make static. * linux-tdep.c (_initialize_linux_tdep): Declare. * objc-lang.c (_initialize_objc_lang): Declare. * opencl-lang.c (builtin_opencl_type, opencl_language_arch_info): Make static. (_initialize_opencl_language): Declare. * record.c (_initialize_record): Declare. * remote.c (demand_private_info, remote_get_tib_address) (remote_supports_cond_tracepoints) (remote_supports_fast_tracepoints, remote_get_tracepoint_status): Make static. * skip.c (_initialize_step_skip): Declare. * symtab.c (skip_prologue_using_lineinfo): Make static. * tracepoint.c (delete_trace_state_variable) (trace_variable_command, delete_trace_variable_command) (get_uploaded_tsv, find_matching_tracepoint_location) (find_matching_tsv, create_tsv_from_upload, get_traceframe_info): Make static. * value.c (pack_unsigned_long): Make static. * varobj.c (varobj_ensure_python_env): Make static. * windows-tdep.c (_initialize_windows_tdep): Declare. * xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
static int
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
remote_supports_fast_tracepoints (void)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_FastTracepoints) == PACKET_ENABLE;
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
static int
remote_supports_static_tracepoints (void)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_StaticTracepoints) == PACKET_ENABLE;
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
}
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
static int
remote_supports_install_in_trace (void)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_InstallInTrace) == PACKET_ENABLE;
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
}
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
static int
remote_supports_enable_disable_tracepoint (struct target_ops *self)
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return (packet_support (PACKET_EnableDisableTracepoints_feature)
== PACKET_ENABLE);
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
}
static int
remote_supports_string_tracing (struct target_ops *self)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_tracenz_feature) == PACKET_ENABLE;
}
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
static int
remote_can_run_breakpoint_commands (struct target_ops *self)
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return packet_support (PACKET_BreakpointCommands) == PACKET_ENABLE;
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_trace_init (struct target_ops *self)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
putpkt ("QTinit");
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK") != 0)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
error (_("Target does not support this command."));
}
static void free_actions_list (char **actions_list);
static void free_actions_list_cleanup_wrapper (void *);
static void
free_actions_list_cleanup_wrapper (void *al)
{
free_actions_list (al);
}
static void
free_actions_list (char **actions_list)
{
int ndx;
if (actions_list == 0)
return;
for (ndx = 0; actions_list[ndx]; ndx++)
xfree (actions_list[ndx]);
xfree (actions_list);
}
/* Recursive routine to walk through command list including loops, and
download packets for each command. */
static void
remote_download_command_source (int num, ULONGEST addr,
struct command_line *cmds)
{
struct remote_state *rs = get_remote_state ();
struct command_line *cmd;
for (cmd = cmds; cmd; cmd = cmd->next)
{
QUIT; /* Allow user to bail out with ^C. */
strcpy (rs->buf, "QTDPsrc:");
encode_source_string (num, addr, "cmd", cmd->line,
rs->buf + strlen (rs->buf),
rs->buf_size - strlen (rs->buf));
putpkt (rs->buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))
warning (_("Target does not support source download."));
if (cmd->control_type == while_control
|| cmd->control_type == while_stepping_control)
{
remote_download_command_source (num, addr, *cmd->body_list);
QUIT; /* Allow user to bail out with ^C. */
strcpy (rs->buf, "QTDPsrc:");
encode_source_string (num, addr, "cmd", "end",
rs->buf + strlen (rs->buf),
rs->buf_size - strlen (rs->buf));
putpkt (rs->buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))
warning (_("Target does not support source download."));
}
}
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
#define BUF_SIZE 2048
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
CORE_ADDR tpaddr;
char addrbuf[40];
char buf[BUF_SIZE];
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
char **tdp_actions;
char **stepping_actions;
int ndx;
struct cleanup *old_chain = NULL;
struct agent_expr *aexpr;
struct cleanup *aexpr_chain = NULL;
char *pkt;
struct breakpoint *b = loc->owner;
2011-07-25 Pedro Alves <pedro@codesourcery.com> gdb/ * breakpoint.h (print_recreate_thread): Declare. (struct breakpoint): Move step_count, pass_count, number_on_target, static_trace_marker_id, static_trace_marker_id_idx ... (struct tracepoint): ... to this new struct. (get_tracepoint, get_tracepoint_by_number_on_target) (get_tracepoint_by_number): Change return type to struct tracepoint pointer. * breakpoint.c (is_tracepoint_type): New, factored out from is_tracepoint. (is_tracepoint): Adjust. (print_one_breakpoint_location): Cast to struct tracepoint as necessary, and adjust. (print_recreate_catch_fork, print_recreate_catch_vfork) (print_recreate_catch_syscall, print_recreate_catch_exec): Call print_recreate_thread. (init_breakpoint_sal): New, factored out from create_breakpoint_sal. (create_breakpoint_sal): Reimplement. (create_breakpoint): Allocate a struct tracecepoint if the caller wanted a tracepoint. Use init_breakpoint_sal and install_breakpoint. (print_recreate_ranged_breakpoint, print_recreate_watchpoint) (print_recreate_masked_watchpoint) (print_recreate_exception_catchpoint): Call print_recreate_thread. (tracepoint_print_one_detail): Adjust. (tracepoint_print_recreate): Adjust. Call print_recreate_thread. Dump the pass count here. (update_static_tracepoint): Adjust. (addr_string_to_sals): Adjust. (create_tracepoint_from_upload): Adjust. Change return type to struct tracepoint pointer. (trace_pass_set_count): Change parameter type to struct tracepoint pointer, and adjust. (trace_pass_command): Adjust. (get_tracepoint, get_tracepoint_by_number_on_target) (get_tracepoint_by_number): Change return type to struct tracepoint pointer, and adjust. (print_recreate_thread): New, factored out from save_breakpoints. (save_breakpoints): Don't print thread and task and passcount recreation here. * remote.c (remote_download_tracepoint): Adjust. * tracepoint.c (trace_actions_command, validate_actionline) (start_tracing, tfind_1, trace_find_tracepoint_command) (trace_dump_command): Adjust. (find_matching_tracepoint): Change return type to struct tracepoint pointer, and adjust. (merge_uploaded_tracepoints, tfile_get_traceframe_address) (tfile_trace_find, tfile_fetch_registers): Adjust. * tracepoint.h (create_tracepoint_from_upload): Change return type to struct tracepoint pointer. * ada-lang.c (print_recreate_exception): Call print_recreate_thread. * mi/mi-cmd-break.c (mi_cmd_break_passcount): Adjust.
2011-07-25 13:24:44 +02:00
struct tracepoint *t = (struct tracepoint *) b;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
gdb/ 2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * gdb.texinfo (GDB/MI Tracepoint Commands): Document -trace-frame-collected. gdb: 2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * mi/mi-cmds.c (mi_cmds): Register -trace-frame-collected. * mi/mi-cmds.h (mi_cmd_trace_frame_collected): Declare. * mi/mi-main.c (print_variable_or_computed): New function. (mi_cmd_trace_frame_collected): New function. * tracepoint.c (find_trace_state_variable_by_number): New. (struct traceframe_info): Move to tracepoint.h (struct collection_list): Likewise. (do_collect_symbol): Include locals and arguments in the wholly collected variables list. (clear_collection_list): Clear wholly collected variables list and computed variables list. (append_exp): New function. (encode_actions_1): Include variables in the wholly collected variables list. Include memory ranges and full-fledged expressions in the computed expressions list. (encode_actions): Move some code to ... Return the cleanup chain. (encode_actions_rsp): ... here. New function. (get_traceframe_location, get_traceframe_info): Remove static. * tracepoint.h (struct memrange): Moved from tracepoint.c. (struct collection_list): Moved from tracepoint.c. Add two new fields 'wholly_collected' and 'computed'. (find_trace_state_variable_by_number): Declare. (encode_actions): Adjust declaration. (encode_actions_rsp): Declare. (get_traceframe_info, get_traceframe_location): Declare. * NEWS: Mention new MI command -trace-frame-collected.
2013-06-26 10:17:27 +02:00
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
old_chain = make_cleanup (free_actions_list_cleanup_wrapper,
tdp_actions);
(void) make_cleanup (free_actions_list_cleanup_wrapper,
stepping_actions);
tpaddr = loc->address;
sprintf_vma (addrbuf, tpaddr);
xsnprintf (buf, BUF_SIZE, "QTDP:%x:%s:%c:%lx:%x", b->number,
addrbuf, /* address */
(b->enable_state == bp_enabled ? 'E' : 'D'),
t->step_count, t->pass_count);
/* Fast tracepoints are mostly handled by the target, but we can
tell the target how big of an instruction block should be moved
around. */
if (b->type == bp_fast_tracepoint)
{
/* Only test for support at download time; we may not know
target capabilities at definition time. */
if (remote_supports_fast_tracepoints ())
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
Remove isize output argument from fast_tracepoint_valid_at This patch removes the isize output argument from the fast_tracepoint_valid_at gdbarch hook. It was used to return the size of the instruction that needs to be replaced when installing a fast tracepoint. Instead of getting this value from the fast_tracepoint_valid_at hook, we can call the gdb_insn_length function. If we do not do this, then architectures which do not have a restriction on where to install the fast tracepoint will send uninitialized memory off to GDBserver. See remote_download_tracepoint: ~~~ int isize; if (gdbarch_fast_tracepoint_valid_at (target_gdbarch (), tpaddr, &isize, NULL)) xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x", isize); ~~~ The default implementation of fast_tracepoint_valid_at will not set isize resulting in uninitialized memory being sent. Later on, GDBserver could use this information to compute a jump offset. gdb/ChangeLog: * arch-utils.c (default_fast_tracepoint_valid_at): Remove unused isize argument. * arch-utils.h (default_fast_tracepoint_valid_at): Likewise. * breakpoint.c (check_fast_tracepoint_sals): Adjust call to gdbarch_fast_tracepoint_valid_at. * gdbarch.sh (fast_tracepoint_valid_at): Remove isize argument. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): Remove isize argument. Do not set it. * remote.c (remote_download_tracepoint): Adjust call to gdbarch_fast_tracepoint_valid_at. Call gdb_insn_length to get the instruction length.
2015-07-30 19:05:00 +02:00
if (gdbarch_fast_tracepoint_valid_at (loc->gdbarch, tpaddr,
NULL))
xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
Remove isize output argument from fast_tracepoint_valid_at This patch removes the isize output argument from the fast_tracepoint_valid_at gdbarch hook. It was used to return the size of the instruction that needs to be replaced when installing a fast tracepoint. Instead of getting this value from the fast_tracepoint_valid_at hook, we can call the gdb_insn_length function. If we do not do this, then architectures which do not have a restriction on where to install the fast tracepoint will send uninitialized memory off to GDBserver. See remote_download_tracepoint: ~~~ int isize; if (gdbarch_fast_tracepoint_valid_at (target_gdbarch (), tpaddr, &isize, NULL)) xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x", isize); ~~~ The default implementation of fast_tracepoint_valid_at will not set isize resulting in uninitialized memory being sent. Later on, GDBserver could use this information to compute a jump offset. gdb/ChangeLog: * arch-utils.c (default_fast_tracepoint_valid_at): Remove unused isize argument. * arch-utils.h (default_fast_tracepoint_valid_at): Likewise. * breakpoint.c (check_fast_tracepoint_sals): Adjust call to gdbarch_fast_tracepoint_valid_at. * gdbarch.sh (fast_tracepoint_valid_at): Remove isize argument. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): Remove isize argument. Do not set it. * remote.c (remote_download_tracepoint): Adjust call to gdbarch_fast_tracepoint_valid_at. Call gdb_insn_length to get the instruction length.
2015-07-30 19:05:00 +02:00
gdb_insn_length (loc->gdbarch, tpaddr));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
else
/* If it passed validation at definition but fails now,
something is very wrong. */
internal_error (__FILE__, __LINE__,
_("Fast tracepoint not "
"valid during download"));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
else
/* Fast tracepoints are functionally identical to regular
tracepoints, so don't take lack of support as a reason to
give up on the trace run. */
warning (_("Target does not support fast tracepoints, "
"downloading %d as regular tracepoint"), b->number);
}
else if (b->type == bp_static_tracepoint)
{
/* Only test for support at download time; we may not know
target capabilities at definition time. */
if (remote_supports_static_tracepoints ())
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
{
struct static_tracepoint_marker marker;
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
if (target_static_tracepoint_marker_at (tpaddr, &marker))
strcat (buf, ":S");
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
else
error (_("Static tracepoint not valid during download"));
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
}
else
/* Fast tracepoints are functionally identical to regular
tracepoints, so don't take lack of support as a reason
to give up on the trace run. */
error (_("Target does not support static tracepoints"));
}
/* If the tracepoint has a conditional, make it into an agent
expression and append to the definition. */
if (loc->cond)
{
/* Only test support at download time, we may not know target
capabilities at definition time. */
if (remote_supports_cond_tracepoints ())
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
aexpr = gen_eval_for_expr (tpaddr, loc->cond);
aexpr_chain = make_cleanup_free_agent_expr (aexpr);
xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,",
aexpr->len);
pkt = buf + strlen (buf);
for (ndx = 0; ndx < aexpr->len; ++ndx)
pkt = pack_hex_byte (pkt, aexpr->buf[ndx]);
*pkt = '\0';
do_cleanups (aexpr_chain);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
else
warning (_("Target does not support conditional tracepoints, "
"ignoring tp %d cond"), b->number);
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
2011-07-25 Pedro Alves <pedro@codesourcery.com> gdb/ * breakpoint.h (print_recreate_thread): Declare. (struct breakpoint): Move step_count, pass_count, number_on_target, static_trace_marker_id, static_trace_marker_id_idx ... (struct tracepoint): ... to this new struct. (get_tracepoint, get_tracepoint_by_number_on_target) (get_tracepoint_by_number): Change return type to struct tracepoint pointer. * breakpoint.c (is_tracepoint_type): New, factored out from is_tracepoint. (is_tracepoint): Adjust. (print_one_breakpoint_location): Cast to struct tracepoint as necessary, and adjust. (print_recreate_catch_fork, print_recreate_catch_vfork) (print_recreate_catch_syscall, print_recreate_catch_exec): Call print_recreate_thread. (init_breakpoint_sal): New, factored out from create_breakpoint_sal. (create_breakpoint_sal): Reimplement. (create_breakpoint): Allocate a struct tracecepoint if the caller wanted a tracepoint. Use init_breakpoint_sal and install_breakpoint. (print_recreate_ranged_breakpoint, print_recreate_watchpoint) (print_recreate_masked_watchpoint) (print_recreate_exception_catchpoint): Call print_recreate_thread. (tracepoint_print_one_detail): Adjust. (tracepoint_print_recreate): Adjust. Call print_recreate_thread. Dump the pass count here. (update_static_tracepoint): Adjust. (addr_string_to_sals): Adjust. (create_tracepoint_from_upload): Adjust. Change return type to struct tracepoint pointer. (trace_pass_set_count): Change parameter type to struct tracepoint pointer, and adjust. (trace_pass_command): Adjust. (get_tracepoint, get_tracepoint_by_number_on_target) (get_tracepoint_by_number): Change return type to struct tracepoint pointer, and adjust. (print_recreate_thread): New, factored out from save_breakpoints. (save_breakpoints): Don't print thread and task and passcount recreation here. * remote.c (remote_download_tracepoint): Adjust. * tracepoint.c (trace_actions_command, validate_actionline) (start_tracing, tfind_1, trace_find_tracepoint_command) (trace_dump_command): Adjust. (find_matching_tracepoint): Change return type to struct tracepoint pointer, and adjust. (merge_uploaded_tracepoints, tfile_get_traceframe_address) (tfile_trace_find, tfile_fetch_registers): Adjust. * tracepoint.h (create_tracepoint_from_upload): Change return type to struct tracepoint pointer. * ada-lang.c (print_recreate_exception): Call print_recreate_thread. * mi/mi-cmd-break.c (mi_cmd_break_passcount): Adjust.
2011-07-25 13:24:44 +02:00
if (b->commands || *default_collect)
strcat (buf, "-");
putpkt (buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))
error (_("Target does not support tracepoints."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
/* do_single_steps (t); */
if (tdp_actions)
{
for (ndx = 0; tdp_actions[ndx]; ndx++)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
QUIT; /* Allow user to bail out with ^C. */
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c",
b->number, addrbuf, /* address */
tdp_actions[ndx],
((tdp_actions[ndx + 1] || stepping_actions)
? '-' : 0));
putpkt (buf);
remote_get_noisy_reply (&target_buf,
&target_buf_size);
if (strcmp (target_buf, "OK"))
error (_("Error on target while setting tracepoints."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
}
if (stepping_actions)
{
for (ndx = 0; stepping_actions[ndx]; ndx++)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
QUIT; /* Allow user to bail out with ^C. */
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
b->number, addrbuf, /* address */
((ndx == 0) ? "S" : ""),
stepping_actions[ndx],
(stepping_actions[ndx + 1] ? "-" : ""));
putpkt (buf);
remote_get_noisy_reply (&target_buf,
&target_buf_size);
if (strcmp (target_buf, "OK"))
error (_("Error on target while setting tracepoints."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
}
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE)
{
Explicit locations: use new location API This patch converts the code base to use the new struct event_location API being introduced. This patch preserves the current functionality and adds no new features. The "big picture" API usage introduced by this patch may be illustrated with a simple exmaple. Where previously developers would write: void my_command (char *arg, int from_tty) { create_breakpoint (..., arg, ...); ... } one now uses: void my_command (char *arg, int from_tty) { struct event_locaiton *location; struct cleanup *back_to; location = string_to_event_locaiton (&arg, ...); back_to = make_cleanup_delete_event_location (location); create_breakpoint (..., location, ...); do_cleanups (back_to); } Linespec-decoding functions (now called location-decoding) such as decode_line_full no longer skip argument pointers over processed input. That functionality has been moved into string_to_event_location as demonstrated above. gdb/ChangeLog * ax-gdb.c: Include location.h. (agent_command_1) Use linespec location instead of address string. * break-catch-throw.c: Include location.h. (re_set_exception_catchpoint): Use linespec locations instead of address strings. * breakpoint.c: Include location.h. (create_overlay_event_breakpoint, create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint, update_breakpoints_after_exec): Use linespec location instead of address string. (print_breakpoint_location): Use locations and event_location_to_string. Print extra_string for pending locations for non-MI streams. (print_one_breakpoint_location): Use locations and event_location_to_string. (init_raw_breakpoint_without_location): Initialize b->location. (create_thread_event_breakpoint): Use linespec location instead of address string. (init_breakpoint_sal): Likewise. Only save extra_string if it is non-NULL and not the empty string. Use event_location_to_string instead of `addr_string'. Constify `p' and `endp'. Use skip_spaces_const/skip_space_const instead of non-const versions. Copy the location into the breakpoint. If LOCATION is NULL, save the breakpoint address as a linespec location instead of an address string. (create_breakpoint_sal): Change `addr_string' parameter to a struct event_location. All uses updated. (create_breakpoints_sal): Likewise for local variable `addr_string'. (parse_breakpoint_sals): Use locations instead of address strings. Remove check for empty linespec with conditional. Refactor. (decode_static_tracepoint_spec): Make argument const and update function. (create_breakpoint): Change `arg' to a struct event_location and rename. Remove `copy_arg' and `addr_start'. If EXTRA_STRING is empty, set it to NULL. Don't populate `canonical' for pending breakpoints. Pass `extra_string' to find_condition_and_thread. Clear `extra_string' if `rest' was NULL. Do not error with "garbage after location" if setting a dprintf breakpoint. Copy the location into the breakpoint instead of an address string. (break_command_1): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Check against `arg_cp' for a probe linespec. (dprintf_command): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Throw an exception if no format string was specified. (print_recreate_ranged_breakpoint): Use event_location_to_string instead of address strings. (break_range_command, until_break_command) (init_ada_exception_breakpoint): Use locations instead of address strings. (say_where): Print out extra_string for pending locations. (base_breakpoint_dtor): Delete `location' and `location_range_end' of the breakpoint. (base_breakpoint_create_sals_from_location): Use struct event_location instead of address string. Remove `addr_start' and `copy_arg' parameters. (base_breakpoint_decode_location): Use struct event_location instead of address string. (bkpt_re_set): Use locations instead of address strings. Use event_location_empty_p to check for unset location. (bkpt_print_recreate): Use event_location_to_string instead of an address string. Print out extra_string for pending locations. (bkpt_create_sals_from_location, bkpt_decode_location) (bkpt_probe_create_sals_from_location): Use struct event_location instead of address string. (bkpt_probe_decode_location): Use struct event_location instead of address string. (tracepoint_print_recreate): Use event_location_to_string to recreate the tracepoint. (tracepoint_create_sals_from_location, tracepoint_decode_location) (tracepoint_probe_create_sals_from_location) (tracepoint_probe_decode_location): Use struct event_location instead of address string. (dprintf_print_recreate): Use event_location_to_string to recreate the dprintf. (dprintf_re_set): Remove check for valid/missing format string. (strace_marker_create_sals_from_location) (strace_marker_create_breakpoints_sal, strace_marker_decode_location) (update_static_tracepoint): Use struct event_location instead of address string. (location_to_sals): Likewise. Pass `extra_string' to find_condition_and_thread. For newly resolved pending breakpoint locations, clear the location's string representation. Assert that the breakpoint's condition string is NULL when condition_not_parsed. (breakpoint_re_set_default, create_sals_from_location_default) (decode_location_default, trace_command, ftrace_command) (strace_command, create_tracepoint_from_upload): Use locations instead of address strings. * breakpoint.h (struct breakpoint_ops) <create_sals_from_location>: Use struct event_location instead of address string. Update all uses. <decode_location>: Likewise. (struct breakpoint) <addr_string>: Change to struct event_location and rename `location'. <addr_string_range_end>: Change to struct event_location and rename `location_range_end'. (create_breakpoint): Use struct event_location instead of address string. * cli/cli-cmds.c: Include location.h. (edit_command, list_command): Use locations instead of address strings. * elfread.c: Include location.h. (elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string. * guile/scm-breakpoint.c: Include location.h. (bpscm_print_breakpoint_smob): Use event_location_to_string. (gdbscm_register_breakpoint): Use locations instead of address strings. * linespec.c: Include location.h. (struct ls_parser) <stream>: Change to const char *. (PARSER_STREAM): Update. (lionespec_lexer_lex_keyword): According to find_condition_and_thread, keywords must be followed by whitespace. (canonicalize_linespec): Save a linespec location into `canonical'. Save a canonical linespec into `canonical'. (parse_linespec): Change `argptr' to const char * and rename `arg'. All uses updated. Update function description. (linespec_parser_new): Initialize `parser'. Update initialization of parsing stream. (event_location_to_sals): New function. (decode_line_full): Change `argptr' to a struct event_location and rename it `location'. Use locations instead of address strings. Call event_location_to_sals instead of parse_linespec. (decode_line_1): Likewise. (decode_line_with_current_source, decode_line_with_last_displayed) Use locations instead of address strings. (decode_objc): Likewise. Change `argptr' to const char * and rename `arg'. (destroy_linespec_result): Delete the linespec result's location instead of freeing the address string. * linespec.h (struct linespec_result) <addr_string>: Change to struct event_location and rename to ... <location>: ... this. (decode_line_1, decode_line_full): Change `argptr' to struct event_location. All callers updated. * mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h. (mi_cmd_break_insert_1): Use locations instead of address strings. Throw an error if there was "garbage" at the end of the specified linespec. * probe.c: Include location.h. (parse_probes): Change `argptr' to struct event_location. Use event locations instead of address strings. * probe.h (parse_probes): Change `argptr' to struct event_location. * python/py-breakpoint.c: Include location.h. (bppy_get_location): Constify local variable `str'. Use event_location_to_string. (bppy_init): Use locations instead of address strings. * python/py-finishbreakpoint.c: Include location.h. (bpfinishpy_init): Remove local variable `addr_str'. Use locations instead of address strings. * python/python.c: Include location.h. (gdbpy_decode_line): Use locations instead of address strings. * remote.c: Include location.h. (remote_download_tracepoint): Use locations instead of address strings. * spu-tdep.c: Include location.h. (spu_catch_start): Remove local variable `buf'. Use locations instead of address strings. * tracepoint.c: Include location.h. (scope_info): Use locations instead of address strings. (encode_source_string): Constify parameter `src'. * tracepoint.h (encode_source_string): Likewise. gdb/testsuite/ChangeLog * gdb.base/dprintf-pending.exp: Update dprintf "without format" test. Add tests for missing ",FMT" and ",".
2015-08-12 02:09:35 +02:00
if (b->location != NULL)
{
strcpy (buf, "QTDPsrc:");
Explicit locations: use new location API This patch converts the code base to use the new struct event_location API being introduced. This patch preserves the current functionality and adds no new features. The "big picture" API usage introduced by this patch may be illustrated with a simple exmaple. Where previously developers would write: void my_command (char *arg, int from_tty) { create_breakpoint (..., arg, ...); ... } one now uses: void my_command (char *arg, int from_tty) { struct event_locaiton *location; struct cleanup *back_to; location = string_to_event_locaiton (&arg, ...); back_to = make_cleanup_delete_event_location (location); create_breakpoint (..., location, ...); do_cleanups (back_to); } Linespec-decoding functions (now called location-decoding) such as decode_line_full no longer skip argument pointers over processed input. That functionality has been moved into string_to_event_location as demonstrated above. gdb/ChangeLog * ax-gdb.c: Include location.h. (agent_command_1) Use linespec location instead of address string. * break-catch-throw.c: Include location.h. (re_set_exception_catchpoint): Use linespec locations instead of address strings. * breakpoint.c: Include location.h. (create_overlay_event_breakpoint, create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint, update_breakpoints_after_exec): Use linespec location instead of address string. (print_breakpoint_location): Use locations and event_location_to_string. Print extra_string for pending locations for non-MI streams. (print_one_breakpoint_location): Use locations and event_location_to_string. (init_raw_breakpoint_without_location): Initialize b->location. (create_thread_event_breakpoint): Use linespec location instead of address string. (init_breakpoint_sal): Likewise. Only save extra_string if it is non-NULL and not the empty string. Use event_location_to_string instead of `addr_string'. Constify `p' and `endp'. Use skip_spaces_const/skip_space_const instead of non-const versions. Copy the location into the breakpoint. If LOCATION is NULL, save the breakpoint address as a linespec location instead of an address string. (create_breakpoint_sal): Change `addr_string' parameter to a struct event_location. All uses updated. (create_breakpoints_sal): Likewise for local variable `addr_string'. (parse_breakpoint_sals): Use locations instead of address strings. Remove check for empty linespec with conditional. Refactor. (decode_static_tracepoint_spec): Make argument const and update function. (create_breakpoint): Change `arg' to a struct event_location and rename. Remove `copy_arg' and `addr_start'. If EXTRA_STRING is empty, set it to NULL. Don't populate `canonical' for pending breakpoints. Pass `extra_string' to find_condition_and_thread. Clear `extra_string' if `rest' was NULL. Do not error with "garbage after location" if setting a dprintf breakpoint. Copy the location into the breakpoint instead of an address string. (break_command_1): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Check against `arg_cp' for a probe linespec. (dprintf_command): Use string_to_event_location and pass this to create_breakpoint instead of an address string. Throw an exception if no format string was specified. (print_recreate_ranged_breakpoint): Use event_location_to_string instead of address strings. (break_range_command, until_break_command) (init_ada_exception_breakpoint): Use locations instead of address strings. (say_where): Print out extra_string for pending locations. (base_breakpoint_dtor): Delete `location' and `location_range_end' of the breakpoint. (base_breakpoint_create_sals_from_location): Use struct event_location instead of address string. Remove `addr_start' and `copy_arg' parameters. (base_breakpoint_decode_location): Use struct event_location instead of address string. (bkpt_re_set): Use locations instead of address strings. Use event_location_empty_p to check for unset location. (bkpt_print_recreate): Use event_location_to_string instead of an address string. Print out extra_string for pending locations. (bkpt_create_sals_from_location, bkpt_decode_location) (bkpt_probe_create_sals_from_location): Use struct event_location instead of address string. (bkpt_probe_decode_location): Use struct event_location instead of address string. (tracepoint_print_recreate): Use event_location_to_string to recreate the tracepoint. (tracepoint_create_sals_from_location, tracepoint_decode_location) (tracepoint_probe_create_sals_from_location) (tracepoint_probe_decode_location): Use struct event_location instead of address string. (dprintf_print_recreate): Use event_location_to_string to recreate the dprintf. (dprintf_re_set): Remove check for valid/missing format string. (strace_marker_create_sals_from_location) (strace_marker_create_breakpoints_sal, strace_marker_decode_location) (update_static_tracepoint): Use struct event_location instead of address string. (location_to_sals): Likewise. Pass `extra_string' to find_condition_and_thread. For newly resolved pending breakpoint locations, clear the location's string representation. Assert that the breakpoint's condition string is NULL when condition_not_parsed. (breakpoint_re_set_default, create_sals_from_location_default) (decode_location_default, trace_command, ftrace_command) (strace_command, create_tracepoint_from_upload): Use locations instead of address strings. * breakpoint.h (struct breakpoint_ops) <create_sals_from_location>: Use struct event_location instead of address string. Update all uses. <decode_location>: Likewise. (struct breakpoint) <addr_string>: Change to struct event_location and rename `location'. <addr_string_range_end>: Change to struct event_location and rename `location_range_end'. (create_breakpoint): Use struct event_location instead of address string. * cli/cli-cmds.c: Include location.h. (edit_command, list_command): Use locations instead of address strings. * elfread.c: Include location.h. (elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string. * guile/scm-breakpoint.c: Include location.h. (bpscm_print_breakpoint_smob): Use event_location_to_string. (gdbscm_register_breakpoint): Use locations instead of address strings. * linespec.c: Include location.h. (struct ls_parser) <stream>: Change to const char *. (PARSER_STREAM): Update. (lionespec_lexer_lex_keyword): According to find_condition_and_thread, keywords must be followed by whitespace. (canonicalize_linespec): Save a linespec location into `canonical'. Save a canonical linespec into `canonical'. (parse_linespec): Change `argptr' to const char * and rename `arg'. All uses updated. Update function description. (linespec_parser_new): Initialize `parser'. Update initialization of parsing stream. (event_location_to_sals): New function. (decode_line_full): Change `argptr' to a struct event_location and rename it `location'. Use locations instead of address strings. Call event_location_to_sals instead of parse_linespec. (decode_line_1): Likewise. (decode_line_with_current_source, decode_line_with_last_displayed) Use locations instead of address strings. (decode_objc): Likewise. Change `argptr' to const char * and rename `arg'. (destroy_linespec_result): Delete the linespec result's location instead of freeing the address string. * linespec.h (struct linespec_result) <addr_string>: Change to struct event_location and rename to ... <location>: ... this. (decode_line_1, decode_line_full): Change `argptr' to struct event_location. All callers updated. * mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h. (mi_cmd_break_insert_1): Use locations instead of address strings. Throw an error if there was "garbage" at the end of the specified linespec. * probe.c: Include location.h. (parse_probes): Change `argptr' to struct event_location. Use event locations instead of address strings. * probe.h (parse_probes): Change `argptr' to struct event_location. * python/py-breakpoint.c: Include location.h. (bppy_get_location): Constify local variable `str'. Use event_location_to_string. (bppy_init): Use locations instead of address strings. * python/py-finishbreakpoint.c: Include location.h. (bpfinishpy_init): Remove local variable `addr_str'. Use locations instead of address strings. * python/python.c: Include location.h. (gdbpy_decode_line): Use locations instead of address strings. * remote.c: Include location.h. (remote_download_tracepoint): Use locations instead of address strings. * spu-tdep.c: Include location.h. (spu_catch_start): Remove local variable `buf'. Use locations instead of address strings. * tracepoint.c: Include location.h. (scope_info): Use locations instead of address strings. (encode_source_string): Constify parameter `src'. * tracepoint.h (encode_source_string): Likewise. gdb/testsuite/ChangeLog * gdb.base/dprintf-pending.exp: Update dprintf "without format" test. Add tests for missing ",FMT" and ",".
2015-08-12 02:09:35 +02:00
encode_source_string (b->number, loc->address, "at",
event_location_to_string (b->location),
buf + strlen (buf), 2048 - strlen (buf));
putpkt (buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))
warning (_("Target does not support source download."));
}
if (b->cond_string)
{
strcpy (buf, "QTDPsrc:");
encode_source_string (b->number, loc->address,
"cond", b->cond_string, buf + strlen (buf),
2048 - strlen (buf));
putpkt (buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))
warning (_("Target does not support source download."));
}
remote_download_command_source (b->number, loc->address,
breakpoint_commands (b));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
do_cleanups (old_chain);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
static int
remote_can_download_tracepoint (struct target_ops *self)
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
{
struct remote_state *rs = get_remote_state ();
struct trace_status *ts;
int status;
/* Don't try to install tracepoints until we've relocated our
symbols, and fetched and merged the target's tracepoint list with
ours. */
if (rs->starting_up)
return 0;
ts = current_trace_status ();
status = remote_get_trace_status (self, ts);
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
if (status == -1 || !ts->running_known || !ts->running)
return 0;
/* If we are in a tracing experiment, but remote stub doesn't support
installing tracepoint in trace, we have to return. */
if (!remote_supports_install_in_trace ())
return 0;
return 1;
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_download_trace_state_variable (struct target_ops *self,
struct trace_state_variable *tsv)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
struct remote_state *rs = get_remote_state ();
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
char *p;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
xsnprintf (rs->buf, get_remote_packet_size (), "QTDV:%x:%s:%x:",
tsv->number, phex ((ULONGEST) tsv->initial_value, 8),
tsv->builtin);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
p = rs->buf + strlen (rs->buf);
if ((p - rs->buf) + strlen (tsv->name) * 2 >= get_remote_packet_size ())
error (_("Trace state variable name too long for tsv definition packet"));
p += 2 * bin2hex ((gdb_byte *) (tsv->name), p, strlen (tsv->name));
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
*p++ = '\0';
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
putpkt (rs->buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*target_buf == '\0')
error (_("Target does not support this command."));
if (strcmp (target_buf, "OK") != 0)
error (_("Error on target while downloading trace state variable."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
static void
remote_enable_tracepoint (struct target_ops *self,
struct bp_location *location)
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
{
struct remote_state *rs = get_remote_state ();
char addr_buf[40];
sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf, get_remote_packet_size (), "QTEnable:%x:%s",
location->owner->number, addr_buf);
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
putpkt (rs->buf);
remote_get_noisy_reply (&rs->buf, &rs->buf_size);
if (*rs->buf == '\0')
error (_("Target does not support enabling tracepoints while a trace run is ongoing."));
if (strcmp (rs->buf, "OK") != 0)
error (_("Error on target while enabling tracepoint."));
}
static void
remote_disable_tracepoint (struct target_ops *self,
struct bp_location *location)
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
{
struct remote_state *rs = get_remote_state ();
char addr_buf[40];
sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf, get_remote_packet_size (), "QTDisable:%x:%s",
location->owner->number, addr_buf);
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
putpkt (rs->buf);
remote_get_noisy_reply (&rs->buf, &rs->buf_size);
if (*rs->buf == '\0')
error (_("Target does not support disabling tracepoints while a trace run is ongoing."));
if (strcmp (rs->buf, "OK") != 0)
error (_("Error on target while disabling tracepoint."));
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_trace_set_readonly_regions (struct target_ops *self)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
asection *s;
bfd *abfd = NULL;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
bfd_size_type size;
bfd_vma vma;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
int anysecs = 0;
int offset = 0;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
if (!exec_bfd)
return; /* No information to give. */
strcpy (target_buf, "QTro");
offset = strlen (target_buf);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
for (s = exec_bfd->sections; s; s = s->next)
{
char tmp1[40], tmp2[40];
int sec_length;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
if ((s->flags & SEC_LOAD) == 0 ||
/* (s->flags & SEC_CODE) == 0 || */
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
(s->flags & SEC_READONLY) == 0)
continue;
anysecs = 1;
vma = bfd_get_section_vma (abfd, s);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
size = bfd_get_section_size (s);
sprintf_vma (tmp1, vma);
sprintf_vma (tmp2, vma + size);
sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2);
if (offset + sec_length + 1 > target_buf_size)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qXfer_traceframe_info) != PACKET_ENABLE)
warning (_("\
Too many sections for read-only sections definition packet."));
break;
}
xsnprintf (target_buf + offset, target_buf_size - offset, ":%s,%s",
tmp1, tmp2);
offset += sec_length;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
if (anysecs)
{
putpkt (target_buf);
getpkt (&target_buf, &target_buf_size, 0);
}
}
static void
remote_trace_start (struct target_ops *self)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
putpkt ("QTStart");
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*target_buf == '\0')
error (_("Target does not support this command."));
if (strcmp (target_buf, "OK") != 0)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
error (_("Bogus reply from target: %s"), target_buf);
}
static int
remote_get_trace_status (struct target_ops *self, struct trace_status *ts)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
/* Initialize it just to avoid a GCC false warning. */
char *p = NULL;
/* FIXME we need to get register block size some other way. */
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
extern int trace_regblock_size;
enum packet_result result;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qTStatus) == PACKET_DISABLE)
return -1;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
trace_regblock_size = get_remote_arch_state ()->sizeof_g_packet;
putpkt ("qTStatus");
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
TRY
{
p = remote_get_noisy_reply (&target_buf, &target_buf_size);
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
CATCH (ex, RETURN_MASK_ERROR)
{
if (ex.error != TARGET_CLOSE_ERROR)
{
exception_fprintf (gdb_stderr, ex, "qTStatus: ");
return -1;
}
throw_exception (ex);
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
END_CATCH
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
result = packet_ok (p, &remote_protocol_packets[PACKET_qTStatus]);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* If the remote target doesn't do tracing, flag it. */
if (result == PACKET_UNKNOWN)
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
return -1;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* We're working with a live target. */
ts->filename = NULL;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
if (*p++ != 'T')
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
error (_("Bogus trace status reply from target: %s"), target_buf);
/* Function 'parse_trace_status' sets default value of each field of
'ts' at first, so we don't have to do it here. */
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
parse_trace_status (p, ts);
return ts->running;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
2012-03-01 Pedro Alves <palves@redhat.com> * amd64-linux-tdep.c (amd64_linux_record_signal): Make static. * breakpoint.c (create_exception_master_breakpoint, trace_command) (ftrace_command, strace_command): Make static. * d-lang.c (_initialize_d_language): Declare. * dwarf2expr.c (_initialize_dwarf2expr): Declare. * dwarf2loc.c (_initialize_dwarf2loc): * dwarf2read.c (process_psymtab_comp_unit): Make static. * exec.c (exec_get_section_table): Make static. * i386-linux-tdep.c (i386_linux_record_signal): Make static. * infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static. * inferior.c (remove_inferior_command, add_inferior_command) (clone_inferior_command): Make static. * linux-nat.c (linux_nat_thread_address_space) (linux_nat_core_of_thread): Make static. * linux-tdep.c (_initialize_linux_tdep): Declare. * objc-lang.c (_initialize_objc_lang): Declare. * opencl-lang.c (builtin_opencl_type, opencl_language_arch_info): Make static. (_initialize_opencl_language): Declare. * record.c (_initialize_record): Declare. * remote.c (demand_private_info, remote_get_tib_address) (remote_supports_cond_tracepoints) (remote_supports_fast_tracepoints, remote_get_tracepoint_status): Make static. * skip.c (_initialize_step_skip): Declare. * symtab.c (skip_prologue_using_lineinfo): Make static. * tracepoint.c (delete_trace_state_variable) (trace_variable_command, delete_trace_variable_command) (get_uploaded_tsv, find_matching_tracepoint_location) (find_matching_tsv, create_tsv_from_upload, get_traceframe_info): Make static. * value.c (pack_unsigned_long): Make static. * varobj.c (varobj_ensure_python_env): Make static. * windows-tdep.c (_initialize_windows_tdep): Declare. * xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
static void
remote_get_tracepoint_status (struct target_ops *self, struct breakpoint *bp,
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
struct uploaded_tp *utp)
{
struct remote_state *rs = get_remote_state ();
char *reply;
struct bp_location *loc;
struct tracepoint *tp = (struct tracepoint *) bp;
size_t size = get_remote_packet_size ();
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
if (tp)
{
tp->base.hit_count = 0;
tp->traceframe_usage = 0;
for (loc = tp->base.loc; loc; loc = loc->next)
{
/* If the tracepoint was never downloaded, don't go asking for
any status. */
if (tp->number_on_target == 0)
continue;
xsnprintf (rs->buf, size, "qTP:%x:%s", tp->number_on_target,
phex_nz (loc->address, 0));
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (reply && *reply)
{
if (*reply == 'V')
parse_tracepoint_status (reply + 1, bp, utp);
}
}
}
else if (utp)
{
utp->hit_count = 0;
utp->traceframe_usage = 0;
xsnprintf (rs->buf, size, "qTP:%x:%s", utp->number,
phex_nz (utp->addr, 0));
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (reply && *reply)
{
if (*reply == 'V')
parse_tracepoint_status (reply + 1, bp, utp);
}
}
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_trace_stop (struct target_ops *self)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
putpkt ("QTStop");
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*target_buf == '\0')
error (_("Target does not support this command."));
if (strcmp (target_buf, "OK") != 0)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
error (_("Bogus reply from target: %s"), target_buf);
}
static int
remote_trace_find (struct target_ops *self,
enum trace_find_type type, int num,
CORE_ADDR addr1, CORE_ADDR addr2,
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
int *tpp)
{
struct remote_state *rs = get_remote_state ();
char *endbuf = rs->buf + get_remote_packet_size ();
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
char *p, *reply;
int target_frameno = -1, target_tracept = -1;
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
/* Lookups other than by absolute frame number depend on the current
trace selected, so make sure it is correct on the remote end
first. */
if (type != tfind_number)
set_remote_traceframe ();
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
p = rs->buf;
strcpy (p, "QTFrame:");
p = strchr (p, '\0');
switch (type)
{
case tfind_number:
xsnprintf (p, endbuf - p, "%x", num);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case tfind_pc:
xsnprintf (p, endbuf - p, "pc:%s", phex_nz (addr1, 0));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case tfind_tp:
xsnprintf (p, endbuf - p, "tdp:%x", num);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case tfind_range:
xsnprintf (p, endbuf - p, "range:%s:%s", phex_nz (addr1, 0),
phex_nz (addr2, 0));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case tfind_outside:
xsnprintf (p, endbuf - p, "outside:%s:%s", phex_nz (addr1, 0),
phex_nz (addr2, 0));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
default:
error (_("Unknown trace find type %d"), type);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
putpkt (rs->buf);
reply = remote_get_noisy_reply (&(rs->buf), &rs->buf_size);
if (*reply == '\0')
error (_("Target does not support this command."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
while (reply && *reply)
switch (*reply)
{
case 'F':
p = ++reply;
target_frameno = (int) strtol (p, &reply, 16);
if (reply == p)
error (_("Unable to parse trace frame number"));
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
/* Don't update our remote traceframe number cache on failure
to select a remote traceframe. */
if (target_frameno == -1)
return -1;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case 'T':
p = ++reply;
target_tracept = (int) strtol (p, &reply, 16);
if (reply == p)
error (_("Unable to parse tracepoint number"));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
break;
case 'O': /* "OK"? */
if (reply[1] == 'K' && reply[2] == '\0')
reply += 2;
else
error (_("Bogus reply from target: %s"), reply);
break;
default:
error (_("Bogus reply from target: %s"), reply);
}
if (tpp)
*tpp = target_tracept;
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
rs->remote_traceframe_number = target_frameno;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
return target_frameno;
}
static int
remote_get_trace_state_variable_value (struct target_ops *self,
int tsvnum, LONGEST *val)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
struct remote_state *rs = get_remote_state ();
char *reply;
ULONGEST uval;
gdb/ * target.c (target_read_live_memory): New function. (memory_xfer_live_readonly_partial): New. (memory_xfer_partial): If reading from a traceframe, fallback to reading unavailable read-only memory from read-only regions of live target memory. * tracepoint.c (disconnect_tracing): Adjust. (set_current_traceframe): New, factored out from set_traceframe_number. (set_traceframe_number): Reimplement to only change the traceframe number on the GDB side. (do_restore_current_traceframe_cleanup): Adjust. (make_cleanup_restore_traceframe_number): New. (cur_traceframe_number): New global. (tfile_open): Set cur_traceframe_number to no traceframe. (set_tfile_traceframe): New function. (tfile_trace_find): If looking up a traceframe using any method other than by number, make sure the current tfile traceframe matches gdb's current traceframe. Update the current tfile traceframe if the lookup succeeded. (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. * remote.c (remote_traceframe_number): New global. (remote_open_1): Set it to -1. (set_remote_traceframe): New function. (remote_fetch_registers, remote_store_registers) (remote_xfer_memory, remote_xfer_partial) (remote_get_trace_state_variable_value): Make sure the remote traceframe matches gdb's current traceframe. (remote_trace_find): If looking up a traceframe using any method other than by number, make sure the current remote traceframe matches gdb's current traceframe. Update the current remote traceframe if the lookup succeeded. * infrun.c (fetch_inferior_event): Adjust. * tracepoint.h (set_current_traceframe): Declare. (get_traceframe_number, set_traceframe_number): Add describing comments.
2011-02-14 12:22:29 +01:00
set_remote_traceframe ();
xsnprintf (rs->buf, get_remote_packet_size (), "qTV:%x", tsvnum);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (reply && *reply)
{
if (*reply == 'V')
{
unpack_varlen_hex (reply + 1, &uval);
*val = (LONGEST) uval;
return 1;
}
}
return 0;
}
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
static int
remote_save_trace_data (struct target_ops *self, const char *filename)
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
{
struct remote_state *rs = get_remote_state ();
char *p, *reply;
p = rs->buf;
strcpy (p, "QTSave:");
p += strlen (p);
if ((p - rs->buf) + strlen (filename) * 2 >= get_remote_packet_size ())
error (_("Remote file name too long for trace save packet"));
p += 2 * bin2hex ((gdb_byte *) filename, p, strlen (filename));
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
*p++ = '\0';
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
error (_("Bogus reply from target: %s"), reply);
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
return 0;
}
/* This is basically a memory transfer, but needs to be its own packet
because we don't know how the target actually organizes its trace
memory, plus we want to be able to ask for as much as possible, but
not be unhappy if we don't get as much as we ask for. */
static LONGEST
remote_get_raw_trace_data (struct target_ops *self,
gdb_byte *buf, ULONGEST offset, LONGEST len)
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
{
struct remote_state *rs = get_remote_state ();
char *reply;
char *p;
int rslt;
p = rs->buf;
strcpy (p, "qTBuffer:");
p += strlen (p);
p += hexnumstr (p, offset);
*p++ = ',';
p += hexnumstr (p, len);
*p++ = '\0';
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (reply && *reply)
{
/* 'l' by itself means we're at the end of the buffer and
there is nothing more to get. */
if (*reply == 'l')
return 0;
/* Convert the reply into binary. Limit the number of bytes to
convert according to our passed-in buffer size, rather than
what was returned in the packet; if the target is
unexpectedly generous and gives us a bigger reply than we
asked for, we don't want to crash. */
rslt = hex2bin (target_buf, buf, len);
return rslt;
}
/* Something went wrong, flag as an error. */
return -1;
}
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
static void
remote_set_disconnected_tracing (struct target_ops *self, int val)
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
{
struct remote_state *rs = get_remote_state ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_DisconnectedTracing_feature) == PACKET_ENABLE)
{
char *reply;
xsnprintf (rs->buf, get_remote_packet_size (), "QTDisconnected:%x", val);
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
error (_("Bogus reply from target: %s"), reply);
}
else if (val)
warning (_("Target does not support disconnected tracing."));
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
}
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
static int
remote_core_of_thread (struct target_ops *ops, ptid_t ptid)
{
struct thread_info *info = find_thread_ptid (ptid);
if (info && info->priv)
return info->priv->core;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
return -1;
}
static void
remote_set_circular_trace_buffer (struct target_ops *self, int val)
{
struct remote_state *rs = get_remote_state ();
char *reply;
xsnprintf (rs->buf, get_remote_packet_size (), "QTBuffer:circular:%x", val);
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
error (_("Bogus reply from target: %s"), reply);
}
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
static struct traceframe_info *
remote_traceframe_info (struct target_ops *self)
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
{
char *text;
text = target_read_stralloc (&current_target,
TARGET_OBJECT_TRACEFRAME_INFO, NULL);
if (text != NULL)
{
struct traceframe_info *info;
struct cleanup *back_to = make_cleanup (xfree, text);
info = parse_traceframe_info (text);
do_cleanups (back_to);
return info;
}
return NULL;
}
2011-11-14 Stan Shebs <stan@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> * NEWS: Document shorter fast tracepoints and qTMinFTPILen packet. * i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for the minimum instruction size for fast tracepoints. * target.h (struct target_ops): Add new method to_get_min_fast_tracepoint_insn_len. (target_get_min_fast_tracepoint_insn_len): New. * target.c (update_current_target): Set up new target operation. * remote.c (remote_write_bytes_aux): Fix typo. (remote_get_min_fast_tracepoint_insn_len): New. (init_remote_ops): Initialize new field. * gdb.texinfo (Create and Delete Tracepoints): Describe what is needed to get shorter fast tracepoints. (Tracepoint Packets): Document new qTMinFTPILen packet. * linux-x86-low.c (small_jump_insn): New. (i386_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message, build a trampoline and issue a small jump instruction to it. (x86_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message. (x86_get_min_fast_tracepoint_insn_len): New. (the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len. * linux-low.h (struct linux_target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new operation. * linux-low.c (linux_install_fast_tracepoint_jump_pad): Add arguments. (linux_get_min_fast_tracepoint_insn_len): New function. (linux_target_op): Add new operation. * tracepoint.c (gdb_trampoline_buffer): New IPA variable. (gdb_trampoline_buffer_end): Ditto. (gdb_trampoline_buffer_error): Ditto. (struct ipa_sym_addresses): Add fields for new IPA variables. (symbol_list): Add entries for new IPA variables. (struct tracepoint): Add fields to hold the address range of the trampoline used by the tracepoint. (trampoline_buffer_head): New static variable. (trampoline_buffer_tail): Ditto. (claim_trampoline_space): New function. (have_fast_tracepoint_trampoline_buffer): New function. (clone_fast_tracepoint): Fill in trampoline fields of tracepoint structure. (install_fast_tracepoint): Ditto, also add error buffer argument. (cmd_qtminftpilen): New function. (handle_tracepoint_query): Add response to qTMinFTPILen packet. (fast_tracepoint_from_trampoline_address): New function. (fast_tracepoint_collecting): Handle trampoline as part of jump pad space. (set_trampoline_buffer_space): New function. (initialize_tracepoint): Initialize new IPA variables. * target.h (struct target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new get_min_fast_tracepoint_insn_len operation. (target_get_min_fast_tracepoint_insn_len): New. (install_fast_tracepoint_jump_pad): Add arguments. * server.h (IPA_BUFSIZ): Define. * linux-i386-ipa.c: Include extra header files. (initialize_fast_tracepoint_trampoline_buffer): New function. (initialize_low_tracepoint): Call it. * server.h (set_trampoline_buffer_space): Declare. (claim_trampoline_space): Ditto. (have_fast_tracepoint_trampoline_buffer): Ditto. * gdb.trace/ftrace.c: New. * gdb.trace/ftrace.exp: New.
2011-11-14 21:07:25 +01:00
/* Handle the qTMinFTPILen packet. Returns the minimum length of
instruction on which a fast tracepoint may be placed. Returns -1
if the packet is not supported, and 0 if the minimum instruction
length is unknown. */
static int
remote_get_min_fast_tracepoint_insn_len (struct target_ops *self)
2011-11-14 Stan Shebs <stan@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> * NEWS: Document shorter fast tracepoints and qTMinFTPILen packet. * i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for the minimum instruction size for fast tracepoints. * target.h (struct target_ops): Add new method to_get_min_fast_tracepoint_insn_len. (target_get_min_fast_tracepoint_insn_len): New. * target.c (update_current_target): Set up new target operation. * remote.c (remote_write_bytes_aux): Fix typo. (remote_get_min_fast_tracepoint_insn_len): New. (init_remote_ops): Initialize new field. * gdb.texinfo (Create and Delete Tracepoints): Describe what is needed to get shorter fast tracepoints. (Tracepoint Packets): Document new qTMinFTPILen packet. * linux-x86-low.c (small_jump_insn): New. (i386_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message, build a trampoline and issue a small jump instruction to it. (x86_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message. (x86_get_min_fast_tracepoint_insn_len): New. (the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len. * linux-low.h (struct linux_target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new operation. * linux-low.c (linux_install_fast_tracepoint_jump_pad): Add arguments. (linux_get_min_fast_tracepoint_insn_len): New function. (linux_target_op): Add new operation. * tracepoint.c (gdb_trampoline_buffer): New IPA variable. (gdb_trampoline_buffer_end): Ditto. (gdb_trampoline_buffer_error): Ditto. (struct ipa_sym_addresses): Add fields for new IPA variables. (symbol_list): Add entries for new IPA variables. (struct tracepoint): Add fields to hold the address range of the trampoline used by the tracepoint. (trampoline_buffer_head): New static variable. (trampoline_buffer_tail): Ditto. (claim_trampoline_space): New function. (have_fast_tracepoint_trampoline_buffer): New function. (clone_fast_tracepoint): Fill in trampoline fields of tracepoint structure. (install_fast_tracepoint): Ditto, also add error buffer argument. (cmd_qtminftpilen): New function. (handle_tracepoint_query): Add response to qTMinFTPILen packet. (fast_tracepoint_from_trampoline_address): New function. (fast_tracepoint_collecting): Handle trampoline as part of jump pad space. (set_trampoline_buffer_space): New function. (initialize_tracepoint): Initialize new IPA variables. * target.h (struct target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new get_min_fast_tracepoint_insn_len operation. (target_get_min_fast_tracepoint_insn_len): New. (install_fast_tracepoint_jump_pad): Add arguments. * server.h (IPA_BUFSIZ): Define. * linux-i386-ipa.c: Include extra header files. (initialize_fast_tracepoint_trampoline_buffer): New function. (initialize_low_tracepoint): Call it. * server.h (set_trampoline_buffer_space): Declare. (claim_trampoline_space): Ditto. (have_fast_tracepoint_trampoline_buffer): Ditto. * gdb.trace/ftrace.c: New. * gdb.trace/ftrace.exp: New.
2011-11-14 21:07:25 +01:00
{
struct remote_state *rs = get_remote_state ();
char *reply;
/* If we're not debugging a process yet, the IPA can't be
loaded. */
if (!target_has_execution)
return 0;
/* Make sure the remote is pointing at the right process. */
set_general_process ();
xsnprintf (rs->buf, get_remote_packet_size (), "qTMinFTPILen");
2011-11-14 Stan Shebs <stan@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> * NEWS: Document shorter fast tracepoints and qTMinFTPILen packet. * i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for the minimum instruction size for fast tracepoints. * target.h (struct target_ops): Add new method to_get_min_fast_tracepoint_insn_len. (target_get_min_fast_tracepoint_insn_len): New. * target.c (update_current_target): Set up new target operation. * remote.c (remote_write_bytes_aux): Fix typo. (remote_get_min_fast_tracepoint_insn_len): New. (init_remote_ops): Initialize new field. * gdb.texinfo (Create and Delete Tracepoints): Describe what is needed to get shorter fast tracepoints. (Tracepoint Packets): Document new qTMinFTPILen packet. * linux-x86-low.c (small_jump_insn): New. (i386_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message, build a trampoline and issue a small jump instruction to it. (x86_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message. (x86_get_min_fast_tracepoint_insn_len): New. (the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len. * linux-low.h (struct linux_target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new operation. * linux-low.c (linux_install_fast_tracepoint_jump_pad): Add arguments. (linux_get_min_fast_tracepoint_insn_len): New function. (linux_target_op): Add new operation. * tracepoint.c (gdb_trampoline_buffer): New IPA variable. (gdb_trampoline_buffer_end): Ditto. (gdb_trampoline_buffer_error): Ditto. (struct ipa_sym_addresses): Add fields for new IPA variables. (symbol_list): Add entries for new IPA variables. (struct tracepoint): Add fields to hold the address range of the trampoline used by the tracepoint. (trampoline_buffer_head): New static variable. (trampoline_buffer_tail): Ditto. (claim_trampoline_space): New function. (have_fast_tracepoint_trampoline_buffer): New function. (clone_fast_tracepoint): Fill in trampoline fields of tracepoint structure. (install_fast_tracepoint): Ditto, also add error buffer argument. (cmd_qtminftpilen): New function. (handle_tracepoint_query): Add response to qTMinFTPILen packet. (fast_tracepoint_from_trampoline_address): New function. (fast_tracepoint_collecting): Handle trampoline as part of jump pad space. (set_trampoline_buffer_space): New function. (initialize_tracepoint): Initialize new IPA variables. * target.h (struct target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new get_min_fast_tracepoint_insn_len operation. (target_get_min_fast_tracepoint_insn_len): New. (install_fast_tracepoint_jump_pad): Add arguments. * server.h (IPA_BUFSIZ): Define. * linux-i386-ipa.c: Include extra header files. (initialize_fast_tracepoint_trampoline_buffer): New function. (initialize_low_tracepoint): Call it. * server.h (set_trampoline_buffer_space): Declare. (claim_trampoline_space): Ditto. (have_fast_tracepoint_trampoline_buffer): Ditto. * gdb.trace/ftrace.c: New. * gdb.trace/ftrace.exp: New.
2011-11-14 21:07:25 +01:00
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
return -1;
else
{
ULONGEST min_insn_len;
unpack_varlen_hex (reply, &min_insn_len);
return (int) min_insn_len;
}
}
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
static void
remote_set_trace_buffer_size (struct target_ops *self, LONGEST val)
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QTBuffer_size) != PACKET_DISABLE)
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
{
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
enum packet_result result;
gdb_assert (val >= 0 || val == -1);
buf += xsnprintf (buf, endbuf - buf, "QTBuffer:size:");
/* Send -1 as literal "-1" to avoid host size dependency. */
if (val < 0)
{
*buf++ = '-';
buf += hexnumstr (buf, (ULONGEST) -val);
}
else
buf += hexnumstr (buf, (ULONGEST) val);
putpkt (rs->buf);
remote_get_noisy_reply (&rs->buf, &rs->buf_size);
result = packet_ok (rs->buf,
&remote_protocol_packets[PACKET_QTBuffer_size]);
if (result != PACKET_OK)
warning (_("Bogus reply from target: %s"), rs->buf);
}
}
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
static int
remote_set_trace_notes (struct target_ops *self,
const char *user, const char *notes,
const char *stop_notes)
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
{
struct remote_state *rs = get_remote_state ();
char *reply;
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
int nbytes;
buf += xsnprintf (buf, endbuf - buf, "QTNotes:");
if (user)
{
buf += xsnprintf (buf, endbuf - buf, "user:");
nbytes = bin2hex ((gdb_byte *) user, buf, strlen (user));
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
buf += 2 * nbytes;
*buf++ = ';';
}
if (notes)
{
buf += xsnprintf (buf, endbuf - buf, "notes:");
nbytes = bin2hex ((gdb_byte *) notes, buf, strlen (notes));
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
buf += 2 * nbytes;
*buf++ = ';';
}
if (stop_notes)
{
buf += xsnprintf (buf, endbuf - buf, "tstop:");
nbytes = bin2hex ((gdb_byte *) stop_notes, buf, strlen (stop_notes));
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
buf += 2 * nbytes;
*buf++ = ';';
}
/* Ensure the buffer is terminated. */
*buf = '\0';
putpkt (rs->buf);
reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
if (*reply == '\0')
return 0;
if (strcmp (reply, "OK") != 0)
error (_("Bogus reply from target: %s"), reply);
return 1;
}
static int
remote_use_agent (struct target_ops *self, int use)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_QAgent) != PACKET_DISABLE)
{
struct remote_state *rs = get_remote_state ();
/* If the stub supports QAgent. */
xsnprintf (rs->buf, get_remote_packet_size (), "QAgent:%d", use);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (strcmp (rs->buf, "OK") == 0)
{
use_agent = use;
return 1;
}
}
return 0;
}
static int
remote_can_use_agent (struct target_ops *self)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return (packet_support (PACKET_QAgent) != PACKET_DISABLE);
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
struct btrace_target_info
{
/* The ptid of the traced thread. */
ptid_t ptid;
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* The obtained branch trace configuration. */
struct btrace_config conf;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
};
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* Reset our idea of our target's btrace configuration. */
static void
remote_btrace_reset (void)
{
struct remote_state *rs = get_remote_state ();
memset (&rs->btrace_config, 0, sizeof (rs->btrace_config));
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
/* Check whether the target supports branch tracing. */
static int
btrace: add format argument to supports_btrace 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.
2014-01-17 13:29:19 +01:00
remote_supports_btrace (struct target_ops *self, enum btrace_format format)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_Qbtrace_off) != PACKET_ENABLE)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
return 0;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_qXfer_btrace) != PACKET_ENABLE)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
return 0;
btrace: add format argument to supports_btrace 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.
2014-01-17 13:29:19 +01:00
switch (format)
{
case BTRACE_FORMAT_NONE:
return 0;
case BTRACE_FORMAT_BTS:
return (packet_support (PACKET_Qbtrace_bts) == PACKET_ENABLE);
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
case BTRACE_FORMAT_PT:
/* The trace is decoded on the host. Even if our target supports it,
we still need to have libipt to decode the trace. */
#if defined (HAVE_LIBIPT)
return (packet_support (PACKET_Qbtrace_pt) == PACKET_ENABLE);
#else /* !defined (HAVE_LIBIPT) */
return 0;
#endif /* !defined (HAVE_LIBIPT) */
btrace: add format argument to supports_btrace 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.
2014-01-17 13:29:19 +01:00
}
internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
}
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* Synchronize the configuration with the target. */
static void
btrace_sync_conf (const struct btrace_config *conf)
{
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
struct packet_config *packet;
struct remote_state *rs;
char *buf, *pos, *endbuf;
rs = get_remote_state ();
buf = rs->buf;
endbuf = buf + get_remote_packet_size ();
packet = &remote_protocol_packets[PACKET_Qbtrace_conf_bts_size];
if (packet_config_support (packet) == PACKET_ENABLE
&& conf->bts.size != rs->btrace_config.bts.size)
{
pos = buf;
pos += xsnprintf (pos, endbuf - pos, "%s=0x%x", packet->name,
conf->bts.size);
putpkt (buf);
getpkt (&buf, &rs->buf_size, 0);
if (packet_ok (buf, packet) == PACKET_ERROR)
{
if (buf[0] == 'E' && buf[1] == '.')
error (_("Failed to configure the BTS buffer size: %s"), buf + 2);
else
error (_("Failed to configure the BTS buffer size."));
}
rs->btrace_config.bts.size = conf->bts.size;
}
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
packet = &remote_protocol_packets[PACKET_Qbtrace_conf_pt_size];
if (packet_config_support (packet) == PACKET_ENABLE
&& conf->pt.size != rs->btrace_config.pt.size)
{
pos = buf;
pos += xsnprintf (pos, endbuf - pos, "%s=0x%x", packet->name,
conf->pt.size);
putpkt (buf);
getpkt (&buf, &rs->buf_size, 0);
if (packet_ok (buf, packet) == PACKET_ERROR)
{
if (buf[0] == 'E' && buf[1] == '.')
error (_("Failed to configure the trace buffer size: %s"), buf + 2);
else
error (_("Failed to configure the trace buffer size."));
}
rs->btrace_config.pt.size = conf->pt.size;
}
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
}
/* Read the current thread's btrace configuration from the target and
store it into CONF. */
static void
btrace_read_config (struct btrace_config *conf)
{
char *xml;
xml = target_read_stralloc (&current_target,
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
TARGET_OBJECT_BTRACE_CONF, "");
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
if (xml != NULL)
{
struct cleanup *cleanup;
cleanup = make_cleanup (xfree, xml);
parse_xml_btrace_conf (conf, xml);
do_cleanups (cleanup);
}
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
/* Enable branch tracing. */
static struct btrace_target_info *
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
remote_enable_btrace (struct target_ops *self, ptid_t ptid,
const struct btrace_config *conf)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{
struct btrace_target_info *tinfo = NULL;
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
struct packet_config *packet = NULL;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
switch (conf->format)
{
case BTRACE_FORMAT_BTS:
packet = &remote_protocol_packets[PACKET_Qbtrace_bts];
break;
case BTRACE_FORMAT_PT:
packet = &remote_protocol_packets[PACKET_Qbtrace_pt];
break;
}
if (packet == NULL || packet_config_support (packet) != PACKET_ENABLE)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
error (_("Target does not support branch tracing."));
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
btrace_sync_conf (conf);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
set_general_thread (ptid);
buf += xsnprintf (buf, endbuf - buf, "%s", packet->name);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (packet_ok (rs->buf, packet) == PACKET_ERROR)
{
if (rs->buf[0] == 'E' && rs->buf[1] == '.')
error (_("Could not enable branch tracing for %s: %s"),
target_pid_to_str (ptid), rs->buf + 2);
else
error (_("Could not enable branch tracing for %s."),
target_pid_to_str (ptid));
}
tinfo = xzalloc (sizeof (*tinfo));
tinfo->ptid = ptid;
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
/* If we fail to read the configuration, we lose some information, but the
tracing itself is not impacted. */
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
TRY
{
btrace_read_config (&tinfo->conf);
}
CATCH (err, RETURN_MASK_ERROR)
{
if (err.message != NULL)
warning ("%s", err.message);
}
END_CATCH
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
return tinfo;
}
/* Disable branch tracing. */
static void
remote_disable_btrace (struct target_ops *self,
struct btrace_target_info *tinfo)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{
struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_off];
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_config_support (packet) != PACKET_ENABLE)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
error (_("Target does not support branch tracing."));
set_general_thread (tinfo->ptid);
buf += xsnprintf (buf, endbuf - buf, "%s", packet->name);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (packet_ok (rs->buf, packet) == PACKET_ERROR)
{
if (rs->buf[0] == 'E' && rs->buf[1] == '.')
error (_("Could not disable branch tracing for %s: %s"),
target_pid_to_str (tinfo->ptid), rs->buf + 2);
else
error (_("Could not disable branch tracing for %s."),
target_pid_to_str (tinfo->ptid));
}
xfree (tinfo);
}
/* Teardown branch tracing. */
static void
remote_teardown_btrace (struct target_ops *self,
struct btrace_target_info *tinfo)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{
/* We must not talk to the target during teardown. */
xfree (tinfo);
}
/* Read the branch trace. */
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
static enum btrace_error
remote_read_btrace (struct target_ops *self,
btrace: add struct btrace_data 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.
2013-11-13 15:31:07 +01:00
struct btrace_data *btrace,
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
struct btrace_target_info *tinfo,
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
enum btrace_read_type type)
{
struct packet_config *packet = &remote_protocol_packets[PACKET_qXfer_btrace];
struct remote_state *rs = get_remote_state ();
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
struct cleanup *cleanup;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
const char *annex;
char *xml;
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_config_support (packet) != PACKET_ENABLE)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
error (_("Target does not support branch tracing."));
#if !defined(HAVE_LIBEXPAT)
error (_("Cannot process branch tracing result. XML parsing not supported."));
#endif
switch (type)
{
case BTRACE_READ_ALL:
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
annex = "all";
break;
case BTRACE_READ_NEW:
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
annex = "new";
break;
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
case BTRACE_READ_DELTA:
annex = "delta";
break;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
default:
internal_error (__FILE__, __LINE__,
_("Bad branch tracing read type: %u."),
(unsigned int) type);
}
xml = target_read_stralloc (&current_target,
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
TARGET_OBJECT_BTRACE, annex);
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
if (xml == NULL)
return BTRACE_ERR_UNKNOWN;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
cleanup = make_cleanup (xfree, xml);
btrace: add struct btrace_data 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.
2013-11-13 15:31:07 +01:00
parse_xml_btrace (btrace, xml);
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
do_cleanups (cleanup);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
return BTRACE_ERR_NONE;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
}
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
static const struct btrace_config *
remote_btrace_conf (struct target_ops *self,
const struct btrace_target_info *tinfo)
{
return &tinfo->conf;
}
static int
remote_augmented_libraries_svr4_read (struct target_ops *self)
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
return (packet_support (PACKET_augmented_libraries_svr4_read_feature)
== PACKET_ENABLE);
}
/* Implementation of to_load. */
static void
remote_load (struct target_ops *self, const char *name, int from_tty)
{
generic_load (name, from_tty);
}
/* Accepts an integer PID; returns a string representing a file that
can be opened on the remote side to get the symbols for the child
process. Returns NULL if the operation is not supported. */
static char *
remote_pid_to_exec_file (struct target_ops *self, int pid)
{
static char *filename = NULL;
struct inferior *inf;
char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
return NULL;
if (filename != NULL)
xfree (filename);
inf = find_inferior_pid (pid);
if (inf == NULL)
internal_error (__FILE__, __LINE__,
_("not currently attached to process %d"), pid);
if (!inf->fake_pid_p)
{
const int annex_size = 9;
annex = alloca (annex_size);
xsnprintf (annex, annex_size, "%x", pid);
}
filename = target_read_stralloc (&current_target,
TARGET_OBJECT_EXEC_FILE, annex);
return filename;
}
static void
2000-07-30 03:48:28 +02:00
init_remote_ops (void)
{
1999-07-07 22:19:36 +02:00
remote_ops.to_shortname = "remote";
remote_ops.to_longname = "Remote serial target in gdb-specific protocol";
1999-07-07 22:19:36 +02:00
remote_ops.to_doc =
"Use a remote computer via a serial line, using a gdb-specific protocol.\n\
2000-01-11 04:07:37 +01:00
Specify the serial device it is connected to\n\
(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).";
1999-07-07 22:19:36 +02:00
remote_ops.to_open = remote_open;
remote_ops.to_close = remote_close;
remote_ops.to_detach = remote_detach;
remote_ops.to_disconnect = remote_disconnect;
1999-07-07 22:19:36 +02:00
remote_ops.to_resume = remote_resume;
remote_ops.to_wait = remote_wait;
remote_ops.to_fetch_registers = remote_fetch_registers;
remote_ops.to_store_registers = remote_store_registers;
remote_ops.to_prepare_to_store = remote_prepare_to_store;
1999-07-07 22:19:36 +02:00
remote_ops.to_files_info = remote_files_info;
remote_ops.to_insert_breakpoint = remote_insert_breakpoint;
remote_ops.to_remove_breakpoint = remote_remove_breakpoint;
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
remote_ops.to_stopped_by_sw_breakpoint = remote_stopped_by_sw_breakpoint;
remote_ops.to_supports_stopped_by_sw_breakpoint = remote_supports_stopped_by_sw_breakpoint;
remote_ops.to_stopped_by_hw_breakpoint = remote_stopped_by_hw_breakpoint;
remote_ops.to_supports_stopped_by_hw_breakpoint = remote_supports_stopped_by_hw_breakpoint;
remote_ops.to_stopped_by_watchpoint = remote_stopped_by_watchpoint;
remote_ops.to_stopped_data_address = remote_stopped_data_address;
remote_ops.to_watchpoint_addr_within_range =
remote_watchpoint_addr_within_range;
remote_ops.to_can_use_hw_breakpoint = remote_check_watch_resources;
remote_ops.to_insert_hw_breakpoint = remote_insert_hw_breakpoint;
remote_ops.to_remove_hw_breakpoint = remote_remove_hw_breakpoint;
remote_ops.to_region_ok_for_hw_watchpoint
= remote_region_ok_for_hw_watchpoint;
remote_ops.to_insert_watchpoint = remote_insert_watchpoint;
remote_ops.to_remove_watchpoint = remote_remove_watchpoint;
1999-07-07 22:19:36 +02:00
remote_ops.to_kill = remote_kill;
remote_ops.to_load = remote_load;
remote_ops.to_mourn_inferior = remote_mourn;
* target.h (struct target_ops): Remove to_notice_signals; add to_pass_signals. (target_notice_signals): Remove. (target_pass_signals): Add prototype. * target.c (update_current_target): Remove to_notice_signals; mention to_pass_signals. (target_pass_signals): New function. (debug_to_notice_signals): Remove. (setup_target_debug): Do not install debug_to_notice_signals. * infrun.c (signal_pass): New global. (resume): Call target_pass_signals. (handle_inferior_event): Report all signals while stepping over non-steppable watchpoint. Reset trap_expected to ensure breakpoints are re-inserted when stepping over a signal handler. (signal_cache_update): New function. (signal_stop_update): Call it. (signal_print_update): Likewise. (signal_pass_update): Likewise. (handle_command): Call signal_cache_update and target_pass_signals instead of target_notice_signals. (_initialize_infrun): Initialize signal_pass. * linux-nat.c (pass_mask): New global. (linux_nat_pass_signals): New function. (linux_nat_create_inferior): Report all signals initially. (linux_nat_attach): Likewise. (linux_nat_resume): Use pass_mask to decide whether to directly handle an inferior signal. (linux_nat_wait_1): Likewise. (linux_nat_add_target): Install to_pass_signals callback. * nto-procfs.c (notice_signals): Remove. (procfs_resume): Do not call notice_signals. (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (init_procfs_ops): Install to_pass_signals callback instead of to_notice_signals callback. (_initialize_procfs): Report all signals initially. * procfs.c (procfs_notice_signals): Remove. (procfs_pass_signals): New function. (procfs_target): Install to_pass_signals callback instead of to_notice_signals callback. (register_gdb_signals): Remove. (procfs_debug_inferior): Report all signals initially. (procfs_init_inferior): Remove redundant register_gdb_signals call. * remote.c (remote_pass_signals): Add numsigs and pass_signals parameters; use them instead of calling signal_..._state routines. (remote_notice_signals): Remove. (remote_start_remote): Report all signals initially. (remote_resume): Do not call remote_pass_signals. (_initialize_remote): Install to_pass_signals callback instead of to_notice_signals callback.
2011-04-27 15:29:15 +02:00
remote_ops.to_pass_signals = remote_pass_signals;
remote_ops.to_program_signals = remote_program_signals;
remote_ops.to_thread_alive = remote_thread_alive;
Push pruning old threads down to the target 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-10-15 23:44:00 +02:00
remote_ops.to_update_thread_list = remote_update_thread_list;
remote_ops.to_pid_to_str = remote_pid_to_str;
remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_get_ada_task_ptid = remote_get_ada_task_ptid;
remote_ops.to_stop = remote_stop;
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
remote_ops.to_interrupt = remote_interrupt;
remote_ops.to_xfer_partial = remote_xfer_partial;
1999-08-09 23:36:23 +02:00
remote_ops.to_rcmd = remote_rcmd;
remote_ops.to_pid_to_exec_file = remote_pid_to_exec_file;
remote_ops.to_log_command = serial_log_command;
2005-04-15 21:58:59 +02:00
remote_ops.to_get_thread_local_address = remote_get_thread_local_address;
remote_ops.to_stratum = process_stratum;
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
remote_ops.to_has_all_memory = default_child_has_all_memory;
remote_ops.to_has_memory = default_child_has_memory;
remote_ops.to_has_stack = default_child_has_stack;
remote_ops.to_has_registers = default_child_has_registers;
remote_ops.to_has_execution = default_child_has_execution;
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */
2008-10-17 Michael Snyder <msnyder@vmware.com> Target interface for reverse debugging. * target.h (enum target_waitkind): Add new wait event, TARGET_WAITKIND_NO_HISTORY. (struct target_ops): New method to_can_execute_reverse. (target_can_execute_reverse): New macro. * target.c (update_current_target): Inherit to_can_execute_reverse. Remote interface for reverse debugging. * remote.c (remote_can_execute_reverse): New target method. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait_as): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (remote_vcont_resume): Jump out if attempting reverse execution. Event handling interface for reverse debugging. * infrun.c (execution_direction): New state variable. (enum inferior_stop_reason): Add NO_HISTORY reason. (handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY. Handle stepping over a function call in reverse. Handle stepping thru a line range in reverse. Handle setting a step-resume breakpoint in reverse. Handle stepping into a function in reverse. Handle stepping between line ranges in reverse. (print_stop_reason): Print reason for NO_HISTORY. (step_into_function): Rename to handle_step_into_function. (handle_step_into_function_backward): New function. (set_exec_direction_func, show_exec_direction_func): New funcs. (proceed): No need to singlestep over a breakpoint when resuming in reverse. * inferior.h (enum exec_direction_kind): New enum. (execution_direction): Export new execution state variable. * breakpoint.c (make_breakpoint_silent): New function. * breakpoint.h (make_breakpoint_silent): Export. * infcmd.c (finish_command): Check for reverse exec direction. (finish_backward): New function, handle finish cmd in reverse. User interface for reverse execution. * Makefile.in (reverse.c): New file. * reverse.c: New file. User interface for reverse execution.
2008-10-17 21:43:47 +02:00
remote_ops.to_can_execute_reverse = remote_can_execute_reverse;
1999-07-07 22:19:36 +02:00
remote_ops.to_magic = OPS_MAGIC;
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
remote_ops.to_memory_map = remote_memory_map;
* Makefile.in (SFILES): Add target-memory.c. (COMMON_OBS): Add target-memory.o. * memattr.c (lookup_mem_region): Adjust handling for the top of memory. Improve comments. * remote.c (packet_check_result): New function, split out from packet_ok. Recognize "E." as an error prefix. (packet_ok): Use it. (remote_write_bytes_aux): New function, renamed from remote_write_bytes. Take packet header, packet format, and length flag as arguments. (remote_write_bytes): Rewrite to use remote_write_bytes_aux. (remote_send_printf, restore_remote_timeout) (remote_flash_timeout, remote_flash_erase, remote_flash_write) (remote_flash_done): New. (remote_xfer_partial): Handle flash writes. (init_remote_ops, init_remote_async_ops): Set to_flash_erase and to_flash_done. * symfile.c (struct load_section_data): Include a pointer to the cumulative stats and a request queue. Move most members to other types. (struct load_progress_data, struct load_progress_section_data): New types. (load_progress): Handle a NULL baton and zero bytes. Update for type changes. (load_section_callback): Create memory write requests instead of writing to memory. Don't print the progress message here. (clear_memory_write_data): New function. (generic_load): Use target_write_memory_blocks. * target-memory.c: New file. * target.c (update_current_target): Mention new uninherited methods. (memory_xfer_partial): Issue an error for flash writes. (target_flash_erase, target_flash_done): New functions. (target_write_with_progress): Call the progress callback at the start also. * target.h (enum target_object): Add TARGET_OBJECT_FLASH. (target_write_with_progress): Update comment. (struct target_ops): Add to_flash_erase and to_flash_done. (target_flash_erase, target_flash_done, struct memory_write_request) (memory_write_request_s, enum flash_preserve_mode) (target_write_memory_blocks): New, including a vector type for memory_write_request_s.
2006-09-21 16:00:53 +02:00
remote_ops.to_flash_erase = remote_flash_erase;
remote_ops.to_flash_done = remote_flash_done;
remote_ops.to_read_description = remote_read_description;
remote_ops.to_search_memory = remote_search_memory;
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
remote_ops.to_can_async_p = remote_can_async_p;
remote_ops.to_is_async_p = remote_is_async_p;
remote_ops.to_async = remote_async;
remote_ops.to_terminal_inferior = remote_terminal_inferior;
remote_ops.to_terminal_ours = remote_terminal_ours;
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
remote_ops.to_supports_non_stop = remote_supports_non_stop;
remote_ops.to_supports_multi_process = remote_supports_multi_process;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
remote_ops.to_supports_disable_randomization
= remote_supports_disable_randomization;
remote_ops.to_filesystem_is_local = remote_filesystem_is_local;
2012-01-20 Pedro Alves <palves@redhat.com> Ulrich Weigand <ulrich.weigand@linaro.org> * configure.ac [AC_CHECK_FUNCS]: Check for pread and pwrite. * config.in, configure: Regenerate. * target.h (struct target_ops): Add to_fileio_open, to_fileio_pwrite, to_fileio_pread, to_fileio_close, to_fileio_unlink. (target_fileio_open): Add prototype. (target_fileio_pwrite): Likewise. (target_fileio_pread): Likewise. (target_fileio_close): Likewise. (target_fileio_unlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c: Include "gdb/fileio.h". (target_read_stralloc): Accept trailing, but not embedded NUL bytes. (default_fileio_target): New function. (target_fileio_open): Likewise. (target_fileio_pwrite): Likewise. (target_fileio_pread): Likewise. (target_fileio_close): Likewise. (target_fileio_unlink): Likewise. (target_fileio_close_cleanup): Likewise. (target_fileio_read_alloc_1): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * inf-child.c: Include "gdb/fileio.h", <sys/types.h>, <sys/stat.h>, <fcntl.h>, and <unistd.h>. (inf_child_fileio_open_flags_to_host): New function. (inf_child_errno_to_fileio_error): Likewise. (inf_child_fileio_open): Likewise. (inf_child_fileio_pwrite): Likewise. (inf_child_fileio_pread): Likewise. (inf_child_fileio_close): Likewise. (inf_child_fileio_unlink): Likewise. (inf_child_target): Install to_fileio routines. * remote.c (init_remote_ops): Install to_fileio routines.
2012-01-20 10:45:51 +01:00
remote_ops.to_fileio_open = remote_hostio_open;
remote_ops.to_fileio_pwrite = remote_hostio_pwrite;
remote_ops.to_fileio_pread = remote_hostio_pread;
remote_ops.to_fileio_fstat = remote_hostio_fstat;
2012-01-20 Pedro Alves <palves@redhat.com> Ulrich Weigand <ulrich.weigand@linaro.org> * configure.ac [AC_CHECK_FUNCS]: Check for pread and pwrite. * config.in, configure: Regenerate. * target.h (struct target_ops): Add to_fileio_open, to_fileio_pwrite, to_fileio_pread, to_fileio_close, to_fileio_unlink. (target_fileio_open): Add prototype. (target_fileio_pwrite): Likewise. (target_fileio_pread): Likewise. (target_fileio_close): Likewise. (target_fileio_unlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c: Include "gdb/fileio.h". (target_read_stralloc): Accept trailing, but not embedded NUL bytes. (default_fileio_target): New function. (target_fileio_open): Likewise. (target_fileio_pwrite): Likewise. (target_fileio_pread): Likewise. (target_fileio_close): Likewise. (target_fileio_unlink): Likewise. (target_fileio_close_cleanup): Likewise. (target_fileio_read_alloc_1): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * inf-child.c: Include "gdb/fileio.h", <sys/types.h>, <sys/stat.h>, <fcntl.h>, and <unistd.h>. (inf_child_fileio_open_flags_to_host): New function. (inf_child_errno_to_fileio_error): Likewise. (inf_child_fileio_open): Likewise. (inf_child_fileio_pwrite): Likewise. (inf_child_fileio_pread): Likewise. (inf_child_fileio_close): Likewise. (inf_child_fileio_unlink): Likewise. (inf_child_target): Install to_fileio routines. * remote.c (init_remote_ops): Install to_fileio routines.
2012-01-20 10:45:51 +01:00
remote_ops.to_fileio_close = remote_hostio_close;
remote_ops.to_fileio_unlink = remote_hostio_unlink;
remote_ops.to_fileio_readlink = remote_hostio_readlink;
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
remote_ops.to_supports_enable_disable_tracepoint = remote_supports_enable_disable_tracepoint;
remote_ops.to_supports_string_tracing = remote_supports_string_tracing;
2012-02-24 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_supports_cond_breakpoints): New forward declaration. (remote_add_target_side_condition): New function. (remote_insert_breakpoint): Add target-side breakpoint conditional if supported. (remote_insert_hw_breakpoint): Likewise. (init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions hook. * target.c (update_current_target): Inherit to_supports_evaluation_of_breakpoint_conditions. Default to_supports_evaluation_of_breakpoint_conditions to return_zero. * target.h (struct target_ops) <to_supports_evaluation_of_breakpoint_conditions>: New field. (target_supports_evaluation_of_breakpoint_conditions): New #define. * breakpoint.c (get_first_locp_gte_addr): New forward declaration. (condition_evaluation_both, condition_evaluation_auto, condition_evaluation_host, condition_evaluation_target, condition_evaluation_enums, condition_evaluation_mode_1, condition_evaluation_mode): New static globals. (translate_condition_evaluation_mode): New function. (breakpoint_condition_evaluation_mode): New function. (gdb_evaluates_breakpoint_condition_p): New function. (ALL_BP_LOCATIONS_AT_ADDR): New helper macro. (mark_breakpoint_modified): New function. (mark_breakpoint_location_modified): New function. (set_condition_evaluation_mode): New function. (show_condition_evaluation_mode): New function. (bp_location_compare_addrs): New function. (get_first_location_gte_addr): New helper function. (set_breakpoint_condition): Free condition bytecode if locations has become unconditional. Call mark_breakpoint_modified (...). (condition_command): Call update_global_location_list (1) for breakpoints. (breakpoint_xfer_memory): Use is_breakpoint (...). (is_breakpoint): New function. (parse_cond_to_aexpr): New function. (build_target_condition_list): New function. (insert_bp_location): Handle target-side conditional breakpoints and call build_target_condition_list (...). (update_inserted_breakpoint_locations): New function. (insert_breakpoint_locations): Handle target-side conditional breakpoints. (bpstat_check_breakpoint_conditions): Add comment. (bp_condition_evaluator): New function. (bp_location_condition_evaluator): New function. (print_breakpoint_location): Print information on where the condition will be evaluated. (print_one_breakpoint_location): Likewise. (init_bp_location): Call mark_breakpoint_location_modified (...) for breakpoint location. (force_breakpoint_reinsertion): New functions. (update_global_location_list): Handle target-side breakpoint conditions. Reinsert locations that are already inserted if conditions have changed. (bp_location_dtor): Free agent expression bytecode. (disable_breakpoint): Call mark_breakpoint_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (disable_command): Call mark_breakpoint_location_modified (...). Call update_global_location_list (...) with parameter 1 for breakpoints. (enable_breakpoint_disp): Call mark_breakpoint_modified (...). (enable_command): mark_breakpoint_location_modified (...). (_initialize_breakpoint): Update documentation and add condition-evaluation breakpoint subcommand. * breakpoint.h: Include ax.h. (condition_list): New data structure. (condition_status): New enum. (bp_target_info) <cond_list>: New field. (bp_location) <condition_changed, cond_bytecode>: New fields. (is_breakpoint): New prototype.
2012-02-24 16:10:59 +01:00
remote_ops.to_supports_evaluation_of_breakpoint_conditions = remote_supports_cond_breakpoints;
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
remote_ops.to_can_run_breakpoint_commands = remote_can_run_breakpoint_commands;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
remote_ops.to_trace_init = remote_trace_init;
remote_ops.to_download_tracepoint = remote_download_tracepoint;
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
remote_ops.to_can_download_tracepoint = remote_can_download_tracepoint;
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
remote_ops.to_download_trace_state_variable
= remote_download_trace_state_variable;
Add support for enabling and disabling tracepoints while a trace experiment is still running. gdb/ * breakpoint.c (disable_breakpoint): Disable all locations associated with a tracepoint on target if a trace experiment is running. (disable_command): Disable a specific tracepoint location on target if a trace experiment is running. (do_enable_breakpoint): Enable all locations associated with a tracepoint on target if a trace experiment is running. (enable_command) Enable a specific tracepoint location on target if a trace experiment is running. * target.c (update_current_target): Add INHERIT and de_fault clauses for to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint. * target.h: Add declaration of struct bp_location. (struct target_ops): Add new functions to_supports_enable_disable_tracepoint, to_enable_tracepoint and to_disable_tracepoint to target operations. (target_supports_enable_disable_tracepoint): New macro. (target_enable_tracepoint): New macro. (target_disable_tracepoint): New macro. * remote.c (struct remote_state): Add new field. (remote_enable_disable_tracepoint_feature): New. (remote_protocol_features): Add new entry. (remote_supports_enable_disable_tracepoint): New. (remote_enable_tracepoint): New. (remote_disable_tracepoint): New. (init_remote_ops): Add remote_enable_tracepoint, remote_disable_tracepoint and remote_supports_enable_disable_tracepoint to remote operations. * tracepoint.c (start_tracing): Allow tracing to start without any tracepoints enabled with just a warning if they can be re-enabled later. * NEWS: Add news item for the new behaviour of the enable and disable GDB commands when applied to tracepoints. Add news items for the new remote packets QTEnable and QTDisable. gdb/doc/ * gdb.texinfo: Document change in the behaviour of the enable and disable GDB commands when applied to tracepoints. Document the EnableDisableTracepoints remote stub feature. Document QTEnable and QTDisable in the list of tracepoint packets. gdb/gdbserver/ * server.c (handle_query): Add EnableDisableTracepoints to the list of supported features. * tracepoint.c (clear_installed_tracepoints): Uninstall disabled tracepoints. (cmd_qtenable_disable): New. (cmd_qtstart): Install tracepoints even if disabled. (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on receiving a QTEnable or QTDisable packet. (gdb_collect): Skip data collection if fast tracepoint is disabled. (ust_marker_to_static_tracepoint): Do not ignore disabled static tracepoints. (gdb_probe): Skip data collection if static tracepoint is disabled.
2011-05-12 14:09:17 +02:00
remote_ops.to_enable_tracepoint = remote_enable_tracepoint;
remote_ops.to_disable_tracepoint = remote_disable_tracepoint;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
remote_ops.to_trace_set_readonly_regions = remote_trace_set_readonly_regions;
remote_ops.to_trace_start = remote_trace_start;
remote_ops.to_get_trace_status = remote_get_trace_status;
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
remote_ops.to_get_tracepoint_status = remote_get_tracepoint_status;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
remote_ops.to_trace_stop = remote_trace_stop;
remote_ops.to_trace_find = remote_trace_find;
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
remote_ops.to_get_trace_state_variable_value
= remote_get_trace_state_variable_value;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
remote_ops.to_save_trace_data = remote_save_trace_data;
remote_ops.to_upload_tracepoints = remote_upload_tracepoints;
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
remote_ops.to_upload_trace_state_variables
= remote_upload_trace_state_variables;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
remote_ops.to_get_raw_trace_data = remote_get_raw_trace_data;
2011-11-14 Stan Shebs <stan@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> * NEWS: Document shorter fast tracepoints and qTMinFTPILen packet. * i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for the minimum instruction size for fast tracepoints. * target.h (struct target_ops): Add new method to_get_min_fast_tracepoint_insn_len. (target_get_min_fast_tracepoint_insn_len): New. * target.c (update_current_target): Set up new target operation. * remote.c (remote_write_bytes_aux): Fix typo. (remote_get_min_fast_tracepoint_insn_len): New. (init_remote_ops): Initialize new field. * gdb.texinfo (Create and Delete Tracepoints): Describe what is needed to get shorter fast tracepoints. (Tracepoint Packets): Document new qTMinFTPILen packet. * linux-x86-low.c (small_jump_insn): New. (i386_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message, build a trampoline and issue a small jump instruction to it. (x86_install_fast_tracepoint_jump_pad): Add arguments for trampoline and error message. (x86_get_min_fast_tracepoint_insn_len): New. (the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len. * linux-low.h (struct linux_target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new operation. * linux-low.c (linux_install_fast_tracepoint_jump_pad): Add arguments. (linux_get_min_fast_tracepoint_insn_len): New function. (linux_target_op): Add new operation. * tracepoint.c (gdb_trampoline_buffer): New IPA variable. (gdb_trampoline_buffer_end): Ditto. (gdb_trampoline_buffer_error): Ditto. (struct ipa_sym_addresses): Add fields for new IPA variables. (symbol_list): Add entries for new IPA variables. (struct tracepoint): Add fields to hold the address range of the trampoline used by the tracepoint. (trampoline_buffer_head): New static variable. (trampoline_buffer_tail): Ditto. (claim_trampoline_space): New function. (have_fast_tracepoint_trampoline_buffer): New function. (clone_fast_tracepoint): Fill in trampoline fields of tracepoint structure. (install_fast_tracepoint): Ditto, also add error buffer argument. (cmd_qtminftpilen): New function. (handle_tracepoint_query): Add response to qTMinFTPILen packet. (fast_tracepoint_from_trampoline_address): New function. (fast_tracepoint_collecting): Handle trampoline as part of jump pad space. (set_trampoline_buffer_space): New function. (initialize_tracepoint): Initialize new IPA variables. * target.h (struct target_ops): Add arguments to install_fast_tracepoint_jump_pad operation, add new get_min_fast_tracepoint_insn_len operation. (target_get_min_fast_tracepoint_insn_len): New. (install_fast_tracepoint_jump_pad): Add arguments. * server.h (IPA_BUFSIZ): Define. * linux-i386-ipa.c: Include extra header files. (initialize_fast_tracepoint_trampoline_buffer): New function. (initialize_low_tracepoint): Call it. * server.h (set_trampoline_buffer_space): Declare. (claim_trampoline_space): Ditto. (have_fast_tracepoint_trampoline_buffer): Ditto. * gdb.trace/ftrace.c: New. * gdb.trace/ftrace.exp: New.
2011-11-14 21:07:25 +01:00
remote_ops.to_get_min_fast_tracepoint_insn_len = remote_get_min_fast_tracepoint_insn_len;
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
remote_ops.to_set_disconnected_tracing = remote_set_disconnected_tracing;
remote_ops.to_set_circular_trace_buffer = remote_set_circular_trace_buffer;
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
remote_ops.to_set_trace_buffer_size = remote_set_trace_buffer_size;
* NEWS: Mention tracepoint additions. * breakpoint.h (struct tracepoint): New field traceframe_usage. * breakpoint.c (print_one_breakpoint_location): Identify tracepoints as such when reporting hit counts, report trace buffer usage. (create_tracepoint_from_upload): Copy status info. * tracepoint.h (struct trace_status): Rename error_desc to stop_desc, add fields user_name, notes, start_time, stop_time. (struct uploaded_tp): Add fields hit_count, traceframe_usage. * tracepoint.c (trace_user): New global. (trace_notes): New global. (trace_stop_notes): New global. (start_tracing): Add argument and trace note handling. (stop_tracing): Ditto. (trace_start_command): Add notes argument. (trace_stop_command): Ditto. (trace_status_command): Report additional status info. (trace_status_mi): Similarly. (trace_save): Update, record tracepoint status. (set_disconnected_tracing): Call target method directly. (send_disconnected_tracing_value): Remove. (set_trace_user): New function. (set_trace_notes): New function. (set_trace_stop_notes): New function. (parse_trace_status): Handle additional status. (parse_tracepoint_status): New function. (parse_tracepoint_definition): Call it. (tfile_get_tracepoint_status): New function. (init_tfile_ops): Use it. (_initialize_tracepoint): Add new setshows. * target.h (struct target_ops): New methods to_get_tracepoint_status and to_set_trace_notes. (target_get_tracepoint_status): New macro. (target_set_trace_notes): New macro. * target.c (update_current_target): Add new methods. * remote.c (remote_get_tracepoint_status): New function. (remote_set_trace_notes): New function. (init_remote_ops): Add them. * mi/mi-main.c (mi_cmd_trace_start): Add argument to call. (mi_cmd_trace_stop): Ditto. * tracepoint.c (struct tracepoint): New field traceframe_usage. (tracing_start_time): New global. (tracing_stop_time): New global. (tracing_user_name): New global. (tracing_notes): New global. (tracing_stop_note): New global. (cmd_qtstart): Set traceframe_usage, start_time. (stop_tracing): Set stop_time. (cmd_qtstatus): Report additional status. (cmd_qtp): New function. (handle_tracepoint_query): Call it. (cmd_qtnotes): New function. (handle_tracepoint_general_set): Call it. (get_timestamp): Rename from tsv_get_timestamp. * gdb.texinfo (Starting and Stopping Trace Experiments): Document note-related options and variables. (Tracepoint Packets): Document packet changes. * gdb.trace/tstatus.exp: New. * gdb.trace/actions.c: Include string.h.
2011-11-21 00:59:49 +01:00
remote_ops.to_set_trace_notes = remote_set_trace_notes;
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
remote_ops.to_core_of_thread = remote_core_of_thread;
remote_ops.to_verify_memory = remote_verify_memory;
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
remote_ops.to_get_tib_address = remote_get_tib_address;
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
remote_ops.to_set_permissions = remote_set_permissions;
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
remote_ops.to_static_tracepoint_marker_at
= remote_static_tracepoint_marker_at;
remote_ops.to_static_tracepoint_markers_by_strid
= remote_static_tracepoint_markers_by_strid;
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
remote_ops.to_traceframe_info = remote_traceframe_info;
remote_ops.to_use_agent = remote_use_agent;
remote_ops.to_can_use_agent = remote_can_use_agent;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
remote_ops.to_supports_btrace = remote_supports_btrace;
remote_ops.to_enable_btrace = remote_enable_btrace;
remote_ops.to_disable_btrace = remote_disable_btrace;
remote_ops.to_teardown_btrace = remote_teardown_btrace;
remote_ops.to_read_btrace = remote_read_btrace;
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
remote_ops.to_btrace_conf = remote_btrace_conf;
remote_ops.to_augmented_libraries_svr4_read =
remote_augmented_libraries_svr4_read;
}
/* Set up the extended remote vector by making a copy of the standard
remote vector and adding to it. */
static void
2000-07-30 03:48:28 +02:00
init_extended_remote_ops (void)
{
extended_remote_ops = remote_ops;
1999-06-14 20:08:47 +02:00
extended_remote_ops.to_shortname = "extended-remote";
1999-07-07 22:19:36 +02:00
extended_remote_ops.to_longname =
"Extended remote serial target in gdb-specific protocol";
1999-07-07 22:19:36 +02:00
extended_remote_ops.to_doc =
"Use a remote computer via a serial line, using a gdb-specific protocol.\n\
Specify the serial device it is connected to (e.g. /dev/ttya).";
extended_remote_ops.to_open = extended_remote_open;
extended_remote_ops.to_create_inferior = extended_remote_create_inferior;
extended_remote_ops.to_mourn_inferior = extended_remote_mourn;
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
extended_remote_ops.to_detach = extended_remote_detach;
extended_remote_ops.to_attach = extended_remote_attach;
extended_remote_ops.to_post_attach = extended_remote_post_attach;
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
extended_remote_ops.to_kill = extended_remote_kill;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
extended_remote_ops.to_supports_disable_randomization
= extended_remote_supports_disable_randomization;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
extended_remote_ops.to_follow_fork = remote_follow_fork;
Extended-remote fork catch This patch implements catchpoints for fork events on extended-remote Linux targets. Implementation appeared to be straightforward, requiring four new functions in remote.c to implement insert/remove of fork/vfork catchpoints. These functions are essentially stubs that just return 0 ('success') if the required features are enabled. If the fork events are being reported, then catchpoints are set and hit. However, there are some extra issues that arise with catchpoints. 1) Thread creation reporting -- fork catchpoints are hit before the follow_fork has been completed. When stopped at a fork catchpoint in the native implementation, the new process is not 'reported' until after the follow is done. It doesn't show up in the inferiors list or the threads list. However, in the gdbserver case, an 'info threads' while stopped at a fork catchpoint will retrieve the new thread info from the target and add it to GDB's data structures, prior to the follow operations. Because of this premature report, things on the GDB side eventually get very confused. So in remote.c:remote_update_thread_list, we check to see if there are any pending fork parent threads. If there are we remove the related fork child thread from the thread list sent by the target. 2) Kill process before fork is followed -- on the native side in linux-nat.c:linux_nat_kill, there is some code to handle the case where a fork has occurred but follow_fork hasn't been called yet. It does this by using the last status to determine if a follow is pending, and if it is, to kill the child task. The use of last_status is fragile in situations like non-stop mode where other events may have occurred after the fork event. This patch identifies a fork parent in remote.c:extended_remote_kill in a way similar to that used in thread creation reporting above. If one is found, it kills the new child as well. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the case of killing the forking process before the fork has been followed manually. gdb/ChangeLog: * remote.c (remote_insert_fork_catchpoint): New function. (remote_remove_fork_catchpoint): New function. (remote_insert_vfork_catchpoint): New function. (remote_remove_vfork_catchpoint): New function. (pending_fork_parent_callback): New function. (remove_new_fork_child): New function. (remote_update_thread_list): Call remote_notif_get_pending_events and remove_new_fork_child. (extended_remote_kill): Kill fork child when killing the parent before follow_fork completes. (init_extended_remote_ops): Initialize target vector with new fork catchpoint functions.
2015-05-12 18:52:46 +02:00
extended_remote_ops.to_insert_fork_catchpoint
= remote_insert_fork_catchpoint;
extended_remote_ops.to_remove_fork_catchpoint
= remote_remove_fork_catchpoint;
extended_remote_ops.to_insert_vfork_catchpoint
= remote_insert_vfork_catchpoint;
extended_remote_ops.to_remove_vfork_catchpoint
= remote_remove_vfork_catchpoint;
1999-06-14 20:08:47 +02:00
}
1999-09-28 23:55:21 +02:00
static int
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
remote_can_async_p (struct target_ops *ops)
1999-09-28 23:55:21 +02:00
{
struct remote_state *rs = get_remote_state ();
if (!target_async_permitted)
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
/* We only enable async when the user specifically asks for it. */
return 0;
/* We're async whenever the serial device is. */
return serial_can_async_p (rs->remote_desc);
1999-09-28 23:55:21 +02:00
}
static int
add "this" pointers to more target APIs A subsequent pass introduces delegation helper functions to the target API. This delegation is much cleaner if the target_ops pointer is directly available at delegation time. This patch adds the "this" pointer to various to_* methods for this purpose. This updates a number of ports which I am unable to test. Please give them a look-over. Any possible problem here is trivial, though, as all that is required is adding an argument to a function. 2014-02-19 Tom Tromey <tromey@redhat.com> * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint): Add 'ops' argument. * arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add 'ops' argument. * i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument. * ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add 'ops' argument. * inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops' argument. * linux-nat.c (save_sigtrap): Update. (linux_nat_stopped_by_watchpoint, linux_nat_is_async_p) (linux_nat_can_async_p, linux_nat_async): Add 'ops' argument. (linux_nat_close): Update. * mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops' argument. * ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops' argument. * procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument. * record-full.c (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_async, tmp_to_stopped_by_watchpoint) (tmp_to_async): Add 'ops' argument. (record_full_stopped_by_watchpoint, record_full_async) (record_full_can_async_p, record_full_is_async_p): Add 'ops' argument. * remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint) (m32r_stopped_by_watchpoint): Add 'ops' argument. * remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument. * remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p) (remote_is_async_p, remote_async): Add 'ops' argument. (remote_stopped_data_address): Update. * s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument. * target.c (update_current_target) (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Update. (debug_to_stopped_by_watchpoint): Add 'ops' argument. * target.h (struct target_ops) <to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument. (target_can_async_p, target_is_async_p, target_async) (target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
remote_is_async_p (struct target_ops *ops)
1999-09-28 23:55:21 +02:00
{
struct remote_state *rs = get_remote_state ();
if (!target_async_permitted)
Replace 'target async' by 'maintenance set remote-async' and 'target remote' combination. * remote.c (remote_async_wait): Merge into remote_wait, and remove. (remote_async_permitted, remote_async_permitted_set): New variables. (set_maintenance_remote_async_permitted) (show_maintenance_remote_async_permitted): New functions. (remote_async_ops, extended_async_remote_ops): Delete. (remote_async_open, extended_remote_async_open): Delete. (remote_open_1): Drop async_p parameter. Update callers. Replace async_p with remote_async_permitted checks. (extended_async_remote_attach): Delete. (remote_resume, remote_async_resume): Merge and leave remote_resume. (remote_async_terminal_inferior): Rename to... (remote_terminal_inferior): ... this, and add remote_async_termitted check. (remote_async_terminal_ours): Rename to... (remote_terminal_ours): ... this, and add remote_async_termitted check. (remote_wait, remote_async_wait): Merge and leave remote_wait only. (remote_kill, remote_async_kill): Merge and leave remote_kill only. (remote_async_mourn, extended_async_remote_mourn): Delete. (extended_remote_create_inferior_1): Drop async_p parameter. Update callers. Always use extended_remote_ops. (extended_remote_async_create_inferior): Delete. (remote_return_zero): Delete. (init_remote_ops): Register remote_can_async_p, remote_async, remote_async_mask, remote_terminal_inferior and remote_terminal_ours. (remote_can_async_p, remote_is_async_p): Check for remote_async_permitted. (init_remote_async_ops, init_extended_async_remote_ops): Remove. (set_remote_cmd): Don't add async and extended-async targets. (_initialize_remote): Add set/show remote-async maintenance commands. gdb/doc/ * gdb.texinfo (-target-select): Remove reference to target async. (Maintenance Commands): Document "maint set/show remote-async".
2008-06-05 23:35:00 +02:00
/* We only enable async when the user specifically asks for it. */
return 0;
/* We're async whenever the serial device is. */
return serial_is_async_p (rs->remote_desc);
1999-09-28 23:55:21 +02:00
}
1999-10-06 01:13:56 +02:00
/* Pass the SERIAL event on and up to the client. One day this code
will be able to delay notifying the client of an event until the
point where an entire packet has been received. */
1999-10-06 01:13:56 +02:00
static serial_event_ftype remote_async_serial_handler;
1999-09-28 23:55:21 +02:00
static void
2001-07-11 19:52:32 +02:00
remote_async_serial_handler (struct serial *scb, void *context)
1999-09-28 23:55:21 +02:00
{
struct remote_state *rs = context;
1999-10-06 01:13:56 +02:00
/* Don't propogate error information up to the client. Instead let
the client find out about the error by querying the target. */
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
inferior_event_handler (INF_REG_EVENT, NULL);
1999-10-06 01:13:56 +02:00
}
Remote non-stop mode support. * remote.c (pending_stop_reply): New. (struct remote_state) <non_stop_aware, support_vCont_t>: New fields. (remote_async_inferior_event_token) (remote_async_get_pending_events_token): New. (notice_new_inferiors): New, abstracted out from record_currthread. (record_currthread): Call it. (remote_threads_info): Default threads to running in non-stop mode. In non-stop mode, only qfThreadInfo is supported. (remote_close): Discard all pending stop_replies. Close the event sources. (set_stop_requested_callback): New. (remote_start_remote): Implement non-stop mode startup. In all-stop, don't clear the thread list here. (remote_non_stop_feature): New. (remote_protocol_features): Add a "QNonStop" feature. (remote_open_1): Clear cached_wait_status and non_stop_aware. Clear the thread list here. (remote_detach_1): Discard pending stop replies of the process we detached from. (extended_remote_attach_1): Implement non-stop mode. (remote_vcont_probe): Recognize `vCont;t'. (remote_vcont_resume): Implement non-stop mode. (remote_resume): Don't set waiting_for_stop_reply in non-stop mode. (remote_stop_ns): New. (remote_stop): Rename to ... (remote_stop_as): ... this. If we have a cached wait status, don't bother interrupting the remote. (remote_stop): Reimplement as wrapper around remote_stop_as and remote_stop_ns. (interrupt_query): Don't query in async mode. (struct cached_reg, cahed_reg_t): New. (struct stop_reply): New. (stop_reply_queue): New. (stop_reply_xmalloc, stop_reply_xfree) (discard_pending_stop_replies, do_stop_reply_xfree) (queued_stop_reply, push_stop_reply, peek_stop_reply) (remote_parse_stop_reply, remote_get_pending_stop_replies) (process_stop_reply): New. (remote_wait_ns): New. (remote_wait_as): Use remote_parse_stop_reply. Invalidate the notion of current general thread is a process exit was reported. (remote_wait): Call remote_wait_ns in non-stop mode. (handle_notification): New. (putpkt_binary): Handle notifications. Don't care for waiting_for_stop_reply in non-stop mode. (getpkt_sane): Rename to ... (getpkt_or_notif_sane_1): ... this. Add `expecting_notif' argument. Handle it. Handle notifications. (getpkt_sane): Reimplement as wrapper around getpkt_or_notif_sane_1. (getpkt_or_notif_sane): New. (select_new_thread_callback): Check for exited state instead of comparing the ptid against minus_one_ptid. (extended_remote_create_inferior_1): Query the remote about the current thread. (remote_supports_non_stop): New. (init_remote_ops): Register it. (remote_async_inferior_event_handler): New. (remote_async_get_pending_events_handler): New. * infcmd.c (proceed_thread_callback): Comment. (proceed_after_attach_callback, proceed_after_attach): New. (attach_command_post_wait): In background attach, resume all threads, but only if they are unsignalled, and not explicitly stopped. In foreground attach, in non-stop mode, make sure to stop all threads of the just attached to process. (attach_command): In non-stop mode: If doing a background attach, stop at least one thread. If a foreground attach, stop all threads.
2008-10-24 22:38:26 +02:00
static void
remote_async_inferior_event_handler (gdb_client_data data)
{
inferior_event_handler (INF_REG_EVENT, NULL);
}
1999-10-06 01:13:56 +02:00
static void
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
remote_async (struct target_ops *ops, int enable)
1999-10-06 01:13:56 +02:00
{
struct remote_state *rs = get_remote_state ();
Simplify target_async hook interface All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
if (enable)
1999-10-06 01:13:56 +02:00
{
serial_async (rs->remote_desc, remote_async_serial_handler, rs);
When disabling target async, remove all target event sources from the event loop The sigall-reverse.exp test occasionally fails with something like this: (gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM continue Continuing. The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout) This is another event-loop/async related problem exposed by the patch that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9). The problem is that even though gdb_readline_wrapper disables target-async while the secondary prompt is in progress, the record target's async event source is left marked. So when gdb_readline_wrapper nests an event loop to process input, it may happen that that event loop ends up processing a target event while GDB is not really ready for it. Here's the relevant part of the backtrace showing the root issue in action: ... #14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158 #15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57 #16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791 #17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067 #18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339 #19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360 #20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842 #21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279 #22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?") at src/gdb/utils.c:1358 #23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933 With my all-stop-on-top-of-non-stop series, I'm also seeing gdb.server/ext-attach.exp fail occasionally due to the same issue. The first part of the fix is for target_async implementations to make sure to remove/unmark all target-related event sources from the event loop. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2015-02-03 Pedro Alves <palves@redhat.com> * event-loop.c (clear_async_event_handler): New function. * event-loop.h (clear_async_event_handler): New declaration. * record-btrace.c (record_btrace_async): New function. (init_record_btrace_ops): Install record_btrace_async. * record-full.c (record_full_async): New function. (record_full_resume): Don't mark the async event source here. (init_record_full_ops): Install record_full_async. (record_full_core_resume): Don't mark the async event source here. (init_record_full_core_ops): Install record_full_async. * remote.c (remote_async): Mark and clear the async stop reply queue event-loop token as appropriate.
2015-02-03 16:07:54 +01:00
/* If there are pending events in the stop reply queue tell the
event loop to process them. */
if (!QUEUE_is_empty (stop_reply_p, stop_reply_queue))
mark_async_event_handler (remote_async_inferior_event_token);
1999-10-06 01:13:56 +02:00
}
else
When disabling target async, remove all target event sources from the event loop The sigall-reverse.exp test occasionally fails with something like this: (gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM continue Continuing. The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout) This is another event-loop/async related problem exposed by the patch that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9). The problem is that even though gdb_readline_wrapper disables target-async while the secondary prompt is in progress, the record target's async event source is left marked. So when gdb_readline_wrapper nests an event loop to process input, it may happen that that event loop ends up processing a target event while GDB is not really ready for it. Here's the relevant part of the backtrace showing the root issue in action: ... #14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158 #15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57 #16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791 #17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067 #18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339 #19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360 #20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842 #21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279 #22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?") at src/gdb/utils.c:1358 #23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933 With my all-stop-on-top-of-non-stop series, I'm also seeing gdb.server/ext-attach.exp fail occasionally due to the same issue. The first part of the fix is for target_async implementations to make sure to remove/unmark all target-related event sources from the event loop. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2015-02-03 Pedro Alves <palves@redhat.com> * event-loop.c (clear_async_event_handler): New function. * event-loop.h (clear_async_event_handler): New declaration. * record-btrace.c (record_btrace_async): New function. (init_record_btrace_ops): Install record_btrace_async. * record-full.c (record_full_async): New function. (record_full_resume): Don't mark the async event source here. (init_record_full_ops): Install record_full_async. (record_full_core_resume): Don't mark the async event source here. (init_record_full_core_ops): Install record_full_async. * remote.c (remote_async): Mark and clear the async stop reply queue event-loop token as appropriate.
2015-02-03 16:07:54 +01:00
{
serial_async (rs->remote_desc, NULL, NULL);
clear_async_event_handler (remote_async_inferior_event_token);
}
1999-09-28 23:55:21 +02:00
}
1999-07-27 02:51:29 +02:00
static void
1999-12-07 04:56:43 +01:00
set_remote_cmd (char *args, int from_tty)
1999-07-27 02:51:29 +02:00
{
make calls to help_list use enumerator Currently there are many calls to help_list that pass the constant -1 as the "class" value. However, the parameter is declared as being of type enum command_class, and uses of the constant violate this abstraction. This patch fixes the error everywhere it occurs in the gdb sources. Tested by rebuilding. 2014-06-13 Tom Tromey <tromey@redhat.com> * cp-support.c (maint_cplus_command): Pass all_commands, not -1, to help_list. * guile/guile.c (info_guile_command): Pass all_commands, not -1, to help_list. * tui/tui-win.c (tui_command): Pass all_commands, not -1, to help_list. * tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to help_list.Pass all_commands, not -1, to help_list. * cli/cli-dump.c (dump_command, append_command) (srec_dump_command, ihex_dump_command, tekhex_dump_command) (binary_dump_command, binary_append_command): Pass all_commands, not -1, to help_list. * cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not -1, to help_list. * valprint.c (set_print, set_print_raw): Pass all_commands, not -1, to help_list. * typeprint.c (set_print_type): Pass all_commands, not -1, to help_list. * top.c (set_history): Pass all_commands, not -1, to help_list. * target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass all_commands, not -1, to help_list. * symfile.c (overlay_command): Pass all_commands, not -1, to help_list. * spu-tdep.c (info_spu_command): Pass all_commands, not -1, to help_list. * serial.c (serial_set_cmd): Pass all_commands, not -1, to help_list. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not -1, to help_list. * remote.c (remote_command, set_remote_cmd): Pass all_commands, not -1, to help_list. * ravenscar-thread.c (set_ravenscar_command): Pass all_commands, not -1, to help_list. * maint.c (maintenance_command, maintenance_info_command) (maintenance_print_command, maintenance_set_cmd): Pass all_commands, not -1, to help_list. * macrocmd.c (macro_command): Pass all_commands, not -1, to help_list. * language.c (set_check): Pass all_commands, not -1, to help_list. * infcmd.c (unset_command): Pass all_commands, not -1, to help_list. * frame.c (set_backtrace_cmd): Pass all_commands, not -1, to help_list. * dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to help_list. * dcache.c (set_dcache_command): Pass all_commands, not -1, to help_list. * breakpoint.c (save_command): Pass all_commands, not -1, to help_list. * ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass all_commands, not -1, to help_list.
2014-06-05 16:25:00 +02:00
help_list (remote_set_cmdlist, "set remote ", all_commands, gdb_stdout);
1999-07-27 02:51:29 +02:00
}
static void
show_remote_cmd (char *args, int from_tty)
{
/* We can't just use cmd_show_list here, because we want to skip
the redundant "show remote Z-packet" and the legacy aliases. */
struct cleanup *showlist_chain;
struct cmd_list_element *list = remote_show_cmdlist;
2011-08-04 Pedro Alves <pedro@codesourcery.com> * ui-out.h (uiout): Rename to ... (current_uiout): ... this. * ui-out.c (uiout): Rename to ... (current_uiout): ... this. * ada-lang.c (print_it_exception, print_one_exception) (print_mention_exception): Adjust. * breakpoint.c (watchpoint_check): Adjust. (print_breakpoint_location, print_one_breakpoint, breakpoint_1) (default_collect_info, watchpoints_info, print_one_catch_fork) (print_one_catch_vfork, print_one_catch_syscall) (print_one_catch_exec, mention, print_it_ranged_breakpoint) (print_one_ranged_breakpoint, print_mention_ranged_breakpoint) (print_it_watchpoint, print_mention_watchpoint) (print_it_masked_watchpoint, print_mention_masked_watchpoint) (print_it_exception_catchpoint, print_one_exception_catchpoint) (print_mention_exception_catchpoint, say_where, bkpt_print_it) (bkpt_print_mention, momentary_bkpt_print_it) (tracepoint_print_mention, update_static_tracepoint) (tracepoints_info, save_breakpoints): Adjust. * cli-out.c (field_separator): Adjust. * cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust. * exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust. * frame.c (get_current_frame): Adjust. * infcmd.c (run_command_1, print_return_value): Adjust. * inferior.c (inferior_command, info_inferiors_command): Adjust. * infrun.c (print_end_stepping_range_reason): Adjust. (print_signal_exited_reason, print_exited_reason): Adjust. (print_signal_received_reason, print_no_history_reason): Adjust. * interps.c (interp_set): Adjust. * osdata.c (info_osdata_command): Adjust. * progspace.c (maintenance_info_program_spaces_command): Adjust. * remote-fileio.c (remote_fileio_request): Adjust. * remote.c (show_remote_cmd): Adjust. * solib.c (info_sharedlibrary_command): Adjust. * source.c (print_source_lines_base): Adjust. * stack.c (print_stack_frame): Adjust. (do_gdb_disassembly, print_frame_info, print_frame): Adjust. * symfile-mem.c (add_vsyscall_page): Adjust. * symfile.c (load_progress, generic_load) (print_transfer_performance): Adjust. * thread.c (info_threads_command, restore_selected_frame) (thread_command): Adjust. * top.c (make_cleanup_restore_ui_file): Adjust. * tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1) (print_one_static_tracepoint_marker): Adjust. * cli/cli-cmds.c (print_disassembly): Adjust. * cli/cli-decode.c (print_doc_line): Adjust. * cli/cli-interp.c (safe_execute_command): Adjust. * cli/cli-logging.c (set_logging_redirect, pop_output_files) (handle_redirections): Adjust. * cli/cli-script.c (show_user_1): Adjust. * cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust. * mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path) (mi_cmd_env_dir): Adjust. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file) (print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) (mi_cmd_stack_info_depth, mi_cmd_stack_list_args) (list_args_or_locals): Adjust. * mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create) (mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen) (mi_cmd_var_show_format, mi_cmd_var_info_num_children) (mi_cmd_var_list_children, mi_cmd_var_info_type) (mi_cmd_var_info_path_expression, mi_cmd_var_info_expression) (mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression) (mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust. * mi/mi-interp.c (mi_on_normal_stop): Adjust. * mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select) (mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior) (list_available_thread_groups, mi_cmd_list_thread_groups) (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers) (mi_cmd_data_list_register_values, get_register) (mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory) (mi_cmd_data_read_memory_bytes, mi_cmd_list_features) (mi_cmd_list_target_features, mi_cmd_add_inferior) (mi_execute_command, mi_load_progress): Adjust. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust. * python/py-auto-load.c (print_script, info_auto_load_scripts): Adjust. * python/py-breakpoint.c (bppy_get_commands): Adjust. * tui/tui-interp.c (tui_command_loop): Adjust. * tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
struct ui_out *uiout = current_uiout;
showlist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "showlist");
for (; list != NULL; list = list->next)
if (strcmp (list->name, "Z-packet") == 0)
continue;
else if (list->type == not_set_cmd)
/* Alias commands are exactly like the original, except they
don't have the normal type. */
continue;
else
{
struct cleanup *option_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "option");
ui_out_field_string (uiout, "name", list->name);
ui_out_text (uiout, ": ");
if (list->type == show_cmd)
gdb/ * cli/cli-decode.c (set_cmd_prefix): New. (lookup_cmd_for_prefixlist): New. (add_prefix_cmd): Call set_cmd_prefix and update field 'prefix' of each cmd_list_element in *prefixlist. (add_setshow_cmd_full): set_cmd_prefix. (add_alias_cmd): Likewise. * cli/cli-decode.h (struct cmd_list_element) <prefix>: New field. Declare 'auto_boolean_enums'. * cli/cli-setshow.c: Include "observer.h". (notify_command_param_changed_p): New. (add_setshow_auto_boolean_cmd): Move auto_boolean_enums out. Remove 'static'. (do_setshow_command): Split it to ... (do_set_command, do_show_command): ... them. New. (do_set_command): Call observer_notify_command_param_changed if notify_command_param_changed_p returns true. (cmd_show_list): Caller update. * auto-load.c (set_auto_load_cmd): Likewise. * remote.c (show_remote_cmd): Likewise. * cli/cli-setshow.h: Update declarations. * top.c (execute_command): Call do_set_command and do_show_command. * NEWS: Mention new MI notification. * mi/mi-interp.c: Declare mi_command_param_changed. (mi_interpreter_init): Attach mi_command_param_changed to observer command_param_changed. (mi_command_param_changed): New. Remove mi_suppress_breakpoint_notifications. Define global variable mi_suppress_notification. (mi_breakpoint_created): Update. (mi_breakpoint_deleted): Likewise. (mi_breakpoint_modified): Likewise. * mi/mi-main.c (mi_cmd_execute): Likewise. Check command 'gdb-set' and set mi_suppress_notification. * mi/mi-main.h: (mi_suppress_notification): New struct. gdb/doc/ * observer.texi: New observer command_param_changed. * gdb.texinfo (GDB/MI Async Records): Doc for '=cmd-param-changed'. gdb/testsuite/ * gdb.mi/mi-cmd-param-changed.exp: New. * gdb.mi/mi-cli.exp: Update for MI notification "=cmd-param-changed". * gdb.mi/mi-var-rtti.exp, gdb.mi/mi2-cli.exp: Likewise. * gdb.mi/mi2-prompt.exp: Likewise.
2012-08-09 14:53:46 +02:00
do_show_command ((char *) NULL, from_tty, list);
else
cmd_func (list, NULL, from_tty);
/* Close the tuple. */
do_cleanups (option_chain);
}
/* Close the tuple. */
do_cleanups (showlist_chain);
}
1999-07-27 02:51:29 +02:00
1999-06-14 20:08:47 +02:00
/* Function to be called whenever a new objfile (shlib) is detected. */
static void
remote_new_objfile (struct objfile *objfile)
{
struct remote_state *rs = get_remote_state ();
if (rs->remote_desc != 0) /* Have a remote connection. */
remote_check_symbols ();
}
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* Pull all the tracepoints defined on the target and create local
data structures representing them. We don't want to create real
tracepoints yet, we don't want to mess up the user's existing
collection. */
static int
remote_upload_tracepoints (struct target_ops *self, struct uploaded_tp **utpp)
2010-01-06 21:31:28 +01:00
{
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
struct remote_state *rs = get_remote_state ();
char *p;
2010-01-06 21:31:28 +01:00
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* Ask for a first packet of tracepoint definition. */
putpkt ("qTfP");
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
while (*p && *p != 'l')
2010-01-06 21:31:28 +01:00
{
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
parse_tracepoint_definition (p, utpp);
/* Ask for another packet of tracepoint definition. */
putpkt ("qTsP");
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
2010-01-06 21:31:28 +01:00
}
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
return 0;
2010-01-06 21:31:28 +01:00
}
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
static int
remote_upload_trace_state_variables (struct target_ops *self,
struct uploaded_tsv **utsvp)
2010-01-06 21:31:28 +01:00
{
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
struct remote_state *rs = get_remote_state ();
2010-01-06 21:31:28 +01:00
char *p;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
/* Ask for a first packet of variable definition. */
putpkt ("qTfV");
2010-01-06 21:31:28 +01:00
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
while (*p && *p != 'l')
2010-01-06 21:31:28 +01:00
{
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
parse_tsv_definition (p, utsvp);
/* Ask for another packet of variable definition. */
putpkt ("qTsV");
2010-01-06 21:31:28 +01:00
getpkt (&rs->buf, &rs->buf_size, 0);
p = rs->buf;
}
Add trace file support. * tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
2010-01-15 23:37:20 +01:00
return 0;
2010-01-06 21:31:28 +01:00
}
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
/* The "set/show range-stepping" show hook. */
static void
show_range_stepping (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
fprintf_filtered (file,
_("Debugger's willingness to use range stepping "
"is %s.\n"), value);
}
/* The "set/show range-stepping" set hook. */
static void
set_range_stepping (char *ignore_args, int from_tty,
struct cmd_list_element *c)
{
struct remote_state *rs = get_remote_state ();
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
/* Whene enabling, check whether range stepping is actually
supported by the target, and warn if not. */
if (use_range_stepping)
{
if (rs->remote_desc != NULL)
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
{
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
remote_vcont_probe (rs);
Fix several "set remote foo-packet on/off" commands. For several RSP packets, there's a corresponding "set remote foo-packet on/off/auto" command that one can use do bypass auto-detection of support for the packet or feature. However, I noticed that setting several of these commands to 'on' or 'off' doesn't actually have any effect. These are, at least: set remote breakpoint-commands-packet set remote conditional-breakpoints-packet set remote fast-tracepoints-packet set remote static-tracepoints-packet set remote install-in-trace-packet These are commands that control a remote protocol feature that doesn't have a corresponding regular packet, and because of that we cache the knowledge of the remote side support as returned by the qSupported packet in the remote_state object. E.g., in the case of the 'set remote breakpoint-commands-packet' command, whether the feature is supported is recorded in the 'breakpoint_commands' field of the remote_state object. Whether to bypass packet support auto-detection or not is controlled by the 'detect' field of the corresponding packet's packet_config structure. That field is the variable associated directly with the "set remote foo-packet" command. Actual remote stub support for the packet (or feature) is recorded in the 'support' field of the same structure. However, when the user toggles the command, the 'support' field is also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN, discarding the knowledge of whether the target actually supports the feature. If one toggles back to 'auto', it's no big issue for real packets, as they'll just end up re-probed the next time they might be necessary. But features whose support is only reported through qSupported don't get their corresponding (manually added/maintained) fields in remote_state objected updated. As we lost the actual status of the target support for the feature, GDB would need to probe the qSupported features again, which GDB doesn't do. But we can avoid that extra traffic, and clean things up, IMO. Instead of going in that direction, this patch completely decouples struct packet_config's 'detect' and 'support' fields. E.g., when the user does "set remote foo-packet off", instead of setting the packet config's 'support' field to PACKET_DISABLE, the 'support' field is not touched at all anymore. That is, we end up respecting this simple table: | packet_config->detect | packet_config->support | should use packet/feature? | |-----------------------+------------------------+----------------------------| | auto | PACKET_ENABLE | PACKET_ENABLE | | auto | PACKET_DISABLE | PACKET_DISABLE | | auto | PACKET_UNKNOWN | PACKET_UNKNOWN | | yes | don't care | PACKET_ENABLE | | no | don't care | PACKET_DISABLE | This is implemented by the new packet_support function. With that, we need to update this pattern throughout: if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE) to do this instead: if (packet_support (PACKET_qAttached) == PACKET_DISABLE) where as mentioned, the packet_support function takes struct packet_config's 'detect' field into account, like in the table above. As when the packet is force-disabled or force-enabled, the 'support' field is just ignored, if the command is set back to auto, we'll resume respecting whatever the target said it supports. IOW, the end result is that the 'support' field always represents whether the target actually supports the packet or not. After all that, the manually maintained breakpoint_commands and equivalent fields of struct remote_state can then be eliminated, with references replaced by checking the result of calling the packet_support function on the corresponding packet or feature. This required adding new PACKET_foo enum values for several features that didn't have it yet. (The patch does not add corresponding "set remote foo-packet" style commands though, focusing only on bug fixing and laying the groundwork). Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail without this patch. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> * remote.c (struct remote_state): Remove multi_process_aware, non_stop_aware, cond_tracepoints, cond_breakpoints, breakpoint_commands, fast_tracepoints, static_tracepoints, install_in_trace, disconnected_tracing, enable_disable_tracepoints, string_tracing, and augmented_libraries_svr4_read fields. (remote_multi_process_p): Move further below in the file. (struct packet_config): Add comments. (update_packet_config): Delete function. (show_packet_config_cmd): Use packet_config_support. (add_packet_config_cmd): Use NULL as set callback. (packet_ok): "set remote foo-packet"-style commands no longer change config->supported -- adjust. (PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints) (PACKET_BreakpointCommands, PACKET_FastTracepoints) (PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments. (PACKET_QNonStop, PACKET_multiprocess_feature) (PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature) (PACKET_DisconnectedTracing_feature) (PACKET_augmented_libraries_svr4_read_feature): New enum values. (set_remote_protocol_packet_cmd): Delete function. (packet_config_support, packet_support): New functions. (set_remote_protocol_Z_packet_cmd): Don't call update_packet_config. (remote_query_attached, remote_pass_signals) (remote_program_signals, remote_threads_info) (remote_threads_extra_info, remote_start_remote): Use packet_support. (remote_start_remote): Use packet_config_support and packet_support. (init_all_packet_configs): Set all packets to unknown support, instead of calling update_packet_config. (remote_check_symbols): Use packet_support. (remote_supported_packet): Unconditionally set the packet config's support status. (remote_multi_process_feature, remote_non_stop_feature) (remote_cond_tracepoint_feature, remote_cond_breakpoint_feature) (remote_breakpoint_commands_feature) (remote_fast_tracepoint_feature, remote_static_tracepoint_feature) (remote_install_in_trace_feature) (remote_disconnected_tracing_feature) (remote_enable_disable_tracepoint_feature) (remote_string_tracing_feature) (remote_augmented_libraries_svr4_read_feature): Delete functions. (remote_protocol_features): Adjust to use remote_supported_packet for "augmented-libraries-svr4-read", "multiprocess", "QNonStop", "ConditionalTracepoints", "ConditionalBreakpoints", "BreakpointCommands", "FastTracepoints", "StaticTracepoints", "InstallInTrace", "DisconnectedTracing", "DisconnectedTracing", "EnableDisableTracepoints", and "tracenz". (remote_query_supported): Use packet_support. (remote_open_1): Adjust. (extended_remote_attach_1): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_vcont_resume): Use packet_support. (remote_resume, remote_stop_ns, fetch_register_using_p) (remote_prepare_to_store, store_register_using_P) (check_binary_download, remote_write_bytes): Use packet_support. (remote_vkill): Use packet_support. Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (extended_remote_supports_disable_randomization): Use packet_support. (extended_remote_run): Switch on the result of packet_ok instead of checking whether the packet ended up disabled. (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use packet_support. (remote_search_memory): Use packet_config_support. (remote_get_thread_local_address, remote_get_tib_address) (remote_hostio_send_command, remote_can_execute_reverse): Use packet_support. (remote_supports_cond_tracepoints) (remote_supports_cond_breakpoints) (remote_supports_fast_tracepoints) (remote_supports_static_tracepoints) (remote_supports_install_in_trace) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands): Rewrite, checking whether the packet config says the feature is enabled or disabled. (remote_download_tracepoint, remote_trace_set_readonly_regions) (remote_get_trace_status): Use packet_support. (remote_set_disconnected_tracing): Adjust to check whether the feature is enabled with packet_support. (remote_set_trace_buffer_size, remote_use_agent) (remote_can_use_agent, remote_supports_btrace): Use packet_support. (remote_enable_btrace, remote_disable_btrace, remote_read_btrace): Use packet_config_support. (remote_augmented_libraries_svr4_read): Rewrite, checking whether the packet config says the feature is enabled or disabled. (set_range_stepping): Use packet_support. gdb/testsuite/ 2014-04-25 Pedro Alves <palves@redhat.com> * gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to user. (top level): Test that "set remote conditional-breakpoints-packet off" works as intended. * gdb.base/dprintf.exp: Test that "set remote breakpoint-commands-packet off" works as intended. * gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled): New function. (top level): Call it. * gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set remote fast-tracepoints-packet off" works as intended. * gdb.trace/qtro.exp (gdb_is_target_remote): Moved ... * lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-25 19:07:02 +02:00
if (packet_support (PACKET_vCont) == PACKET_ENABLE
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
&& rs->supports_vCont.r)
return;
}
warning (_("Range stepping is not supported by the current target"));
}
}
void
2000-07-30 03:48:28 +02:00
_initialize_remote (void)
{
struct remote_state *rs;
struct cmd_list_element *cmd;
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
const char *cmd_name;
1999-06-14 20:08:47 +02:00
/* architecture specific data */
remote_gdbarch_data_handle =
gdbarch_data_register_post_init (init_remote_state);
remote_g_packet_data_handle =
gdbarch_data_register_pre_init (remote_g_packet_data_init);
/* Initialize the per-target state. At the moment there is only one
of these, not one per target. Only one target is active at a
time. */
remote_state = new_remote_state ();
init_remote_ops ();
add_target (&remote_ops);
init_extended_remote_ops ();
add_target (&extended_remote_ops);
1999-06-07 21:19:32 +02:00
/* Hook into new objfile notification. */
doc/ChangeLog: * observer.texi (GDB Observers): New observer "new_objfile". ChangeLog: * observer.sh: Add "struct objfile" forward declaration. * target.h (deprecated_target_new_objfile_hook): Remove. * symfile.c (deprecated_target_new_objfile_hook): Remove. (clear_symtab_users): Call observer_notify_new_objfile. (symbol_file_add_with_addrs_or_offsets): Likewise. * rs6000-nat.c: Include "observer.h". (vmap_ldinfo): Call observer_notify_new_objfile. (xcoff_relocate_core): Likewise. * remote.c (remote_new_objfile_chain): Remove. (remote_new_objfile): Do not call remote_new_objfile_chain. (_initialize_remote): Use observer_attach_new_objfile. * tui/tui-hooks.c (tui_target_new_objfile_chain): Remove. (tui_new_objfile_hook): Do not call tui_target_new_objfile_chain. (_initialize_tui_hooks): Use observer_attach_new_objfile. * aix-thread.c: Include "observer.h". (target_new_objfile_chain): Remove. (new_objfile): Do not call target_new_objfile_chain. (_initialize_aix_thread): Use observer_attach_new_objfile. * hpux-thread.c: Include "observer.h" (target_new_objfile_chain): Remove. (hpux_thread_new_objfile): Make static. Do not call target_new_objfile_chain. (_initialize_hpux_thread): Use observer_attach_new_objfile. * linux-thread-db.c: Include "observer.h". (target_new_objfile_chain): Remove. (thread_db_new_objfile): Do not call target_new_objfile_chain. (_initialize_thread_db): Use observer_attach_new_objfile. * sol-thread.c: Include "observer.h". (target_new_objfile_chain): Remove. (sol_thread_new_objfile): Make static. Do not call target_new_objfile_chain. (_initialize_sol_thread): Use observer_attach_new_objfile. * Makefile.in (aix-thread.o, hpux-thread.o, linux-thread-db.o, rs6000-nat.o, sol-thread.o, tui-hooks.o): Add dependency on $(observer_h).
2007-05-11 21:55:20 +02:00
observer_attach_new_objfile (remote_new_objfile);
/* We're no longer interested in notification events of an inferior
when it exits. */
observer_attach_inferior_exit (discard_pending_stop_replies);
/* Set up signal handlers. */
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_sigint_remote_token =
create_async_signal_handler (async_remote_interrupt, NULL);
gdb/ Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
2013-08-05 17:03:06 +02:00
async_sigint_remote_twice_token =
create_async_signal_handler (async_remote_interrupt_twice, NULL);
#if 0
init_remote_threadtests ();
#endif
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
stop_reply_queue = QUEUE_alloc (stop_reply_p, stop_reply_xfree);
/* set/show remote ... */
add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, _("\
1999-07-27 02:51:29 +02:00
Remote protocol specific variables\n\
Configure various remote-protocol specific variables such as\n\
the packets being used"),
1999-09-13 23:40:00 +02:00
&remote_set_cmdlist, "set remote ",
0 /* allow-unknown */, &setlist);
add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\
1999-07-27 02:51:29 +02:00
Remote protocol specific variables\n\
Configure various remote-protocol specific variables such as\n\
the packets being used"),
1999-09-13 23:40:00 +02:00
&remote_show_cmdlist, "show remote ",
0 /* allow-unknown */, &showlist);
1999-07-27 02:51:29 +02:00
add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\
Compare section data on target to the exec file.\n\
Argument is a single section name (default: all loaded sections).\n\
To compare only read-only loaded sections, specify the -r option."),
&cmdlist);
add_cmd ("packet", class_maintenance, packet_command, _("\
Send an arbitrary packet to a remote target.\n\
maintenance packet TEXT\n\
If GDB is talking to an inferior via the GDB serial protocol, then\n\
this command sends the string TEXT to the inferior, and displays the\n\
response packet. GDB supplies the initial `$' character, and the\n\
terminating `#' character and checksum."),
&maintenancelist);
add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break, _("\
Set whether to send break if interrupted."), _("\
Show whether to send break if interrupted."), _("\
If set, a break, instead of a cntrl-c, is sent to the remote target."),
set_remotebreak, show_remotebreak,
&setlist, &showlist);
cmd_name = "remotebreak";
cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
deprecate_cmd (cmd, "set remote interrupt-sequence");
cmd_name = "remotebreak"; /* needed because lookup_cmd updates the pointer */
cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1);
deprecate_cmd (cmd, "show remote interrupt-sequence");
add_setshow_enum_cmd ("interrupt-sequence", class_support,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
interrupt_sequence_modes, &interrupt_sequence_mode,
_("\
Set interrupt sequence to remote target."), _("\
Show interrupt sequence to remote target."), _("\
Valid value is \"Ctrl-C\", \"BREAK\" or \"BREAK-g\". The default is \"Ctrl-C\"."),
NULL, show_interrupt_sequence,
&remote_set_cmdlist,
&remote_show_cmdlist);
add_setshow_boolean_cmd ("interrupt-on-connect", class_support,
&interrupt_on_connect, _("\
Set whether interrupt-sequence is sent to remote target when gdb connects to."), _(" \
Show whether interrupt-sequence is sent to remote target when gdb connects to."), _(" \
If set, interrupt sequence is sent to remote target."),
NULL, NULL,
&remote_set_cmdlist, &remote_show_cmdlist);
/* Install commands for configuring memory read/write packets. */
1999-11-09 02:23:30 +01:00
add_cmd ("remotewritesize", no_class, set_memory_write_packet_size, _("\
Set the maximum number of bytes per memory write packet (deprecated)."),
1999-11-09 02:23:30 +01:00
&setlist);
add_cmd ("remotewritesize", no_class, show_memory_write_packet_size, _("\
Show the maximum number of bytes per memory write packet (deprecated)."),
1999-11-09 02:23:30 +01:00
&showlist);
add_cmd ("memory-write-packet-size", no_class,
set_memory_write_packet_size, _("\
Set the maximum number of bytes per memory-write packet.\n\
Specify the number of bytes in a packet or 0 (zero) for the\n\
default packet size. The actual limit is further reduced\n\
dependent on the target. Specify ``fixed'' to disable the\n\
further restriction and ``limit'' to enable that restriction."),
1999-11-09 02:23:30 +01:00
&remote_set_cmdlist);
add_cmd ("memory-read-packet-size", no_class,
set_memory_read_packet_size, _("\
Set the maximum number of bytes per memory-read packet.\n\
Specify the number of bytes in a packet or 0 (zero) for the\n\
default packet size. The actual limit is further reduced\n\
dependent on the target. Specify ``fixed'' to disable the\n\
further restriction and ``limit'' to enable that restriction."),
1999-11-09 02:23:30 +01:00
&remote_set_cmdlist);
add_cmd ("memory-write-packet-size", no_class,
show_memory_write_packet_size,
_("Show the maximum number of bytes per memory-write packet."),
1999-11-09 02:23:30 +01:00
&remote_show_cmdlist);
add_cmd ("memory-read-packet-size", no_class,
show_memory_read_packet_size,
_("Show the maximum number of bytes per memory-read packet."),
1999-11-09 02:23:30 +01:00
&remote_show_cmdlist);
add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class,
&remote_hw_watchpoint_limit, _("\
Set the maximum number of target hardware watchpoints."), _("\
Show the maximum number of target hardware watchpoints."), _("\
Specify a negative limit for unlimited."),
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
NULL, NULL, /* FIXME: i18n: The maximum
number of target hardware
watchpoints is %s. */
&remote_set_cmdlist, &remote_show_cmdlist);
add_setshow_zinteger_cmd ("hardware-watchpoint-length-limit", no_class,
&remote_hw_watchpoint_length_limit, _("\
Set the maximum length (in bytes) of a target hardware watchpoint."), _("\
Show the maximum length (in bytes) of a target hardware watchpoint."), _("\
Specify a negative limit for unlimited."),
NULL, NULL, /* FIXME: i18n: The maximum
length (in bytes) of a target
hardware watchpoint is %s. */
&remote_set_cmdlist, &remote_show_cmdlist);
add_setshow_zinteger_cmd ("hardware-breakpoint-limit", no_class,
&remote_hw_breakpoint_limit, _("\
Set the maximum number of target hardware breakpoints."), _("\
Show the maximum number of target hardware breakpoints."), _("\
Specify a negative limit for unlimited."),
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
NULL, NULL, /* FIXME: i18n: The maximum
number of target hardware
breakpoints is %s. */
&remote_set_cmdlist, &remote_show_cmdlist);
add_setshow_zuinteger_cmd ("remoteaddresssize", class_obscure,
&remote_address_size, _("\
Set the maximum size of the address (in bits) in a memory packet."), _("\
Show the maximum size of the address (in bits) in a memory packet."), NULL,
NULL,
NULL, /* FIXME: i18n: */
&setlist, &showlist);
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
init_all_packet_configs ();
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_X],
"X", "binary-download", 1);
1999-06-14 20:08:47 +02:00
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_vCont],
"vCont", "verbose-resume", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_QPassSignals],
"QPassSignals", "pass-signals", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_QProgramSignals],
"QProgramSignals", "program-signals", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qSymbol],
"qSymbol", "symbol-lookup", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_P],
"P", "set-register", 1);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_p],
"p", "fetch-register", 1);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Z0],
"Z0", "software-breakpoint", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Z1],
"Z1", "hardware-breakpoint", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Z2],
"Z2", "write-watchpoint", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Z3],
"Z3", "read-watchpoint", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Z4],
"Z4", "access-watchpoint", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_auxv],
"qXfer:auxv:read", "read-aux-vector", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_exec_file],
"qXfer:exec-file:read", "pid-to-exec-file", 0);
XML feature description support. * NEWS: Mention target descriptions, "set tdesc filename", "unset tdesc filename", "show tdesc filename", and qXfer:features:read. * arch-utils.c (choose_architecture_for_target): New function. (gdbarch_info_fill): Call it. * target-descriptions.c (struct property): Make members non-const. (struct target_desc): Add arch member. (target_description_filename): New variable. (target_find_description): Try via XML first. (tdesc_architecture): New. (free_target_description, make_cleanup_free_target_description): New. (set_tdesc_property): Call xstrdup. (set_tdesc_architecture, tdesc_set_cmdlist, tdesc_show_cmdlist) (tdesc_unset_cmdlist, unset_tdesc_cmd, unset_tdesc_filename_cmd) (set_tdesc_cmd, show_tdesc_cmd, set_tdesc_filename_cmd) (show_tdesc_filename_cmd, _initialize_target_descriptions): New. * target-descriptions.h (tdesc_architecture) (make_cleanup_free_target_description, set_tdesc_architecture): New prototypes. * Makefile.in (SFILES): Add xml-tdesc.c. (COMMON_OBS): Add xml-tdesc.o. (target-descriptions.o): Update. (xml-tdesc.o): New rule. * xml-tdesc.c, xml-tdesc.h: New files. * remote.c (PACKET_qXfer_features): New enum. (remote_protocol_features): Add qXfer:features:read. (remote_xfer_partial): Handle TARGET_OBJECT_AVAILABLE_FEATURES. (_initialize_remote): Register qXfer:features:read. * target.h (enum target_object): Add TARGET_OBJECT_AVAILABLE_FEATURES. * features/gdb-target.dtd: New file. * linux-i386-low.c (the_low_target): Set arch_string. * linux-x86-64-low.c (the_low_target): Likewise. * linux-low.c (linux_arch_string): New. (linux_target_ops): Add it. * linux-low.h (struct linux_target_ops): Add arch_string. * server.c (write_qxfer_response): Use const void * for DATA. (get_features_xml): New. (handle_query): Handle qXfer:features:read. Report it for qSupported. * target.h (struct target_ops): Add arch_string method. * gdb.texinfo (Target Descriptions): New section. (General Query Packets): Add QPassSignals anchor. Mention qXfer:features:read under qSupported. Expand mentions of qXfer:memory-map:read and QPassSignals. Document qXfer:features:read.
2007-01-09 23:55:10 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_features],
"qXfer:features:read", "target-features", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_libraries],
"qXfer:libraries:read", "library-info", 0);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_libraries_svr4],
"qXfer:libraries-svr4:read", "library-info-svr4", 0);
gdb/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
2006-09-21 15:54:03 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_memory_map],
"qXfer:memory-map:read", "memory-map", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_spu_read],
"qXfer:spu:read", "read-spu-object", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_spu_write],
"qXfer:spu:write", "write-spu-object", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_osdata],
"qXfer:osdata:read", "osdata", 0);
Implement core awareness. * bcache.c (compare_ints): Remove (print_percentage): Use compare_positive_ints. * defs.h (compare_positive_ints): Declare. * linux-nat.h (struct lin_lwp): New field core. (linux_nat_core_of_thread_1): Declare. * linux-nat.c (add_lwp): Init the 'core' field. (linux_nat_wait_1): Record the core. (linux_nat_core_of_thread_1, linux_nat_core_of_thread): New. (linux_nat_add_target): Register the above. * linux-thread-db.c (update_thread_core): New. (thread_db_find_new_threads): Update core information for every thread. * remote.c (struct private_thread_info): New. (free_private_thread_info, demand_private_info): New. (PACKET_qXfer_threads, use_osdata_threads): New. (struct thread_item, threads_parsing_context (start_thread, end_thread, thread_attributes) (thread_children, threads_children, threads_elements): New. (remote_threads_info): Try qXfer:threads before anything else. (remote_protocol_packets): Register qXfer:threads. (remote_open_1): Init use_osdata_threads. (struct stop_reply): New field 'core'. (remote_parse_stop_reply): Parse core number. (process_stop_reply): Record core number. (remote_xfer_partial): Handle qXfer:threads. (remote_core_of_thread): New. (init_remote_ops): Register remote_core_of_thread. (_initialize_remote): Register qXfer:read. * target.c (target_core_of_thread): New * target.h (enum target_object): New value TARGET_OBJECT_THREADS. (struct target_ops): New field to_core_of_threads. (target_core_of_thread): Declare. * gdbthread.h (struct thread_info): New field private_dtor. * thread.c (print_thread_info): Report the core. * ui-out.c (MAX_UI_OUT_LEVELS): Increase. * utils.c (compare_positive_ints): New. * features/threads.dtd: New. * mi/mi-interp.c (mi_on_normal_stop): Report the core. * mi/mi-main.c (struct collect_cores_data, collect_cores) (do_nothing, free_vector_of_osdata_items) (splay_tree_int_comparator, free_splay_tree): New. (print_one_inferior_data): Implemented printing of selected inferiors. Collect and print cores. (output_cores): New. (mi_cmd_list_thread_groups): Support --recurse. Permit specifying thread groups together with --available.
2010-01-12 22:40:25 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_threads],
"qXfer:threads:read", "threads", 0);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_read],
"qXfer:siginfo:read", "read-siginfo-object", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_write],
"qXfer:siginfo:write", "write-siginfo-object", 0);
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
add_packet_config_cmd
(&remote_protocol_packets[PACKET_qXfer_traceframe_info],
"qXfer:traceframe-info:read", "traceframe-info", 0);
gdb/ * target.h (struct traceframe_info): Forward declare. (enum target_object): Add TARGET_OBJECT_TRACEFRAME_INFO. (struct target_ops) <to_traceframe_info>: New field. (target_traceframe_info): New. * target.c (update_current_target): Inherit and default to_traceframe_info. * remote.c (PACKET_qXfer_traceframe_info): New. (remote_protocol_features): Register qXfer:traceframe-info:read. (remote_xfer_partial): Handle TARGET_OBJECT_TRACEFRAME_INFO. (remote_traceframe_info): New. (init_remote_ops): Install it. (_initialize_remote): Install "set/show remote traceframe-info" commands. * tracepoint.h (parse_traceframe_info): Declare. * tracepoint.c (struct mem_range): New. (mem_range_s): New typedef. (struct traceframe_info): New. (traceframe_info): New global. (free_traceframe_info): New function. (clear_traceframe_info): New function. (start_tracing, tfind_1, set_traceframe_number): Clear traceframe info. (build_traceframe_info): New function. (tfile_traceframe_info): New function. (init_tfile_ops): Install tfile_traceframe_info. (traceframe_info_start_memory, free_result): New functions. (memory_attributes, traceframe_info_elements): New globals. (parse_traceframe_info, get_traceframe_info): New functions. * features/traceframe-info.dtd: New file. * Makefile.in (XMLFILES): Add traceframe-info.dtd. gdb/gdbserver/ * server.c (handle_qxfer_traceframe_info): New. (qxfer_packets): Register "traceframe-info". (handle_query): Report support for qXfer:traceframe-info:read+. * tracepoint.c (match_blocktype): New. (traceframe_find_block_type): Rename to ... (traceframe_walk_blocks): ... this. Add callback filter argument, and use it. (traceframe_find_block_type): New, reimplemented on top of traceframe_walk_blocks. (build_traceframe_info_xml): New. (traceframe_read_info): New. * server.h (traceframe_read_info): Declare. gdb/doc/ * gdb.texinfo (Remote Configuration): Mention set/show remote traceframe-info. (Tools/Packages Optional for Building GDB): Mention that expat is used for traceframe info. (Remote Protocol) <Menu>: Add "Traceframe Info Format". (General Query Packets) <qSupported>: Describe the qXfer:traceframe-info:read feature. (qXfer::read): Describe qXfer:traceframe-info:read. (Traceframe Info Format): New section.
2011-02-14 12:13:12 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_uib],
"qXfer:uib:read", "unwind-info-block", 0);
* remote.c: Add an enumeration for configurable remote packets. (remote_protocol_packets, set_remote_protocol_packet_cmd) (show_remote_protocol_packet_cmd): New. (remote_protocol_vcont) (set_remote_protocol_vcont_packet_cmd) (show_remote_protocol_vcont_packet_cmd) (remote_protocol_qSymbol) (set_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (remote_protocol_P, set_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (remote_protocol_Z) (set_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (set_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (set_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (set_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (set_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (remote_protocol_binary_download) (set_remote_protocol_binary_download_cmd) (show_remote_protocol_binary_download_cmd) (remote_protocol_qPart_auxv) (set_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (remote_protocol_qGetTLSAddr) (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_protocol_p) (set_remote_protocol_p_packet_cmd) (show_remote_protocol_p_packet_cmd): Delete. (init_all_packet_configs): Simplify. (set_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_packet_cmd) (remote_check_symbols, remote_vcont_probe, remote_vcont_resume) (remote_fetch_registers, remote_prepare_to_store) (remote_store_registers, check_binary_download) (remote_write_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, remote_xfer_partial) (remote_get_thread_local_address): Update for packet array. (_initialize_remote): Likewise; also update for common set/show commands.
2006-02-20 16:19:06 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTLSAddr],
2005-04-15 21:58:59 +02:00
"qGetTLSAddr", "get-thread-local-storage-address",
0);
Support for Windows OS Thread Information Block. * NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
2010-04-16 09:49:37 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTIBAddr],
"qGetTIBAddr", "get-thread-information-block-address",
0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_bc],
"bc", "reverse-continue", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_bs],
"bs", "reverse-step", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qSupported],
"qSupported", "supported-packets", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qSearch_memory],
"qSearch:memory", "search-memory", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qTStatus],
"qTStatus", "trace-status", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_setfs],
"vFile:setfs", "hostio-setfs", 0);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_open],
"vFile:open", "hostio-open", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_pread],
"vFile:pread", "hostio-pread", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_pwrite],
"vFile:pwrite", "hostio-pwrite", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_close],
"vFile:close", "hostio-close", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_unlink],
"vFile:unlink", "hostio-unlink", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_readlink],
"vFile:readlink", "hostio-readlink", 0);
Implement remote_bfd_iovec_stat This commit adds a new packet "vFile:fstat:" to the remote protocol that can be used by to retrieve information about files that have been previously opened using vFile:open. vFile:fstat: support is added to GDB, and remote_bfd_iovec_stat is implemented using it. If vFile:fstat: is not supported by the remote GDB creates a dummy result by zeroing the supplied stat structure and setting its st_size field to INT_MAX. This mimics GDB's previous behaviour, with the exception that GDB did not previously zero the structure so all other fields would have been returned unchanged, which is to say very likely populated with random values from the stack. gdb/ChangeLog: * remote-fileio.h (remote_fileio_to_host_stat): New declaration. * remote-fileio.c (remote_fileio_to_host_uint): New function. (remote_fileio_to_host_ulong): Likewise. (remote_fileio_to_host_mode): Likewise. (remote_fileio_to_host_time): Likewise. (remote_fileio_to_host_stat): Likewise. * remote.c (PACKET_vFile_fstat): New enum value. (remote_protocol_features): Register the "vFile:fstat" feature. (remote_hostio_fstat): New function. (remote_bfd_iovec_stat): Use the above. (_initialize_remote): Register new "set/show remote hostio-fstat-packet" command. * symfile.c (separate_debug_file_exists): Update comment. * NEWS: Announce new vFile:fstat packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-fstat-packet" command. (General Query Packets): Document the vFile:fstat qSupported features. (Host I/O Packets): Document the vFile:fstat packet.
2015-03-11 18:53:57 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_fstat],
"vFile:fstat", "hostio-fstat", 0);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_vAttach],
"vAttach", "attach", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vRun],
"vRun", "run", 0);
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_QStartNoAckMode],
"QStartNoAckMode", "noack", 0);
Implement remote multi-process extensions. * remote.c (struct remote_state): Add extended and multi_process_aware fields. (remote_multi_process_p): New. (PACKET_vKill): New. (record_currthread): Use thread_change_ptid. Notice new inferiors. (set_thread, remote_thread_alive): Use write_ptid. (write_ptid, read_ptid): New. (remote_current_thread, remote_threads_extra_info): Use them. (remote_threads_info): Likewise. Detect new inferiors. (remote_start_remote): Add inferior to inferior list. (remote_multi_process_feature): New. (remote_protocol_features): Add "multiprocess" feature. (remote_query_supported): Pass "multiprocess+" as supported features. (remote_open_1): Clear multi_process_aware. Set extended accordingly. (remote_detach_1): Detach current process. Use extended packet format for extended-remote multi-process. Detach process from the inferior list. Only mourn after printing output. (extended_remote_attach_1): Add process to the inferior list. (remote_vcont_resume): Use write_ptid to pass the thread ids. (remote_wait): Use read_ptid. Implement the extended multi-process extension format of the 'W' and 'X' reply packets. Remove exited inferiors from inferior list. (remote_xfer_memory): Set general thread. (remote_vkill): New. (extended_remote_kill): New. (remote_mourn_1): Discard all inferiors. (select_new_thread_callback): New. (extended_remote_mourn_1): If there are more processes to debug, switch to a thread in another process, and don't pop the target. (extended_remote_create_inferior_1): Add the new process to the inferior list. (remote_stopped_by_watchpoint): Indenting. (remote_xfer_partial): Set the general thread. (remote_pid_to_str): If the remote is multi-process aware, print the process id as well as the thread id. (remote_get_thread_local_address): Use write_ptid. (init_extended_remote_ops): Register extended_remote_kill. (_initialize_remote): Register new packets. Change magic_null_ptid's, not_sent_ptid's and any_thread_ptid's pid member to 42000. * thread.c (thread_change_ptid): Also account for the inferior pid changing. * inferior.h (discard_all_inferiors): Declare. * inferior.c (discard_all_inferiors): New.
2008-09-22 17:18:30 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_vKill],
"vKill", "kill", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qAttached],
"qAttached", "query-attached", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_ConditionalTracepoints],
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
"ConditionalTracepoints",
"conditional-tracepoints", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_ConditionalBreakpoints],
"ConditionalBreakpoints",
"conditional-breakpoints", 0);
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_BreakpointCommands],
"BreakpointCommands",
"breakpoint-commands", 0);
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_FastTracepoints],
"FastTracepoints", "fast-tracepoints", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_TracepointSource],
"TracepointSource", "TracepointSource", 0);
2010-06-11 Stan Shebs <stan@codesourcery.com> Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
2010-06-12 02:05:22 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_QAllow],
"QAllow", "allow", 0);
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_StaticTracepoints],
"StaticTracepoints", "static-tracepoints", 0);
gdb/ * remote.c (struct remote_state): <install_in_trace> new field. (PACKET_InstallInTrace): New enum value. (remote_install_in_trace_feature): Support InstallInTrace. (remote_supports_install_in_trace): Likewise. (remote_protocol_features): Likewise. (_initialize_remote): Likewise. (remote_can_download_tracepoint): New. * target.h (struct target): New field `to_can_download_tracepoint'. (target_can_download_tracepoint): New macro. * target.c (update_current_target): Update. * breakpoint.h (struct bp_location): Add comment on field `duplicate'. (should_be_inserted): Don't differentiate breakpoint and tracepoint. (remove_breakpoints): Don't remove tracepoints. (tracepoint_locations_match ): New. (breakpoint_locations_match): Call it. (disable_breakpoints_in_unloaded_shlib): Handle tracepoint. (download_tracepoint_locations): New. (update_global_location_list): Call it. * tracepoint.c (find_matching_tracepoint): Delete. (find_matching_tracepoint_location): Renamed from find_matching_tracepoint. Return bp_location rather than tracepoint. (merge_uploaded_tracepoints): Set `inserted' field to 1 if tracepoint is found. gdb/doc/ * gdb.texinfo (Create and Delete Tracepoints): Describe changed behavior of tracepoint. (General Query Packets): New feature InstallInTrace. (Remote Configuration): Document "set remote install-in-trace-packet". gdb/gdbserver/ * server.c (handle_query): Handle InstallInTrace for qSupported. * tracepoint.c (add_tracepoint): Sort list. (install_tracepoint, download_tracepoint): New. (cmd_qtdp): Call them to install and download tracepoints. (sort_tracepoints): Removed. (cmd_qtstart): Update. gdb/testsuite/ * gdb.trace/change-loc-1.c: New. * gdb.trace/change-loc-2.c: New. * gdb.trace/change-loc.c: New. * gdb.trace/change-loc.exp: New. * gdb.trace/change-loc.h: New. * gdb.trace/trace-break.c (marker): Define new symbol. * gdb.trace/trace-break.exp (break_trace_same_addr_5): New. (break_trace_same_addr_6): New.
2011-11-14 16:18:54 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_InstallInTrace],
"InstallInTrace", "install-in-trace", 0);
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_statictrace_read],
"qXfer:statictrace:read", "read-sdata-object", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_fdpic],
"qXfer:fdpic:read", "read-fdpic-loadmap", 0);
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_QDisableRandomization],
"QDisableRandomization", "disable-randomization", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_QAgent],
"QAgent", "agent", 0);
2012-03-08 Stan Shebs <stan@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (QTBuffer:size) New remote command. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Add an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function. Allocate trace buffer memory. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Add QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments): Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size. (General Query Packets): Document QTBuffer:size. gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file.
2013-03-08 16:06:39 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_QTBuffer_size],
"QTBuffer:size", "trace-buffer-size", 0);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_off],
"Qbtrace:off", "disable-btrace", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_bts],
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
"Qbtrace:bts", "enable-btrace-bts", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_pt],
"Qbtrace:pt", "enable-btrace-pt", 0);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
"qXfer:btrace", "read-btrace", 0);
record btrace: add configuration struct 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.
2013-11-28 15:44:13 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace_conf],
"qXfer:btrace-conf", "read-btrace-conf", 0);
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_conf_bts_size],
"Qbtrace-conf:bts:size", "btrace-conf-bts-size", 0);
remote+docs: software/hardware breakpoint traps This adjusts target remote to tell the core whether a trap was caused by a breakpoint. To that end, the patch teaches GDB about new RSP stop reasons "T05 swbreak" and "T05 hwbreak", that remote targets report back to GDB, similarly to how "T05 watch" indicates a stop caused by a watchpoint. Because targets that can report these events are expected to themselves adjust the PC after a software breakpoint, these new stop reasons must only be reported if the stub is talking to a GDB that understands them. Because of that, the use of the new stop reasons needs to be handshaked on initial connection, using the qSupported mechanism. GDB simply sends "swbreak+" in its qSupports query, and the stub reports back "swbreak+" too. Because these new stop reasons are required to fix a fundamental non-stop mode problem, this commit extends the remote non-stop intro section in the manual, documenting the events as required. To be clear, GDB will still cope with remote targets that don't support these new stop reasons; it will behave just like today. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * NEWS: Mention the new "swbreak" and "hwbreak" stop reasons. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values. (packet_set_cmd_state): New function. (remote_protocol_features): Register the "swbreak" and "hwbreak" features. (remote_query_supported): If not disabled with the corresponding "set remote foo-packet" command, report support for the swbreak and hwbreak features. (struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete field. <stop_reason>: New field. (remote_parse_stop_reply): Handle "swbreak" and "hwbreak". (remote_wait_as): Adjust. (remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint): New functions. (remote_stopped_by_watchpoint): New function. (init_remote_ops): Install them. (_initialize_remote): Register new "set/show remote swbreak-feature-packet" and "set/show remote swbreak-feature-packet" commands. gdb/doc/ChangeLog: 2015-03-04 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): Document the "set/show remote swbreak-feature-packet" and "set/show remote hwbreak-feature-packet" commands. (Packets) <Z0>: Add cross link to the "swbreak" stop reason's decription. (Stop Reply Packets): Document the swbreak and hwbreak stop reasons. (General Query Packets): Document the swbreak and hwbreak qSupported features. (Remote Non-Stop): Explain that swbreak and hwbreak are required.
2015-03-04 21:41:16 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_swbreak_feature],
"swbreak-feature", "swbreak-feature", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_hwbreak_feature],
"hwbreak-feature", "hwbreak-feature", 0);
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_fork_event_feature],
"fork-event-feature", "fork-event-feature", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_vfork_event_feature],
"vfork-event-feature", "vfork-event-feature", 0);
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_conf_pt_size],
"Qbtrace-conf:pt:size", "btrace-conf-pt-size", 0);
/* Assert that we've registered "set remote foo-packet" commands
for all packet configs. */
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
{
int i;
for (i = 0; i < PACKET_MAX; i++)
{
/* Ideally all configs would have a command associated. Some
still don't though. */
int excepted;
switch (i)
{
case PACKET_QNonStop:
case PACKET_multiprocess_feature:
case PACKET_EnableDisableTracepoints_feature:
case PACKET_tracenz_feature:
case PACKET_DisconnectedTracing_feature:
case PACKET_augmented_libraries_svr4_read_feature:
Make compare-sections work against all targets; add compare-sections [-r] tests. 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-05-20 20:11:39 +02:00
case PACKET_qCRC:
/* Additions to this list need to be well justified:
pre-existing packets are OK; new packets are not. */
Fix remote connection to targets that don't support the QNonStop packet. ... and others. The recent patch that fixed several "set remote foo-packet on/off" commands introduced a regression, observable when connecting GDB to QEMU. For instance: (gdb) set debug remote 1 (gdb) tar rem :4444 Remote debugging using :4444 Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack Packet received: PacketSize=1000;qXfer:features:read+ Packet qSupported (supported-packets) is supported Sending packet: $Hgp0.0#ad...Ack Packet received: OK Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack Packet received: [...] Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack Packet received: [...] !!! -> Sending packet: $QNonStop:0#8c...Ack Packet received: Remote refused setting all-stop mode with: The "QNonStop" feature is associated with the PACKET_QNonStop packet, with a default of PACKET_DISABLE, so GDB should not be sending the packet at all. The patch that introduced the regression decoupled packet_config's 'detect' and 'support' fields, making the former (an auto_boolean) purely the associated "set remote foo-packet" command's variable. In the example above, the packet config's 'supported' field does end up correctly set to PACKET_DISABLE. However, nothing is presently initializing packet configs that don't actually have a command associated. Those configs's 'detect' field then ends up set to AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces GDB to assume the packet is supported, irrespective of what the target claims it supports, just like if the user had done "set remote foo-packet on" (this being the associated command, if there was one). Ideally, all packet configs would have a command associated. While that isn't true, make sure all packet configs are initialized, even if no command is associated, and add an assertion that prevents adding more packets/features without an associated command. Tested on x86_64 Fedora 17, against pristine gdbserver, and against a gdbserver with the QNonStop packet/feature disabled with a local hack. gdb/ 2014-04-29 Pedro Alves <palves@redhat.com> * remote.c (struct packet_config) <detect>: Extend comment. (add_packet_config_cmd): Don't set the config's detect or support fields here. (init_all_packet_configs): Also initialize the config's 'detect' field. (reset_all_packet_configs_support): New function. (remote_open_1): Call reset_all_packet_configs_support instead of init_all_packet_configs. (_initialize_remote): Initialize all packet configs. Assert that all packets have an associated command, except a few known outliers.
2014-04-29 15:01:27 +02:00
excepted = 1;
break;
default:
excepted = 0;
break;
}
/* This catches both forgetting to add a config command, and
forgetting to remove a packet from the exception list. */
gdb_assert (excepted == (remote_protocol_packets[i].name == NULL));
}
}
/* Keep the old ``set remote Z-packet ...'' working. Each individual
Z sub-packet has its own set and show commands, but users may
have sets to this variable in their .gdbinit files (or in their
documentation). */
add_setshow_auto_boolean_cmd ("Z-packet", class_obscure,
&remote_Z_packet_detect, _("\
Set use of remote protocol `Z' packets"), _("\
Show use of remote protocol `Z' packets "), _("\
When set, GDB will attempt to use the remote breakpoint and watchpoint\n\
packets."),
set_remote_protocol_Z_packet_cmd,
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
show_remote_protocol_Z_packet_cmd,
/* FIXME: i18n: Use of remote protocol
`Z' packets is %s. */
&remote_set_cmdlist, &remote_show_cmdlist);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
add_prefix_cmd ("remote", class_files, remote_command, _("\
Manipulate files on the remote system\n\
Transfer files to and from the remote target system."),
&remote_cmdlist, "remote ",
0 /* allow-unknown */, &cmdlist);
add_cmd ("put", class_files, remote_put_command,
_("Copy a local file to the remote system."),
&remote_cmdlist);
add_cmd ("get", class_files, remote_get_command,
_("Copy a remote file to the local system."),
&remote_cmdlist);
add_cmd ("delete", class_files, remote_delete_command,
_("Delete a remote file."),
&remote_cmdlist);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
remote_exec_file = xstrdup ("");
add_setshow_string_noescape_cmd ("exec-file", class_files,
&remote_exec_file, _("\
Set the remote pathname for \"run\""), _("\
Show the remote pathname for \"run\""), NULL, NULL, NULL,
&remote_set_cmdlist, &remote_show_cmdlist);
range stepping: gdb This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
2013-05-23 19:15:35 +02:00
add_setshow_boolean_cmd ("range-stepping", class_run,
&use_range_stepping, _("\
Enable or disable range stepping."), _("\
Show whether target-assisted range stepping is enabled."), _("\
If on, and the target supports it, when stepping a source line, GDB\n\
tells the target to step the corresponding range of addresses itself instead\n\
of issuing multiple single-steps. This speeds up source level\n\
stepping. If off, GDB always issues single-steps, even if range\n\
stepping is supported by the target. The default is on."),
set_range_stepping,
show_range_stepping,
&setlist,
&showlist);
/* Eventually initialize fileio. See fileio.c */
initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist);
/* Take advantage of the fact that the TID field is not used, to tag
special ptids with it set to != 0. */
magic_null_ptid = ptid_build (42000, -1, 1);
not_sent_ptid = ptid_build (42000, -2, 1);
any_thread_ptid = ptid_build (42000, 0, 1);
Make tracepoint operations go through target vector. * target.h (enum trace_find_type): New enum. (struct target_ops): New fields to_trace_init, to_download_tracepoint, to_download_trace_state_variable, to_trace_set_readonly_regions, to_trace_start, to_get_trace_status, to_trace_stop, to_trace_find, to_get_trace_state_variable_value, to_set_disconnected_tracing. (target_trace_init): New macro. (target_download_tracepoint): New macro. (target_download_trace_state_variable): New macro. (target_trace_start): New macro. (target_trace_set_readonly_regions): New macro. (target_get_trace_status): New macro. (target_trace_stop): New macro. (target_trace_find): New macro. (target_get_trace_state_variable_value): New macro. (target_set_disconnected_tracing): New macro. * target.c (update_current_target): Inherit and set defaults for tracepoint operations. * tracepoint.c (default_collect): Make globally visible. (target_is_remote): Remove, along with all calls. (tvariables_info): Call target_get_trace_state_variable_value. (remote_set_transparent_ranges): Remove. (trace_start_command): Call target_trace_init, target_download_tracepoint, etc. (download_tracepoint): Remove. (trace_stop_command): Simplify. (stop_tracing): Call target_trace_stop. (get_trace_status): Call target_get_trace_status. (trace_status_command): Add case for targets that cannot trace. (finish_tfind_command): Change to take numerical arguments, call target_trace_find. (trace_find_command): Update call to finish_tfind_command. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. (set_disconnected_tracing_value): Call target_set_disconnected_tracing. * remote.c: Add protocol encoding bits from tracepoint.c. (trace_error): Move from tracepoint.c. (remote_get_noisy_reply): Ditto. (free_actions_list_cleanup_wrapper): Ditto. (free_actions_list): Ditto. (remote_trace_init): New function. (remote_download_tracepoint): New function. (remote_download_trace_state_variable): New function. (remote_trace_set_readonly_regions): New function. (remote_trace_start): New function. (remote_get_trace_status): New function. (remote_trace_stop): New function. (remote_trace_find): New function. (remote_download_trace_state_variable): New function. (remote_set_disconnected_tracing): New function. (init_remote_ops): Add tracepoint operations.
2010-01-07 20:17:46 +01:00
target_buf_size = 2048;
target_buf = xmalloc (target_buf_size);
}