#include "remote-notif.h"
#include "regcache.h"
#include "value.h"
-#include "observer.h"
+#include "observable.h"
#include "solib.h"
#include "cli/cli-decode.h"
#include "cli/cli-setshow.h"
}
\f
-static int
+static bool
remote_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR addr,
struct static_tracepoint_marker *marker)
{
if (*p++ == 'm')
{
parse_static_tracepoint_marker_definition (p, NULL, marker);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
remote_static_tracepoint_markers_by_strid (struct target_ops *self,
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;
+ std::vector<static_tracepoint_marker> markers;
const char *p;
+ static_tracepoint_marker marker;
/* Ask for a first packet of static tracepoint marker
definition. */
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);
+ 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));
- }
+ if (strid == NULL || marker.str_id == strid)
+ markers.push_back (std::move (marker));
}
while (*p++ == ','); /* comma-separated list */
/* Ask for another packet of static tracepoint definition. */
p = rs->buf;
}
- do_cleanups (old_chain);
return markers;
}
enum gdb_signal sig = ws->value.sig;
if (signal_print_state (sig))
- observer_notify_signal_received (sig);
+ gdb::observers::signal_received.notify (sig);
}
- observer_notify_normal_stop (NULL, 1);
+ gdb::observers::normal_stop.notify (NULL, 1);
}
/* Process all initial stop replies the remote side sent in response
/* All-stop protocol, and blocked waiting for stop reply. Send
an interrupt request. */
else if (!target_terminal::is_ours () && rs->waiting_for_stop_reply)
- target_interrupt (inferior_ptid);
+ target_interrupt ();
else
rs->got_ctrlc_during_io = 1;
}
child_pid = ptid_get_pid (child_ptid);
remote_detach_pid (child_pid);
- detach_inferior (child_pid);
}
}
return 0;
/* Implement the to_interrupt function for the remote targets. */
static void
-remote_interrupt (struct target_ops *self, ptid_t ptid)
+remote_interrupt (struct target_ops *self)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
else if (rs->ctrlc_pending_p)
interrupt_query ();
else
- target_interrupt (inferior_ptid);
+ target_interrupt ();
}
/* Ask the user what to do when an interrupt is received. */
fprintf_unfiltered (gdb_stdlog, "Sending packet: %s", str.c_str ());
- if (str.length () > REMOTE_DEBUG_MAX_CHAR)
- {
- fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
- str.length () - REMOTE_DEBUG_MAX_CHAR);
- }
+ if (len > REMOTE_DEBUG_MAX_CHAR)
+ fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]",
+ len - REMOTE_DEBUG_MAX_CHAR);
fprintf_unfiltered (gdb_stdlog, "...");
fprintf_unfiltered (gdb_stdlog, "Packet received: %s",
str.c_str ());
- if (str.length () > REMOTE_DEBUG_MAX_CHAR)
- {
- fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
- str.length () - REMOTE_DEBUG_MAX_CHAR);
- }
+ if (val > REMOTE_DEBUG_MAX_CHAR)
+ fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]",
+ val - REMOTE_DEBUG_MAX_CHAR);
fprintf_unfiltered (gdb_stdlog, "\n");
}
/* Implementation of to_fileio_readlink. */
-static char *
+static gdb::optional<std::string>
remote_hostio_readlink (struct target_ops *self,
struct inferior *inf, const char *filename,
int *remote_errno)
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;
+ return {};
remote_buffer_add_string (&p, &left, "vFile:readlink:");
&attachment_len);
if (len < 0)
- return NULL;
+ return {};
- ret = (char *) xmalloc (len + 1);
+ std::string ret (len, '\0');
read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
- (gdb_byte *) ret, len);
+ (gdb_byte *) &ret[0], len);
if (read_len != len)
error (_("Readlink returned %d, but %d bytes."), len, read_len);
- ret[len] = '\0';
return ret;
}
memset (&rs->btrace_config, 0, sizeof (rs->btrace_config));
}
-/* Check whether the target supports branch tracing. */
-
-static int
-remote_supports_btrace (struct target_ops *self, enum btrace_format format)
-{
- if (packet_support (PACKET_Qbtrace_off) != PACKET_ENABLE)
- return 0;
- if (packet_support (PACKET_qXfer_btrace) != PACKET_ENABLE)
- return 0;
-
- switch (format)
- {
- case BTRACE_FORMAT_NONE:
- return 0;
-
- case BTRACE_FORMAT_BTS:
- return (packet_support (PACKET_Qbtrace_bts) == PACKET_ENABLE);
-
- 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) */
- }
-
- internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
-}
-
/* Synchronize the configuration with the target. */
static void
if (!warned)
{
warned = 1;
- warning (_("GDB does not support Intel Processor Trace. "
- "\"record\" will not work in this session."));
+ warning (_("Target is recording using Intel Processor Trace "
+ "but support was disabled at compile time."));
}
continue;
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;
- 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;
add_target (&extended_remote_ops);
/* Hook into new objfile notification. */
- observer_attach_new_objfile (remote_new_objfile);
+ gdb::observers::new_objfile.attach (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);
+ gdb::observers::inferior_exit.attach (discard_pending_stop_replies);
#if 0
init_remote_threadtests ();