diff options
author | Pedro Alves <palves@redhat.com> | 2010-07-01 10:36:12 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2010-07-01 10:36:12 +0000 |
commit | 0fb4aa4bfcc2aa61c27132f94cf1656dca137dc9 (patch) | |
tree | c431424ed51b11bebcff4bc2409f79f9e802edcb /gdb/remote.c | |
parent | 76fa04a48e54c68fa6f16db02634b86ff340b98e (diff) | |
download | gdb-0fb4aa4bfcc2aa61c27132f94cf1656dca137dc9.zip gdb-0fb4aa4bfcc2aa61c27132f94cf1656dca137dc9.tar.gz gdb-0fb4aa4bfcc2aa61c27132f94cf1656dca137dc9.tar.bz2 |
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.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 35d517d..385d62a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -322,6 +322,9 @@ struct remote_state /* True if the stub reports support for fast tracepoints. */ int fast_tracepoints; + /* True if the stub reports support for static tracepoints. */ + int static_tracepoints; + /* True if the stub can continue running a trace while GDB is disconnected. */ int disconnected_tracing; @@ -1198,6 +1201,7 @@ enum { PACKET_qXfer_spu_write, PACKET_qXfer_osdata, PACKET_qXfer_threads, + PACKET_qXfer_statictrace_read, PACKET_qGetTIBAddr, PACKET_qGetTLSAddr, PACKET_qSupported, @@ -1212,6 +1216,7 @@ enum { PACKET_qAttached, PACKET_ConditionalTracepoints, PACKET_FastTracepoints, + PACKET_StaticTracepoints, PACKET_bc, PACKET_bs, PACKET_TracepointSource, @@ -2772,6 +2777,98 @@ remote_threads_extra_info (struct thread_info *tp) } +static int +remote_static_tracepoint_marker_at (CORE_ADDR addr, + struct static_tracepoint_marker *marker) +{ + struct remote_state *rs = get_remote_state (); + char *p = rs->buf; + + sprintf (p, "qTSTMat:"); + 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 void +free_current_marker (void *arg) +{ + struct static_tracepoint_marker **marker_p = arg; + + if (*marker_p != NULL) + { + release_static_tracepoint_marker (*marker_p); + xfree (*marker_p); + } + else + *marker_p = NULL; +} + +static VEC(static_tracepoint_marker_p) * +remote_static_tracepoint_markers_by_strid (const char *strid) +{ + 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 @@ -3552,6 +3649,16 @@ remote_fast_tracepoint_feature (const struct protocol_feature *feature, } static void +remote_static_tracepoint_feature (const struct protocol_feature *feature, + enum packet_support support, + const char *value) +{ + struct remote_state *rs = get_remote_state (); + + rs->static_tracepoints = (support == PACKET_ENABLE); +} + +static void remote_disconnected_tracing_feature (const struct protocol_feature *feature, enum packet_support support, const char *value) @@ -3593,6 +3700,8 @@ static struct protocol_feature remote_protocol_features[] = { PACKET_ConditionalTracepoints }, { "FastTracepoints", PACKET_DISABLE, remote_fast_tracepoint_feature, PACKET_FastTracepoints }, + { "StaticTracepoints", PACKET_DISABLE, remote_static_tracepoint_feature, + PACKET_StaticTracepoints }, { "DisconnectedTracing", PACKET_DISABLE, remote_disconnected_tracing_feature, -1 }, { "ReverseContinue", PACKET_DISABLE, remote_supported_packet, @@ -8046,6 +8155,16 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object, [PACKET_qXfer_siginfo_write]); } + if (object == TARGET_OBJECT_STATIC_TRACE_DATA) + { + if (readbuf) + return remote_read_qxfer (ops, "statictrace", annex, readbuf, offset, len, + &remote_protocol_packets + [PACKET_qXfer_statictrace_read]); + else + return -1; + } + /* Only handle flash writes. */ if (writebuf != NULL) { @@ -9478,6 +9597,14 @@ remote_supports_fast_tracepoints (void) return rs->fast_tracepoints; } +static int +remote_supports_static_tracepoints (void) +{ + struct remote_state *rs = get_remote_state (); + + return rs->static_tracepoints; +} + static void remote_trace_init (void) { @@ -9606,6 +9733,25 @@ remote_download_tracepoint (struct breakpoint *t) give up on the trace run. */ warning (_("Target does not support fast tracepoints, downloading %d as regular tracepoint"), t->number); } + else if (t->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 ()) + { + struct static_tracepoint_marker marker; + + if (target_static_tracepoint_marker_at (tpaddr, &marker)) + strcat (buf, ":S"); + else + error ("Static tracepoint not valid during download"); + } + 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) @@ -10101,6 +10247,10 @@ Specify the serial device it is connected to\n\ remote_ops.to_verify_memory = remote_verify_memory; remote_ops.to_get_tib_address = remote_get_tib_address; remote_ops.to_set_permissions = remote_set_permissions; + 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; } /* Set up the extended remote vector by making a copy of the standard @@ -10579,6 +10729,12 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, add_packet_config_cmd (&remote_protocol_packets[PACKET_QAllow], "QAllow", "allow", 0); + add_packet_config_cmd (&remote_protocol_packets[PACKET_StaticTracepoints], + "StaticTracepoints", "static-tracepoints", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_statictrace_read], + "qXfer:statictrace:read", "read-sdata-object", 0); + /* 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 |