44#include "gdbsupport/filestuff.h"
45#include "gdbsupport/rsp-low.h"
49#include "gdbsupport/gdb_sys_time.h"
51#include "gdbsupport/event-loop.h"
61#include "gdbsupport/fileio.h"
70#include "gdbsupport/agent.h"
73#include "gdbsupport/scoped_restore.h"
74#include "gdbsupport/environ.h"
75#include "gdbsupport/byte-vector.h"
76#include "gdbsupport/search.h"
79#include <unordered_map>
81#include "gdbsupport/selftest.h"
86Use a remote computer via a serial line, using a gdb-specific protocol.\n\
87Specify the serial device it is connected to\n\
88(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
94#define OPAQUETHREADBYTES 8
133 gdb_assert_not_reached (
"invalid var_auto_boolean");
143 if (target_connected)
144 return _(
"on the current remote target");
146 return _(
"on future remote targets");
332#define MAXTHREADLISTRESULTS 32
346 int pread (
int fd, gdb_byte *read_buf,
size_t len, ULONGEST
offset);
387 std::unique_ptr<packet_reg[]>
regs;
560 std::unordered_map<struct gdbarch *, remote_arch_state>
566 N_(
"Remote target using gdb-specific protocol"),
616 "memory-read-packet-size",
620 "memory-write-packet-size",
709 static void open (
const char *,
int);
711 void close ()
override;
717 void resume (ptid_t,
int,
enum gdb_signal)
override;
758 void kill ()
override;
760 void load (
const char *,
int)
override;
764 void pass_signals (gdb::array_view<const unsigned char>)
override;
767 gdb::array_view<const int>)
override;
790 void stop (ptid_t)
override;
799 const gdb_byte *writebuf,
800 ULONGEST offset, ULONGEST len,
801 ULONGEST *xfered_len)
override;
805 void rcmd (
const char *command,
struct ui_file *output)
override;
815 CORE_ADDR load_module_addr,
816 CORE_ADDR offset)
override;
820 std::vector<mem_region>
memory_map ()
override;
822 void flash_erase (ULONGEST address, LONGEST length)
override;
828 int search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
829 const gdb_byte *pattern, ULONGEST pattern_len,
830 CORE_ADDR *found_addrp)
override;
836 void async (
bool)
override;
858 int flags,
int mode,
int warn_if_slow,
859 fileio_error *target_errno)
override;
861 int fileio_pwrite (
int fd,
const gdb_byte *write_buf,
int len,
862 ULONGEST offset, fileio_error *target_errno)
override;
865 ULONGEST offset, fileio_error *target_errno)
override;
867 int fileio_fstat (
int fd,
struct stat *sb, fileio_error *target_errno)
override;
869 int fileio_close (
int fd, fileio_error *target_errno)
override;
872 const char *filename,
873 fileio_error *target_errno)
override;
875 gdb::optional<std::string>
877 const char *filename,
878 fileio_error *target_errno)
override;
920 CORE_ADDR addr1, CORE_ADDR addr2,
int *tpp)
override;
941 const char *stopnotes)
override;
946 CORE_ADDR memaddr, ULONGEST
size)
override;
957 std::vector<static_tracepoint_marker>
965 struct btrace_target_info *
972 enum btrace_error
read_btrace (
struct btrace_data *data,
973 struct btrace_target_info *btinfo,
974 enum btrace_read_type
type)
override;
976 const struct btrace_config *
btrace_conf (
const struct btrace_target_info *)
override;
991 gdb::byte_vector &tags,
int type)
override;
994 const gdb::byte_vector &tags,
int type)
override;
1001 void remote_file_put (
const char *local_file,
const char *remote_file,
1003 void remote_file_get (
const char *remote_file,
const char *local_file,
1008 ULONGEST offset, fileio_error *remote_errno);
1010 ULONGEST offset, fileio_error *remote_errno);
1012 ULONGEST offset, fileio_error *remote_errno);
1015 fileio_error *remote_errno,
const char **attachment,
1016 int *attachment_len);
1018 fileio_error *remote_errno);
1021 int flags,
int mode,
int warn_if_slow,
1022 fileio_error *remote_errno);
1026 fileio_error *remote_errno);
1038 static void open_1 (
const char *
name,
int from_tty,
int extended_p);
1043 ptid_t ptid,
int step, gdb_signal siggnal);
1045 gdb_signal siggnal);
1050 target_wait_flags options);
1052 target_wait_flags options);
1078 (
bool *may_global_wildcard_vcont);
1103 char *
write_ptid (
char *buf,
const char *endbuf, ptid_t ptid);
1115 int result_limit,
int *done,
int *result_count,
1119 void *context,
int looplimit);
1133 const char *argument);
1147 gdb_signal siggnal);
1169 const gdb_byte *myaddr,
1172 ULONGEST *xfered_len_units,
1177 const gdb_byte *myaddr, ULONGEST len,
1178 int unit_size, ULONGEST *xfered_len);
1182 int unit_size, ULONGEST *xfered_len_units);
1188 ULONGEST *xfered_len);
1191 gdb_byte *myaddr, ULONGEST len,
1193 ULONGEST *xfered_len);
1199 ULONGEST length, ULONGEST *xfered_len,
1200 const gdb_byte *data);
1206 int putpkt (const
char *buf);
1211 return putpkt (buf.data ());
1216 int getpkt (gdb::char_vector *buf,
bool forever =
false,
1217 bool *is_notif =
nullptr);
1233 const gdb_byte *writebuf,
1234 ULONGEST offset, LONGEST len,
1235 ULONGEST *xfered_len,
1236 const unsigned int which_packet);
1240 gdb_byte *readbuf, ULONGEST offset,
1242 ULONGEST *xfered_len,
1243 const unsigned int which_packet);
1262 N_(
"Extended remote target using gdb-specific protocol"),
1276 static void open (
const char *,
int);
1280 char **,
int)
override;
1285 void attach (
const char *,
int)
override;
1367static int hexnumnstr (
char *, ULONGEST,
int);
1377 const unsigned int which_packet,
1385static ptid_t
read_ptid (
const char *buf,
const char **obuf);
1540 error (_(
"remote.c: error in outgoing packet."));
1542 error (_(
"remote.c: error in outgoing packet at field #%ld."),
1543 strtol (buf, NULL, 16));
1545 error (_(
"Target returns error code '%s'."), buf);
1562 buf = rs->
buf.data ();
1565 else if (startswith (buf,
"qRelocInsn:"))
1568 CORE_ADDR from, to, org_to;
1570 int adjusted_size = 0;
1573 p = buf + strlen (
"qRelocInsn:");
1574 pp = unpack_varlen_hex (p, &ul);
1576 error (_(
"invalid qRelocInsn packet: %s"), buf);
1580 unpack_varlen_hex (p, &ul);
1590 catch (
const gdb_exception &ex)
1592 if (ex.error == MEMORY_ERROR)
1605 _(
"warning: relocating instruction: "));
1612 adjusted_size = to - org_to;
1614 xsnprintf (buf, rs->
buf.size (),
"qRelocInsn:%x", adjusted_size);
1618 else if (buf[0] ==
'O' && buf[1] !=
'K')
1634 auto p = this->
m_arch_states.emplace (std::piecewise_construct,
1635 std::forward_as_tuple (
gdbarch),
1636 std::forward_as_tuple (
gdbarch));
1637 rsa = &p.first->second;
1670 char *remote_exec_file;
1673 if (remote_exec_file == NULL)
1676 return remote_exec_file;
1683 const char *remote_exec_file)
1713 int regnum, num_remote_regs, offset;
1734 for (num_remote_regs = 0,
regnum = 0;
1738 remote_regs[num_remote_regs++] = ®s[
regnum];
1740 std::sort (remote_regs, remote_regs + num_remote_regs,
1762 int *
pnum,
int *poffset)
1771 *poffset = regs[
regnum].offset;
1890 _(
"Send the ASCII ETX character (Ctrl-c) "
1891 "to the remote target to interrupt the "
1892 "execution of the program.\n"));
1895 _(
"send a break signal to the remote target "
1896 "to interrupt the execution of the program.\n"));
1899 _(
"Send a break signal and 'g' a.k.a. Magic SysRq g to "
1900 "the remote target to interrupt the execution "
1901 "of Linux kernel.\n"));
1903 internal_error (_(
"Invalid value for interrupt_sequence_mode: %s."),
1952#define DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED 16384
1956#define MIN_MEMORY_PACKET_SIZE 20
1965 if (config->
size <= 0)
1968 return config->
size;
1987 if (config->
size > 0
1988 && what_they_get > config->
size)
1989 what_they_get = config->
size;
2003 if (rs->
buf.size () < what_they_get + 1)
2004 rs->
buf.resize (2 * what_they_get);
2006 return what_they_get;
2014 bool target_connected)
2016 int fixed_p = config->
fixed_p;
2020 error (_(
"Argument required (integer, \"fixed\" or \"limit\")."));
2021 else if (strcmp (args,
"hard") == 0
2022 || strcmp (args,
"fixed") == 0)
2024 else if (strcmp (args,
"soft") == 0
2025 || strcmp (args,
"limit") == 0)
2031 size = strtoul (args, &end, 0);
2033 error (_(
"Invalid %s (bad syntax)."), config->
name);
2041 if (fixed_p && !config->
fixed_p)
2044 long query_size = (
size <= 0
2048 if (target_connected
2049 && !
query (_(
"The target may not be able to correctly handle a %s\n"
2050 "of %ld bytes. Change the packet size? "),
2051 config->
name, query_size))
2052 error (_(
"Packet size not changed."));
2053 else if (!target_connected
2054 && !
query (_(
"Future remote targets may not be able to "
2055 "correctly handle a %s\nof %ld bytes. Change the "
2056 "packet size for future remote targets? "),
2057 config->
name, query_size))
2058 error (_(
"Packet size not changed."));
2065 gdb_printf (_(
"The %s %s is set to \"%s\".\n"), config->
name, target_type,
2079 if (config->
size == 0)
2080 gdb_printf (_(
"The %s %s is 0 (default). "), config->
name, target_type);
2086 gdb_printf (_(
"Packets are fixed at %ld bytes.\n"),
2090 if (remote !=
nullptr)
2091 gdb_printf (_(
"Packets are limited to %ld bytes.\n"),
2094 gdb_puts (
"The actual limit will be further reduced "
2095 "dependent on the target.\n");
2107 if (remote !=
nullptr)
2127 if (remote !=
nullptr)
2141 gdb_printf (file, _(
"The maximum number of target hardware "
2142 "watchpoints is %s.\n"),
value);
2152 gdb_printf (file, _(
"The maximum length (in bytes) of a target "
2153 "hardware watchpoint is %s.\n"),
value);
2163 gdb_printf (file, _(
"The maximum number of target hardware "
2164 "breakpoints is %s.\n"),
value);
2180 gdb_printf (file, _(
"Number of remote packet characters to "
2181 "display is %s.\n"),
value);
2198 if (remote !=
nullptr)
2217 if (remote !=
nullptr)
2245 gdb_assert (c->
var.has_value ());
2251 if (packet_idx >= 0 && packet_idx <
PACKET_MAX)
2258 if (remote !=
nullptr)
2263 gdb_printf (_(
"Support for the '%s' packet %s is set to \"%s\".\n"),
name,
2264 target_type, support);
2268 internal_error (_(
"Could not find config for %s"), c->
name);
2275 const char *support =
"internal-error";
2279 if (remote !=
nullptr)
2287 support =
"enabled";
2290 support =
"disabled";
2293 support =
"unknown";
2300 _(
"Support for the '%s' packet %s is \"auto\", "
2308 _(
"Support for the '%s' packet %s is \"%s\".\n"),
2317 const char *title,
int legacy)
2324 gdb::unique_xmalloc_ptr<char> set_doc
2325 = xstrprintf (
"Set use of remote protocol `%s' (%s) packet.",
2327 gdb::unique_xmalloc_ptr<char> show_doc
2328 = xstrprintf (
"Show current use of remote protocol `%s' (%s) packet.",
2331 gdb::unique_xmalloc_ptr<char> cmd_name = xstrprintf (
"%s-packet", title);
2334 &config->
detect, set_doc.get (),
2335 show_doc.get (), NULL,
2348 static std::vector<gdb::unique_xmalloc_ptr<char>> legacy_names;
2349 gdb::unique_xmalloc_ptr<char> legacy_name
2350 = xstrprintf (
"%s-packet",
name);
2355 legacy_names.emplace_back (std::move (legacy_name));
2367 && isxdigit (
buf[1]) && isxdigit (
buf[2])
2374 if (
buf[0] ==
'E' &&
buf[1] ==
'.')
2401 internal_error (_(
"packet_ok: attempt to use a disabled packet"));
2423 error (_(
"Protocol error: %s (%s) conflicting enabled responses."),
2429 error (_(
"Enabled packet %s (%s) not recognized by stub"),
2445 return packet_ok (buf.data (), which_packet);
2464 gdb_assert_not_reached (
"bad switch");
2481 gdb_assert (c->
var.has_value ());
2487 if (packet_idx >= 0 && packet_idx <
PACKET_MAX)
2492 internal_error (_(
"Could not find config for %s"), c->
name);
2521 if (remote !=
nullptr)
2530 gdb_printf (_(
"Use of Z packets %s is set to \"%s\".\n"), target_type,
2622 xsnprintf (rs->
buf.data (),
size,
"qAttached:%x",
pid);
2624 xsnprintf (rs->
buf.data (),
size,
"qAttached");
2632 if (strcmp (rs->
buf.data (),
"1") == 0)
2636 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
2706 inf->push_target (
this);
2710 inf->attach_flag = attached;
2711 inf->fake_pid_p = fake_pid_p;
2791 int pid = currthread.
pid ();
2832 currthread.pid (), -1, 1);
2858 gdb_assert (thread != NULL);
2860 if (thread->
priv == NULL)
2863 return gdb::checked_static_cast<remote_thread_info *> (thread->
priv.get ());
2894 char *pass_packet, *p;
2904 pass_packet = (
char *)
xmalloc (count * 3 + strlen (
"QPassSignals:") + 1);
2905 strcpy (pass_packet,
"QPassSignals:");
2906 p = pass_packet + strlen (pass_packet);
2912 *p++ = tohex (i >> 4);
2913 *p++ = tohex (i & 15);
2931 xfree (pass_packet);
2940 gdb::array_view<const int> syscall_counts)
2942 const char *catch_packet;
2952 if (needed && any_count == 0)
2955 for (
size_t i = 0; i < syscall_counts.size (); i++)
2957 if (syscall_counts[i] != 0)
2963 pid, needed, any_count, n_sysno);
2965 std::string built_packet;
2971 const int maxpktsz = strlen (
"QCatchSyscalls:1") + n_sysno * 9 + 1;
2972 built_packet.reserve (maxpktsz);
2973 built_packet =
"QCatchSyscalls:1";
2977 for (
size_t i = 0; i < syscall_counts.size (); i++)
2979 if (syscall_counts[i] != 0)
2980 string_appendf (built_packet,
";%zx", i);
2987 catch_packet =
"QCatchSyscalls:1";
2990 catch_packet = built_packet.c_str ();
2993 catch_packet =
"QCatchSyscalls:0";
3018 gdb_assert (signals.size () < 256);
3019 for (
size_t i = 0; i < signals.size (); i++)
3024 packet = (
char *)
xmalloc (count * 3 + strlen (
"QProgramSignals:") + 1);
3025 strcpy (packet,
"QProgramSignals:");
3026 p = packet + strlen (packet);
3027 for (
size_t i = 0; i < signals.size (); i++)
3032 *p++ = tohex (i >> 4);
3033 *p++ = tohex (i & 15);
3065 char *buf = rs->
buf.data ();
3072 *buf++ = gen ?
'g' :
'c';
3074 xsnprintf (buf, endbuf - buf,
"0");
3076 xsnprintf (buf, endbuf - buf,
"0");
3077 else if (ptid == minus_one_ptid)
3078 xsnprintf (buf, endbuf - buf,
"-1");
3136 if (ptid.pid () != 0 && ptid.lwp () == 0)
3159 p = rs->
buf.data ();
3167 return (rs->
buf[0] ==
'O' && rs->
buf[1] ==
'K');
3176 if (
info->priv != NULL)
3179 return !
name.empty () ?
name.c_str () : NULL;
3220#define TAG_THREADID 1
3222#define TAG_DISPLAY 4
3223#define TAG_THREADNAME 8
3224#define TAG_MOREDISPLAY 16
3226#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES * 2)
3228static const char *
unpack_nibble (
const char *buf,
int *val);
3236static const char *
unpack_string (
const char *src,
char *dest,
int length);
3273 buf += xsnprintf (buf, endbuf - buf,
"p-%x.", -
pid);
3275 buf += xsnprintf (buf, endbuf - buf,
"p%x.",
pid);
3279 buf += xsnprintf (buf, endbuf - buf,
"-%x", -tid);
3281 buf += xsnprintf (buf, endbuf - buf,
"%x", tid);
3293 const char *p = buf;
3295 ULONGEST
pid = 0, tid = 0;
3300 pp = unpack_varlen_hex (p + 1, &
pid);
3302 error (_(
"invalid remote ptid: %s"), p);
3305 pp = unpack_varlen_hex (p + 1, &tid);
3308 return ptid_t (
pid, tid);
3312 pp = unpack_varlen_hex (p, &tid);
3334 return ptid_t (
pid, tid);
3340 if (ch >=
'a' && ch <=
'f')
3341 return ch -
'a' + 10;
3342 if (ch >=
'0' && ch <=
'9')
3344 if (ch >=
'A' && ch <=
'F')
3345 return ch -
'A' + 10;
3361 retval = retval << 4;
3369 *val = fromhex (*buf++);
3383 buf = pack_hex_byte (buf, (
value >> 24) & 0xff);
3384 buf = pack_hex_byte (buf, (
value >> 16) & 0xff);
3385 buf = pack_hex_byte (buf, (
value >> 8) & 0x0ff);
3386 buf = pack_hex_byte (buf, (
value & 0xff));
3398static char *pack_string (
char *pkt,
char *
string);
3401pack_string (
char *pkt,
char *
string)
3406 len = strlen (
string);
3409 pkt = pack_hex_byte (pkt, len);
3413 if ((ch ==
'\0') || (ch ==
'#'))
3434 unsigned char *altid;
3436 altid = (
unsigned char *)
id;
3439 pkt = pack_hex_byte (pkt, *altid++);
3451 altref = (
char *)
id;
3453 while (inbuf < limit)
3457 *altref++ = (x << 4) | y;
3470 unsigned char *
scan;
3472 scan = (
unsigned char *)
id;
3488 unsigned char *
scan;
3502 unsigned char *csrc, *cdest;
3504 csrc = (
unsigned char *) src;
3505 cdest = (
unsigned char *) dest;
3516 unsigned char *srcp, *destp;
3518 srcp = (
char *) src;
3519 destp = (
char *) dest;
3523 result &= (*srcp++ == *destp++) ? 1 : 0;
3554#define TAG_THREADID 1
3557#define TAG_DISPLAY 4
3558#define TAG_THREADNAME 8
3559#define TAG_MOREDISPLAY 16
3571 const char *limit = pkt + rs->
buf.size ();
3576 info->display[0] =
'\0';
3578 info->more_display[0] =
'\0';
3586 warning (_(
"Incomplete response to threadinfo request."));
3589 warning (_(
"ERROR RMT Thread info mismatch."));
3597 while ((pkt < limit) && mask && *pkt)
3603 warning (_(
"ERROR RMT: threadinfo tag mismatch."));
3611 warning (_(
"ERROR RMT: length of threadid is not 16."));
3616 mask = mask & ~TAG_THREADID;
3626 warning (_(
"ERROR RMT: 'exists' length too long."));
3635 mask = mask & ~TAG_THREADNAME;
3641 mask = mask & ~TAG_DISPLAY;
3647 mask = mask & ~TAG_MOREDISPLAY;
3650 warning (_(
"ERROR RMT: unknown thread info tag."));
3668 if (rs->
buf[0] ==
'\0')
3684 pkt = pack_nibble (pkt, startflag);
3685 pkt = pack_hex_byte (pkt, threadcount);
3700 int count, resultcount, done;
3710 while ((count-- > 0) && (pkt < limit))
3713 if (resultcount++ >= result_limit)
3726 int result_limit,
int *done,
int *result_count,
3741 if (rs->
buf[0] ==
'\0')
3761 warning (_(
"HMM: threadlist did not echo arg thread, dropping it."));
3764 if (*result_count <= 0)
3768 warning (_(
"RMT ERROR : failed to get remote thread list."));
3773 if (*result_count > result_limit)
3776 warning (_(
"RMT ERROR: threadlist response longer than requested."));
3790 void *context,
int looplimit)
3793 int done, i, result_count;
3801 if (loopcount++ > looplimit)
3804 warning (_(
"Remote fetch threadlist -infinite loop-."));
3809 &done, &result_count,
3816 if (result_count >= 1)
3820 while (result_count--)
3874 return item.
ptid == ptid;
3877 auto it = std::find_if (this->
items.begin (),
3881 return it != this->
items.end ();
3890 return item.
ptid == ptid;
3893 auto it = std::remove_if (this->
items.begin (),
3897 if (it != this->
items.end ())
3898 this->
items.erase (it);
3902 std::vector<thread_item>
items;
3912 ptid_t ptid (
pid, lwp);
3914 context->
items.emplace_back (ptid);
3919#define CRAZY_MAX_THREADS 1000
3928 if (rs->
buf[0] ==
'Q' && rs->
buf[1] ==
'C')
3955#if defined(HAVE_LIBEXPAT)
3958start_thread (
struct gdb_xml_parser *parser,
3970 data->items.emplace_back (ptid);
3975 item.
core = *(ULONGEST *) attr->
value.get ();
3979 item.
name = (
const char *) attr->
value.get ();
3987end_thread (
struct gdb_xml_parser *parser,
3989 void *user_data,
const char *body_text)
3994 if (body_text != NULL && *body_text !=
'\0')
3995 data->items.back ().extra = body_text;
4011 {
"thread", thread_attributes, thread_children,
4013 start_thread, end_thread },
4018 {
"threads", NULL, threads_children,
4030#if defined(HAVE_LIBEXPAT)
4033 gdb::optional<gdb::char_vector> xml
4036 if (xml && (*xml)[0] !=
'\0')
4039 threads_elements, xml->data (), context);
4062 bufp = rs->
buf.data ();
4063 if (bufp[0] !=
'\0')
4065 while (*bufp++ ==
'm')
4070 context->
items.emplace_back (ptid);
4072 while (*bufp++ ==
',');
4075 bufp = rs->
buf.data ();
4095 for (
thread_info *tp ATTRIBUTE_UNUSED :
inf->non_exited_threads ())
4119 if (context.
items.empty ()
4135 if (tp->inf->process_target () !=
this)
4161 if (item.
ptid != null_ptid)
4175 info->name = std::move (item.
name);
4209 internal_error (_(
"remote_threads_extra_info"));
4212 || (tp->
ptid.pid () != 0 && tp->
ptid.lwp () == 0))
4220 if (!extra.empty ())
4221 return extra.c_str ();
4233 char *b = rs->
buf.data ();
4236 xsnprintf (b, endb - b,
"qThreadExtraInfo,");
4242 if (rs->
buf[0] != 0)
4244 extra.resize (strlen (rs->
buf.data ()) / 2);
4245 hex2bin (rs->
buf.data (), (gdb_byte *) &extra[0], extra.size ());
4246 return extra.c_str ();
4259 string_appendf (extra,
" Name: %s", threadinfo.
shortname);
4262 if (!extra.empty ())
4264 string_appendf (extra,
" State: %s", threadinfo.
display);
4268 if (!extra.empty ())
4270 string_appendf (extra,
" Priority: %s", threadinfo.
more_display);
4272 return extra.c_str ();
4283 char *p = rs->
buf.data ();
4290 p = rs->
buf.data ();
4293 error (_(
"Remote failure reply: %s"), p);
4304std::vector<static_tracepoint_marker>
4308 std::vector<static_tracepoint_marker> markers;
4316 p = rs->
buf.data ();
4318 error (_(
"Remote failure reply: %s"), p);
4326 if (strid == NULL || marker.
str_id == strid)
4327 markers.push_back (std::move (marker));
4329 while (*p++ ==
',');
4333 p = rs->
buf.data ();
4406 int lose, num_segments = 0, do_sections, do_segments;
4407 CORE_ADDR text_addr, data_addr, bss_addr, segments[2];
4414 buf = rs->
buf.data ();
4416 if (buf[0] ==
'\000')
4421 warning (_(
"Remote failure reply: %s"), buf);
4429 text_addr = data_addr = bss_addr = 0;
4433 if (startswith (ptr,
"Text="))
4437 while (*ptr && *ptr !=
';')
4438 text_addr = (text_addr << 4) + fromhex (*ptr++);
4440 if (startswith (ptr,
";Data="))
4443 while (*ptr && *ptr !=
';')
4444 data_addr = (data_addr << 4) + fromhex (*ptr++);
4449 if (!lose && startswith (ptr,
";Bss="))
4452 while (*ptr && *ptr !=
';')
4453 bss_addr = (bss_addr << 4) + fromhex (*ptr++);
4455 if (bss_addr != data_addr)
4456 warning (_(
"Target reported unsupported offsets: %s"), buf);
4461 else if (startswith (ptr,
"TextSeg="))
4465 while (*ptr && *ptr !=
';')
4466 text_addr = (text_addr << 4) + fromhex (*ptr++);
4469 if (startswith (ptr,
";DataSeg="))
4472 while (*ptr && *ptr !=
';')
4473 data_addr = (data_addr << 4) + fromhex (*ptr++);
4481 error (_(
"Malformed response to offset query, %s"), buf);
4482 else if (*ptr !=
'\0')
4483 warning (_(
"Target reported unsupported offsets: %s"), buf);
4489 do_segments = (data != NULL);
4490 do_sections = num_segments == 0;
4492 if (num_segments > 0)
4494 segments[0] = text_addr;
4495 segments[1] = data_addr;
4501 else if (data !=
nullptr && data->segments.size () == 2)
4503 segments[0] = data->segments[0].base + text_addr;
4504 segments[1] = data->segments[1].base + data_addr;
4512 else if (data && data->segments.size () == 1)
4514 segments[0] = data->segments[0].base + text_addr;
4525 num_segments, segments);
4527 if (ret == 0 && !do_sections)
4528 error (_(
"Can not handle qOffsets TextSeg "
4529 "response with this symbol file"));
4568 internal_error (_(
"Invalid value for interrupt_sequence_mode: %s."),
4591 p1 = strchr (p,
':');
4595 if (strncmp (p,
"thread", p1 - p) == 0)
4598 p1 = strchr (p,
';');
4619 ptid_t ptid = null_ptid;
4624 if (wait_status != NULL)
4626 if (ptid == null_ptid)
4648 bool fake_pid_p =
false;
4656 if (curr_ptid != null_ptid)
4713 enum gdb_signal sig = ws.
sig ();
4739 while (pending_stop_replies-- > 0)
4741 ptid_t waiton_ptid = minus_one_ptid;
4744 int ignore_event = 0;
4772 enum gdb_signal sig = ws.
sig ();
4776 if (sig == GDB_SIGNAL_TRAP)
4783 || ws.
sig () != GDB_SIGNAL_0)
4795 inf->needs_setup =
true;
4824 if (
inf->needs_setup)
4849 if (lowest_stopped == NULL
4851 || thread->per_inf_num < lowest_stopped->
per_inf_num)
4852 lowest_stopped = thread;
4864 thread = lowest_stopped;
4891 static scoped_restore_tmpl<bool>
4896 return make_scoped_restore (&rs->
starting_up,
true);
4959 const char v_mustreplyempty[] =
"vMustReplyEmpty";
4961 putpkt (v_mustreplyempty);
4963 if (strcmp (rs->
buf.data (),
"OK") == 0)
4968 else if (strcmp (rs->
buf.data (),
"") != 0)
4969 error (_(
"Remote replied unexpectedly to '%s': %s"), v_mustreplyempty,
4988 putpkt (
"QStartNoAckMode");
5021 error (_(
"Non-stop mode requested, but remote "
5022 "does not support non-stop"));
5027 if (strcmp (rs->
buf.data (),
"OK") != 0)
5028 error (_(
"Remote refused setting non-stop mode with: %s"),
5044 if (strcmp (rs->
buf.data (),
"OK") != 0)
5045 error (_(
"Remote refused setting all-stop mode with: %s"),
5066 char *wait_status = NULL;
5068 if (rs->
buf[0] ==
'W' || rs->
buf[0] ==
'X')
5071 error (_(
"The target is not running (try extended-remote?)"));
5077 wait_status = (
char *) alloca (strlen (rs->
buf.data ()) + 1);
5078 strcpy (wait_status, rs->
buf.data ());
5102 if (curr_thread == null_ptid)
5110 "current thread; picking first in list.");
5148 gdb_assert (wait_status != NULL);
5169 if (strcmp (rs->
buf.data (),
"OK") != 0)
5183 error (_(
"The target is not running (try extended-remote?)"));
5207 if (
inf->pspace->symfile_object_file ==
nullptr)
5225 gdb_printf (_(
"Trace is already running on the target.\n"));
5332 while (startswith (reply.data (),
"qSymbol:"))
5337 end = hex2bin (tmp,
reinterpret_cast <gdb_byte *
> (msg.data ()),
5355 phex_nz (sym_addr, addr_size), &reply[8]);
5366 static int udp_warning = 0;
5372 if (!udp_warning && startswith (
name,
"udp:"))
5374 warning (_(
"The remote protocol may be unreliable over UDP.\n"
5375 "Some events may be lost, rendering further debugging "
5398 "WriteReg:%x;WriteMem:%x;"
5399 "InsertBreak:%x;InsertTrace:%x;"
5400 "InsertFastTrace:%x;Stop:%x",
5409 if (strcmp (rs->
buf.data (),
"OK") != 0)
5410 warning (_(
"Remote refused setting permissions with: %s"),
5445 const char *argument)
5449 warning (_(
"Remote qSupported response supplied an unexpected value for"
5450 " \"%s\"."), feature->
name);
5471 warning (_(
"Remote target reported \"%s\" without a size."),
5477 packet_size = strtol (
value, &value_end, 16);
5478 if (errno != 0 || *value_end !=
'\0' || packet_size < 0)
5480 warning (_(
"Remote target reported \"%s\" with a bad size: \"%s\"."),
5610#if defined(HAVE_LIBEXPAT)
5617 char *p = strtok_r (copy,
",", &saveptr);
5621 if (strcmp (p, xml) == 0)
5628 while ((p = strtok_r (NULL,
",", &saveptr)) != NULL);
5643 msg->append (append);
5715 q =
"qSupported:" + q;
5724 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
5729 memset (seen, 0,
sizeof (seen));
5731 next = rs->
buf.data ();
5735 char *p, *end, *name_end, *
value;
5741 end = strchr (p,
';');
5744 end = p + strlen (p);
5754 warning (_(
"empty item in \"qSupported\" response"));
5759 name_end = strchr (p,
'=');
5764 value = name_end + 1;
5785 warning (_(
"unrecognized item \"%s\" "
5786 "in \"qSupported\" response"), p);
5799 feature->
func (
this, feature, is_supported,
value);
5858 if (
query (_(
"The target is not responding to GDB commands.\n"
5859 "Stop debugging it? ")))
5916 throw_error (TARGET_CLOSE_ERROR, _(
"Disconnected from target."));
5925 error (_(
"To open a remote debug connection, you need to specify what\n"
5926 "serial device is attached to the remote system\n"
5927 "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.)."));
5935 && !
query (_(
"Already connected to a remote target. Disconnect? ")))
5936 error (_(
"Still connected."));
5958 perror_with_name (
name);
5970 perror_with_name (
name);
5983 gdb_puts (
"Remote debugging using ");
6055 catch (
const gdb_exception &ex)
6059 if (ex.error != TARGET_CLOSE_ERROR)
6115 strcpy (rs->
buf.data (),
"D");
6120 if (rs->
buf[0] ==
'O' && rs->
buf[1] ==
'K')
6122 else if (rs->
buf[0] ==
'\0')
6123 error (_(
"Remote doesn't know how to detach"));
6125 error (_(
"Can't detach process."));
6142 error (_(
"No process to detach from."));
6161 gdb_puts (_(
"Ending remote debugging.\n"));
6180 if (reply->ptid.pid () !=
pid)
6193 is_fork_parent = (tp != NULL
6198 if (!is_fork_parent)
6206 gdb_printf (_(
"[Inferior %d (%s) detached]\n"),
6207 inf->num, infpid.c_str ());
6267 const char *execd_pathname)
6285 error (_(
"Argument given to \"disconnect\" when remotely debugging."));
6294 gdb_puts (
"Ending remote debugging.\n");
6305 char *wait_status = NULL;
6313 error (_(
"This target does not support attaching to a process"));
6327 wait_status = (
char *) alloca (strlen (rs->
buf.data ()) + 1);
6328 strcpy (wait_status, rs->
buf.data ());
6330 else if (strcmp (rs->
buf.data (),
"OK") != 0)
6331 error (_(
"Attaching to %s failed with: %s"),
6336 error (_(
"This target does not support attaching to a process"));
6338 error (_(
"Attaching to %s failed"),
6352 if (thread !=
nullptr)
6378 gdb_assert (wait_status != NULL);
6387 gdb_assert (wait_status == NULL);
6420 strcpy (rs->
buf.data (),
"vCont?");
6423 buf = rs->
buf.data ();
6426 if (startswith (buf,
"vCont"))
6429 int support_c, support_C;
6437 while (p && *p ==
';')
6440 if (*p ==
's' && (*(p + 1) ==
';' || *(p + 1) == 0))
6442 else if (*p ==
'S' && (*(p + 1) ==
';' || *(p + 1) == 0))
6444 else if (*p ==
'c' && (*(p + 1) ==
';' || *(p + 1) == 0))
6446 else if (*p ==
'C' && (*(p + 1) ==
';' || *(p + 1) == 0))
6448 else if (*p ==
't' && (*(p + 1) ==
';' || *(p + 1) == 0))
6450 else if (*p ==
'r' && (*(p + 1) ==
';' || *(p + 1) == 0))
6453 p = strchr (p,
';');
6458 if (!support_c || !support_C)
6476 ptid_t ptid,
int step, gdb_signal siggnal)
6480 if (step && siggnal != GDB_SIGNAL_0)
6481 p += xsnprintf (p, endp - p,
";S%02x", siggnal);
6495 if (ptid == minus_one_ptid)
6503 gdb_assert (tp != NULL);
6509 p += xsnprintf (p, endp - p,
";r%s,%s",
6516 p += xsnprintf (p, endp - p,
";s");
6519 p += xsnprintf (p, endp - p,
";s");
6520 else if (siggnal != GDB_SIGNAL_0)
6521 p += xsnprintf (p, endp - p,
";C%02x", siggnal);
6523 p += xsnprintf (p, endp - p,
";c");
6530 nptid = ptid_t (ptid.pid (), -1);
6532 p += xsnprintf (p, endp - p,
":");
6535 else if (ptid != minus_one_ptid)
6537 p += xsnprintf (p, endp - p,
":");
6549 if (thread->
priv != NULL)
6567 && thread->stop_signal () != GDB_SIGNAL_0)
6570 0, thread->stop_signal ());
6571 thread->set_stop_signal (GDB_SIGNAL_0);
6593 if (ptid == minus_one_ptid)
6601 buf = rs->
buf.data ();
6606 warning (_(
" - Can't pass signal %d to target in reverse: ignored."),
6610 error (_(
"Remote reverse-step not supported."));
6612 error (_(
"Remote reverse-continue not supported."));
6614 strcpy (buf, step ?
"bs" :
"bc");
6616 else if (siggnal != GDB_SIGNAL_0)
6618 buf[0] = step ?
'S' :
'C';
6619 buf[1] = tohex (((
int) siggnal >> 4) & 0xf);
6620 buf[2] = tohex (((
int) siggnal) & 0xf);
6624 strcpy (buf, step ?
"s" :
"c");
6638 enum gdb_signal siggnal)
6651 p = rs->
buf.data ();
6658 p += xsnprintf (p, endp - p,
"vCont");
6668 else if (scope_ptid == minus_one_ptid || scope_ptid.is_pid ())
6674 if (step || siggnal != GDB_SIGNAL_0)
6702 if (strcmp (rs->
buf.data (),
"OK") != 0)
6703 error (_(
"Unexpected vCont reply in non-stop mode: %s"),
6786 if (
inf->priv == NULL)
6789 return gdb::checked_static_cast<remote_inferior *> (
inf->priv.get ());
6806 void push_action (ptid_t ptid,
bool step, gdb_signal siggnal);
6852 if (strcmp (rs->
buf.data (),
"OK") != 0)
6853 error (_(
"Unexpected vCont reply in non-stop mode: %s"), rs->
buf.data ());
6860#define MAX_ACTION_SIZE 200
6873 ptid, step, siggnal);
6878 size_t rsize = endp - buf;
6888 memcpy (
m_p, buf, rsize);
6954 bool may_global_wildcard_vcont =
true;
6968 bool any_pending_vcont_resume =
false;
6982 may_global_wildcard_vcont =
false;
6987 any_pending_vcont_resume =
true;
6993 may_global_wildcard_vcont =
false;
6998 if (!any_pending_vcont_resume)
7033 if (
info.step ||
info.sig != GDB_SIGNAL_0
7043 bool any_process_wildcard =
false;
7049 any_process_wildcard =
true;
7054 if (any_process_wildcard)
7059 if (may_global_wildcard_vcont)
7062 false, GDB_SIGNAL_0);
7071 false, GDB_SIGNAL_0);
7110 char *p = rs->
buf.data ();
7117 bool needs_commit =
false;
7127 if (
info.sig != GDB_SIGNAL_0)
7132 needs_commit =
true;
7149 "vCont-resume (%d, %ld, %s)", tp->ptid.pid(),
7151 pulongest (tp->ptid.tid ()));
7158 gdb_assert (
info.sig == GDB_SIGNAL_0);
7161 sr->
ptid = tp->ptid;
7164 sr->
arch = tp->inf->gdbarch;
7182 error (_(
"Remote server does not support stopping threads"));
7184 if (ptid == minus_one_ptid
7186 p += xsnprintf (p, endp - p,
"vCont;t");
7191 p += xsnprintf (p, endp - p,
"vCont;t:");
7195 nptid = ptid_t (ptid.pid (), -1);
7214 if (strcmp (rs->
buf.data (),
"OK") != 0)
7249 char *p = rs->
buf.data ();
7252 xsnprintf (p, endp - p,
"vCtrlC");
7264 error (_(
"No support for interrupting the remote target."));
7266 error (_(
"Interrupting target failed: %s"), rs->
buf.data ());
7329 if (
query (_(
"The target is not responding to interrupt requests.\n"
7330 "Stop debugging it? ")))
7333 throw_error (TARGET_CLOSE_ERROR, _(
"Disconnected from target."));
7338 if (
query (_(
"Interrupted while waiting for the program.\n"
7339 "Give up waiting? ")))
7367 for (p = msg; p[0] && p[1]; p += 2)
7370 char c = fromhex (p[0]) * 16 + fromhex (p[1]);
7495 (
bool *may_global_wildcard)
7508 *may_global_wildcard =
false;
7513 *may_global_wildcard =
false;
7514 if (event->ptid != null_ptid)
7540 if (reply != NULL && reply->
ptid.pid () ==
inf->
pid)
7546 (
"discarding in-flight notification: ptid: %s, ws: %s\n",
7547 reply->
ptid.to_string().c_str(),
7558 return event->ptid.pid () == inf->pid;
7562 (
"discarding queued stop reply: ptid: %s, ws: %s\n",
7563 (*it)->ptid.to_string().c_str(),
7564 (*it)->ws.to_string ().c_str ());
7581 return event->rs == rs;
7598 return event->ptid.matches (ptid);
7605 result = iter->release ();
7611 "notif: discard queued event: 'Stop' in %s\n",
7612 ptid.to_string ().c_str ());
7649 "notif: push 'Stop' %s to queue %d\n",
7650 new_event->
ptid.to_string ().c_str (),
7668 if (ptid == event->ptid
7680 for ( ; p < pend; p++,
prefix++)
7697 event->ptid = null_ptid;
7699 event->ws.set_ignore ();
7701 event->regcache.clear ();
7720 p1 = strchr (p,
':');
7722 error (_(
"Malformed packet(a) (missing colon): %s\n\
7726 error (_(
"Malformed packet(a) (missing register number): %s\n\
7739 else if (
strprefix (p, p1,
"syscall_entry"))
7743 p = unpack_varlen_hex (++p1, &sysno);
7744 event->ws.set_syscall_entry ((
int) sysno);
7746 else if (
strprefix (p, p1,
"syscall_return"))
7750 p = unpack_varlen_hex (++p1, &sysno);
7751 event->ws.set_syscall_return ((
int) sysno);
7758 p = unpack_varlen_hex (++p1, &addr);
7759 event->watch_data_address = (CORE_ADDR) addr;
7769 error (_(
"Unexpected swbreak stop reason"));
7774 p = strchrnul (p1 + 1,
';');
7784 error (_(
"Unexpected hwbreak stop reason"));
7787 p = strchrnul (p1 + 1,
';');
7791 event->ws.set_loaded ();
7792 p = strchrnul (p1 + 1,
';');
7794 else if (
strprefix (p, p1,
"replaylog"))
7796 event->ws.set_no_history ();
7799 p = strchrnul (p1 + 1,
';');
7805 p = unpack_varlen_hex (++p1, &c);
7809 event->ws.set_forked (
read_ptid (++p1, &p));
7811 event->ws.set_vforked (
read_ptid (++p1, &p));
7812 else if (
strprefix (p, p1,
"vforkdone"))
7814 event->ws.set_vfork_done ();
7815 p = strchrnul (p1 + 1,
';');
7823 p = unpack_varlen_hex (++p1, &ignored);
7824 pathlen = (p - p1) / 2;
7828 gdb::unique_xmalloc_ptr<char> pathname
7829 ((
char *)
xmalloc (pathlen + 1));
7830 hex2bin (p1, (gdb_byte *) pathname.get (), pathlen);
7831 pathname.get ()[pathlen] =
'\0';
7834 event->ws.set_execd (std::move (pathname));
7843 event->ws.set_thread_created ();
7844 p = strchrnul (p1 + 1,
';');
7853 p = strchrnul (p1 + 1,
';');
7859 p_temp = unpack_varlen_hex (p, &pnum);
7868 if (event->
ptid == null_ptid)
7874 const char *thr = strstr (p1 + 1,
";thread:");
7876 event->ptid =
read_ptid (thr + strlen (
";thread:"),
7883 = (
event->ptid == null_ptid
7897 p = strchrnul (p1 + 1,
';');
7902 event->arch =
inf->gdbarch;
7903 rsa =
event->rs->get_remote_arch_state (event->
arch);
7911 error (_(
"Remote sent bad register number %s: %s\n\
7913 hex_string (pnum), p, buf);
7916 cached_reg.
data = (gdb_byte *)
7920 fieldsize = hex2bin (p, cached_reg.
data,
7924 warning (_(
"Remote reply is too short: %s"), buf);
7926 event->regcache.push_back (cached_reg);
7932 p = strchrnul (p1 + 1,
';');
7937 error (_(
"Remote register badly formatted: %s\nhere: %s"),
7950 sig = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
7951 if (GDB_SIGNAL_FIRST <= sig && sig < GDB_SIGNAL_LAST)
7952 event->ws.set_stopped ((
enum gdb_signal) sig);
7954 event->ws.set_stopped (GDB_SIGNAL_UNKNOWN);
7961 p = unpack_varlen_hex (&buf[1], &
value);
7962 event->ws.set_thread_exited (
value);
7964 error (_(
"stop reply packet badly formatted: %s"), buf);
7976 p = unpack_varlen_hex (&buf[1], &
value);
7981 event->ws.set_exited (
value);
7986 if (GDB_SIGNAL_FIRST <=
value &&
value < GDB_SIGNAL_LAST)
7987 event->ws.set_signalled ((
enum gdb_signal)
value);
7989 event->ws.set_signalled (GDB_SIGNAL_UNKNOWN);
8003 else if (startswith (p,
"process:"))
8007 p +=
sizeof (
"process:") - 1;
8008 unpack_varlen_hex (p, &upid);
8012 error (_(
"unknown stop reply packet: %s"), buf);
8015 error (_(
"unknown stop reply packet: %s"), buf);
8016 event->ptid = ptid_t (
pid);
8020 event->ws.set_no_resumed ();
8021 event->ptid = minus_one_ptid;
8077 "notif: process: '%s' ack pending event\n",
8081 nc->
ack (
this, nc, rs->
buf.data (),
8088 if (strcmp (rs->
buf.data (),
"OK") == 0)
8098 "notif: process: '%s' no pending reply\n",
8152 bool process_wide_stop
8159 bool ambiguous =
false;
8170 if (first_resumed_thread ==
nullptr)
8171 first_resumed_thread = thr;
8172 else if (!process_wide_stop
8173 || first_resumed_thread->
ptid.pid () != thr->ptid.pid ())
8177 gdb_assert (first_resumed_thread !=
nullptr);
8186 static bool warned =
false;
8202 if (process_wide_stop)
8203 warning (_(
"multi-inferior target stopped without "
8204 "sending a process-id, using first "
8205 "non-exited inferior"));
8207 warning (_(
"multi-threaded target stopped without "
8208 "sending a thread-id, using first "
8209 "non-exited thread"));
8216 if (process_wide_stop)
8217 return ptid_t (first_resumed_thread->
ptid.pid ());
8219 return first_resumed_thread->
ptid;
8235 if (ptid == null_ptid)
8237 gdb_assert (ptid != null_ptid);
8287 target_wait_flags options)
8292 bool is_notif =
false;
8297 ret =
getpkt (&rs->
buf,
false , &is_notif);
8300 if (ret != -1 && !is_notif)
8307 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
8313 warning (_(
"Invalid remote reply: %s"), rs->
buf.data ());
8332 return minus_one_ptid;
8336 ret =
getpkt (&rs->
buf,
true , &is_notif);
8356 target_wait_flags options)
8359 ptid_t event_ptid = null_ptid;
8382 status->set_no_resumed ();
8383 return minus_one_ptid;
8391 int ret =
getpkt (&rs->
buf, forever, &is_notif);
8395 if (ret != -1 && is_notif)
8396 return minus_one_ptid;
8399 return minus_one_ptid;
8401 buf = rs->
buf.data ();
8405 if (buf[0] !=
'F' && buf[0] !=
'O')
8415 warning (_(
"Remote failure reply: %s"), buf);
8416 status->set_stopped (GDB_SIGNAL_0);
8430 case 'N':
case 'T':
case 'S':
case 'X':
case 'W':
8453 (
"Can't send signals to this remote system. %s not sent.\n",
8464 warning (_(
"Invalid remote reply: %s"), buf);
8470 return minus_one_ptid;
8476 return minus_one_ptid;
8483 if (event_ptid != null_ptid)
8493 if (event_ptid == null_ptid)
8496 if (event_ptid == null_ptid)
8508 target_wait_flags options)
8557 if (reg->
pnum == -1)
8560 p = rs->
buf.data ();
8567 buf = rs->
buf.data ();
8576 error (_(
"Could not fetch register \"%s\"; remote failure reply '%s'"),
8595 error (_(
"fetch_register_using_p: early buf termination"));
8597 regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
8616 error (_(
"Could not read registers; remote failure reply '%s'"),
8622 while ((rs->
buf[0] <
'0' || rs->
buf[0] >
'9')
8623 && (rs->
buf[0] <
'A' || rs->
buf[0] >
'F')
8624 && (rs->
buf[0] <
'a' || rs->
buf[0] >
'f')
8625 && rs->
buf[0] !=
'x')
8631 buf_len = strlen (rs->
buf.data ());
8634 if (buf_len % 2 != 0)
8635 error (_(
"Remote 'g' packet reply is of odd length: %s"), rs->
buf.data ());
8650 buf_len = strlen (rs->
buf.data ());
8654 error (_(
"Remote 'g' packet reply is too long (expected %ld bytes, got %d "
8669 if (buf_len < 2 * rsa->sizeof_g_packet)
8671 long sizeof_g_packet = buf_len / 2;
8675 long offset = rsa->
regs[i].offset;
8678 if (rsa->
regs[i].pnum == -1)
8681 if (offset >= sizeof_g_packet)
8682 rsa->
regs[i].in_g_packet = 0;
8683 else if (offset + reg_size > sizeof_g_packet)
8684 error (_(
"Truncated register %d in remote 'g' packet"), i);
8686 rsa->
regs[i].in_g_packet = 1;
8707 p = rs->
buf.data ();
8710 if (p[0] == 0 || p[1] == 0)
8712 internal_error (_(
"unexpected end of 'g' packet reply"));
8714 if (p[0] ==
'x' && p[1] ==
'x')
8717 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
8728 if ((r->
offset + reg_size) * 2 > strlen (rs->
buf.data ()))
8730 internal_error (_(
"unexpected end of 'g' packet reply"));
8733 gdb_assert (r->
offset * 2 < strlen (rs->
buf.data ()));
8771 warning (_(
"could not set remote traceframe"));
8789 gdb_assert (reg != NULL);
8814 if (!rsa->
regs[i].in_g_packet)
8840 if (rsa->
regs[i].in_g_packet)
8858 char *buf = rs->
buf.data ();
8865 if (reg->
pnum == -1)
8869 p = buf + strlen (buf);
8880 error (_(
"Could not write register \"%s\"; remote failure reply '%s'"),
8885 internal_error (_(
"Bad result from packet_ok"));
8918 p = rs->
buf.data ();
8924 error (_(
"Could not write registers; remote failure reply '%s'"),
8946 gdb_assert (reg != NULL);
8969 if (!rsa->
regs[i].in_g_packet)
8983 for (i = 0; num != 0; i++)
8986 return std::max (i, 1);
9009 for (i = width - 1; i >= 0; i--)
9011 buf[i] =
"0123456789abcdef"[(num & 0xf)];
9029 if (address_size > 0
9030 && address_size < (
sizeof (ULONGEST) * 8))
9036 mask = (mask << address_size) - 1;
9068 p = rs->
buf.data ();
9079 if (rs->
buf[0] ==
'\0')
9141 const gdb_byte *myaddr,
9144 ULONGEST *xfered_len_units,
9145 char packet_format,
int use_length)
9153 int payload_capacity_bytes;
9154 int payload_length_bytes;
9156 if (packet_format !=
'X' && packet_format !=
'M')
9157 internal_error (_(
"remote_write_bytes_aux: bad packet format"));
9171 payload_capacity_bytes -= strlen (
"$,:#NN");
9174 payload_capacity_bytes += 1;
9175 payload_capacity_bytes -= strlen (header);
9176 payload_capacity_bytes -=
hexnumlen (memaddr);
9180 strcat (rs->
buf.data (), header);
9181 p = rs->
buf.data () + strlen (header);
9184 if (packet_format ==
'X')
9187 todo_units = std::min (len_units,
9188 (ULONGEST) payload_capacity_bytes / unit_size);
9190 payload_capacity_bytes -=
hexnumlen (todo_units);
9191 todo_units = std::min (todo_units, payload_capacity_bytes / unit_size);
9197 = std::min (len_units,
9198 (ULONGEST) (payload_capacity_bytes / unit_size) / 2);
9200 payload_capacity_bytes -=
hexnumlen (todo_units);
9201 todo_units = std::min (todo_units,
9202 (payload_capacity_bytes / unit_size) / 2);
9205 if (todo_units <= 0)
9206 internal_error (_(
"minimum packet size too small to write data"));
9225 plenlen =
hexnumstr (p, (ULONGEST) todo_units);
9234 if (packet_format ==
'X')
9239 payload_length_bytes =
9240 remote_escape_output (myaddr, todo_units, unit_size, (gdb_byte *) p,
9241 &units_written, payload_capacity_bytes);
9252 if (new_todo_units != units_written)
9253 payload_length_bytes =
9254 remote_escape_output (myaddr, new_todo_units, unit_size,
9255 (gdb_byte *) p, &units_written,
9256 payload_capacity_bytes);
9259 p += payload_length_bytes;
9260 if (use_length && units_written < todo_units)
9266 plen +=
hexnumnstr (plen, (ULONGEST) units_written,
9276 p += 2 * bin2hex (myaddr, p, todo_units * unit_size);
9277 units_written = todo_units;
9283 if (rs->
buf[0] ==
'E')
9288 *xfered_len_units = (ULONGEST) units_written;
9304 ULONGEST len,
int unit_size,
9305 ULONGEST *xfered_len)
9307 const char *packet_format = NULL;
9315 packet_format =
"X";
9318 packet_format =
"M";
9321 internal_error (_(
"remote_write_bytes: bad internal state"));
9323 internal_error (_(
"bad switch"));
9327 memaddr, myaddr, len, unit_size, xfered_len,
9328 packet_format[0], 1);
9348 int unit_size, ULONGEST *xfered_len_units)
9361 todo_units = std::min (len_units,
9362 (ULONGEST) (buf_size_bytes / unit_size) / 2);
9366 p = rs->
buf.data ();
9370 p +=
hexnumstr (p, (ULONGEST) todo_units);
9374 if (rs->
buf[0] ==
'E'
9375 && isxdigit (rs->
buf[1]) && isxdigit (rs->
buf[2])
9376 && rs->
buf[3] ==
'\0')
9380 p = rs->
buf.data ();
9381 decoded_bytes = hex2bin (p, myaddr, todo_units * unit_size);
9383 *xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
9398 ULONGEST *xfered_len)
9406 ULONGEST memend = memaddr + len;
9411 if (memaddr >= p.addr)
9413 if (memend <= p.endaddr)
9419 else if (memaddr >= p.endaddr)
9427 len = p.endaddr - memaddr;
9444 gdb_byte *myaddr, ULONGEST len,
int unit_size,
9445 ULONGEST *xfered_len)
9468 LONGEST oldlen = len;
9471 gdb_assert (len <= oldlen);
9476 len, unit_size, xfered_len);
9484 return (*xfered_len != 0) ?
9513 va_start (ap, format);
9516 int size = vsnprintf (rs->
buf.data (), max_size, format, ap);
9520 if (
size >= max_size)
9521 internal_error (_(
"Too long remote packet."));
9524 error (_(
"Communication problem with target."));
9542 scoped_restore restore_timeout
9546 phex (address, addr_size),
9551 error (_(
"Remote target does not support flash erase"));
9553 error (_(
"Error erasing flash with vFlashErase packet"));
9561 ULONGEST length, ULONGEST *xfered_len,
9562 const gdb_byte *data)
9564 scoped_restore restore_timeout
9575 scoped_restore restore_timeout
9583 error (_(
"Remote target does not support vFlashDone"));
9585 error (_(
"Error finishing flash operation"));
9604 int saved_errno = errno;
9607 throw_error (TARGET_CLOSE_ERROR,
"%s: %s.",
string,
9608 safe_strerror (saved_errno));
9623 scoped_restore restore_quit_target
9625 scoped_restore restore_quit
9643 throw_error (TARGET_CLOSE_ERROR, _(
"Remote connection closed"));
9647 "Target disconnected"));
9666 scoped_restore restore_quit_target
9668 scoped_restore restore_quit
9676 "Target disconnected"));
9721 unsigned char csum = 0;
9722 gdb::def_vector<char> data (cnt + 6);
9723 char *buf2 = data.data ();
9740 error (_(
"Cannot execute this command while the target is running.\n"
9741 "Use the \"interrupt\" command to stop the target\n"
9742 "and then try again."));
9751 for (i = 0; i < cnt; i++)
9757 *p++ = tohex ((csum >> 4) & 0xf);
9758 *p++ = tohex (csum & 0xf);
9768 int len = (int) (p - buf2);
9779 if (len > max_chars)
9781 (
"Sending packet: %s [%d bytes omitted]", str.c_str (),
9836 (
" Notification received: %s",
9925 char *buf = buf_p->data ();
9946 unsigned char pktcsum;
9961 else if (check_0 < 0 || check_1 < 0)
9973 pktcsum = (fromhex (check_0) << 4) | fromhex (check_1);
9974 if (csum == pktcsum)
9978 (
"Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s",
9992 repeat = c -
' ' + 3;
9996 if (repeat > 0 && repeat <= 255 && bc > 0)
9998 if (bc + repeat - 1 >= buf_p->size () - 1)
10001 buf_p->resize (buf_p->size () + repeat);
10002 buf = buf_p->data ();
10005 memset (&buf[bc], buf[bc - 1], repeat);
10011 gdb_printf (_(
"Invalid run length encoding: %s\n"), buf);
10015 if (bc >= buf_p->size () - 1)
10018 buf_p->resize (buf_p->size () * 2);
10019 buf = buf_p->data ();
10064 strcpy (buf->data (),
"timeout");
10068 else if (is_notif !=
nullptr)
10082 for (tries = 1; tries <=
MAX_TRIES; tries++)
10099 if (is_notif !=
nullptr)
10106 throw_error (TARGET_CLOSE_ERROR,
10107 _(
"Watchdog timeout has expired. "
10108 "Target detached."));
10129 gdb_printf (_(
"Ignoring packet error, continuing...\n"));
10151 std::min (val, max_chars));
10153 if (val > max_chars)
10155 (
"Packet received: %s [%d bytes omitted]", str.c_str (),
10165 if (is_notif != NULL)
10174 gdb_assert (c ==
'%');
10177 (
" Notification received: %s",
10180 if (is_notif != NULL)
10187 if (is_notif !=
nullptr)
10215 error (_(
"Can't kill fork child process %d"), child_pid);
10223 if (event->ptid.pid () !=
inf->
pid)
10229 int child_pid =
event->ws.child_ptid ().pid ();
10233 error (_(
"Can't kill fork child process %d"), child_pid);
10246 gdb_assert (
inf !=
nullptr);
10281 error (_(
"Can't kill process"));
10308 internal_error (_(
"Bad result from packet_ok"));
10323 catch (
const gdb_exception_error &ex)
10325 if (ex.error == TARGET_CLOSE_ERROR)
10406 "QDisableRandomization:%x", val);
10409 if (*reply ==
'\0')
10410 error (_(
"Target does not support QDisableRandomization."));
10411 if (strcmp (reply,
"OK") != 0)
10412 error (_(
"Bogus QDisableRandomization reply from target: %s"), reply);
10427 strcpy (rs->
buf.data (),
"vRun;");
10428 len = strlen (rs->
buf.data ());
10431 error (_(
"Remote file name too long for run packet"));
10432 len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->
buf.data () + len,
10433 strlen (remote_exec_file));
10435 if (!args.empty ())
10439 gdb_argv argv (args.c_str ());
10440 for (i = 0; argv[i] != NULL; i++)
10443 error (_(
"Argument list too long for run packet"));
10444 rs->
buf[len++] =
';';
10445 len += 2 * bin2hex ((gdb_byte *) argv[i], rs->
buf.data () + len,
10450 rs->
buf[len++] =
'\0';
10463 if (remote_exec_file[0] ==
'\0')
10464 error (_(
"Running the default executable on the remote target failed; "
10465 "try \"set remote exec-file\"?"));
10467 error (_(
"Running \"%s\" on the remote target failed"),
10470 gdb_assert_not_reached (
"bad switch");
10481 const char *packet,
10488 std::string encoded_value = bin2hex ((
const gdb_byte *)
value,
10492 "%s:%s", packet, encoded_value.c_str ());
10496 if (strcmp (rs->
buf.data (),
"OK") != 0)
10497 warning (_(
"Unable to %s environment variable '%s' on remote."),
10510 putpkt (
"QEnvironmentReset");
10512 if (strcmp (rs->
buf.data (),
"OK") != 0)
10513 warning (_(
"Unable to reset environment on remote."));
10521 for (
const std::string &el : e->user_set_env ())
10528 for (
const std::string &el : e->user_unset_env ())
10543 if (!inferior_cwd.empty ())
10545 std::string hexpath
10546 = bin2hex ((
const gdb_byte *) inferior_cwd.data (),
10547 inferior_cwd.size ());
10550 "QSetWorkingDir:%s", hexpath.c_str ());
10557 "QSetWorkingDir:");
10564Remote replied unexpectedly while setting the inferior's working\n\
10579 const std::string &args,
10580 char **env,
int from_tty)
10601 "QStartupWithShell:%d", startup_with_shell ? 1 : 0);
10604 if (strcmp (rs->
buf.data (),
"OK") != 0)
10606Remote replied unexpectedly while setting startup-with-shell: %s"),
10620 if (remote_exec_file[0])
10621 error (_(
"Remote target does not support \"set remote exec-file\""));
10622 if (!args.empty ())
10623 error (_(
"Remote target does not support \"set args\" or run ARGS"));
10652 xsnprintf (
buf, buf_end -
buf,
"%s",
";");
10658 xsnprintf (
buf, buf_end -
buf,
"X%x,", (
int) aexpr->buf.size ());
10660 for (
int i = 0; i < aexpr->buf.size (); ++i)
10661 buf = pack_hex_byte (
buf, aexpr->buf[i]);
10676 sprintf (
buf,
";cmds:%x,", bp_tgt->
persist);
10683 sprintf (
buf,
"X%x,", (
int) aexpr->buf.size ());
10685 for (
int i = 0; i < aexpr->buf.size (); ++i)
10686 buf = pack_hex_byte (
buf, aexpr->buf[i]);
10716 p = rs->
buf.data ();
10724 xsnprintf (p, endbuf - p,
",%d", bp_tgt->
kind);
10749 throw_error (NOT_SUPPORTED_ERROR, _(
"\
10750Target doesn't support breakpoints that have target side commands."));
10765 char *p = rs->
buf.data ();
10779 xsnprintf (p, endbuf - p,
",%d", bp_tgt->
kind);
10784 return (rs->
buf[0] ==
'E');
10805 internal_error (_(
"hw_bp_to_z: bad watchpoint type %d"),
type);
10827 xsnprintf (rs->
buf.data (), endbuf - rs->
buf.data (),
"Z%x,", packet);
10828 p = strchr (rs->
buf.data (),
'\0');
10831 xsnprintf (p, endbuf - p,
",%x", len);
10837 + to_underlying (packet))))
10846 internal_error (_(
"remote_insert_watchpoint: reached end of function"));
10851 CORE_ADDR start,
int length)
10855 return diff < length;
10877 xsnprintf (rs->
buf.data (), endbuf - rs->
buf.data (),
"z%x,", packet);
10878 p = strchr (rs->
buf.data (),
'\0');
10881 xsnprintf (p, endbuf - p,
",%x", len);
10886 + to_underlying (packet))))
10894 internal_error (_(
"remote_remove_watchpoint: reached end of function"));
10948 return (thread->
priv != NULL
10969 return (thread->
priv != NULL
10988 return (thread->
priv != NULL
10998 if (thread->
priv != NULL
11028 p = rs->
buf.data ();
11037 xsnprintf (p, endbuf - p,
",%x", bp_tgt->
kind);
11051 if (rs->
buf[1] ==
'.')
11053 message = strchr (&rs->
buf[2],
'.');
11055 error (_(
"Remote failure reply: %s"), message + 1);
11063 internal_error (_(
"remote_insert_hw_breakpoint: reached end of function"));
11073 char *p = rs->
buf.data ();
11090 xsnprintf (p, endbuf - p,
",%x", bp_tgt->
kind);
11103 internal_error (_(
"remote_remove_hw_breakpoint: reached end of function"));
11112 unsigned long host_crc, target_crc;
11127 (
long) lma, (
long)
size);
11132 host_crc = xcrc32 (data,
size, 0xffffffff);
11141 for (target_crc = 0, tmp = &rs->
buf[1]; *tmp; tmp++)
11142 target_crc = target_crc * 16 + fromhex (*tmp);
11144 return (host_crc == target_crc);
11161 const char *sectname;
11162 bfd_size_type
size;
11165 int mismatched = 0;
11170 error (_(
"command cannot be used without an exec file"));
11172 if (args != NULL && strcmp (args,
"-r") == 0)
11180 if (!(s->flags & SEC_LOAD))
11183 if (read_only && (s->flags & SEC_READONLY) == 0)
11186 size = bfd_section_size (s);
11190 sectname = bfd_section_name (s);
11191 if (args && strcmp (args, sectname) != 0)
11197 gdb::byte_vector sectdata (
size);
11199 sectdata.data (), 0,
size);
11204 error (_(
"target memory fault, section %s, range %s -- %s"), sectname,
11208 gdb_printf (
"Section %s, range %s -- %s: ", sectname,
11219 if (mismatched > 0)
11220 warning (_(
"One or more sections of the target image does "
11221 "not match the loaded file"));
11222 if (args && !matched)
11223 gdb_printf (_(
"No loaded section named '%s'.\n"), args);
11232 const char *annex,
const gdb_byte *writebuf,
11233 ULONGEST offset, LONGEST len,
11234 ULONGEST *xfered_len,
11235 const unsigned int which_packet)
11246 i = snprintf (rs->
buf.data (), max_size,
11247 "qXfer:%s:write:%s:%s:",
11248 object_name, annex ? annex :
"",
11249 phex_nz (offset,
sizeof offset));
11250 max_size -= (i + 1);
11253 buf_len = remote_escape_output
11254 (writebuf, len, 1, (gdb_byte *) rs->
buf.data () + i, &max_size, max_size);
11261 unpack_varlen_hex (rs->
buf.data (), &n);
11277 gdb_byte *readbuf, ULONGEST offset,
11279 ULONGEST *xfered_len,
11280 const unsigned int which_packet)
11283 LONGEST i, n, packet_len;
11312 "qXfer:%s:read:%s:%s,%s",
11313 object_name, annex ? annex :
"",
11314 phex_nz (offset,
sizeof offset),
11315 phex_nz (n,
sizeof n));
11326 if (rs->
buf[0] !=
'l' && rs->
buf[0] !=
'm')
11327 error (_(
"Unknown remote qXfer reply: %s"), rs->
buf.data ());
11332 if (rs->
buf[0] ==
'm' && packet_len == 1)
11333 error (_(
"Remote qXfer reply contained no data."));
11336 i = remote_unescape_input ((gdb_byte *) rs->
buf.data () + 1,
11337 packet_len - 1, readbuf, n);
11342 if (rs->
buf[0] ==
'l' && offset + i > 0)
11360 const char *annex, gdb_byte *readbuf,
11361 const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
11362 ULONGEST *xfered_len)
11384 if (writebuf != NULL)
11407 readbuf, offset, len, xfered_len,
11414 if (writebuf != NULL)
11436 gdb_assert (annex == NULL);
11442 (
"features", annex, readbuf, offset, len, xfered_len,
11447 (
"libraries", annex, readbuf, offset, len, xfered_len,
11452 (
"libraries-svr4", annex, readbuf, offset, len, xfered_len,
11456 gdb_assert (annex == NULL);
11458 (
"memory-map", annex, readbuf, offset, len, xfered_len,
11465 (
"osdata", annex, readbuf, offset, len, xfered_len,
11469 gdb_assert (annex == NULL);
11471 (
"threads", annex, readbuf, offset, len, xfered_len,
11475 gdb_assert (annex == NULL);
11477 (
"traceframe-info", annex, readbuf, offset, len, xfered_len,
11490 (
"btrace", annex, readbuf, offset, len, xfered_len,
11495 (
"btrace-conf", annex, readbuf, offset, len, xfered_len,
11500 (
"exec-file", annex, readbuf, offset, len, xfered_len,
11515 error (_(
"remote query is only available after target open"));
11517 gdb_assert (annex != NULL);
11518 gdb_assert (readbuf != NULL);
11520 p2 = rs->
buf.data ();
11522 *p2++ = query_type;
11533 gdb_assert (isprint (annex[i]) && annex[i] !=
'$' && annex[i] !=
'#');
11538 gdb_assert (annex[i] ==
'\0');
11545 strcpy ((
char *) readbuf, rs->
buf.data ());
11547 *xfered_len = strlen ((
char *) readbuf);
11561 const gdb_byte *pattern, ULONGEST pattern_len,
11562 CORE_ADDR *found_addrp)
11570 int escaped_pattern_len;
11572 int used_pattern_len;
11575 ULONGEST found_addr;
11577 auto read_memory = [
this] (CORE_ADDR addr, gdb_byte *result,
size_t len)
11586 if (pattern_len > search_space_len)
11588 if (pattern_len == 0)
11590 *found_addrp = start_addr;
11601 return simple_search_memory (
read_memory, start_addr, search_space_len,
11602 pattern, pattern_len, found_addrp);
11609 i = snprintf (rs->
buf.data (), max_size,
11610 "qSearch:memory:%s;%s;",
11611 phex_nz (start_addr, addr_size),
11612 phex_nz (search_space_len,
sizeof (search_space_len)));
11613 max_size -= (i + 1);
11616 escaped_pattern_len =
11617 remote_escape_output (pattern, pattern_len, 1,
11618 (gdb_byte *) rs->
buf.data () + i,
11619 &used_pattern_len, max_size);
11622 if (used_pattern_len != pattern_len)
11623 error (_(
"Pattern is too large to transmit to remote target."));
11633 return simple_search_memory (
read_memory, start_addr, search_space_len,
11634 pattern, pattern_len, found_addrp);
11639 if (rs->
buf[0] ==
'0')
11641 else if (rs->
buf[0] ==
'1')
11644 if (rs->
buf[1] !=
',')
11645 error (_(
"Unknown qSearch:memory reply: %s"), rs->
buf.data ());
11646 unpack_varlen_hex (&rs->
buf[2], &found_addr);
11647 *found_addrp = found_addr;
11650 error (_(
"Unknown qSearch:memory reply: %s"), rs->
buf.data ());
11659 char *p = rs->
buf.data ();
11662 error (_(
"remote rcmd is only available after target open"));
11665 if (command == NULL)
11669 strcpy (rs->
buf.data (),
"qRcmd,");
11670 p = strchr (rs->
buf.data (),
'\0');
11672 if ((strlen (rs->
buf.data ()) + strlen (command) * 2 + 8)
11674 error (_(
"\"monitor\" command ``%s'' is too long."), command);
11677 bin2hex ((
const gdb_byte *) command, p, strlen (command));
11680 error (_(
"Communication problem with target."));
11699 buf = rs->
buf.data ();
11700 if (buf[0] ==
'\0')
11701 error (_(
"Target does not support this command."));
11702 if (buf[0] ==
'O' && buf[1] !=
'K')
11707 if (strcmp (buf,
"OK") == 0)
11709 if (strlen (buf) == 3 && buf[0] ==
'E'
11710 && isxdigit (buf[1]) && isxdigit (buf[2]))
11712 error (_(
"Protocol error with Rcmd"));
11714 for (p = buf; p[0] !=
'\0' && p[1] !=
'\0'; p += 2)
11716 char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
11724std::vector<mem_region>
11727 std::vector<mem_region> result;
11728 gdb::optional<gdb::char_vector> text
11745 void sending (gdb::array_view<const char> &buf)
override
11754 void received (gdb::array_view<const char> &buf)
override
11771 for (
int i = 0; i < buf.size (); ++i)
11773 gdb_byte c = buf[i];
11777 gdb_printf (&stb,
"\\x%02x", (
unsigned char) c);
11790 if (buf.size () == 0 || buf.data ()[0] ==
'\0')
11791 error (_(
"a remote packet must not be empty"));
11794 if (remote ==
nullptr)
11795 error (_(
"packets can only be sent to a remote target"));
11804 error (_(
"error while fetching packet from remote target"));
11806 gdb::array_view<const char> view (&rs->
buf[0], bytes);
11816 gdb::array_view<const char> view
11817 = gdb::make_array_view (args, args ==
nullptr ? 0 : strlen (args));
11826static void threadset_test_cmd (
char *cmd,
int tty);
11828static void threadalive_test (
char *cmd,
int tty);
11830static void threadlist_test_cmd (
char *cmd,
int tty);
11832int get_and_display_threadinfo (
threadref *ref);
11834static void threadinfo_test_cmd (
char *cmd,
int tty);
11836static int thread_display_step (
threadref *ref,
void *context);
11838static void threadlist_update_test_cmd (
char *cmd,
int tty);
11840static void init_remote_threadtests (
void);
11842#define SAMPLE_THREAD 0x05060708
11845threadset_test_cmd (
const char *cmd,
int tty)
11847 int sample_thread = SAMPLE_THREAD;
11850 set_general_thread (sample_thread);
11855threadalive_test (
const char *cmd,
int tty)
11857 int sample_thread = SAMPLE_THREAD;
11859 ptid_t ptid = ptid_t (
pid, sample_thread, 0);
11861 if (remote_thread_alive (ptid))
11867void output_threadid (
char *title,
threadref *ref);
11870output_threadid (
char *title,
threadref *ref)
11880threadlist_test_cmd (
const char *cmd,
int tty)
11884 int done, result_count;
11888 if (!remote_get_threadlist (startflag, &nextthread, 3, &done,
11889 &result_count, &threadlist[0]))
11896 while (
scan < limit)
11897 output_threadid (
" thread ",
scan++);
11904 output_threadid (
"Threadid: ", &
info->threadid);
11911get_and_display_threadinfo (
threadref *ref)
11919 if (0 != (result = remote_get_threadinfo (ref, set, &threadinfo)))
11920 display_thread_info (&threadinfo);
11925threadinfo_test_cmd (
const char *cmd,
int tty)
11927 int athread = SAMPLE_THREAD;
11933 if (!get_and_display_threadinfo (&thread))
11934 gdb_printf (
"FAIL cannot get thread info\n");
11938thread_display_step (
threadref *ref,
void *context)
11941 return get_and_display_threadinfo (ref);
11945threadlist_update_test_cmd (
const char *cmd,
int tty)
11947 gdb_printf (
"Remote Threadlist update test\n");
11952init_remote_threadtests (
void)
11955 _(
"Fetch and print the remote list of "
11956 "thread identifiers, one pkt only."));
11958 _(
"Fetch and display info about one thread."));
11960 _(
"Test setting to a different thread."));
11962 _(
"Iterate through updating all remote thread info."));
11964 _(
"Remote thread alive test."));
11974 if (ptid == null_ptid)
11976 else if (ptid.is_pid ())
11990 return "Remote target";
11997 return "Thread <main>";
11999 if (ptid.lwp () == 0)
12002 return string_printf (
"Thread %d.%ld",
12003 ptid.pid (), ptid.lwp ());
12005 return string_printf (
"Thread %ld", ptid.lwp ());
12019 char *p = rs->
buf.data ();
12023 strcpy (p,
"qGetTLSAddr:");
12039 unpack_varlen_hex (rs->
buf.data (), &addr);
12043 throw_error (TLS_GENERIC_ERROR,
12044 _(
"Remote target doesn't support qGetTLSAddr packet"));
12046 throw_error (TLS_GENERIC_ERROR,
12047 _(
"Remote target failed to process qGetTLSAddr request"));
12050 throw_error (TLS_GENERIC_ERROR,
12051 _(
"TLS not supported or disabled on this target"));
12065 char *p = rs->
buf.data ();
12069 strcpy (p,
"qGetTIBAddr:");
12080 unpack_varlen_hex (rs->
buf.data (), &val);
12082 *addr = (CORE_ADDR) val;
12086 error (_(
"Remote target doesn't support qGetTIBAddr packet"));
12088 error (_(
"Remote target failed to process qGetTIBAddr request"));
12091 error (_(
"qGetTIBAddr not supported or disabled on this target"));
12116 std::vector<remote_g_packet_guess>
guesses;
12127 if (data ==
nullptr)
12138 gdb_assert (tdesc != NULL);
12141 if (guess.bytes == bytes)
12142 internal_error (_(
"Duplicate g packet description added for size %d"),
12145 data->guesses.emplace_back (bytes, tdesc);
12156 return !data->guesses.empty ();
12169 if (!data->guesses.empty ())
12174 if (guess.bytes == bytes)
12175 return guess.tdesc;
12195 int len = strlen (
string);
12198 error (_(
"Packet too long for target."));
12200 memcpy (*buffer,
string, len);
12218 if (2 * len > *left)
12219 error (_(
"Packet too long for target."));
12221 bin2hex (bytes, *buffer, len);
12222 *buffer += 2 * len;
12241 error (_(
"Packet too long for target."));
12264 fileio_error *remote_errno,
const char **attachment)
12268 *remote_errno = FILEIO_SUCCESS;
12269 *attachment = NULL;
12271 if (buffer[0] !=
'F')
12275 *retcode = strtol (&buffer[1], &p, 16);
12276 if (errno != 0 || p == &buffer[1])
12283 *remote_errno = (fileio_error) strtol (p + 1, &p2, 16);
12284 if (errno != 0 || p + 1 == p2)
12293 *attachment = p + 1;
12296 else if (*p ==
'\0')
12320 fileio_error *remote_errno,
const char **attachment,
12321 int *attachment_len)
12324 int ret, bytes_read;
12325 const char *attachment_tmp;
12329 *remote_errno = FILEIO_ENOSYS;
12338 if (bytes_read < 0)
12340 *remote_errno = FILEIO_EINVAL;
12347 *remote_errno = FILEIO_EINVAL;
12350 *remote_errno = FILEIO_ENOSYS;
12359 *remote_errno = FILEIO_EINVAL;
12364 if ((attachment_tmp == NULL && attachment != NULL)
12365 || (attachment_tmp != NULL && attachment == NULL))
12367 *remote_errno = FILEIO_EINVAL;
12373 if (attachment_tmp != NULL)
12375 *attachment = attachment_tmp;
12376 *attachment_len = bytes_read - (*attachment - rs->
buf.data ());
12395 if (this->fd ==
fd)
12405 fileio_error *remote_errno)
12408 int required_pid = (
inf == NULL ||
inf->fake_pid_p) ? 0 :
inf->
pid;
12409 char *p = rs->
buf.data ();
12422 xsnprintf (arg,
sizeof (arg),
"%x", required_pid);
12426 remote_errno, NULL, NULL);
12432 rs->
fs_pid = required_pid;
12441 int flags,
int mode,
int warn_if_slow,
12442 fileio_error *remote_errno)
12445 char *p = rs->
buf.data ();
12450 static int warning_issued = 0;
12452 gdb_printf (_(
"Reading %s from remote target...\n"),
12455 if (!warning_issued)
12457 warning (_(
"File transfers from remote targets can be slow."
12458 " Use \"set sysroot\" to access files locally"
12460 warning_issued = 1;
12470 strlen (filename));
12479 remote_errno, NULL, NULL);
12484 int flags,
int mode,
int warn_if_slow,
12485 fileio_error *remote_errno)
12495 ULONGEST offset, fileio_error *remote_errno)
12498 char *p = rs->
buf.data ();
12512 p += remote_escape_output (write_buf, len, 1, (gdb_byte *) p, &out_len,
12514 - (p - rs->
buf.data ())));
12517 remote_errno, NULL, NULL);
12522 ULONGEST offset, fileio_error *remote_errno)
12532 ULONGEST offset, fileio_error *remote_errno)
12535 char *p = rs->
buf.data ();
12536 const char *attachment;
12538 int ret, attachment_len;
12552 remote_errno, &attachment,
12558 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12560 if (read_len != ret)
12561 error (_(
"Read returned %d, but %d bytes."), ret, (
int) read_len);
12573 && this->offset <=
offset
12574 && offset < this->
offset + this->
buf.size ())
12576 ULONGEST max = this->offset + this->
buf.size ();
12578 if (offset + len > max)
12581 memcpy (read_buf, &this->
buf[offset - this->offset], len);
12592 ULONGEST offset, fileio_error *remote_errno)
12598 ret = cache->
pread (fd, read_buf, len, offset);
12618 cache->
buf.size (),
12619 cache->
offset, remote_errno);
12626 cache->
buf.resize (ret);
12627 return cache->
pread (fd, read_buf, len, offset);
12632 ULONGEST offset, fileio_error *remote_errno)
12643 char *p = rs->
buf.data ();
12653 remote_errno, NULL, NULL);
12666 fileio_error *remote_errno)
12669 char *p = rs->
buf.data ();
12678 strlen (filename));
12681 remote_errno, NULL, NULL);
12686 fileio_error *remote_errno)
12693gdb::optional<std::string>
12695 fileio_error *remote_errno)
12698 char *p = rs->
buf.data ();
12699 const char *attachment;
12701 int len, attachment_len;
12710 strlen (filename));
12713 remote_errno, &attachment,
12719 std::string ret (len,
'\0');
12721 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12722 (gdb_byte *) &ret[0], len);
12723 if (read_len != len)
12724 error (_(
"Readlink returned %d, but %d bytes."), len, read_len);
12735 char *p = rs->
buf.data ();
12737 int attachment_len, ret;
12738 const char *attachment;
12739 struct fio_stat fst;
12747 remote_errno, &attachment,
12751 if (*remote_errno != FILEIO_ENOSYS)
12767 memset (st, 0,
sizeof (
struct stat));
12768 st->st_size = INT_MAX;
12772 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12773 (gdb_byte *) &fst,
sizeof (fst));
12775 if (read_len != ret)
12776 error (_(
"vFile:fstat returned %d, but %d bytes."), ret, read_len);
12778 if (read_len !=
sizeof (fst))
12779 error (_(
"vFile:fstat returned %d bytes, but expecting %d."),
12780 read_len, (
int)
sizeof (fst));
12805 fileio_error remote_errno;
12811 FILEIO_O_RDONLY, 0700, 0,
12822 static int warning_issued = 0;
12824 if (!warning_issued)
12826 warning (_(
"remote target does not support file"
12827 " transfer, attempting to access files"
12828 " from local filesystem."));
12829 warning_issued = 1;
12842 int host_error = fileio_error_to_host (errnum);
12844 if (host_error == -1)
12845 error (_(
"Unknown remote I/O error %d"), errnum);
12847 error (_(
"Remote I/O error: %s"), safe_strerror (host_error));
12866 fileio_error remote_errno;
12881 ATTRIBUTE_UNUSED_RESULT
int release () noexcept
12889 int get () const noexcept
12903remote_file_put (
const char *local_file,
const char *remote_file,
int from_tty)
12907 if (remote ==
nullptr)
12908 error (_(
"command can only be used with remote target"));
12917 int retcode, bytes, io_size;
12918 fileio_error remote_errno;
12919 int bytes_in_buffer;
12923 gdb_file_up file = gdb_fopen_cloexec (local_file,
"rb");
12925 perror_with_name (local_file);
12929 remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
12931 0700, 0, &remote_errno));
12932 if (fd.
get () == -1)
12938 gdb::byte_vector buffer (io_size);
12940 bytes_in_buffer = 0;
12943 while (bytes_in_buffer || !saw_eof)
12947 bytes = fread (buffer.data () + bytes_in_buffer, 1,
12948 io_size - bytes_in_buffer,
12952 if (ferror (file.get ()))
12953 error (_(
"Error reading %s."), local_file);
12959 if (bytes_in_buffer == 0)
12967 bytes += bytes_in_buffer;
12968 bytes_in_buffer = 0;
12971 offset, &remote_errno);
12975 else if (retcode == 0)
12976 error (_(
"Remote write of %d bytes returned 0!"), bytes);
12977 else if (retcode < bytes)
12981 bytes_in_buffer = bytes - retcode;
12982 memmove (buffer.data (), buffer.data () + retcode, bytes_in_buffer);
12992 gdb_printf (_(
"Successfully sent file \"%s\".\n"), local_file);
12996remote_file_get (
const char *remote_file,
const char *local_file,
int from_tty)
13000 if (remote ==
nullptr)
13001 error (_(
"command can only be used with remote target"));
13010 fileio_error remote_errno;
13011 int bytes, io_size;
13016 remote_file, FILEIO_O_RDONLY, 0, 0,
13018 if (fd.
get () == -1)
13021 gdb_file_up file = gdb_fopen_cloexec (local_file,
"wb");
13023 perror_with_name (local_file);
13028 gdb::byte_vector buffer (io_size);
13043 bytes = fwrite (buffer.data (), 1, bytes, file.get ());
13045 perror_with_name (local_file);
13052 gdb_printf (_(
"Successfully fetched file \"%s\".\n"), remote_file);
13060 if (remote ==
nullptr)
13061 error (_(
"command can only be used with remote target"));
13070 fileio_error remote_errno;
13077 gdb_printf (_(
"Successfully deleted file \"%s\".\n"), remote_file);
13086 gdb_argv argv (args);
13087 if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
13088 error (_(
"Invalid parameters to remote put"));
13099 gdb_argv argv (args);
13100 if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
13101 error (_(
"Invalid parameters to remote get"));
13112 gdb_argv argv (args);
13113 if (argv[0] == NULL || argv[1] != NULL)
13114 error (_(
"Invalid parameters to remote delete"));
13206 if (strcmp (rs->
buf.data (),
"OK") != 0)
13207 error (_(
"Target does not support this command."));
13220 for (cmd = cmds; cmd; cmd = cmd->
next)
13223 strcpy (rs->
buf.data (),
"QTDPsrc:");
13225 rs->
buf.data () + strlen (rs->
buf.data ()),
13226 rs->
buf.size () - strlen (rs->
buf.data ()));
13229 if (strcmp (rs->
buf.data (),
"OK"))
13230 warning (_(
"Target does not support source download."));
13238 strcpy (rs->
buf.data (),
"QTDPsrc:");
13240 rs->
buf.data () + strlen (rs->
buf.data ()),
13241 rs->
buf.size () - strlen (rs->
buf.data ()));
13244 if (strcmp (rs->
buf.data (),
"OK"))
13245 warning (_(
"Target does not support source download."));
13255 std::vector<std::string> tdp_actions;
13256 std::vector<std::string> stepping_actions;
13259 tracepoint *t = gdb::checked_static_cast<tracepoint *> (b);
13262 const char *err_msg = _(
"Tracepoint packet too large for target.");
13272 tpaddr =
loc->address;
13273 strcpy (addrbuf, phex (tpaddr,
sizeof (CORE_ADDR)));
13274 ret = snprintf (buf.data (), buf.size (),
"QTDP:%x:%s:%c:%lx:%x",
13279 if (ret < 0 || ret >= buf.size ())
13280 error (
"%s", err_msg);
13294 size_left = buf.size () - strlen (buf.data ());
13295 ret = snprintf (buf.data () + strlen (buf.data ()),
13299 if (ret < 0 || ret >= size_left)
13300 error (
"%s", err_msg);
13305 internal_error (_(
"Fast tracepoint not valid during download"));
13311 warning (_(
"Target does not support fast tracepoints, "
13312 "downloading %d as regular tracepoint"), b->
number);
13325 size_left = buf.size () - strlen (buf.data ());
13326 ret = snprintf (buf.data () + strlen (buf.data ()),
13329 if (ret < 0 || ret >= size_left)
13330 error (
"%s", err_msg);
13333 error (_(
"Static tracepoint not valid during download"));
13339 error (_(
"Target does not support static tracepoints"));
13352 size_left = buf.size () - strlen (buf.data ());
13354 ret = snprintf (buf.data () + strlen (buf.data ()),
13355 size_left,
":X%x,", (
int) aexpr->buf.size ());
13357 if (ret < 0 || ret >= size_left)
13358 error (
"%s", err_msg);
13360 size_left = buf.size () - strlen (buf.data ());
13364 if (aexpr->buf.size () * 2 + 1 > size_left)
13365 error (
"%s", err_msg);
13367 pkt = buf.data () + strlen (buf.data ());
13369 for (
int ndx = 0; ndx < aexpr->buf.size (); ++ndx)
13370 pkt = pack_hex_byte (pkt, aexpr->buf[ndx]);
13374 warning (_(
"Target does not support conditional tracepoints, "
13375 "ignoring tp %d cond"), b->
number);
13380 size_left = buf.size () - strlen (buf.data ());
13382 ret = snprintf (buf.data () + strlen (buf.data ()),
13385 if (ret < 0 || ret >= size_left)
13386 error (
"%s", err_msg);
13391 if (strcmp (rs->
buf.data (),
"OK"))
13392 error (_(
"Target does not support tracepoints."));
13395 for (
auto action_it = tdp_actions.begin ();
13396 action_it != tdp_actions.end (); action_it++)
13400 bool has_more = ((action_it + 1) != tdp_actions.end ()
13401 || !stepping_actions.empty ());
13403 ret = snprintf (buf.data (), buf.size (),
"QTDP:-%x:%s:%s%c",
13405 action_it->c_str (),
13406 has_more ?
'-' : 0);
13408 if (ret < 0 || ret >= buf.size ())
13409 error (
"%s", err_msg);
13413 if (strcmp (rs->
buf.data (),
"OK"))
13414 error (_(
"Error on target while setting tracepoints."));
13417 for (
auto action_it = stepping_actions.begin ();
13418 action_it != stepping_actions.end (); action_it++)
13422 bool is_first = action_it == stepping_actions.begin ();
13423 bool has_more = (action_it + 1) != stepping_actions.end ();
13425 ret = snprintf (buf.data (), buf.size (),
"QTDP:-%x:%s:%s%s%s",
13427 is_first ?
"S" :
"",
13428 action_it->c_str (),
13429 has_more ?
"-" :
"");
13431 if (ret < 0 || ret >= buf.size ())
13432 error (
"%s", err_msg);
13436 if (strcmp (rs->
buf.data (),
"OK"))
13437 error (_(
"Error on target while setting tracepoints."));
13444 ret = snprintf (buf.data (), buf.size (),
"QTDPsrc:");
13446 if (ret < 0 || ret >= buf.size ())
13447 error (
"%s", err_msg);
13449 const char *str = b->
locspec->to_string ();
13451 buf.data () + strlen (buf.data ()),
13452 buf.size () - strlen (buf.data ()));
13455 if (strcmp (rs->
buf.data (),
"OK"))
13456 warning (_(
"Target does not support source download."));
13460 ret = snprintf (buf.data (), buf.size (),
"QTDPsrc:");
13462 if (ret < 0 || ret >= buf.size ())
13463 error (
"%s", err_msg);
13467 buf.data () + strlen (buf.data ()),
13468 buf.size () - strlen (buf.data ()));
13471 if (strcmp (rs->
buf.data (),
"OK"))
13472 warning (_(
"Target does not support source download."));
13516 p = rs->
buf.data () + strlen (rs->
buf.data ());
13517 if ((p - rs->
buf.data ()) + tsv.
name.length () * 2
13519 error (_(
"Trace state variable name too long for tsv definition packet"));
13520 p += 2 * bin2hex ((gdb_byte *) (tsv.
name.data ()), p, tsv.
name.length ());
13524 if (rs->
buf[0] ==
'\0')
13525 error (_(
"Target does not support this command."));
13526 if (strcmp (rs->
buf.data (),
"OK") != 0)
13527 error (_(
"Error on target while downloading trace state variable."));
13537 phex (location->
address, sizeof (CORE_ADDR)));
13540 if (rs->
buf[0] ==
'\0')
13541 error (_(
"Target does not support enabling tracepoints while a trace run is ongoing."));
13542 if (strcmp (rs->
buf.data (),
"OK") != 0)
13543 error (_(
"Error on target while enabling tracepoint."));
13553 phex (location->
address, sizeof (CORE_ADDR)));
13556 if (rs->
buf[0] ==
'\0')
13557 error (_(
"Target does not support disabling tracepoints while a trace run is ongoing."));
13558 if (strcmp (rs->
buf.data (),
"OK") != 0)
13559 error (_(
"Error on target while disabling tracepoint."));
13566 bfd_size_type
size;
13577 strcpy (rs->
buf.data (),
"QTro");
13578 offset = strlen (rs->
buf.data ());
13579 for (s = abfd->sections; s; s = s->next)
13581 char tmp1[40], tmp2[40];
13584 if ((s->flags & SEC_LOAD) == 0
13586 || (s->flags & SEC_READONLY) == 0)
13590 vma = bfd_section_vma (s);
13591 size = bfd_section_size (s);
13592 bfd_sprintf_vma (abfd, tmp1, vma);
13593 bfd_sprintf_vma (abfd, tmp2, vma +
size);
13594 sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2);
13595 if (offset + sec_length + 1 > rs->
buf.size ())
13600Too many sections for read-only sections definition packet."));
13603 xsnprintf (rs->
buf.data () + offset, rs->
buf.size () - offset,
":%s,%s",
13605 offset += sec_length;
13621 if (rs->
buf[0] ==
'\0')
13622 error (_(
"Target does not support this command."));
13623 if (strcmp (rs->
buf.data (),
"OK") != 0)
13624 error (_(
"Bogus reply from target: %s"), rs->
buf.data ());
13648 catch (
const gdb_exception_error &ex)
13650 if (ex.error != TARGET_CLOSE_ERROR)
13668 error (_(
"Bogus trace status reply from target: %s"), rs->
buf.data ());
13696 phex_nz (
loc.address, 0));
13699 if (reply && *reply)
13710 xsnprintf (rs->
buf.data (),
size,
"qTP:%x:%s", utp->
number,
13711 phex_nz (utp->
addr, 0));
13714 if (reply && *reply)
13729 if (rs->
buf[0] ==
'\0')
13730 error (_(
"Target does not support this command."));
13731 if (strcmp (rs->
buf.data (),
"OK") != 0)
13732 error (_(
"Bogus reply from target: %s"), rs->
buf.data ());
13737 CORE_ADDR addr1, CORE_ADDR addr2,
13743 int target_frameno = -1, target_tracept = -1;
13751 p = rs->
buf.data ();
13752 strcpy (p,
"QTFrame:");
13753 p = strchr (p,
'\0');
13757 xsnprintf (p, endbuf - p,
"%x", num);
13760 xsnprintf (p, endbuf - p,
"pc:%s", phex_nz (addr1, 0));
13763 xsnprintf (p, endbuf - p,
"tdp:%x", num);
13766 xsnprintf (p, endbuf - p,
"range:%s:%s", phex_nz (addr1, 0),
13767 phex_nz (addr2, 0));
13770 xsnprintf (p, endbuf - p,
"outside:%s:%s", phex_nz (addr1, 0),
13771 phex_nz (addr2, 0));
13774 error (_(
"Unknown trace find type %d"),
type);
13779 if (*reply ==
'\0')
13780 error (_(
"Target does not support this command."));
13782 while (reply && *reply)
13787 target_frameno = (int) strtol (p, &reply, 16);
13789 error (_(
"Unable to parse trace frame number"));
13792 if (target_frameno == -1)
13797 target_tracept = (int) strtol (p, &reply, 16);
13799 error (_(
"Unable to parse tracepoint number"));
13802 if (reply[1] ==
'K' && reply[2] ==
'\0')
13805 error (_(
"Bogus reply from target: %s"), reply);
13808 error (_(
"Bogus reply from target: %s"), reply);
13811 *tpp = target_tracept;
13814 return target_frameno;
13829 if (reply && *reply)
13833 unpack_varlen_hex (reply + 1, &uval);
13834 *val = (LONGEST) uval;
13847 p = rs->
buf.data ();
13848 strcpy (p,
"QTSave:");
13850 if ((p - rs->
buf.data ()) + strlen (filename) * 2
13852 error (_(
"Remote file name too long for trace save packet"));
13853 p += 2 * bin2hex ((gdb_byte *) filename, p, strlen (filename));
13857 if (*reply ==
'\0')
13858 error (_(
"Target does not support this command."));
13859 if (strcmp (reply,
"OK") != 0)
13860 error (_(
"Bogus reply from target: %s"), reply);
13877 p = rs->
buf.data ();
13878 strcpy (p,
"qTBuffer:");
13887 if (reply && *reply)
13899 rslt = hex2bin (reply, buf, len);
13918 "QTDisconnected:%x", val);
13921 if (*reply ==
'\0')
13922 error (_(
"Target does not support this command."));
13923 if (strcmp (reply,
"OK") != 0)
13924 error (_(
"Bogus reply from target: %s"), reply);
13927 warning (_(
"Target does not support disconnected tracing."));
13935 if (
info != NULL &&
info->priv != NULL)
13948 "QTBuffer:circular:%x", val);
13951 if (*reply ==
'\0')
13952 error (_(
"Target does not support this command."));
13953 if (strcmp (reply,
"OK") != 0)
13954 error (_(
"Bogus reply from target: %s"), reply);
13960 gdb::optional<gdb::char_vector> text
13992 if (*reply ==
'\0')
13996 ULONGEST min_insn_len;
13998 unpack_varlen_hex (reply, &min_insn_len);
14000 return (
int) min_insn_len;
14010 char *buf = rs->
buf.data ();
14014 gdb_assert (val >= 0 || val == -1);
14015 buf += xsnprintf (buf, endbuf - buf,
"QTBuffer:size:");
14020 buf +=
hexnumstr (buf, (ULONGEST) -val);
14023 buf +=
hexnumstr (buf, (ULONGEST) val);
14030 warning (_(
"Bogus reply from target: %s"), rs->
buf.data ());
14036 const char *stop_notes)
14040 char *buf = rs->
buf.data ();
14044 buf += xsnprintf (buf, endbuf - buf,
"QTNotes:");
14047 buf += xsnprintf (buf, endbuf - buf,
"user:");
14048 nbytes = bin2hex ((gdb_byte *) user, buf, strlen (user));
14054 buf += xsnprintf (buf, endbuf - buf,
"notes:");
14055 nbytes = bin2hex ((gdb_byte *) notes, buf, strlen (notes));
14061 buf += xsnprintf (buf, endbuf - buf,
"tstop:");
14062 nbytes = bin2hex ((gdb_byte *) stop_notes, buf, strlen (stop_notes));
14071 if (*reply ==
'\0')
14074 if (strcmp (reply,
"OK") != 0)
14075 error (_(
"Bogus reply from target: %s"), reply);
14092 if (strcmp (rs->
buf.data (),
"OK") == 0)
14108#if defined (HAVE_LIBEXPAT)
14113check_xml_btrace_version (
struct gdb_xml_parser *parser,
14121 if (strcmp (
version,
"1.0") != 0)
14128parse_xml_btrace_block (
struct gdb_xml_parser *parser,
14133 struct btrace_data *btrace;
14134 ULONGEST *begin, *end;
14136 btrace = (
struct btrace_data *) user_data;
14138 switch (btrace->format)
14140 case BTRACE_FORMAT_BTS:
14143 case BTRACE_FORMAT_NONE:
14144 btrace->format = BTRACE_FORMAT_BTS;
14145 btrace->variant.bts.blocks =
new std::vector<btrace_block>;
14154 btrace->variant.bts.blocks->emplace_back (*begin, *end);
14160parse_xml_raw (
struct gdb_xml_parser *parser,
const char *body_text,
14161 gdb_byte **pdata,
size_t *psize)
14166 len = strlen (body_text);
14172 gdb::unique_xmalloc_ptr<gdb_byte>
data ((gdb_byte *)
xmalloc (
size));
14183 if (hi == 0 || lo == 0)
14186 *bin++ = fromhex (hi) * 16 + fromhex (lo);
14190 *pdata =
data.release ();
14197parse_xml_btrace_pt_config_cpu (
struct gdb_xml_parser *parser,
14202 struct btrace_data *btrace;
14203 const char *vendor;
14204 ULONGEST *family, *model, *stepping;
14215 btrace = (
struct btrace_data *) user_data;
14217 if (strcmp (vendor,
"GenuineIntel") == 0)
14218 btrace->variant.pt.config.cpu.vendor = CV_INTEL;
14220 btrace->variant.pt.config.cpu.family = *family;
14221 btrace->variant.pt.config.cpu.model = *model;
14222 btrace->variant.pt.config.cpu.stepping = *stepping;
14228parse_xml_btrace_pt_raw (
struct gdb_xml_parser *parser,
14230 void *user_data,
const char *body_text)
14232 struct btrace_data *btrace;
14234 btrace = (
struct btrace_data *) user_data;
14235 parse_xml_raw (parser, body_text, &btrace->variant.pt.data,
14236 &btrace->variant.pt.size);
14242parse_xml_btrace_pt (
struct gdb_xml_parser *parser,
14247 struct btrace_data *btrace;
14249 btrace = (
struct btrace_data *) user_data;
14250 btrace->format = BTRACE_FORMAT_PT;
14251 btrace->variant.pt.config.cpu.vendor = CV_UNKNOWN;
14252 btrace->variant.pt.data = NULL;
14253 btrace->variant.pt.size = 0;
14272 parse_xml_btrace_pt_config_cpu, NULL },
14289 {
"block", block_attributes, NULL,
14298 check_xml_btrace_version, NULL },
14309#if defined (HAVE_LIBEXPAT)
14312 btrace_data result;
14313 result.format = BTRACE_FORMAT_NONE;
14318 error (_(
"Error parsing branch trace."));
14321 *btrace = std::move (result);
14325 error (_(
"Cannot process branch trace. XML support was disabled at "
14331#if defined (HAVE_LIBEXPAT)
14336parse_xml_btrace_conf_bts (
struct gdb_xml_parser *parser,
14341 struct btrace_config *conf;
14344 conf = (
struct btrace_config *) user_data;
14345 conf->format = BTRACE_FORMAT_BTS;
14346 conf->bts.size = 0;
14350 conf->bts.size = (
unsigned int) *(ULONGEST *)
size->value.get ();
14356parse_xml_btrace_conf_pt (
struct gdb_xml_parser *parser,
14361 struct btrace_config *conf;
14364 conf = (
struct btrace_config *) user_data;
14365 conf->format = BTRACE_FORMAT_PT;
14370 conf->pt.size = (
unsigned int) *(ULONGEST *)
size->value.get ();
14385 parse_xml_btrace_conf_bts, NULL },
14387 parse_xml_btrace_conf_pt, NULL },
14397 {
"btrace-conf", btrace_conf_attributes, btrace_conf_children,
14409#if defined (HAVE_LIBEXPAT)
14413 btrace_conf_elements, xml, conf);
14415 error (_(
"Error parsing branch trace configuration."));
14419 error (_(
"Cannot process the branch trace configuration. XML support "
14420 "was disabled at compile time."));
14439 char *buf, *pos, *endbuf;
14442 buf = rs->
buf.data ();
14449 pos += xsnprintf (pos, endbuf - pos,
"%s=0x%x",
14459 if (buf[0] ==
'E' && buf[1] ==
'.')
14460 error (_(
"Failed to configure the BTS buffer size: %s"), buf + 2);
14462 error (_(
"Failed to configure the BTS buffer size."));
14472 pos += xsnprintf (pos, endbuf - pos,
"%s=0x%x",
14482 if (buf[0] ==
'E' && buf[1] ==
'.')
14483 error (_(
"Failed to configure the trace buffer size: %s"), buf + 2);
14485 error (_(
"Failed to configure the trace buffer size."));
14501 gdb::optional<gdb::char_vector> xml
14514 int btrace_target_pushed = 0;
14515#if !defined (HAVE_LIBIPT)
14526 memset (&rs->
btrace_config, 0x00, sizeof (
struct btrace_config));
14532#if !defined (HAVE_LIBIPT)
14538 warning (_(
"Target is recording using Intel Processor Trace "
14539 "but support was disabled at compile time."));
14549 if (!btrace_target_pushed)
14551 btrace_target_pushed = 1;
14553 gdb_printf (_(
"Target is recording using %s.\n"),
14564struct btrace_target_info *
14566 const struct btrace_config *conf)
14570 char *buf = rs->
buf.data ();
14573 unsigned int which_packet;
14574 switch (conf->format)
14576 case BTRACE_FORMAT_BTS:
14579 case BTRACE_FORMAT_PT:
14583 internal_error (_(
"Bad branch btrace format: %u."),
14584 (
unsigned int) conf->format);
14589 error (_(
"Target does not support branch tracing."));
14593 ptid_t ptid = tp->
ptid;
14596 buf += xsnprintf (buf, endbuf - buf,
"%s",
14603 if (rs->
buf[0] ==
'E' && rs->
buf[1] ==
'.')
14604 error (_(
"Could not enable branch tracing for %s: %s"),
14607 error (_(
"Could not enable branch tracing for %s."),
14611 btrace_target_info *tinfo =
new btrace_target_info { ptid };
14619 catch (
const gdb_exception_error &
err)
14621 if (
err.message != NULL)
14622 warning (
"%s",
err.what ());
14634 char *buf = rs->
buf.data ();
14638 error (_(
"Target does not support branch tracing."));
14642 buf += xsnprintf (buf, endbuf - buf,
"%s",
14649 if (rs->
buf[0] ==
'E' && rs->
buf[1] ==
'.')
14650 error (_(
"Could not disable branch tracing for %s: %s"),
14653 error (_(
"Could not disable branch tracing for %s."),
14673 struct btrace_target_info *tinfo,
14674 enum btrace_read_type
type)
14679 error (_(
"Target does not support branch tracing."));
14681#if !defined(HAVE_LIBEXPAT)
14682 error (_(
"Cannot process branch tracing result. XML parsing not supported."));
14687 case BTRACE_READ_ALL:
14690 case BTRACE_READ_NEW:
14693 case BTRACE_READ_DELTA:
14697 internal_error (_(
"Bad branch tracing read type: %u."),
14698 (
unsigned int)
type);
14701 gdb::optional<gdb::char_vector> xml
14705 return BTRACE_ERR_UNKNOWN;
14709 return BTRACE_ERR_NONE;
14712const struct btrace_config *
14715 return &tinfo->conf;
14741 static gdb::optional<gdb::char_vector> filename;
14742 char *annex = NULL;
14749 internal_error (_(
"not currently attached to process %d"),
pid);
14751 if (!
inf->fake_pid_p)
14753 const int annex_size = 9;
14755 annex = (
char *) alloca (annex_size);
14756 xsnprintf (annex, annex_size,
"%x",
pid);
14762 return filename ? filename->data () :
nullptr;
14808 if (tp->inf ==
inf && priv != NULL)
14811 error (_(
"Thread handle size mismatch: %d vs %zu (from remote)"),
14822gdb::array_view<const gdb_byte>
14919 xsnprintf (rs->
buf.data (),
size,
"QThreadEvents:%x",
enable ? 1 : 0);
14926 if (strcmp (rs->
buf.data (),
"OK") != 0)
14927 error (_(
"Remote refused setting thread events: %s"), rs->
buf.data ());
14930 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
14946 for (; list != NULL; list = list->
next)
14947 if (strcmp (list->
name,
"Z-packet") == 0)
14958 uiout->
text (
": ");
14977 if (
inf->pspace != pspace)
14982 if (remote ==
nullptr)
14997 if (
inf->in_initial_library_scan)
15011 if (thread !=
nullptr)
15042 p = rs->
buf.data ();
15043 while (*p && *p !=
'l')
15049 p = rs->
buf.data ();
15063 p = rs->
buf.data ();
15064 while (*p && *p !=
'l')
15070 p = rs->
buf.data ();
15083 _(
"Debugger's willingness to use range stepping "
15084 "is %s.\n"),
value);
15110 warning (_(
"Range stepping is not supported by the current target"));
15118 gdb_printf (file, _(
"Debugging of remote protocol is %s.\n"),
15127 _(
"Timeout limit to wait for target to respond is %s.\n"),
15143 size_t len,
int type)
15147 std::string request = string_printf (
"qMemTags:%s,%s:%s",
15148 phex_nz (address, addr_size),
15149 phex_nz (len,
sizeof (len)),
15152 strcpy (packet.data (), request.c_str ());
15161 gdb::byte_vector &tags)
15163 if (reply.empty () || reply[0] ==
'E' || reply[0] !=
'm')
15167 tags = hex2bin (reply.data () + 1);
15176 size_t len,
int type,
15177 const gdb::byte_vector &tags)
15182 std::string request = string_printf (
"QMemTags:%s,%s:%s:",
15183 phex_nz (address, addr_size),
15184 phex_nz (len,
sizeof (len)),
15186 request += bin2hex (tags.data (), tags.size ());
15189 if (packet.size () < request.length ())
15190 error (_(
"Contents too big for packet QMemTags."));
15192 strcpy (packet.data (), request.c_str ());
15199 gdb::byte_vector &tags,
int type)
15203 gdb_assert_not_reached (
"remote fetch_memtags called with packet disabled");
15219 const gdb::byte_vector &tags,
int type)
15223 gdb_assert_not_reached (
"remote store_memtags called with packet disabled");
15252test_memory_tagging_functions ()
15259 scoped_restore restore_memtag_support_
15260 = make_scoped_restore (&config->
support);
15271 gdb::char_vector packet;
15272 gdb::byte_vector tags, bv;
15273 std::string expected, reply;
15274 packet.resize (32000);
15278 expected =
"qMemTags:0,0:0";
15280 SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
15282 expected =
"qMemTags:deadbeef,10:1";
15284 SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
15290 strcpy (packet.data (), reply.c_str ());
15293 SELF_CHECK (tags.size () == 0);
15299 for (
int i = 0; i < 5; i++)
15302 reply =
"m" + bin2hex (bv.data (), bv.size ());
15303 strcpy (packet.data (), reply.c_str ());
15306 SELF_CHECK (tags.size () == 5);
15308 for (
int i = 0; i < 5; i++)
15309 SELF_CHECK (tags[i] == i);
15315 expected =
"QMemTags:0,0:0:";
15317 SELF_CHECK (memcmp (packet.data (), expected.c_str (),
15318 expected.length ()) == 0);
15322 for (
int i = 0; i < 5; i++)
15323 tags.push_back (i);
15324 expected =
"QMemTags:deadbeef,ff:1:0001020304";
15326 SELF_CHECK (memcmp (packet.data (), expected.c_str (),
15327 expected.length ()) == 0);
15346 init_remote_threadtests ();
15352Remote protocol specific variables.\n\
15353Configure various remote-protocol specific variables such as\n\
15354the packets being used."),
15358Remote protocol specific variables.\n\
15359Configure various remote-protocol specific variables such as\n\
15360the packets being used."),
15365Compare section data on target to the exec file.\n\
15366Argument is a single section name (default: all loaded sections).\n\
15367To compare only read-only loaded sections, specify the -r option."),
15371Send an arbitrary packet to a remote target.\n\
15372 maintenance packet TEXT\n\
15373If GDB is talking to an inferior via the GDB serial protocol, then\n\
15374this command sends the string TEXT to the inferior, and displays the\n\
15375response packet. GDB supplies the initial `$' character, and the\n\
15376terminating `#' character and checksum."),
15381Set whether to send break if interrupted."), _(
"\
15382Show whether to send break if interrupted."), _(
"\
15383If set, a break, instead of a cntrl-c, is sent to the remote target."),
15392Set interrupt sequence to remote target."), _(
"\
15393Show interrupt sequence to remote target."), _(
"\
15394Valid value is \"Ctrl-C\", \"BREAK\" or \"BREAK-g\". The default is \"Ctrl-C\"."),
15401Set whether interrupt-sequence is sent to remote target when gdb connects to."), _(
"\
15402Show whether interrupt-sequence is sent to remote target when gdb connects to."), _(
"\
15403If set, interrupt sequence is sent to remote target."),
15410Set the maximum number of bytes per memory write packet (deprecated)."),
15413Show the maximum number of bytes per memory write packet (deprecated)."),
15417Set the maximum number of bytes per memory-write packet.\n\
15418Specify the number of bytes in a packet or 0 (zero) for the\n\
15419default packet size. The actual limit is further reduced\n\
15420dependent on the target. Specify \"fixed\" to disable the\n\
15421further restriction and \"limit\" to enable that restriction."),
15425Set the maximum number of bytes per memory-read packet.\n\
15426Specify the number of bytes in a packet or 0 (zero) for the\n\
15427default packet size. The actual limit is further reduced\n\
15428dependent on the target. Specify \"fixed\" to disable the\n\
15429further restriction and \"limit\" to enable that restriction."),
15433 _(
"Show the maximum number of bytes per memory-write packet."),
15437 _(
"Show the maximum number of bytes per memory-read packet."),
15442Set the maximum number of target hardware watchpoints."), _(
"\
15443Show the maximum number of target hardware watchpoints."), _(
"\
15444Specify \"unlimited\" for unlimited hardware watchpoints."),
15451Set the maximum length (in bytes) of a target hardware watchpoint."), _(
"\
15452Show the maximum length (in bytes) of a target hardware watchpoint."), _(
"\
15453Specify \"unlimited\" to allow watchpoints of unlimited size."),
15458Set the maximum number of target hardware breakpoints."), _(
"\
15459Show the maximum number of target hardware breakpoints."), _(
"\
15460Specify \"unlimited\" for unlimited hardware breakpoints."),
15466Set the maximum size of the address (in bits) in a memory packet."), _(
"\
15467Show the maximum size of the address (in bits) in a memory packet."), NULL,
15482 "catch-syscalls", 0);
15485 "program-signals", 0);
15488 "set-working-dir", 0);
15491 "startup-with-shell", 0);
15494 "environment-hex-encoded", 0);
15497 "environment-reset", 0);
15500 "environment-unset", 0);
15519 "read-aux-vector", 0);
15522 "pid-to-exec-file", 0);
15525 "qXfer:features:read",
"target-features", 0);
15528 "library-info", 0);
15531 "qXfer:libraries-svr4:read",
"library-info-svr4", 0);
15542 "read-siginfo-object", 0);
15545 "write-siginfo-object", 0);
15548 "qXfer:traceframe-info:read",
"traceframe-info", 0);
15551 "unwind-info-block", 0);
15554 "get-thread-local-storage-address", 0);
15557 "get-thread-information-block-address", 0);
15567 "search-memory", 0);
15586 "hostio-readlink", 0);
15601 "ConditionalTracepoints",
"conditional-tracepoints",
15605 "ConditionalBreakpoints",
"conditional-breakpoints",
15609 "breakpoint-commands", 0);
15612 "fast-tracepoints", 0);
15615 "TracepointSource", 0);
15620 "static-tracepoints", 0);
15623 "install-in-trace", 0);
15626 "qXfer:statictrace:read",
"read-sdata-object", 0);
15629 "read-fdpic-loadmap", 0);
15632 "disable-randomization", 0);
15637 "trace-buffer-size", 0);
15651 "read-btrace-conf", 0);
15654 "btrace-conf-bts-size", 0);
15657 "multiprocess-feature", 0);
15660 "swbreak-feature", 0);
15663 "hwbreak-feature", 0);
15666 "fork-event-feature", 0);
15669 "vfork-event-feature", 0);
15672 "btrace-conf-pt-size", 0);
15675 "verbose-resume-supported", 0);
15678 "exec-event-feature", 0);
15686 "no-resumed-stop-reply", 0);
15689 "memory-tagging-feature",
"memory-tagging-feature", 0);
15731Set use of remote protocol `Z' packets."), _(
"\
15732Show use of remote protocol `Z' packets."), _(
"\
15733When set, GDB will attempt to use the remote breakpoint and watchpoint\n\
15742Manipulate files on the remote system.\n\
15743Transfer files to and from the remote target system."),
15748 _(
"Copy a local file to the remote system."),
15752 _(
"Copy a remote file to the local system."),
15756 _(
"Delete a remote file."),
15761Set the remote pathname for \"run\"."), _(
"\
15762Show the remote pathname for \"run\"."), NULL,
15770Enable or disable range stepping."), _(
"\
15771Show whether target-assisted range stepping is enabled."), _(
"\
15772If on, and the target supports it, when stepping a source line, GDB\n\
15773tells the target to step the corresponding range of addresses itself instead\n\
15774of issuing multiple single-steps. This speeds up source level\n\
15775stepping. If off, GDB always issues single-steps, even if range\n\
15776stepping is supported by the target. The default is on."),
15783Set watchdog timer."), _(
"\
15784Show watchdog timer."), _(
"\
15785When non-zero, this timeout is used instead of waiting forever for a target\n\
15786to finish a low-level step or continue operation. If the specified amount\n\
15787of time passes without a response from the target, an error occurs."),
15794Set the maximum number of characters to display for each remote packet."), _(
"\
15795Show the maximum number of characters to display for each remote packet."), _(
"\
15796Specify \"unlimited\" to display all the characters."),
15801 _(
"Set debugging of remote protocol."),
15802 _(
"Show debugging of remote protocol."),
15804When enabled, each packet sent or received with the remote target\n\
15812Set timeout limit to wait for target to respond."), _(
"\
15813Show timeout limit to wait for target to respond."), _(
"\
15814This value is used to set the time limit for gdb to wait for a response\n\
15824 selftests::register_test (
"remote_memory_tagging",
15825 selftests::test_memory_tagging_functions);
static struct @5 attributes[]
struct gdbarch * target_gdbarch(void)
void mark_async_event_handler(async_event_handler *async_handler_ptr)
async_event_handler * create_async_event_handler(async_event_handler_func *proc, gdb_client_data client_data, const char *name)
void clear_async_event_handler(async_event_handler *async_handler_ptr)
void delete_async_event_handler(async_event_handler **async_handler_ptr)
bool async_event_handler_marked(async_event_handler *handler)
agent_expr_up gen_eval_for_expr(CORE_ADDR scope, struct expression *expr)
std::unique_ptr< agent_expr > agent_expr_up
int breakpoints_should_be_inserted_now(void)
struct command_line * breakpoint_commands(struct breakpoint *b)
void remove_breakpoints_inf(inferior *inf)
void insert_breakpoints(void)
@ bp_static_marker_tracepoint
bool supports_disable_randomization() override
bool can_attach() override
void post_attach(int) override
bool can_create_inferior() override
void attach(const char *, int) override
const target_info & info() const override
static void open(const char *, int)
void create_inferior(const char *, const std::string &, char **, int) override
void detach(inferior *, int) override
const std::string & cwd() const
void push_target(struct target_ops *t)
struct process_stratum_target * process_target()
struct program_space * pspace
void follow_fork(inferior *child_inf, ptid_t child_ptid, target_waitkind fork_kind, bool follow_child, bool detach_on_fork) override
thread_info * find_thread(ptid_t ptid)
void follow_exec(inferior *follow_inf, ptid_t ptid, const char *execd_pathname) override
bool has_execution(inferior *inf) override
void raw_collect(int regnum, void *buf) const override
void raw_supply(int regnum, const void *buf) override
void raw_update(int regnum) override
void set(unsigned key, void *datum)
gdb_signal last_sent_signal
int remote_traceframe_number
threadref resultthreadlist[MAXTHREADLISTRESULTS]
long explicit_packet_size
std::unordered_map< struct gdbarch *, remote_arch_state > m_arch_states
bool wait_forever_enabled_p
bool use_threadinfo_query
bool use_threadextra_query
char * last_program_signals_packet
std::vector< stop_reply_up > stop_reply_queue
vCont_action_support supports_vCont
exec_direction_kind last_resume_exec_dir
struct readahead_cache readahead_cache
struct async_event_handler * remote_async_inferior_event_token
struct remote_arch_state * get_remote_arch_state(struct gdbarch *gdbarch)
struct serial * remote_desc
bool waiting_for_stop_reply
struct remote_notif_state * notif_state
threadref echo_nextthread
void remote_notif_get_pending_events(const notif_client *nc)
struct stop_reply * remote_notif_remove_queued_reply(ptid_t ptid)
enum btrace_error read_btrace(struct btrace_data *data, struct btrace_target_info *btinfo, enum btrace_read_type type) override
void extended_remote_restart()
int getpkt(gdb::char_vector *buf, bool forever=false, bool *is_notif=nullptr)
const char * thread_name(struct thread_info *) override
int remote_hostio_pread(int fd, gdb_byte *read_buf, int len, ULONGEST offset, fileio_error *remote_errno)
bool stopped_data_address(CORE_ADDR *) override
thread_info * remote_add_thread(ptid_t ptid, bool running, bool executing, bool silent_p)
int readchar(int timeout)
bool augmented_libraries_svr4_read() override
int fileio_pwrite(int fd, const gdb_byte *write_buf, int len, ULONGEST offset, fileio_error *target_errno) override
target_xfer_status remote_xfer_live_readonly_partial(gdb_byte *readbuf, ULONGEST memaddr, ULONGEST len, int unit_size, ULONGEST *xfered_len)
void kill_new_fork_children(inferior *inf)
bool supports_disable_randomization() override
void load(const char *, int) override
bool can_run_breakpoint_commands() override
int insert_watchpoint(CORE_ADDR, int, enum target_hw_bp_type, struct expression *) override
void discard_pending_stop_replies_in_queue()
ptid_t select_thread_for_ambiguous_stop_reply(const struct target_waitstatus &status)
int upload_tracepoints(struct uploaded_tp **utpp) override
int insert_hw_breakpoint(struct gdbarch *, struct bp_target_info *) override
struct remote_state * get_remote_state()
void download_tracepoint(struct bp_location *location) override
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
std::vector< mem_region > memory_map() override
void process_initial_stop_replies(int from_tty)
void teardown_btrace(struct btrace_target_info *tinfo) override
void log_command(const char *cmd) override
void remote_detach_pid(int pid)
bool fetch_memtags(CORE_ADDR address, size_t len, gdb::byte_vector &tags, int type) override
void flash_erase(ULONGEST address, LONGEST length) override
ptid_t get_ada_task_ptid(long lwp, ULONGEST thread) override
bool stopped_by_sw_breakpoint() override
int upload_trace_state_variables(struct uploaded_tsv **utsvp) override
void trace_init() override
int remote_threadlist_iterator(rmt_thread_action stepfunction, void *context, int looplimit)
void remote_btrace_maybe_reopen()
void get_tracepoint_status(tracepoint *tp, struct uploaded_tp *utp) override
char * append_resumption(char *p, char *endp, ptid_t ptid, int step, gdb_signal siggnal)
bool get_trace_state_variable_value(int tsv, LONGEST *val) override
int fileio_close(int fd, fileio_error *target_errno) override
bool is_async_p() override
target_xfer_status remote_read_bytes_1(CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len_units, int unit_size, ULONGEST *xfered_len_units)
ptid_t wait_ns(ptid_t ptid, struct target_waitstatus *status, target_wait_flags options)
void download_trace_state_variable(const trace_state_variable &tsv) override
void prepare_to_store(struct regcache *) override
int verify_memory(const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size) override
ptid_t wait_as(ptid_t ptid, target_waitstatus *status, target_wait_flags options)
void resume(ptid_t, int, enum gdb_signal) override
int remove_watchpoint(CORE_ADDR, int, enum target_hw_bp_type, struct expression *) override
int remote_get_threadinfo(threadref *threadid, int fieldset, gdb_ext_thread_info *info)
void remote_file_get(const char *remote_file, const char *local_file, int from_tty)
void follow_exec(inferior *, ptid_t, const char *) override
int fileio_unlink(struct inferior *inf, const char *filename, fileio_error *target_errno) override
bool start_remote_1(int from_tty, int extended_p)
std::vector< static_tracepoint_marker > static_tracepoint_markers_by_strid(const char *id) override
bool use_agent(bool use) override
void terminal_inferior() override
long get_memory_write_packet_size()
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
void terminal_ours() override
bool can_download_tracepoint() override
void remote_notice_new_inferior(ptid_t currthread, bool executing)
void discard_pending_stop_replies(struct inferior *inf)
packet_result remote_send_printf(const char *format,...) ATTRIBUTE_PRINTF(2
void disable_btrace(struct btrace_target_info *tinfo) override
bool supports_stopped_by_sw_breakpoint() override
thread_info * thread_handle_to_thread_info(const gdb_byte *thread_handle, int handle_len, inferior *inf) override
void remote_check_symbols()
void remote_download_command_source(int num, ULONGEST addr, struct command_line *cmds)
static void open_1(const char *name, int from_tty, int extended_p)
int remote_resume_with_vcont(ptid_t scope_ptid, int step, gdb_signal siggnal)
void set_general_process()
void remote_interrupt_as()
void print_one_stopped_thread(thread_info *thread)
void set_thread(ptid_t ptid, int gen)
const struct btrace_config * btrace_conf(const struct btrace_target_info *) override
int peek_stop_reply(ptid_t ptid)
int remote_unpack_thread_info_response(const char *pkt, threadref *expectedref, gdb_ext_thread_info *info)
target_xfer_status 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)
packet_result target_xfer_status remote_flash_write(ULONGEST address, ULONGEST length, ULONGEST *xfered_len, const gdb_byte *data)
void process_g_packet(struct regcache *regcache)
int remove_vfork_catchpoint(int) override
int parse_threadlist_response(const char *pkt, int result_limit, threadref *original_echo, threadref *resultlist, int *doneflag)
int remote_hostio_pwrite(int fd, const gdb_byte *write_buf, int len, ULONGEST offset, fileio_error *remote_errno)
ULONGEST get_memory_xfer_limit() override
bool has_pending_events() override
bool supports_non_stop() override
void remote_detach_1(struct inferior *inf, int from_tty)
bool supports_evaluation_of_breakpoint_conditions() override
target_xfer_status remote_read_qxfer(const char *object_name, const char *annex, gdb_byte *readbuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, const unsigned int which_packet)
bool supports_stopped_by_hw_breakpoint() override
int remote_hostio_pread_vFile(int fd, gdb_byte *read_buf, int len, ULONGEST offset, fileio_error *remote_errno)
long get_memory_packet_size(struct memory_packet_config *config)
int remove_exec_catchpoint(int) override
ptid_t process_stop_reply(struct stop_reply *stop_reply, target_waitstatus *status)
gdb::optional< std::string > fileio_readlink(struct inferior *inf, const char *filename, fileio_error *target_errno) override
void set_remote_traceframe()
thread_control_capabilities get_thread_control_capabilities() override
void trace_stop() override
int fileio_open(struct inferior *inf, const char *filename, int flags, int mode, int warn_if_slow, fileio_error *target_errno) override
void interrupt() override
ptid_t remote_current_thread(ptid_t oldpid)
int remote_hostio_send_command(int command_bytes, int which_packet, fileio_error *remote_errno, const char **attachment, int *attachment_len)
int get_min_fast_tracepoint_insn_len() override
int fileio_fstat(int fd, struct stat *sb, fileio_error *target_errno) override
void store_registers(struct regcache *, int) override
void extended_remote_set_inferior_cwd()
int trace_find(enum trace_find_type type, int num, CORE_ADDR addr1, CORE_ADDR addr2, int *tpp) override
struct btrace_target_info * enable_btrace(thread_info *tp, const struct btrace_config *conf) override
char * append_pending_thread_resumptions(char *p, char *endp, ptid_t ptid)
~remote_target() override
bool supports_string_tracing() override
bool get_tib_address(ptid_t ptid, CORE_ADDR *addr) override
static void open(const char *, int)
bool stopped_by_watchpoint() override
void extended_remote_environment_support()
int remote_supports_fast_tracepoints()
void pass_ctrlc() override
int remote_vkill(int pid)
CORE_ADDR get_thread_local_address(ptid_t ptid, CORE_ADDR load_module_addr, CORE_ADDR offset) override
int remote_supports_static_tracepoints()
int async_wait_fd() override
void remote_file_delete(const char *remote_file, int from_tty)
int remote_hostio_open(struct inferior *inf, const char *filename, int flags, int mode, int warn_if_slow, fileio_error *remote_errno)
struct stop_reply * queued_stop_reply(ptid_t ptid)
inferior * remote_add_inferior(bool fake_pid_p, int pid, int attached, int try_open_exec)
void detach(inferior *, int) override
void set_circular_trace_buffer(int val) override
int region_ok_for_hw_watchpoint(CORE_ADDR, int) override
int remote_hostio_unlink(inferior *inf, const char *filename, fileio_error *remote_errno)
void mourn_inferior() override
void set_trace_buffer_size(LONGEST val) override
bool can_use_agent() override
int remove_breakpoint(struct gdbarch *, struct bp_target_info *, enum remove_bp_reason) override
int remote_supports_cond_tracepoints()
void remote_supported_packet(const struct protocol_feature *feature, enum packet_support support, const char *argument)
bool supports_multi_process() override
int can_use_hw_breakpoint(enum bptype, int, int) override
void remote_file_put(const char *local_file, const char *remote_file, int from_tty)
bool watchpoint_addr_within_range(CORE_ADDR, CORE_ADDR, int) override
bool store_memtags(CORE_ADDR address, size_t len, const gdb::byte_vector &tags, int type) override
void store_registers_using_G(const struct regcache *regcache)
bool can_execute_reverse() override
int remote_get_threads_with_ql(threads_listing_context *context)
void disconnect(const char *, int) override
int insert_breakpoint(struct gdbarch *, struct bp_target_info *) override
void remote_parse_stop_reply(const char *buf, stop_reply *event)
int remote_get_threads_with_qxfer(threads_listing_context *context)
bool thread_alive(ptid_t ptid) override
void disable_tracepoint(struct bp_location *location) override
void thread_events(int) override
void remote_vcont_probe()
void update_thread_list() override
remote_features m_features
int remote_hostio_close(int fd, fileio_error *remote_errno)
bool stopped_by_hw_breakpoint() override
void set_disconnected_tracing(int val) override
std::string pid_to_str(ptid_t) override
void remote_serial_write(const char *str, int len)
void remote_serial_quit_handler()
LONGEST get_raw_trace_data(gdb_byte *buf, ULONGEST offset, LONGEST len) override
char * remote_get_noisy_reply()
target_xfer_status remote_write_qxfer(const char *object_name, const char *annex, const gdb_byte *writebuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, const unsigned int which_packet)
int save_trace_data(const char *filename) override
int remote_get_threadlist(int startflag, threadref *nextthread, int result_limit, int *done, int *result_count, threadref *threadlist)
int can_do_single_step() override
const struct target_desc * read_description() override
void remote_packet_size(const protocol_feature *feature, packet_support support, const char *value)
int remote_supports_install_in_trace()
int insert_vfork_catchpoint(int) override
void remote_resume_with_hc(ptid_t ptid, int step, gdb_signal siggnal)
void check_binary_download(CORE_ADDR addr)
int remove_hw_breakpoint(struct gdbarch *, struct bp_target_info *) override
void program_signals(gdb::array_view< const unsigned char >) override
const char * extra_thread_info(struct thread_info *) override
bool set_trace_notes(const char *user, const char *notes, const char *stopnotes) override
int insert_exec_catchpoint(int) override
bool supports_memory_tagging() override
int extended_remote_run(const std::string &args)
int core_of_thread(ptid_t ptid) override
bool can_async_p() override
void set_permissions() override
int remote_hostio_set_filesystem(struct inferior *inf, fileio_error *remote_errno)
int stop_reply_queue_length()
int search_memory(CORE_ADDR start_addr, ULONGEST search_space_len, const gdb_byte *pattern, ULONGEST pattern_len, CORE_ADDR *found_addrp) override
void start_remote(int from_tty, int extended_p)
int remote_get_threads_with_qthreadinfo(threads_listing_context *context)
bool static_tracepoint_marker_at(CORE_ADDR, struct static_tracepoint_marker *marker) override
bool supports_enable_disable_tracepoint() override
void remote_interrupt_ns()
void remote_query_supported()
bool filesystem_is_local() override
void send_interrupt_sequence()
int putpkt_binary(const char *buf, int cnt)
remote_state m_remote_state
long get_memory_read_packet_size()
void pass_signals(gdb::array_view< const unsigned char >) override
void check_pending_events_prevent_wildcard_vcont(bool *may_global_wildcard_vcont)
void send_environment_packet(const char *action, const char *packet, const char *value)
void set_continue_thread(ptid_t ptid)
const char * connection_string() override
void rcmd(const char *command, struct ui_file *output) override
void push_stop_reply(struct stop_reply *new_event)
void btrace_sync_conf(const btrace_config *conf)
void remove_new_fork_children(threads_listing_context *context)
int fetch_register_using_p(struct regcache *regcache, packet_reg *reg)
const char * pid_to_exec_file(int pid) override
int store_register_using_P(const struct regcache *regcache, packet_reg *reg)
void set_general_thread(ptid_t ptid)
enum exec_direction_kind execution_direction() override
int get_trace_status(struct trace_status *ts) override
int putpkt(const char *buf)
target_xfer_status remote_read_bytes(CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, int unit_size, ULONGEST *xfered_len)
ptid_t get_current_thread(const char *wait_status)
void fetch_registers(struct regcache *, int) override
thread_info * add_current_inferior_and_thread(const char *wait_status)
long get_remote_packet_size(void)
int remove_fork_catchpoint(int) override
void trace_start() override
int remote_query_attached(int pid)
void trace_set_readonly_regions() override
long read_frame(gdb::char_vector *buf_p)
void remote_stop_ns(ptid_t ptid)
void follow_fork(inferior *, ptid_t, target_waitkind, bool, bool) override
int fileio_pread(int fd, gdb_byte *read_buf, int len, ULONGEST offset, fileio_error *target_errno) override
int insert_fork_catchpoint(int) override
void flash_done() override
void async(bool) override
const target_info & info() const override
traceframe_info_up traceframe_info() override
void commit_resumed() override
target_xfer_status remote_write_bytes(CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len, int unit_size, ULONGEST *xfered_len)
gdb::array_view< const gdb_byte > thread_info_to_thread_handle(struct thread_info *tp) override
int set_syscall_catchpoint(int, bool, int, gdb::array_view< const int >) override
char * write_ptid(char *buf, const char *endbuf, ptid_t ptid)
void enable_tracepoint(struct bp_location *location) override
void extended_remote_disable_randomization(int val)
void fetch_registers_using_g(struct regcache *regcache)
scoped_remote_fd(remote_target *remote, int fd)
DISABLE_COPY_AND_ASSIGN(scoped_remote_fd)
ATTRIBUTE_UNUSED_RESULT int release() noexcept
const std::string & string()
static void ours_for_output()
void set_pending_waitstatus(const target_waitstatus &ws)
void set_running(bool running)
bool has_pending_waitstatus() const
void clear_pending_waitstatus()
struct target_waitstatus pending_follow
const target_waitstatus & pending_waitstatus() const
private_thread_info_up priv
void set_stop_pc(CORE_ADDR stop_pc)
void set_stop_signal(gdb_signal sig)
thread_control_state control
void putstrn(const char *str, int n, int quoter, bool async_safe=false)
virtual void puts(const char *str)
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
void text(const char *string)
vcont_builder(remote_target *remote)
void push_action(ptid_t ptid, bool step, gdb_signal siggnal)
struct cmd_list_element * showlist
void error_no_arg(const char *why)
struct cmd_list_element * cmdlist
struct cmd_list_element * setlist
struct cmd_list_element * showdebuglist
struct cmd_list_element * maintenancelist
struct cmd_list_element * setdebuglist
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
set_show_commands add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_unlimited_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void cmd_func(struct cmd_list_element *cmd, const char *args, int from_tty)
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_auto_boolean_cmd(const char *name, enum command_class theclass, enum auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void do_show_command(const char *arg, int from_tty, struct cmd_list_element *c)
void reopen_exec_file(void)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * get_exec_file(int err)
int check_quit_flag(void)
quit_handler_ftype * quit_handler
int gdb_insn_length(struct gdbarch *gdbarch, CORE_ADDR addr)
void exception_fprintf(struct ui_file *file, const struct gdb_exception &e, const char *prefix,...)
void exec_file_locate_attach(int pid, int defer_bp_reset, int from_tty)
void validate_exec_file(int from_tty)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
frame_info_ptr get_current_frame(void)
void set_current_sal_from_frame(frame_info_ptr)
static void ATTRIBUTE_PRINTF(1, 0)
int is_target_filename(const char *name)
#define TARGET_SYSROOT_PREFIX
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
int gdbarch_has_global_breakpoints(struct gdbarch *gdbarch)
int gdbarch_num_regs(struct gdbarch *gdbarch)
int gdbarch_fast_tracepoint_valid_at(struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg)
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
int gdbarch_remote_register_number(struct gdbarch *gdbarch, int regno)
int gdbarch_has_global_solist(struct gdbarch *gdbarch)
void gdbarch_relocate_instruction(struct gdbarch *gdbarch, CORE_ADDR *to, CORE_ADDR from)
int gdbarch_addressable_memory_unit_size(struct gdbarch *gdbarch)
CORE_ADDR gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
struct thread_info * any_live_thread_of_inferior(inferior *inf)
all_threads_safe_range all_threads_safe()
struct thread_info * add_thread(process_stratum_target *targ, ptid_t ptid)
int thread_count(process_stratum_target *proc_target)
struct thread_info * add_thread_silent(process_stratum_target *targ, ptid_t ptid)
struct thread_info * first_thread_of_inferior(inferior *inf)
void delete_thread(thread_info *thread)
void switch_to_thread_no_regs(struct thread_info *thread)
all_non_exited_threads_range all_non_exited_threads(process_stratum_target *proc_target=nullptr, ptid_t filter_ptid=minus_one_ptid)
void set_executing(process_stratum_target *targ, ptid_t ptid, bool executing)
struct thread_info * inferior_thread(void)
void switch_to_thread(struct thread_info *thr)
void set_running(process_stratum_target *targ, ptid_t ptid, bool running)
void thread_change_ptid(process_stratum_target *targ, ptid_t old_ptid, ptid_t new_ptid)
struct thread_info * any_thread_of_inferior(inferior *inf)
int thread_is_in_step_over_chain(struct thread_info *tp)
bool in_thread_list(process_stratum_target *targ, ptid_t ptid)
void switch_to_no_thread()
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
void inferior_event_handler(enum inferior_event_type event_type)
void setup_inferior(int from_tty)
void notice_new_inferior(thread_info *thr, bool leave_running, int from_tty)
void inferior_appeared(struct inferior *inf, int pid)
struct inferior * add_inferior_with_spaces(void)
struct inferior * find_inferior_ptid(process_stratum_target *targ, ptid_t ptid)
struct inferior * find_inferior_pid(process_stratum_target *targ, int pid)
bool print_inferior_events
void detach_inferior(inferior *inf)
struct inferior * current_inferior(void)
struct inferior * add_inferior(int pid)
void switch_to_inferior_no_thread(inferior *inf)
int number_of_live_inferiors(process_stratum_target *proc_target)
all_inferiors_range all_inferiors(process_stratum_target *proc_target=nullptr)
void generic_mourn_inferior(void)
all_non_exited_inferiors_range all_non_exited_inferiors(process_stratum_target *proc_target=nullptr)
void update_signals_program_target(void)
void notify_signal_received(gdb_signal sig)
int signal_print_state(int signo)
void set_last_target_status(process_stratum_target *target, ptid_t ptid, const target_waitstatus &status)
void notify_normal_stop(bpstat *bs, int print_frame)
static bool follow_fork()
bool disable_randomization
int signal_pass_state(int signo)
void stop_all_threads(const char *reason, inferior *inf)
void init_wait_for_inferior(void)
void print_target_wait_results(ptid_t waiton_ptid, ptid_t result_ptid, const struct target_waitstatus &ws)
static void scan(growable_macro_buffer *dest, shared_macro_buffer *src, struct macro_name_list *no_loop, const macro_scope &scope)
struct ui_file * gdb_stdtarg
int memory_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason)
int memory_insert_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
std::vector< mem_region > parse_memory_map(const char *memory_map)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
observable< struct objfile * > new_objfile
observable< program_space * > all_objfiles_removed
void objfile_relocate(struct objfile *objfile, const section_offsets &new_offsets)
#define SECT_OFF_BSS(objfile)
#define SECT_OFF_DATA(objfile)
#define SECT_OFF_TEXT(objfile)
#define prefix(a, b, R, do)
void switch_to_target_no_thread(process_stratum_target *target)
struct program_space * current_program_space
struct address_space * maybe_new_address_space(void)
void update_address_spaces(void)
void record_btrace_push_target(void)
int register_size(struct gdbarch *gdbarch, int regnum)
struct regcache * get_thread_arch_regcache(process_stratum_target *target, ptid_t ptid, struct gdbarch *gdbarch)
void remote_fileio_request(remote_target *remote, char *buf, int ctrlc_pending_p)
void remote_fileio_to_host_stat(struct fio_stat *fst, struct stat *st)
void initialize_remote_fileio(struct cmd_list_element **remote_set_cmdlist, struct cmd_list_element **remote_show_cmdlist)
void remote_fileio_reset(void)
void handle_notification(struct remote_notif_state *state, const char *buf)
struct remote_notif_state * remote_notif_state_allocate(remote_target *remote)
void remote_notif_process(struct remote_notif_state *state, const notif_client *except)
void remote_notif_ack(remote_target *remote, const notif_client *nc, const char *buf)
struct notif_event * remote_notif_parse(remote_target *remote, const notif_client *nc, const char *buf)
std::unique_ptr< notif_event > notif_event_up
static void remote_async_inferior_event_handler(gdb_client_data)
static packet_config remote_protocol_packets[PACKET_MAX]
static const struct protocol_feature remote_protocol_features[]
bool is_remote_target(process_stratum_target *target)
static int remote_packet_max_chars
static void record_currthread(struct remote_state *rs, ptid_t currthread)
static bool is_fork_status(target_waitkind kind)
static int hexnumlen(ULONGEST num)
static void show_remote_timeout(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void show_remote_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int remote_hw_breakpoint_limit
static char * pack_threadid(char *pkt, threadref *id)
static int hexnumstr(char *, ULONGEST)
static int stub_unpack_int(const char *buff, int fieldlength)
static void resume_clear_thread_private_info(struct thread_info *thread)
static void remote_unpush_and_throw(remote_target *target)
static notif_event_up remote_notif_stop_alloc_reply()
static void show_watchdog(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static const registry< gdbarch >::key< struct remote_g_packet_data > remote_g_packet_data_handle
static void remote_put_command(const char *args, int from_tty)
static const target_waitstatus * thread_pending_fork_status(struct thread_info *thread)
static bool parse_fetch_memtags_reply(const gdb::char_vector &reply, gdb::byte_vector &tags)
static void create_store_memtags_request(gdb::char_vector &packet, CORE_ADDR address, size_t len, int type, const gdb::byte_vector &tags)
static int align_for_efficient_write(int todo, CORE_ADDR memaddr)
static void show_interrupt_sequence(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static enum Z_packet_type watchpoint_to_Z_packet(int type)
static int threadref_to_int(threadref *ref)
static const int remote_flash_timeout
std::unique_ptr< stop_reply > stop_reply_up
static void set_remote_exec_file(const char *ignored, int from_tty, struct cmd_list_element *c)
static unsigned int remote_address_size
static const ptid_t not_sent_ptid(42000, -2, 1)
static void remote_add_target_side_commands(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, char *buf)
static void remote_query_supported_append(std::string *msg, const char *append)
static void unpush_and_perror(remote_target *target, const char *string)
void register_remote_support_xml(const char *xml)
static int remote_add_target_side_condition(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, char *buf, char *buf_end)
static const char * interrupt_sequence_mode
#define BUF_THREAD_ID_SIZE
static void remote_objfile_changed_check_symbols(program_space *pspace)
static struct packet_reg * packet_reg_from_pnum(struct gdbarch *gdbarch, struct remote_arch_state *rsa, LONGEST pnum)
static void remote_get_command(const char *args, int from_tty)
unsigned char threadref[OPAQUETHREADBYTES]
static int remote_thread_always_alive(ptid_t ptid)
static void remote_delete_command(const char *args, int from_tty)
void remote_file_delete(const char *remote_file, int from_tty)
static const ptid_t any_thread_ptid(42000, 0, 1)
static void trace_error(char *buf)
static void init_all_packet_configs(void)
static void remote_serial_quit_handler()
static long get_fixed_memory_packet_size(struct memory_packet_config *config)
static const char * unpack_nibble(const char *buf, int *val)
static void show_memory_packet_size(memory_packet_config *config, remote_target *remote)
static remote_inferior * get_remote_inferior(inferior *inf)
static char * pack_int(char *buf, int value)
static remote_target * as_remote_target(process_stratum_target *target)
static void remote_buffer_add_string(char **buffer, int *left, const char *string)
void send_remote_packet(gdb::array_view< const char > &buf, send_remote_packet_callbacks *callbacks)
static memory_packet_config memory_read_packet_config
static char * remote_support_xml
#define MIN_MEMORY_PACKET_SIZE
static memory_packet_config memory_write_packet_config
static void copy_threadref(threadref *dest, threadref *src)
static const char * unpack_threadid(const char *inbuf, threadref *id)
static const char * unpack_int(const char *buf, int *value)
static enum auto_boolean remote_Z_packet_detect
static void remote_unpush_target(remote_target *target)
static void add_packet_config_cmd(const unsigned int which_packet, const char *name, const char *title, int legacy)
static char * remote_hostio_error(fileio_error errnum)
static void set_pspace_remote_exec_file(struct program_space *pspace, const char *remote_exec_file)
static packet_description packets_descriptions[PACKET_MAX]
static int strprefix(const char *p, const char *pend, const char *prefix)
static void show_hardware_watchpoint_length_limit(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static struct packet_reg * packet_reg_from_regnum(struct gdbarch *gdbarch, struct remote_arch_state *rsa, long regnum)
void remote_notif_get_pending_events(remote_target *remote, const notif_client *nc)
static int map_regcache_remote_table(struct gdbarch *gdbarch, struct packet_reg *regs)
static void show_remote_cmd(const char *args, int from_tty)
const notif_client notif_client_stop
static int remote_newthread_step(threadref *ref, void *context)
static void show_packet_config_cmd(ui_file *file, const unsigned int which_packet, remote_target *remote)
static void remote_new_objfile(struct objfile *objfile)
#define CRAZY_MAX_THREADS
static void show_memory_read_packet_size(const char *args, int from_tty)
static void show_remote_exec_file(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
static void show_remote_protocol_Z_packet_cmd(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
int remote_register_number_and_offset(struct gdbarch *gdbarch, int regnum, int *pnum, int *poffset)
static remote_target * get_current_remote_target()
static void remote_packet_size(remote_target *remote, const protocol_feature *feature, enum packet_support support, const char *value)
static const target_info extended_remote_target_info
static void show_remote_protocol_packet_cmd(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void create_fetch_memtags_request(gdb::char_vector &packet, CORE_ADDR address, size_t len, int type)
static int remote_hw_watchpoint_length_limit
void remote_file_put(const char *local_file, const char *remote_file, int from_tty)
static int stubhex(int ch)
static enum packet_support packet_config_support(const packet_config *config)
static bool interrupt_on_connect
static void compare_sections_command(const char *args, int from_tty)
static void show_hardware_watchpoint_limit(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static std::string escape_buffer(const char *buf, int n)
static char * pack_threadlist_request(char *pkt, int startflag, int threadcount, threadref *nextthread)
static int remote_notif_stop_can_get_pending_events(remote_target *remote, const notif_client *self)
const char interrupt_sequence_control_c[]
static ptid_t first_remote_resumed_thread(remote_target *target)
static const registry< program_space >::key< char, gdb::xfree_deleter< char > > remote_pspace_data
static int remote_hw_watchpoint_limit
static char * pack_threadinfo_request(char *pkt, int mode, threadref *id)
static remote_thread_info * get_remote_thread_info(thread_info *thread)
static void remote_notif_stop_ack(remote_target *remote, const notif_client *self, const char *buf, struct notif_event *event)
static void parse_xml_btrace_conf(struct btrace_config *conf, const char *xml)
static ptid_t stop_reply_extract_thread(const char *stop_reply)
static const char * unpack_byte(const char *buf, int *value)
static struct cmd_list_element * remote_show_cmdlist
static std::string remote_exec_file_var
static int threadmatch(threadref *dest, threadref *src)
static void set_memory_read_packet_size(const char *args, int from_tty)
static const char *const interrupt_sequence_modes[]
static void remote_supported_packet(remote_target *remote, const struct protocol_feature *feature, enum packet_support support, const char *argument)
const char interrupt_sequence_break_g[]
static void parse_xml_btrace(struct btrace_data *btrace, const char *buffer)
static void remote_buffer_add_int(char **buffer, int *left, ULONGEST value)
void register_remote_g_packet_guess(struct gdbarch *gdbarch, int bytes, const struct target_desc *tdesc)
static void show_remotebreak(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int hexnumnstr(char *, ULONGEST, int)
@ PACKET_exec_event_feature
@ PACKET_TracepointSource
@ PACKET_qXfer_siginfo_write
@ PACKET_memory_tagging_feature
@ PACKET_QStartupWithShell
@ PACKET_qXfer_statictrace_read
@ PACKET_QEnvironmentHexEncoded
@ PACKET_EnableDisableTracepoints_feature
@ PACKET_qXfer_siginfo_read
@ PACKET_augmented_libraries_svr4_read_feature
@ PACKET_qXfer_btrace_conf
@ PACKET_QEnvironmentReset
@ PACKET_StaticTracepoints
@ PACKET_fork_event_feature
@ PACKET_ConditionalBreakpoints
@ PACKET_QEnvironmentUnset
@ PACKET_qXfer_memory_map
@ PACKET_QDisableRandomization
@ PACKET_vfork_event_feature
@ PACKET_Qbtrace_conf_bts_size
@ PACKET_qXfer_traceframe_info
@ PACKET_multiprocess_feature
@ PACKET_ConditionalTracepoints
@ PACKET_BreakpointCommands
@ PACKET_DisconnectedTracing_feature
@ PACKET_qXfer_libraries_svr4
@ PACKET_Qbtrace_conf_pt_size
const char interrupt_sequence_break[]
#define OPAQUETHREADBYTES
static void set_remotebreak(const char *args, int from_tty, struct cmd_list_element *c)
static void set_memory_packet_size(const char *args, struct memory_packet_config *config, bool target_connected)
static void remote_buffer_add_bytes(char **buffer, int *left, const gdb_byte *bytes, int len)
static remote_target * curr_quit_handler_target
static bool has_single_non_exited_thread(inferior *inf)
void _initialize_remote()
static int remote_hostio_parse_result(const char *buffer, int *retcode, fileio_error *remote_errno, const char **attachment)
static void remote_btrace_reset(remote_state *rs)
static void show_range_stepping(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void show_hardware_breakpoint_limit(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void btrace_read_config(thread_info *tp, btrace_config *conf)
static struct cmd_list_element * remote_cmdlist
static struct serial * remote_serial_open(const char *name)
static const target_info remote_target_info
void int_to_threadref(threadref *id, int value)
static bool use_range_stepping
static const char remote_doc[]
static void set_memory_write_packet_size(const char *args, int from_tty)
static void set_remote_protocol_Z_packet_cmd(const char *args, int from_tty, struct cmd_list_element *c)
static struct cmd_list_element * remote_set_cmdlist
int putpkt(remote_target *remote, const char *buf)
void remote_file_get(const char *remote_file, const char *local_file, int from_tty)
static void cli_packet_command(const char *args, int from_tty)
static const char * get_remote_exec_file(void)
#define MAXTHREADLISTRESULTS
static void set_remote_protocol_packet_cmd(const char *args, int from_tty, cmd_list_element *c)
int(* rmt_thread_action)(threadref *ref, void *context)
static const char * get_target_type_name(bool target_connected)
static serial_event_ftype remote_async_serial_handler
#define DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED
static void remote_notif_stop_parse(remote_target *remote, const notif_client *self, const char *buf, struct notif_event *event)
static const char * get_packet_support_name(auto_boolean support)
static CORE_ADDR remote_address_masked(CORE_ADDR)
static enum packet_result packet_check_result(const char *buf)
static void show_remote_packet_max_chars(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static ptid_t read_ptid(const char *buf, const char **obuf)
static struct remote_g_packet_data * get_g_packet_data(struct gdbarch *gdbarch)
static void remote_console_output(const char *msg)
static const ptid_t magic_null_ptid(42000, -1, 1)
static bool remote_read_description_p(struct target_ops *target)
bool remote_target_is_non_stop_p(remote_target *t)
static const char * unpack_string(const char *src, char *dest, int length)
static void show_memory_write_packet_size(const char *args, int from_tty)
static void set_range_stepping(const char *ignore_args, int from_tty, struct cmd_list_element *c)
#define REMOTE_SCOPED_DEBUG_ENTER_EXIT
#define remote_debug_printf_nofunc(fmt,...)
#define remote_debug_printf(fmt,...)
int serial_send_break(struct serial *scb)
int serial_setparity(struct serial *scb, int parity)
int serial_write(struct serial *scb, const void *buf, size_t count)
void serial_raw(struct serial *scb)
int serial_can_async_p(struct serial *scb)
void serial_log_command(struct target_ops *self, const char *cmd)
int serial_readchar(struct serial *scb, int timeout)
void serial_async(struct serial *scb, serial_event_ftype *handler, void *context)
struct serial * serial_open(const char *name)
int serial_flush_input(struct serial *scb)
int serial_setbaudrate(struct serial *scb, int rate)
int serial_is_async_p(struct serial *scb)
void serial_close(struct serial *scb)
void serial_event_ftype(struct serial *scb, void *context)
void solib_add(const char *pattern, int from_tty, int readsyms)
void no_shared_libraries(const char *ignored, int from_tty)
CORE_ADDR value_address() const
struct minimal_symbol * minsym
std::vector< agent_expr * > conditions
std::vector< agent_expr * > tcommands
counted_command_line commands
bp_location_range locations() const
gdb::unique_xmalloc_ptr< char > cond_string
enum enable_state enable_state
static void print_packet(gdb::array_view< const char > &buf)
void sending(gdb::array_view< const char > &buf) override
void received(gdb::array_view< const char > &buf) override
gdb::optional< setting > var
__extension__ enum cmd_types type
struct cmd_list_element * next
void set_context(void *context)
counted_command_line body_list_0
struct command_line * next
enum command_control_type control_type
gdb::unique_xmalloc_ptr< void > value
void(* ack)(remote_target *remote, const notif_client *self, const char *buf, struct notif_event *event)
struct program_space * pspace
::section_offsets section_offsets
enum packet_support support
struct objfile * symfile_object_file
enum packet_support default_support
void(* func)(remote_target *remote, const struct protocol_feature *, enum packet_support, const char *)
int pread(int fd, gdb_byte *read_buf, size_t len, ULONGEST offset)
void invalidate_fd(int fd)
std::unique_ptr< packet_reg[]> regs
remote_arch_state(struct gdbarch *gdbarch)
long actual_register_packet_size
int remote_vfork_event_p() const
DISABLE_COPY_AND_ASSIGN(remote_features)
enum packet_support packet_support(int) const
packet_config m_protocol_packets[PACKET_MAX]
memory_packet_config m_memory_read_packet_config
~remote_features()=default
void reset_all_packet_configs_support()
int remote_exec_event_p() const
packet_result packet_ok(const char *buf, const int which_packet)
int remote_fork_event_p() const
int remote_multi_process_p() const
memory_packet_config m_memory_write_packet_config
enum auto_boolean packet_set_cmd_state(int packet) const
bool remote_memory_tagging_p() const
std::vector< remote_g_packet_guess > guesses
const struct target_desc * tdesc
remote_g_packet_guess(int bytes_, const struct target_desc *tdesc_)
struct async_event_handler * get_pending_events_token
struct notif_event * pending_event[REMOTE_NOTIF_LAST]
const struct resumed_pending_vcont_info & resumed_pending_vcont_info() const
gdb::byte_vector thread_handle
void set_resumed_pending_vcont(bool step, gdb_signal sig)
enum resume_state get_resume_state() const
CORE_ADDR watch_data_address
struct resumed_pending_vcont_info m_resumed_pending_vcont_info
enum target_stop_reason stop_reason
enum resume_state m_resume_state
scoped_mark_target_starting(remote_target *target)
static scoped_restore_tmpl< bool > set_starting_up_flag(remote_target *target)
remote_target_ref m_remote_target
gdb::ref_ptr< remote_target, target_ops_ref_policy > remote_target_ref
scoped_restore_tmpl< bool > m_restore_starting_up
virtual void sending(gdb::array_view< const char > &buf)=0
virtual void received(gdb::array_view< const char > &buf)=0
std::vector< cached_reg_t > regcache
CORE_ADDR watch_data_address
struct target_waitstatus ws
enum target_stop_reason stop_reason
target_ops * beneath() const
virtual gdb::array_view< const_gdb_byte > virtual thread_info_to_thread_handle(struct thread_info *) TARGET_DEFAULT_RETURN(gdb voi stop)(ptid_t) TARGET_DEFAULT_IGNORE()
virtual const struct target_desc * read_description() TARGET_DEFAULT_RETURN(NULL)
struct bfd_section * the_bfd_section
target_waitstatus & set_stopped(gdb_signal sig)
target_waitstatus & set_ignore()
target_waitkind kind() const
std::string to_string() const
CORE_ADDR step_range_start
DISABLE_COPY_AND_ASSIGN(thread_item)
thread_item & operator=(thread_item &&other)=default
thread_item(ptid_t ptid_)
gdb::byte_vector thread_handle
void remove_thread(ptid_t ptid)
std::vector< thread_item > items
bool contains_thread(ptid_t ptid) const
ULONGEST traceframe_usage
ULONGEST traceframe_usage
void reread_symbols(int from_tty)
void generic_load(const char *args, int from_tty)
symfile_segment_data_up get_symfile_segment_data(bfd *abfd)
int symfile_map_offsets_to_segments(bfd *abfd, const struct symfile_segment_data *data, section_offsets &offsets, int num_segment_bases, const CORE_ADDR *segment_bases)
std::unique_ptr< symfile_segment_data > symfile_segment_data_up
std::vector< CORE_ADDR > section_offsets
void target_find_description(void)
void target_clear_description(void)
std::vector< target_section > target_section_table
void target_announce_detach(int from_tty)
void fileio_handles_invalidate_target(target_ops *targ)
ptid_t target_wait(ptid_t ptid, struct target_waitstatus *status, target_wait_flags options)
int target_trace_find(trace_find_type type, int num, CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
void target_async(bool enable)
gdb::optional< gdb::char_vector > target_read_stralloc(struct target_ops *ops, enum target_object object, const char *annex)
bool target_async_permitted
const struct target_section * target_section_by_addr(struct target_ops *target, CORE_ADDR addr)
int simple_verify_memory(struct target_ops *ops, const gdb_byte *data, CORE_ADDR lma, ULONGEST size)
bool target_can_async_p()
bool target_static_tracepoint_marker_at(CORE_ADDR addr, static_tracepoint_marker *marker)
void target_update_thread_list(void)
bool target_has_execution(inferior *inf)
const target_section_table * target_get_section_table(struct target_ops *target)
void add_target(const target_info &t, target_open_ftype *func, completer_ftype *completer)
void target_announce_attach(int from_tty, int pid)
LONGEST target_read(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *buf, ULONGEST offset, LONGEST len)
bool target_is_non_stop_p()
std::string target_pid_to_str(ptid_t ptid)
std::string normal_pid_to_str(ptid_t ptid)
void target_preopen(int from_tty)
void target_mourn_inferior(ptid_t ptid)
int target_verify_memory(const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
bool may_insert_fast_tracepoints
@ TARGET_XFER_UNAVAILABLE
@ TARGET_OBJECT_AVAILABLE_FEATURES
@ TARGET_OBJECT_LIBRARIES_SVR4
@ TARGET_OBJECT_BTRACE_CONF
@ TARGET_OBJECT_TRACEFRAME_INFO
@ TARGET_OBJECT_SIGNAL_INFO
@ TARGET_OBJECT_OPENVMS_UIB
@ TARGET_OBJECT_EXEC_FILE
@ TARGET_OBJECT_MEMORY_MAP
@ TARGET_OBJECT_LIBRARIES
@ TARGET_OBJECT_STATIC_TRACE_DATA
bool may_insert_tracepoints
thread_control_capabilities
bool may_insert_breakpoints
std::unique_ptr< target_ops, target_ops_deleter > target_ops_up
struct trace_status * current_trace_status(void)
void parse_trace_status(const char *line, struct trace_status *ts)
void parse_tracepoint_status(const char *p, tracepoint *tp, struct uploaded_tp *utp)
int get_traceframe_number(void)
void encode_actions_rsp(struct bp_location *tloc, std::vector< std::string > *tdp_actions, std::vector< std::string > *stepping_actions)
void parse_tsv_definition(const char *line, struct uploaded_tsv **utsvp)
void trace_reset_local_state(void)
void parse_static_tracepoint_marker_definition(const char *line, const char **pp, static_tracepoint_marker *marker)
int traceframe_available_memory(std::vector< mem_range > *result, CORE_ADDR memaddr, ULONGEST len)
std::string default_collect
void merge_uploaded_tracepoints(struct uploaded_tp **uploaded_tps)
struct std::unique_ptr< traceframe_info > parse_traceframe_info(const char *tframe_info)
int encode_source_string(int tpnum, ULONGEST addr, const char *srctype, const char *src, char *buf, int buf_size)
void parse_tracepoint_definition(const char *line, struct uploaded_tp **utpp)
void merge_uploaded_trace_state_variables(struct uploaded_tsv **uploaded_tsvs)
std::unique_ptr< traceframe_info > traceframe_info_up
int query(const char *ctlstr,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
int parse_pid_to_attach(const char *args)
@ TARGET_WAITKIND_NO_RESUMED
@ TARGET_WAITKIND_THREAD_EXITED
@ TARGET_WAITKIND_SIGNALLED
@ TARGET_WAITKIND_STOPPED
@ TARGET_WAITKIND_NO_HISTORY
@ TARGET_WAITKIND_VFORKED
@ TARGET_STOPPED_BY_SW_BREAKPOINT
@ TARGET_STOPPED_BY_WATCHPOINT
@ TARGET_STOPPED_BY_HW_BREAKPOINT
@ TARGET_STOPPED_BY_NO_REASON
void void gdb_xml_error(struct gdb_xml_parser *parser, const char *format,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF(2
void void struct gdb_xml_value * xml_find_attribute(std::vector< gdb_xml_value > &attributes, const char *name)
int gdb_xml_parse_quick(const char *name, const char *dtd_name, const struct gdb_xml_element *elements, const char *document, void *user_data)
gdb_xml_attribute_handler gdb_xml_parse_attr_ulongest