45#include "gdbsupport/filestuff.h"
46#include "gdbsupport/rsp-low.h"
50#include "gdbsupport/gdb_sys_time.h"
52#include "gdbsupport/event-loop.h"
62#include "gdbsupport/fileio.h"
71#include "gdbsupport/agent.h"
75#include "gdbsupport/scoped_restore.h"
76#include "gdbsupport/environ.h"
77#include "gdbsupport/byte-vector.h"
78#include "gdbsupport/search.h"
80#include <unordered_map>
82#include "gdbsupport/selftest.h"
87Use a remote computer via a serial line, using a gdb-specific protocol.\n\
88Specify the serial device it is connected to\n\
89(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
95#define OPAQUETHREADBYTES 8
154#define MAXTHREADLISTRESULTS 32
168 int pread (
int fd, gdb_byte *read_buf,
size_t len, ULONGEST
offset);
212 std::unique_ptr<packet_reg[]>
regs;
388 std::unordered_map<struct gdbarch *, remote_arch_state>
394 N_(
"Remote target using gdb-specific protocol"),
413 static void open (
const char *,
int);
415 void close ()
override;
421 void resume (ptid_t,
int,
enum gdb_signal)
override;
462 void kill ()
override;
464 void load (
const char *,
int)
override;
468 void pass_signals (gdb::array_view<const unsigned char>)
override;
471 gdb::array_view<const int>)
override;
494 void stop (ptid_t)
override;
503 const gdb_byte *writebuf,
504 ULONGEST offset, ULONGEST len,
505 ULONGEST *xfered_len)
override;
509 void rcmd (
const char *command,
struct ui_file *output)
override;
519 CORE_ADDR load_module_addr,
520 CORE_ADDR offset)
override;
524 std::vector<mem_region>
memory_map ()
override;
526 void flash_erase (ULONGEST address, LONGEST length)
override;
532 int search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
533 const gdb_byte *pattern, ULONGEST pattern_len,
534 CORE_ADDR *found_addrp)
override;
540 void async (
bool)
override;
562 int flags,
int mode,
int warn_if_slow,
563 fileio_error *target_errno)
override;
565 int fileio_pwrite (
int fd,
const gdb_byte *write_buf,
int len,
566 ULONGEST offset, fileio_error *target_errno)
override;
569 ULONGEST offset, fileio_error *target_errno)
override;
571 int fileio_fstat (
int fd,
struct stat *sb, fileio_error *target_errno)
override;
573 int fileio_close (
int fd, fileio_error *target_errno)
override;
576 const char *filename,
577 fileio_error *target_errno)
override;
579 gdb::optional<std::string>
581 const char *filename,
582 fileio_error *target_errno)
override;
616 CORE_ADDR addr1, CORE_ADDR addr2,
int *tpp)
override;
637 const char *stopnotes)
override;
642 CORE_ADDR memaddr, ULONGEST
size)
override;
653 std::vector<static_tracepoint_marker>
668 enum btrace_error
read_btrace (
struct btrace_data *data,
670 enum btrace_read_type
type)
override;
687 gdb::byte_vector &tags,
int type)
override;
690 const gdb::byte_vector &tags,
int type)
override;
704 ULONGEST offset, fileio_error *remote_errno);
706 ULONGEST offset, fileio_error *remote_errno);
708 ULONGEST offset, fileio_error *remote_errno);
711 fileio_error *remote_errno,
const char **attachment,
712 int *attachment_len);
714 fileio_error *remote_errno);
717 int flags,
int mode,
int warn_if_slow,
718 fileio_error *remote_errno);
722 fileio_error *remote_errno);
734 static void open_1 (
const char *
name,
int from_tty,
int extended_p);
739 ptid_t ptid,
int step, gdb_signal siggnal);
746 target_wait_flags options);
748 target_wait_flags options);
774 (
bool *may_global_wildcard_vcont);
799 char *
write_ptid (
char *buf,
const char *endbuf, ptid_t ptid);
811 int result_limit,
int *done,
int *result_count,
815 void *context,
int looplimit);
829 const char *argument);
865 const gdb_byte *myaddr,
868 ULONGEST *xfered_len_units,
873 const gdb_byte *myaddr, ULONGEST len,
874 int unit_size, ULONGEST *xfered_len);
878 int unit_size, ULONGEST *xfered_len_units);
884 ULONGEST *xfered_len);
887 gdb_byte *myaddr, ULONGEST len,
889 ULONGEST *xfered_len);
895 ULONGEST length, ULONGEST *xfered_len,
896 const gdb_byte *data);
902 int putpkt (const
char *buf);
907 return putpkt (buf.data ());
912 void getpkt (gdb::char_vector *buf,
int forever);
914 int expecting_notif,
int *is_notif);
915 int getpkt_sane (gdb::char_vector *buf,
int forever);
933 const gdb_byte *writebuf,
934 ULONGEST offset, LONGEST len,
935 ULONGEST *xfered_len,
940 gdb_byte *readbuf, ULONGEST offset,
942 ULONGEST *xfered_len,
960 N_(
"Extended remote target using gdb-specific protocol"),
974 static void open (
const char *,
int);
978 char **,
int)
override;
983 void attach (
const char *,
int)
override;
1065static int hexnumnstr (
char *, ULONGEST,
int);
1078static ptid_t
read_ptid (
const char *buf,
const char **obuf);
1233 error (_(
"remote.c: error in outgoing packet."));
1235 error (_(
"remote.c: error in outgoing packet at field #%ld."),
1236 strtol (buf, NULL, 16));
1238 error (_(
"Target returns error code '%s'."), buf);
1255 buf = rs->
buf.data ();
1258 else if (startswith (buf,
"qRelocInsn:"))
1261 CORE_ADDR from, to, org_to;
1263 int adjusted_size = 0;
1266 p = buf + strlen (
"qRelocInsn:");
1267 pp = unpack_varlen_hex (p, &ul);
1269 error (_(
"invalid qRelocInsn packet: %s"), buf);
1273 unpack_varlen_hex (p, &ul);
1283 catch (
const gdb_exception &ex)
1285 if (ex.error == MEMORY_ERROR)
1298 _(
"warning: relocating instruction: "));
1305 adjusted_size = to - org_to;
1307 xsnprintf (buf, rs->
buf.size (),
"qRelocInsn:%x", adjusted_size);
1311 else if (buf[0] ==
'O' && buf[1] !=
'K')
1327 auto p = this->
m_arch_states.emplace (std::piecewise_construct,
1328 std::forward_as_tuple (
gdbarch),
1329 std::forward_as_tuple (
gdbarch));
1330 rsa = &p.first->second;
1363 char *remote_exec_file;
1366 if (remote_exec_file == NULL)
1369 return remote_exec_file;
1376 const char *remote_exec_file)
1406 int regnum, num_remote_regs, offset;
1427 for (num_remote_regs = 0,
regnum = 0;
1431 remote_regs[num_remote_regs++] = ®s[
regnum];
1433 std::sort (remote_regs, remote_regs + num_remote_regs,
1455 int *
pnum,
int *poffset)
1464 *poffset = regs[
regnum].offset;
1583 _(
"Send the ASCII ETX character (Ctrl-c) "
1584 "to the remote target to interrupt the "
1585 "execution of the program.\n"));
1588 _(
"send a break signal to the remote target "
1589 "to interrupt the execution of the program.\n"));
1592 _(
"Send a break signal and 'g' a.k.a. Magic SysRq g to "
1593 "the remote target to interrupt the execution "
1594 "of Linux kernel.\n"));
1596 internal_error (_(
"Invalid value for interrupt_sequence_mode: %s."),
1660#define DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED 16384
1664#define MIN_MEMORY_PACKET_SIZE 20
1673 if (config->
size <= 0)
1676 return config->
size;
1695 if (config->
size > 0
1696 && what_they_get > config->
size)
1697 what_they_get = config->
size;
1711 if (rs->
buf.size () < what_they_get + 1)
1712 rs->
buf.resize (2 * what_they_get);
1714 return what_they_get;
1723 int fixed_p = config->
fixed_p;
1727 error (_(
"Argument required (integer, `fixed' or `limited')."));
1728 else if (strcmp (args,
"hard") == 0
1729 || strcmp (args,
"fixed") == 0)
1731 else if (strcmp (args,
"soft") == 0
1732 || strcmp (args,
"limit") == 0)
1738 size = strtoul (args, &end, 0);
1740 error (_(
"Invalid %s (bad syntax)."), config->
name);
1748 if (fixed_p && !config->
fixed_p)
1751 long query_size = (
size <= 0
1755 if (!
query (_(
"The target may not be able to correctly handle a %s\n"
1756 "of %ld bytes. Change the packet size? "),
1757 config->
name, query_size))
1758 error (_(
"Packet size not changed."));
1768 if (config->
size == 0)
1773 gdb_printf (_(
"Packets are fixed at %ld bytes.\n"),
1780 gdb_printf (_(
"Packets are limited to %ld bytes.\n"),
1783 gdb_puts (
"The actual limit will be further reduced "
1784 "dependent on the target.\n");
1791 "memory-write-packet-size",
1813 gdb_printf (file, _(
"The maximum number of target hardware "
1814 "watchpoints is %s.\n"),
value);
1824 gdb_printf (file, _(
"The maximum length (in bytes) of a target "
1825 "hardware watchpoint is %s.\n"),
value);
1835 gdb_printf (file, _(
"The maximum number of target hardware "
1836 "breakpoints is %s.\n"),
value);
1852 gdb_printf (file, _(
"Number of remote packet characters to "
1853 "display is %s.\n"),
value);
1865 "memory-read-packet-size",
1920 const char *support =
"internal-error";
1925 support =
"enabled";
1928 support =
"disabled";
1931 support =
"unknown";
1938 _(
"Support for the `%s' packet "
1939 "is auto-detected, currently %s.\n"),
1940 config->
name, support);
1945 _(
"Support for the `%s' packet is currently %s.\n"),
1946 config->
name, support);
1953 const char *title,
int legacy)
1956 config->
title = title;
1957 gdb::unique_xmalloc_ptr<char> set_doc
1958 = xstrprintf (
"Set use of remote protocol `%s' (%s) packet.",
1960 gdb::unique_xmalloc_ptr<char> show_doc
1961 = xstrprintf (
"Show current use of remote protocol `%s' (%s) packet.",
1964 gdb::unique_xmalloc_ptr<char> cmd_name = xstrprintf (
"%s-packet", title);
1967 &config->
detect, set_doc.get (),
1968 show_doc.get (), NULL,
1980 static std::vector<gdb::unique_xmalloc_ptr<char>> legacy_names;
1981 gdb::unique_xmalloc_ptr<char> legacy_name
1982 = xstrprintf (
"%s-packet",
name);
1987 legacy_names.emplace_back (std::move (legacy_name));
1999 && isxdigit (buf[1]) && isxdigit (buf[2])
2006 if (buf[0] ==
'E' && buf[1] ==
'.')
2030 internal_error (_(
"packet_ok: attempt to use a disabled packet"));
2052 error (_(
"Protocol error: %s (%s) conflicting enabled responses."),
2058 error (_(
"Enabled packet %s (%s) not recognized by stub"),
2254 gdb_assert_not_reached (
"bad switch");
2275 gdb_assert (c->
var.has_value ());
2287 internal_error (_(
"Could not find config for %s"),
2452 xsnprintf (rs->
buf.data (),
size,
"qAttached:%x",
pid);
2454 xsnprintf (rs->
buf.data (),
size,
"qAttached");
2463 if (strcmp (rs->
buf.data (),
"1") == 0)
2467 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
2537 inf->push_target (
this);
2541 inf->attach_flag = attached;
2542 inf->fake_pid_p = fake_pid_p;
2622 int pid = currthread.pid ();
2664 currthread.pid (), -1, 1);
2690 gdb_assert (thread != NULL);
2692 if (thread->
priv == NULL)
2695 return gdb::checked_static_cast<remote_thread_info *> (thread->
priv.get ());
2726 char *pass_packet, *p;
2736 pass_packet = (
char *)
xmalloc (count * 3 + strlen (
"QPassSignals:") + 1);
2737 strcpy (pass_packet,
"QPassSignals:");
2738 p = pass_packet + strlen (pass_packet);
2744 *p++ = tohex (i >> 4);
2745 *p++ = tohex (i & 15);
2763 xfree (pass_packet);
2772 gdb::array_view<const int> syscall_counts)
2774 const char *catch_packet;
2784 if (needed && any_count == 0)
2787 for (
size_t i = 0; i < syscall_counts.size (); i++)
2789 if (syscall_counts[i] != 0)
2795 pid, needed, any_count, n_sysno);
2797 std::string built_packet;
2803 const int maxpktsz = strlen (
"QCatchSyscalls:1") + n_sysno * 9 + 1;
2804 built_packet.reserve (maxpktsz);
2805 built_packet =
"QCatchSyscalls:1";
2809 for (
size_t i = 0; i < syscall_counts.size (); i++)
2811 if (syscall_counts[i] != 0)
2812 string_appendf (built_packet,
";%zx", i);
2819 catch_packet =
"QCatchSyscalls:1";
2822 catch_packet = built_packet.c_str ();
2825 catch_packet =
"QCatchSyscalls:0";
2850 gdb_assert (signals.size () < 256);
2851 for (
size_t i = 0; i < signals.size (); i++)
2856 packet = (
char *)
xmalloc (count * 3 + strlen (
"QProgramSignals:") + 1);
2857 strcpy (packet,
"QProgramSignals:");
2858 p = packet + strlen (packet);
2859 for (
size_t i = 0; i < signals.size (); i++)
2864 *p++ = tohex (i >> 4);
2865 *p++ = tohex (i & 15);
2897 char *buf = rs->
buf.data ();
2904 *buf++ = gen ?
'g' :
'c';
2906 xsnprintf (buf, endbuf - buf,
"0");
2908 xsnprintf (buf, endbuf - buf,
"0");
2909 else if (ptid == minus_one_ptid)
2910 xsnprintf (buf, endbuf - buf,
"-1");
2968 if (ptid.pid () != 0 && ptid.lwp () == 0)
2991 p = rs->
buf.data ();
2999 return (rs->
buf[0] ==
'O' && rs->
buf[1] ==
'K');
3008 if (
info->priv != NULL)
3011 return !
name.empty () ?
name.c_str () : NULL;
3052#define TAG_THREADID 1
3054#define TAG_DISPLAY 4
3055#define TAG_THREADNAME 8
3056#define TAG_MOREDISPLAY 16
3058#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES * 2)
3060static const char *
unpack_nibble (
const char *buf,
int *val);
3068static const char *
unpack_string (
const char *src,
char *dest,
int length);
3106 buf += xsnprintf (buf, endbuf - buf,
"p-%x.", -
pid);
3108 buf += xsnprintf (buf, endbuf - buf,
"p%x.",
pid);
3112 buf += xsnprintf (buf, endbuf - buf,
"-%x", -tid);
3114 buf += xsnprintf (buf, endbuf - buf,
"%x", tid);
3126 const char *p =
buf;
3128 ULONGEST
pid = 0, tid = 0;
3133 pp = unpack_varlen_hex (p + 1, &
pid);
3135 error (_(
"invalid remote ptid: %s"), p);
3138 pp = unpack_varlen_hex (p + 1, &tid);
3141 return ptid_t (
pid, tid);
3145 pp = unpack_varlen_hex (p, &tid);
3167 return ptid_t (
pid, tid);
3173 if (ch >=
'a' && ch <=
'f')
3174 return ch -
'a' + 10;
3175 if (ch >=
'0' && ch <=
'9')
3177 if (ch >=
'A' && ch <=
'F')
3178 return ch -
'A' + 10;
3194 retval = retval << 4;
3202 *val = fromhex (*
buf++);
3231static char *pack_string (
char *pkt,
char *
string);
3234pack_string (
char *pkt,
char *
string)
3239 len = strlen (
string);
3242 pkt = pack_hex_byte (pkt, len);
3246 if ((ch ==
'\0') || (ch ==
'#'))
3267 unsigned char *altid;
3269 altid = (
unsigned char *)
id;
3272 pkt = pack_hex_byte (pkt, *altid++);
3284 altref = (
char *)
id;
3286 while (inbuf < limit)
3290 *altref++ = (x << 4) | y;
3303 unsigned char *
scan;
3305 scan = (
unsigned char *)
id;
3321 unsigned char *
scan;
3335 unsigned char *csrc, *cdest;
3337 csrc = (
unsigned char *) src;
3338 cdest = (
unsigned char *) dest;
3349 unsigned char *srcp, *destp;
3351 srcp = (
char *) src;
3352 destp = (
char *) dest;
3356 result &= (*srcp++ == *destp++) ? 1 : 0;
3387#define TAG_THREADID 1
3390#define TAG_DISPLAY 4
3391#define TAG_THREADNAME 8
3392#define TAG_MOREDISPLAY 16
3404 const char *limit = pkt + rs->
buf.size ();
3409 info->display[0] =
'\0';
3411 info->more_display[0] =
'\0';
3419 warning (_(
"Incomplete response to threadinfo request."));
3422 warning (_(
"ERROR RMT Thread info mismatch."));
3430 while ((pkt < limit) && mask && *pkt)
3436 warning (_(
"ERROR RMT: threadinfo tag mismatch."));
3444 warning (_(
"ERROR RMT: length of threadid is not 16."));
3449 mask = mask & ~TAG_THREADID;
3459 warning (_(
"ERROR RMT: 'exists' length too long."));
3468 mask = mask & ~TAG_THREADNAME;
3474 mask = mask & ~TAG_DISPLAY;
3480 mask = mask & ~TAG_MOREDISPLAY;
3483 warning (_(
"ERROR RMT: unknown thread info tag."));
3501 if (rs->
buf[0] ==
'\0')
3517 pkt = pack_nibble (pkt, startflag);
3518 pkt = pack_hex_byte (pkt, threadcount);
3533 int count, resultcount, done;
3543 while ((count-- > 0) && (pkt < limit))
3546 if (resultcount++ >= result_limit)
3559 int result_limit,
int *done,
int *result_count,
3574 if (rs->
buf[0] ==
'\0')
3594 warning (_(
"HMM: threadlist did not echo arg thread, dropping it."));
3597 if (*result_count <= 0)
3601 warning (_(
"RMT ERROR : failed to get remote thread list."));
3606 if (*result_count > result_limit)
3609 warning (_(
"RMT ERROR: threadlist response longer than requested."));
3623 void *context,
int looplimit)
3626 int done, i, result_count;
3634 if (loopcount++ > looplimit)
3637 warning (_(
"Remote fetch threadlist -infinite loop-."));
3642 &done, &result_count,
3649 if (result_count >= 1)
3653 while (result_count--)
3707 return item.
ptid == ptid;
3710 auto it = std::find_if (this->
items.begin (),
3714 return it != this->
items.end ();
3723 return item.
ptid == ptid;
3726 auto it = std::remove_if (this->
items.begin (),
3730 if (it != this->
items.end ())
3731 this->
items.erase (it);
3735 std::vector<thread_item>
items;
3745 ptid_t ptid (
pid, lwp);
3747 context->
items.emplace_back (ptid);
3752#define CRAZY_MAX_THREADS 1000
3761 if (rs->
buf[0] ==
'Q' && rs->
buf[1] ==
'C')
3788#if defined(HAVE_LIBEXPAT)
3791start_thread (
struct gdb_xml_parser *parser,
3803 data->items.emplace_back (ptid);
3808 item.
core = *(ULONGEST *) attr->
value.get ();
3812 item.
name = (
const char *) attr->
value.get ();
3820end_thread (
struct gdb_xml_parser *parser,
3822 void *user_data,
const char *body_text)
3827 if (body_text != NULL && *body_text !=
'\0')
3828 data->items.back ().extra = body_text;
3844 {
"thread", thread_attributes, thread_children,
3846 start_thread, end_thread },
3851 {
"threads", NULL, threads_children,
3863#if defined(HAVE_LIBEXPAT)
3866 gdb::optional<gdb::char_vector> xml
3869 if (xml && (*xml)[0] !=
'\0')
3872 threads_elements, xml->data (), context);
3895 bufp = rs->
buf.data ();
3896 if (bufp[0] !=
'\0')
3898 while (*bufp++ ==
'm')
3903 context->
items.emplace_back (ptid);
3905 while (*bufp++ ==
',');
3908 bufp = rs->
buf.data ();
3928 for (
thread_info *tp ATTRIBUTE_UNUSED :
inf->non_exited_threads ())
3952 if (context.
items.empty ()
3968 if (tp->inf->process_target () !=
this)
3994 if (item.
ptid != null_ptid)
4008 info->name = std::move (item.
name);
4042 internal_error (_(
"remote_threads_extra_info"));
4045 || (tp->
ptid.pid () != 0 && tp->
ptid.lwp () == 0))
4053 if (!extra.empty ())
4054 return extra.c_str ();
4066 char *b = rs->
buf.data ();
4069 xsnprintf (b, endb - b,
"qThreadExtraInfo,");
4075 if (rs->
buf[0] != 0)
4077 extra.resize (strlen (rs->
buf.data ()) / 2);
4078 hex2bin (rs->
buf.data (), (gdb_byte *) &extra[0], extra.size ());
4079 return extra.c_str ();
4092 string_appendf (extra,
" Name: %s", threadinfo.
shortname);
4095 if (!extra.empty ())
4097 string_appendf (extra,
" State: %s", threadinfo.
display);
4101 if (!extra.empty ())
4103 string_appendf (extra,
" Priority: %s", threadinfo.
more_display);
4105 return extra.c_str ();
4116 char *p = rs->
buf.data ();
4123 p = rs->
buf.data ();
4126 error (_(
"Remote failure reply: %s"), p);
4137std::vector<static_tracepoint_marker>
4141 std::vector<static_tracepoint_marker> markers;
4149 p = rs->
buf.data ();
4151 error (_(
"Remote failure reply: %s"), p);
4159 if (strid == NULL || marker.
str_id == strid)
4160 markers.push_back (std::move (marker));
4162 while (*p++ ==
',');
4166 p = rs->
buf.data ();
4239 int lose, num_segments = 0, do_sections, do_segments;
4240 CORE_ADDR text_addr, data_addr, bss_addr, segments[2];
4247 buf = rs->
buf.data ();
4249 if (buf[0] ==
'\000')
4254 warning (_(
"Remote failure reply: %s"), buf);
4262 text_addr = data_addr = bss_addr = 0;
4266 if (startswith (ptr,
"Text="))
4270 while (*ptr && *ptr !=
';')
4271 text_addr = (text_addr << 4) + fromhex (*ptr++);
4273 if (startswith (ptr,
";Data="))
4276 while (*ptr && *ptr !=
';')
4277 data_addr = (data_addr << 4) + fromhex (*ptr++);
4282 if (!lose && startswith (ptr,
";Bss="))
4285 while (*ptr && *ptr !=
';')
4286 bss_addr = (bss_addr << 4) + fromhex (*ptr++);
4288 if (bss_addr != data_addr)
4289 warning (_(
"Target reported unsupported offsets: %s"), buf);
4294 else if (startswith (ptr,
"TextSeg="))
4298 while (*ptr && *ptr !=
';')
4299 text_addr = (text_addr << 4) + fromhex (*ptr++);
4302 if (startswith (ptr,
";DataSeg="))
4305 while (*ptr && *ptr !=
';')
4306 data_addr = (data_addr << 4) + fromhex (*ptr++);
4314 error (_(
"Malformed response to offset query, %s"), buf);
4315 else if (*ptr !=
'\0')
4316 warning (_(
"Target reported unsupported offsets: %s"), buf);
4322 do_segments = (data != NULL);
4323 do_sections = num_segments == 0;
4325 if (num_segments > 0)
4327 segments[0] = text_addr;
4328 segments[1] = data_addr;
4334 else if (data !=
nullptr && data->segments.size () == 2)
4336 segments[0] = data->segments[0].base + text_addr;
4337 segments[1] = data->segments[1].base + data_addr;
4345 else if (data && data->segments.size () == 1)
4347 segments[0] = data->segments[0].base + text_addr;
4358 num_segments, segments);
4360 if (ret == 0 && !do_sections)
4361 error (_(
"Can not handle qOffsets TextSeg "
4362 "response with this symbol file"));
4401 internal_error (_(
"Invalid value for interrupt_sequence_mode: %s."),
4424 p1 = strchr (p,
':');
4428 if (strncmp (p,
"thread", p1 - p) == 0)
4431 p1 = strchr (p,
';');
4452 ptid_t ptid = null_ptid;
4457 if (wait_status != NULL)
4459 if (ptid == null_ptid)
4482 bool fake_pid_p =
false;
4490 if (curr_ptid != null_ptid)
4547 enum gdb_signal sig = ws.
sig ();
4572 while (pending_stop_replies-- > 0)
4574 ptid_t waiton_ptid = minus_one_ptid;
4577 int ignore_event = 0;
4605 enum gdb_signal sig = ws.
sig ();
4609 if (sig == GDB_SIGNAL_TRAP)
4616 || ws.
sig () != GDB_SIGNAL_0)
4628 inf->needs_setup =
true;
4657 if (
inf->needs_setup)
4682 if (lowest_stopped == NULL
4684 || thread->per_inf_num < lowest_stopped->
per_inf_num)
4685 lowest_stopped = thread;
4697 thread = lowest_stopped;
4724 static scoped_restore_tmpl<bool>
4729 return make_scoped_restore (&rs->
starting_up,
true);
4789 const char v_mustreplyempty[] =
"vMustReplyEmpty";
4791 putpkt (v_mustreplyempty);
4793 if (strcmp (rs->
buf.data (),
"OK") == 0)
4795 else if (strcmp (rs->
buf.data (),
"") != 0)
4796 error (_(
"Remote replied unexpectedly to '%s': %s"), v_mustreplyempty,
4816 putpkt (
"QStartNoAckMode");
4849 error (_(
"Non-stop mode requested, but remote "
4850 "does not support non-stop"));
4855 if (strcmp (rs->
buf.data (),
"OK") != 0)
4856 error (_(
"Remote refused setting non-stop mode with: %s"),
4872 if (strcmp (rs->
buf.data (),
"OK") != 0)
4873 error (_(
"Remote refused setting all-stop mode with: %s"),
4894 char *wait_status = NULL;
4896 if (rs->
buf[0] ==
'W' || rs->
buf[0] ==
'X')
4899 error (_(
"The target is not running (try extended-remote?)"));
4905 wait_status = (
char *) alloca (strlen (rs->
buf.data ()) + 1);
4906 strcpy (wait_status, rs->
buf.data ());
4930 if (curr_thread == null_ptid)
4938 "current thread; picking first in list.");
4976 gdb_assert (wait_status != NULL);
4997 if (strcmp (rs->
buf.data (),
"OK") != 0)
5011 error (_(
"The target is not running (try extended-remote?)"));
5035 if (
inf->pspace->symfile_object_file ==
nullptr)
5053 gdb_printf (_(
"Trace is already running on the target.\n"));
5163 while (startswith (reply.data (),
"qSymbol:"))
5168 end = hex2bin (tmp,
reinterpret_cast <gdb_byte *
> (msg.data ()),
5186 phex_nz (sym_addr, addr_size), &reply[8]);
5197 static int udp_warning = 0;
5203 if (!udp_warning && startswith (
name,
"udp:"))
5205 warning (_(
"The remote protocol may be unreliable over UDP.\n"
5206 "Some events may be lost, rendering further debugging "
5229 "WriteReg:%x;WriteMem:%x;"
5230 "InsertBreak:%x;InsertTrace:%x;"
5231 "InsertFastTrace:%x;Stop:%x",
5240 if (strcmp (rs->
buf.data (),
"OK") != 0)
5241 warning (_(
"Remote refused setting permissions with: %s"),
5276 const char *argument)
5280 warning (_(
"Remote qSupported response supplied an unexpected value for"
5281 " \"%s\"."), feature->
name);
5302 warning (_(
"Remote target reported \"%s\" without a size."),
5308 packet_size = strtol (
value, &value_end, 16);
5309 if (errno != 0 || *value_end !=
'\0' || packet_size < 0)
5311 warning (_(
"Remote target reported \"%s\" with a bad size: \"%s\"."),
5441#if defined(HAVE_LIBEXPAT)
5448 char *p = strtok_r (copy,
",", &saveptr);
5452 if (strcmp (p, xml) == 0)
5459 while ((p = strtok_r (NULL,
",", &saveptr)) != NULL);
5474 msg->append (append);
5536 q =
"qSupported:" + q;
5546 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
5551 memset (seen, 0,
sizeof (seen));
5553 next = rs->
buf.data ();
5557 char *p, *end, *name_end, *
value;
5563 end = strchr (p,
';');
5566 end = p + strlen (p);
5576 warning (_(
"empty item in \"qSupported\" response"));
5581 name_end = strchr (p,
'=');
5586 value = name_end + 1;
5607 warning (_(
"unrecognized item \"%s\" "
5608 "in \"qSupported\" response"), p);
5621 feature->
func (
this, feature, is_supported,
value);
5680 if (
query (_(
"The target is not responding to GDB commands.\n"
5681 "Stop debugging it? ")))
5738 throw_error (TARGET_CLOSE_ERROR, _(
"Disconnected from target."));
5747 error (_(
"To open a remote debug connection, you need to specify what\n"
5748 "serial device is attached to the remote system\n"
5749 "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.)."));
5757 && !
query (_(
"Already connected to a remote target. Disconnect? ")))
5758 error (_(
"Still connected."));
5805 gdb_puts (
"Remote debugging using ");
5877 catch (
const gdb_exception &ex)
5881 if (ex.error != TARGET_CLOSE_ERROR)
5937 strcpy (rs->
buf.data (),
"D");
5942 if (rs->
buf[0] ==
'O' && rs->
buf[1] ==
'K')
5944 else if (rs->
buf[0] ==
'\0')
5945 error (_(
"Remote doesn't know how to detach"));
5947 error (_(
"Can't detach process."));
5964 error (_(
"No process to detach from."));
5983 gdb_puts (_(
"Ending remote debugging.\n"));
6002 if (reply->ptid.pid () !=
pid)
6015 is_fork_parent = (tp != NULL
6020 if (!is_fork_parent)
6028 gdb_printf (_(
"[Inferior %d (%s) detached]\n"),
6029 inf->num, infpid.c_str ());
6089 const char *execd_pathname)
6107 error (_(
"Argument given to \"disconnect\" when remotely debugging."));
6116 gdb_puts (
"Ending remote debugging.\n");
6127 char *wait_status = NULL;
6135 error (_(
"This target does not support attaching to a process"));
6150 wait_status = (
char *) alloca (strlen (rs->
buf.data ()) + 1);
6151 strcpy (wait_status, rs->
buf.data ());
6153 else if (strcmp (rs->
buf.data (),
"OK") != 0)
6154 error (_(
"Attaching to %s failed with: %s"),
6159 error (_(
"This target does not support attaching to a process"));
6161 error (_(
"Attaching to %s failed"),
6175 if (thread !=
nullptr)
6201 gdb_assert (wait_status != NULL);
6210 gdb_assert (wait_status == NULL);
6243 strcpy (rs->
buf.data (),
"vCont?");
6246 buf = rs->
buf.data ();
6249 if (startswith (buf,
"vCont"))
6252 int support_c, support_C;
6260 while (p && *p ==
';')
6263 if (*p ==
's' && (*(p + 1) ==
';' || *(p + 1) == 0))
6265 else if (*p ==
'S' && (*(p + 1) ==
';' || *(p + 1) == 0))
6267 else if (*p ==
'c' && (*(p + 1) ==
';' || *(p + 1) == 0))
6269 else if (*p ==
'C' && (*(p + 1) ==
';' || *(p + 1) == 0))
6271 else if (*p ==
't' && (*(p + 1) ==
';' || *(p + 1) == 0))
6273 else if (*p ==
'r' && (*(p + 1) ==
';' || *(p + 1) == 0))
6276 p = strchr (p,
';');
6281 if (!support_c || !support_C)
6300 ptid_t ptid,
int step, gdb_signal siggnal)
6304 if (step && siggnal != GDB_SIGNAL_0)
6305 p += xsnprintf (p, endp - p,
";S%02x", siggnal);
6319 if (ptid == minus_one_ptid)
6327 gdb_assert (tp != NULL);
6333 p += xsnprintf (p, endp - p,
";r%s,%s",
6340 p += xsnprintf (p, endp - p,
";s");
6343 p += xsnprintf (p, endp - p,
";s");
6344 else if (siggnal != GDB_SIGNAL_0)
6345 p += xsnprintf (p, endp - p,
";C%02x", siggnal);
6347 p += xsnprintf (p, endp - p,
";c");
6354 nptid = ptid_t (ptid.pid (), -1);
6356 p += xsnprintf (p, endp - p,
":");
6359 else if (ptid != minus_one_ptid)
6361 p += xsnprintf (p, endp - p,
":");
6373 if (thread->
priv != NULL)
6391 && thread->stop_signal () != GDB_SIGNAL_0)
6394 0, thread->stop_signal ());
6395 thread->set_stop_signal (GDB_SIGNAL_0);
6417 if (ptid == minus_one_ptid)
6425 buf = rs->
buf.data ();
6430 warning (_(
" - Can't pass signal %d to target in reverse: ignored."),
6434 error (_(
"Remote reverse-step not supported."));
6436 error (_(
"Remote reverse-continue not supported."));
6438 strcpy (buf, step ?
"bs" :
"bc");
6440 else if (siggnal != GDB_SIGNAL_0)
6442 buf[0] = step ?
'S' :
'C';
6443 buf[1] = tohex (((
int) siggnal >> 4) & 0xf);
6444 buf[2] = tohex (((
int) siggnal) & 0xf);
6448 strcpy (buf, step ?
"s" :
"c");
6462 enum gdb_signal siggnal)
6478 p = rs->
buf.data ();
6485 p += xsnprintf (p, endp - p,
"vCont");
6495 else if (scope_ptid == minus_one_ptid || scope_ptid.is_pid ())
6501 if (step || siggnal != GDB_SIGNAL_0)
6529 if (strcmp (rs->
buf.data (),
"OK") != 0)
6530 error (_(
"Unexpected vCont reply in non-stop mode: %s"),
6613 if (
inf->priv == NULL)
6616 return gdb::checked_static_cast<remote_inferior *> (
inf->priv.get ());
6633 void push_action (ptid_t ptid,
bool step, gdb_signal siggnal);
6679 if (strcmp (rs->
buf.data (),
"OK") != 0)
6680 error (_(
"Unexpected vCont reply in non-stop mode: %s"), rs->
buf.data ());
6687#define MAX_ACTION_SIZE 200
6700 ptid, step, siggnal);
6705 size_t rsize = endp - buf;
6715 memcpy (
m_p, buf, rsize);
6781 bool may_global_wildcard_vcont =
true;
6795 bool any_pending_vcont_resume =
false;
6809 may_global_wildcard_vcont =
false;
6814 any_pending_vcont_resume =
true;
6820 may_global_wildcard_vcont =
false;
6825 if (!any_pending_vcont_resume)
6860 if (
info.step ||
info.sig != GDB_SIGNAL_0
6870 bool any_process_wildcard =
false;
6876 any_process_wildcard =
true;
6881 if (any_process_wildcard)
6886 if (may_global_wildcard_vcont)
6889 false, GDB_SIGNAL_0);
6898 false, GDB_SIGNAL_0);
6937 char *p = rs->
buf.data ();
6944 bool needs_commit =
false;
6954 if (
info.sig != GDB_SIGNAL_0)
6959 needs_commit =
true;
6976 "vCont-resume (%d, %ld, %s)", tp->ptid.pid(),
6978 pulongest (tp->ptid.tid ()));
6985 gdb_assert (
info.sig == GDB_SIGNAL_0);
6988 sr->
ptid = tp->ptid;
6991 sr->
arch = tp->inf->gdbarch;
7015 error (_(
"Remote server does not support stopping threads"));
7017 if (ptid == minus_one_ptid
7019 p += xsnprintf (p, endp - p,
"vCont;t");
7024 p += xsnprintf (p, endp - p,
"vCont;t:");
7028 nptid = ptid_t (ptid.pid (), -1);
7047 if (strcmp (rs->
buf.data (),
"OK") != 0)
7082 char *p = rs->
buf.data ();
7085 xsnprintf (p, endp - p,
"vCtrlC");
7097 error (_(
"No support for interrupting the remote target."));
7099 error (_(
"Interrupting target failed: %s"), rs->
buf.data ());
7162 if (
query (_(
"The target is not responding to interrupt requests.\n"
7163 "Stop debugging it? ")))
7166 throw_error (TARGET_CLOSE_ERROR, _(
"Disconnected from target."));
7171 if (
query (_(
"Interrupted while waiting for the program.\n"
7172 "Give up waiting? ")))
7200 for (p = msg; p[0] && p[1]; p += 2)
7203 char c = fromhex (p[0]) * 16 + fromhex (p[1]);
7328 (
bool *may_global_wildcard)
7341 *may_global_wildcard =
false;
7346 *may_global_wildcard =
false;
7347 if (event->ptid != null_ptid)
7373 if (reply != NULL && reply->
ptid.pid () ==
inf->
pid)
7379 (
"discarding in-flight notification: ptid: %s, ws: %s\n",
7380 reply->
ptid.to_string().c_str(),
7391 return event->ptid.pid () == inf->pid;
7395 (
"discarding queued stop reply: ptid: %s, ws: %s\n",
7396 reply->
ptid.to_string().c_str(),
7414 return event->rs == rs;
7431 return event->ptid.matches (ptid);
7438 result = iter->release ();
7444 "notif: discard queued event: 'Stop' in %s\n",
7445 ptid.to_string ().c_str ());
7482 "notif: push 'Stop' %s to queue %d\n",
7483 new_event->
ptid.to_string ().c_str (),
7501 if (ptid == event->ptid
7513 for ( ; p < pend; p++,
prefix++)
7530 event->ptid = null_ptid;
7532 event->ws.set_ignore ();
7534 event->regcache.clear ();
7553 p1 = strchr (p,
':');
7555 error (_(
"Malformed packet(a) (missing colon): %s\n\
7559 error (_(
"Malformed packet(a) (missing register number): %s\n\
7572 else if (
strprefix (p, p1,
"syscall_entry"))
7576 p = unpack_varlen_hex (++p1, &sysno);
7577 event->ws.set_syscall_entry ((
int) sysno);
7579 else if (
strprefix (p, p1,
"syscall_return"))
7583 p = unpack_varlen_hex (++p1, &sysno);
7584 event->ws.set_syscall_return ((
int) sysno);
7591 p = unpack_varlen_hex (++p1, &addr);
7592 event->watch_data_address = (CORE_ADDR) addr;
7601 error (_(
"Unexpected swbreak stop reason"));
7606 p = strchrnul (p1 + 1,
';');
7615 error (_(
"Unexpected hwbreak stop reason"));
7618 p = strchrnul (p1 + 1,
';');
7622 event->ws.set_loaded ();
7623 p = strchrnul (p1 + 1,
';');
7625 else if (
strprefix (p, p1,
"replaylog"))
7627 event->ws.set_no_history ();
7630 p = strchrnul (p1 + 1,
';');
7636 p = unpack_varlen_hex (++p1, &c);
7640 event->ws.set_forked (
read_ptid (++p1, &p));
7642 event->ws.set_vforked (
read_ptid (++p1, &p));
7643 else if (
strprefix (p, p1,
"vforkdone"))
7645 event->ws.set_vfork_done ();
7646 p = strchrnul (p1 + 1,
';');
7654 p = unpack_varlen_hex (++p1, &ignored);
7655 pathlen = (p - p1) / 2;
7659 gdb::unique_xmalloc_ptr<char> pathname
7660 ((
char *)
xmalloc (pathlen + 1));
7661 hex2bin (p1, (gdb_byte *) pathname.get (), pathlen);
7662 pathname.get ()[pathlen] =
'\0';
7665 event->ws.set_execd (std::move (pathname));
7674 event->ws.set_thread_created ();
7675 p = strchrnul (p1 + 1,
';');
7684 p = strchrnul (p1 + 1,
';');
7690 p_temp = unpack_varlen_hex (p, &pnum);
7699 if (event->
ptid == null_ptid)
7705 const char *thr = strstr (p1 + 1,
";thread:");
7707 event->ptid =
read_ptid (thr + strlen (
";thread:"),
7714 = (
event->ptid == null_ptid
7728 p = strchrnul (p1 + 1,
';');
7733 event->arch =
inf->gdbarch;
7734 rsa =
event->rs->get_remote_arch_state (event->
arch);
7742 error (_(
"Remote sent bad register number %s: %s\n\
7744 hex_string (pnum), p, buf);
7747 cached_reg.
data = (gdb_byte *)
7751 fieldsize = hex2bin (p, cached_reg.
data,
7755 warning (_(
"Remote reply is too short: %s"), buf);
7757 event->regcache.push_back (cached_reg);
7763 p = strchrnul (p1 + 1,
';');
7768 error (_(
"Remote register badly formatted: %s\nhere: %s"),
7781 sig = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
7782 if (GDB_SIGNAL_FIRST <= sig && sig < GDB_SIGNAL_LAST)
7783 event->ws.set_stopped ((
enum gdb_signal) sig);
7785 event->ws.set_stopped (GDB_SIGNAL_UNKNOWN);
7792 p = unpack_varlen_hex (&buf[1], &
value);
7793 event->ws.set_thread_exited (
value);
7795 error (_(
"stop reply packet badly formatted: %s"), buf);
7807 p = unpack_varlen_hex (&buf[1], &
value);
7812 event->ws.set_exited (
value);
7817 if (GDB_SIGNAL_FIRST <=
value &&
value < GDB_SIGNAL_LAST)
7818 event->ws.set_signalled ((
enum gdb_signal)
value);
7820 event->ws.set_signalled (GDB_SIGNAL_UNKNOWN);
7834 else if (startswith (p,
"process:"))
7838 p +=
sizeof (
"process:") - 1;
7839 unpack_varlen_hex (p, &upid);
7843 error (_(
"unknown stop reply packet: %s"), buf);
7846 error (_(
"unknown stop reply packet: %s"), buf);
7847 event->ptid = ptid_t (
pid);
7851 event->ws.set_no_resumed ();
7852 event->ptid = minus_one_ptid;
7908 "notif: process: '%s' ack pending event\n",
7912 nc->
ack (
this, nc, rs->
buf.data (),
7919 if (strcmp (rs->
buf.data (),
"OK") == 0)
7929 "notif: process: '%s' no pending reply\n",
7983 bool process_wide_stop
7990 bool ambiguous =
false;
8001 if (first_resumed_thread ==
nullptr)
8002 first_resumed_thread = thr;
8003 else if (!process_wide_stop
8004 || first_resumed_thread->
ptid.pid () != thr->ptid.pid ())
8008 gdb_assert (first_resumed_thread !=
nullptr);
8017 static bool warned =
false;
8033 if (process_wide_stop)
8034 warning (_(
"multi-inferior target stopped without "
8035 "sending a process-id, using first "
8036 "non-exited inferior"));
8038 warning (_(
"multi-threaded target stopped without "
8039 "sending a thread-id, using first "
8040 "non-exited thread"));
8047 if (process_wide_stop)
8048 return ptid_t (first_resumed_thread->
ptid.pid ());
8050 return first_resumed_thread->
ptid;
8066 if (ptid == null_ptid)
8068 gdb_assert (ptid != null_ptid);
8118 target_wait_flags options)
8131 if (ret != -1 && !is_notif)
8138 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
8144 warning (_(
"Invalid remote reply: %s"), rs->
buf.data ());
8163 return minus_one_ptid;
8187 target_wait_flags options)
8190 ptid_t event_ptid = null_ptid;
8213 status->set_no_resumed ();
8214 return minus_one_ptid;
8226 if (ret != -1 && is_notif)
8227 return minus_one_ptid;
8230 return minus_one_ptid;
8232 buf = rs->
buf.data ();
8236 if (buf[0] !=
'F' && buf[0] !=
'O')
8246 warning (_(
"Remote failure reply: %s"), buf);
8247 status->set_stopped (GDB_SIGNAL_0);
8261 case 'N':
case 'T':
case 'S':
case 'X':
case 'W':
8284 (
"Can't send signals to this remote system. %s not sent.\n",
8295 warning (_(
"Invalid remote reply: %s"), buf);
8301 return minus_one_ptid;
8307 return minus_one_ptid;
8314 if (event_ptid != null_ptid)
8324 if (event_ptid == null_ptid)
8327 if (event_ptid == null_ptid)
8339 target_wait_flags options)
8388 if (reg->
pnum == -1)
8391 p = rs->
buf.data ();
8398 buf = rs->
buf.data ();
8407 error (_(
"Could not fetch register \"%s\"; remote failure reply '%s'"),
8426 error (_(
"fetch_register_using_p: early buf termination"));
8428 regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
8447 error (_(
"Could not read registers; remote failure reply '%s'"),
8453 while ((rs->
buf[0] <
'0' || rs->
buf[0] >
'9')
8454 && (rs->
buf[0] <
'A' || rs->
buf[0] >
'F')
8455 && (rs->
buf[0] <
'a' || rs->
buf[0] >
'f')
8456 && rs->
buf[0] !=
'x')
8462 buf_len = strlen (rs->
buf.data ());
8465 if (buf_len % 2 != 0)
8466 error (_(
"Remote 'g' packet reply is of odd length: %s"), rs->
buf.data ());
8481 buf_len = strlen (rs->
buf.data ());
8485 error (_(
"Remote 'g' packet reply is too long (expected %ld bytes, got %d "
8500 if (buf_len < 2 * rsa->sizeof_g_packet)
8502 long sizeof_g_packet = buf_len / 2;
8506 long offset = rsa->
regs[i].offset;
8509 if (rsa->
regs[i].pnum == -1)
8512 if (offset >= sizeof_g_packet)
8513 rsa->
regs[i].in_g_packet = 0;
8514 else if (offset + reg_size > sizeof_g_packet)
8515 error (_(
"Truncated register %d in remote 'g' packet"), i);
8517 rsa->
regs[i].in_g_packet = 1;
8538 p = rs->
buf.data ();
8541 if (p[0] == 0 || p[1] == 0)
8543 internal_error (_(
"unexpected end of 'g' packet reply"));
8545 if (p[0] ==
'x' && p[1] ==
'x')
8548 regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
8559 if ((r->
offset + reg_size) * 2 > strlen (rs->
buf.data ()))
8561 internal_error (_(
"unexpected end of 'g' packet reply"));
8564 gdb_assert (r->
offset * 2 < strlen (rs->
buf.data ()));
8602 warning (_(
"could not set remote traceframe"));
8620 gdb_assert (reg != NULL);
8645 if (!rsa->
regs[i].in_g_packet)
8671 if (rsa->
regs[i].in_g_packet)
8689 char *buf = rs->
buf.data ();
8696 if (reg->
pnum == -1)
8700 p = buf + strlen (buf);
8711 error (_(
"Could not write register \"%s\"; remote failure reply '%s'"),
8716 internal_error (_(
"Bad result from packet_ok"));
8749 p = rs->
buf.data ();
8755 error (_(
"Could not write registers; remote failure reply '%s'"),
8777 gdb_assert (reg != NULL);
8800 if (!rsa->
regs[i].in_g_packet)
8814 for (i = 0; num != 0; i++)
8817 return std::max (i, 1);
8840 for (i = width - 1; i >= 0; i--)
8842 buf[i] =
"0123456789abcdef"[(num & 0xf)];
8860 if (address_size > 0
8861 && address_size < (
sizeof (ULONGEST) * 8))
8867 mask = (mask << address_size) - 1;
8899 p = rs->
buf.data ();
8910 if (rs->
buf[0] ==
'\0')
8972 const gdb_byte *myaddr,
8975 ULONGEST *xfered_len_units,
8976 char packet_format,
int use_length)
8984 int payload_capacity_bytes;
8985 int payload_length_bytes;
8987 if (packet_format !=
'X' && packet_format !=
'M')
8988 internal_error (_(
"remote_write_bytes_aux: bad packet format"));
9002 payload_capacity_bytes -= strlen (
"$,:#NN");
9005 payload_capacity_bytes += 1;
9006 payload_capacity_bytes -= strlen (header);
9007 payload_capacity_bytes -=
hexnumlen (memaddr);
9011 strcat (rs->
buf.data (), header);
9012 p = rs->
buf.data () + strlen (header);
9015 if (packet_format ==
'X')
9018 todo_units = std::min (len_units,
9019 (ULONGEST) payload_capacity_bytes / unit_size);
9021 payload_capacity_bytes -=
hexnumlen (todo_units);
9022 todo_units = std::min (todo_units, payload_capacity_bytes / unit_size);
9028 = std::min (len_units,
9029 (ULONGEST) (payload_capacity_bytes / unit_size) / 2);
9031 payload_capacity_bytes -=
hexnumlen (todo_units);
9032 todo_units = std::min (todo_units,
9033 (payload_capacity_bytes / unit_size) / 2);
9036 if (todo_units <= 0)
9037 internal_error (_(
"minimum packet size too small to write data"));
9056 plenlen =
hexnumstr (p, (ULONGEST) todo_units);
9065 if (packet_format ==
'X')
9070 payload_length_bytes =
9071 remote_escape_output (myaddr, todo_units, unit_size, (gdb_byte *) p,
9072 &units_written, payload_capacity_bytes);
9083 if (new_todo_units != units_written)
9084 payload_length_bytes =
9085 remote_escape_output (myaddr, new_todo_units, unit_size,
9086 (gdb_byte *) p, &units_written,
9087 payload_capacity_bytes);
9090 p += payload_length_bytes;
9091 if (use_length && units_written < todo_units)
9097 plen +=
hexnumnstr (plen, (ULONGEST) units_written,
9107 p += 2 * bin2hex (myaddr, p, todo_units * unit_size);
9108 units_written = todo_units;
9114 if (rs->
buf[0] ==
'E')
9119 *xfered_len_units = (ULONGEST) units_written;
9135 ULONGEST len,
int unit_size,
9136 ULONGEST *xfered_len)
9138 const char *packet_format = NULL;
9146 packet_format =
"X";
9149 packet_format =
"M";
9152 internal_error (_(
"remote_write_bytes: bad internal state"));
9154 internal_error (_(
"bad switch"));
9158 memaddr, myaddr, len, unit_size, xfered_len,
9159 packet_format[0], 1);
9179 int unit_size, ULONGEST *xfered_len_units)
9192 todo_units = std::min (len_units,
9193 (ULONGEST) (buf_size_bytes / unit_size) / 2);
9197 p = rs->
buf.data ();
9201 p +=
hexnumstr (p, (ULONGEST) todo_units);
9205 if (rs->
buf[0] ==
'E'
9206 && isxdigit (rs->
buf[1]) && isxdigit (rs->
buf[2])
9207 && rs->
buf[3] ==
'\0')
9211 p = rs->
buf.data ();
9212 decoded_bytes = hex2bin (p, myaddr, todo_units * unit_size);
9214 *xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
9229 ULONGEST *xfered_len)
9237 ULONGEST memend = memaddr + len;
9242 if (memaddr >= p.addr)
9244 if (memend <= p.endaddr)
9250 else if (memaddr >= p.endaddr)
9258 len = p.endaddr - memaddr;
9275 gdb_byte *myaddr, ULONGEST len,
int unit_size,
9276 ULONGEST *xfered_len)
9299 LONGEST oldlen = len;
9302 gdb_assert (len <= oldlen);
9307 len, unit_size, xfered_len);
9315 return (*xfered_len != 0) ?
9344 va_start (ap, format);
9347 int size = vsnprintf (rs->
buf.data (), max_size, format, ap);
9351 if (
size >= max_size)
9352 internal_error (_(
"Too long remote packet."));
9355 error (_(
"Communication problem with target."));
9373 scoped_restore restore_timeout
9377 phex (address, addr_size),
9382 error (_(
"Remote target does not support flash erase"));
9384 error (_(
"Error erasing flash with vFlashErase packet"));
9392 ULONGEST length, ULONGEST *xfered_len,
9393 const gdb_byte *data)
9395 scoped_restore restore_timeout
9406 scoped_restore restore_timeout
9414 error (_(
"Remote target does not support vFlashDone"));
9416 error (_(
"Error finishing flash operation"));
9435 int saved_errno = errno;
9438 throw_error (TARGET_CLOSE_ERROR,
"%s: %s.",
string,
9439 safe_strerror (saved_errno));
9454 scoped_restore restore_quit_target
9456 scoped_restore restore_quit
9474 throw_error (TARGET_CLOSE_ERROR, _(
"Remote connection closed"));
9478 "Target disconnected."));
9497 scoped_restore restore_quit_target
9499 scoped_restore restore_quit
9507 "Target disconnected."));
9552 unsigned char csum = 0;
9553 gdb::def_vector<char> data (cnt + 6);
9554 char *buf2 = data.data ();
9571 error (_(
"Cannot execute this command while the target is running.\n"
9572 "Use the \"interrupt\" command to stop the target\n"
9573 "and then try again."));
9582 for (i = 0; i < cnt; i++)
9588 *p++ = tohex ((csum >> 4) & 0xf);
9589 *p++ = tohex (csum & 0xf);
9599 int len = (int) (p - buf2);
9610 if (len > max_chars)
9612 (
"Sending packet: %s [%d bytes omitted]", str.c_str (),
9667 (
" Notification received: %s",
9756 char *buf = buf_p->data ();
9777 unsigned char pktcsum;
9792 else if (check_0 < 0 || check_1 < 0)
9804 pktcsum = (fromhex (check_0) << 4) | fromhex (check_1);
9805 if (csum == pktcsum)
9809 (
"Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s",
9823 repeat = c -
' ' + 3;
9827 if (repeat > 0 && repeat <= 255 && bc > 0)
9829 if (bc + repeat - 1 >= buf_p->size () - 1)
9832 buf_p->resize (buf_p->size () + repeat);
9833 buf = buf_p->data ();
9836 memset (&buf[bc], buf[bc - 1], repeat);
9842 gdb_printf (_(
"Invalid run length encoding: %s\n"), buf);
9846 if (bc >= buf_p->size () - 1)
9849 buf_p->resize (buf_p->size () * 2);
9850 buf = buf_p->data ();
9904 int forever,
int expecting_notif,
9913 strcpy (buf->data (),
"timeout");
9917 else if (expecting_notif)
9931 for (tries = 1; tries <=
MAX_TRIES; tries++)
9948 if (expecting_notif)
9955 throw_error (TARGET_CLOSE_ERROR,
9956 _(
"Watchdog timeout has expired. "
9957 "Target detached."));
9978 gdb_printf (_(
"Ignoring packet error, continuing...\n"));
10000 std::min (val, max_chars));
10002 if (val > max_chars)
10004 (
"Packet received: %s [%d bytes omitted]", str.c_str (),
10014 if (is_notif != NULL)
10023 gdb_assert (c ==
'%');
10026 (
" Notification received: %s",
10029 if (is_notif != NULL)
10036 if (expecting_notif)
10077 error (_(
"Can't kill fork child process %d"), child_pid);
10085 if (event->ptid.pid () !=
inf->
pid)
10091 int child_pid =
event->ws.child_ptid ().pid ();
10095 error (_(
"Can't kill fork child process %d"), child_pid);
10109 gdb_assert (
inf !=
nullptr);
10144 error (_(
"Can't kill process"));
10172 internal_error (_(
"Bad result from packet_ok"));
10187 catch (
const gdb_exception_error &ex)
10189 if (ex.error == TARGET_CLOSE_ERROR)
10269 "QDisableRandomization:%x", val);
10272 if (*reply ==
'\0')
10273 error (_(
"Target does not support QDisableRandomization."));
10274 if (strcmp (reply,
"OK") != 0)
10275 error (_(
"Bogus QDisableRandomization reply from target: %s"), reply);
10290 strcpy (rs->
buf.data (),
"vRun;");
10291 len = strlen (rs->
buf.data ());
10294 error (_(
"Remote file name too long for run packet"));
10295 len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->
buf.data () + len,
10296 strlen (remote_exec_file));
10298 if (!args.empty ())
10302 gdb_argv argv (args.c_str ());
10303 for (i = 0; argv[i] != NULL; i++)
10306 error (_(
"Argument list too long for run packet"));
10307 rs->
buf[len++] =
';';
10308 len += 2 * bin2hex ((gdb_byte *) argv[i], rs->
buf.data () + len,
10313 rs->
buf[len++] =
'\0';
10326 if (remote_exec_file[0] ==
'\0')
10327 error (_(
"Running the default executable on the remote target failed; "
10328 "try \"set remote exec-file\"?"));
10330 error (_(
"Running \"%s\" on the remote target failed"),
10333 gdb_assert_not_reached (
"bad switch");
10344 const char *packet,
10351 std::string encoded_value = bin2hex ((
const gdb_byte *)
value,
10355 "%s:%s", packet, encoded_value.c_str ());
10359 if (strcmp (rs->
buf.data (),
"OK") != 0)
10360 warning (_(
"Unable to %s environment variable '%s' on remote."),
10373 putpkt (
"QEnvironmentReset");
10375 if (strcmp (rs->
buf.data (),
"OK") != 0)
10376 warning (_(
"Unable to reset environment on remote."));
10382 for (
const std::string &el : e->user_set_env ())
10387 for (
const std::string &el : e->user_unset_env ())
10402 if (!inferior_cwd.empty ())
10404 std::string hexpath
10405 = bin2hex ((
const gdb_byte *) inferior_cwd.data (),
10406 inferior_cwd.size ());
10409 "QSetWorkingDir:%s", hexpath.c_str ());
10416 "QSetWorkingDir:");
10425Remote replied unexpectedly while setting the inferior's working\n\
10440 const std::string &args,
10441 char **env,
int from_tty)
10462 "QStartupWithShell:%d", startup_with_shell ? 1 : 0);
10465 if (strcmp (rs->
buf.data (),
"OK") != 0)
10467Remote replied unexpectedly while setting startup-with-shell: %s"),
10481 if (remote_exec_file[0])
10482 error (_(
"Remote target does not support \"set remote exec-file\""));
10483 if (!args.empty ())
10484 error (_(
"Remote target does not support \"set args\" or run ARGS"));
10513 xsnprintf (
buf, buf_end -
buf,
"%s",
";");
10519 xsnprintf (
buf, buf_end -
buf,
"X%x,", aexpr->len);
10521 for (
int i = 0; i < aexpr->len; ++i)
10522 buf = pack_hex_byte (
buf, aexpr->buf[i]);
10537 sprintf (
buf,
";cmds:%x,", bp_tgt->
persist);
10544 sprintf (
buf,
"X%x,", aexpr->len);
10546 for (
int i = 0; i < aexpr->len; ++i)
10547 buf = pack_hex_byte (
buf, aexpr->buf[i]);
10577 p = rs->
buf.data ();
10585 xsnprintf (p, endbuf - p,
",%d", bp_tgt->
kind);
10610 throw_error (NOT_SUPPORTED_ERROR, _(
"\
10611Target doesn't support breakpoints that have target side commands."));
10626 char *p = rs->
buf.data ();
10640 xsnprintf (p, endbuf - p,
",%d", bp_tgt->
kind);
10645 return (rs->
buf[0] ==
'E');
10666 internal_error (_(
"hw_bp_to_z: bad watchpoint type %d"),
type);
10687 xsnprintf (rs->
buf.data (), endbuf - rs->
buf.data (),
"Z%x,", packet);
10688 p = strchr (rs->
buf.data (),
'\0');
10691 xsnprintf (p, endbuf - p,
",%x", len);
10705 internal_error (_(
"remote_insert_watchpoint: reached end of function"));
10710 CORE_ADDR start,
int length)
10714 return diff < length;
10735 xsnprintf (rs->
buf.data (), endbuf - rs->
buf.data (),
"z%x,", packet);
10736 p = strchr (rs->
buf.data (),
'\0');
10739 xsnprintf (p, endbuf - p,
",%x", len);
10751 internal_error (_(
"remote_remove_watchpoint: reached end of function"));
10805 return (thread->
priv != NULL
10826 return (thread->
priv != NULL
10845 return (thread->
priv != NULL
10855 if (thread->
priv != NULL
10885 p = rs->
buf.data ();
10894 xsnprintf (p, endbuf - p,
",%x", bp_tgt->
kind);
10908 if (rs->
buf[1] ==
'.')
10910 message = strchr (&rs->
buf[2],
'.');
10912 error (_(
"Remote failure reply: %s"), message + 1);
10920 internal_error (_(
"remote_insert_hw_breakpoint: reached end of function"));
10930 char *p = rs->
buf.data ();
10947 xsnprintf (p, endbuf - p,
",%x", bp_tgt->
kind);
10960 internal_error (_(
"remote_remove_hw_breakpoint: reached end of function"));
10969 unsigned long host_crc, target_crc;
10984 (
long) lma, (
long)
size);
10989 host_crc = xcrc32 (data,
size, 0xffffffff);
10999 for (target_crc = 0, tmp = &rs->
buf[1]; *tmp; tmp++)
11000 target_crc = target_crc * 16 + fromhex (*tmp);
11002 return (host_crc == target_crc);
11019 const char *sectname;
11020 bfd_size_type
size;
11023 int mismatched = 0;
11028 error (_(
"command cannot be used without an exec file"));
11030 if (args != NULL && strcmp (args,
"-r") == 0)
11038 if (!(s->flags & SEC_LOAD))
11041 if (read_only && (s->flags & SEC_READONLY) == 0)
11044 size = bfd_section_size (s);
11048 sectname = bfd_section_name (s);
11049 if (args && strcmp (args, sectname) != 0)
11055 gdb::byte_vector sectdata (
size);
11057 sectdata.data (), 0,
size);
11062 error (_(
"target memory fault, section %s, range %s -- %s"), sectname,
11066 gdb_printf (
"Section %s, range %s -- %s: ", sectname,
11077 if (mismatched > 0)
11078 warning (_(
"One or more sections of the target image does not match\n\
11079the loaded file\n"));
11080 if (args && !matched)
11081 gdb_printf (_(
"No loaded section named '%s'.\n"), args);
11090 const char *annex,
const gdb_byte *writebuf,
11091 ULONGEST offset, LONGEST len,
11092 ULONGEST *xfered_len,
11104 i = snprintf (rs->
buf.data (), max_size,
11105 "qXfer:%s:write:%s:%s:",
11106 object_name, annex ? annex :
"",
11107 phex_nz (offset,
sizeof offset));
11108 max_size -= (i + 1);
11111 buf_len = remote_escape_output
11112 (writebuf, len, 1, (gdb_byte *) rs->
buf.data () + i, &max_size, max_size);
11119 unpack_varlen_hex (rs->
buf.data (), &n);
11135 gdb_byte *readbuf, ULONGEST offset,
11137 ULONGEST *xfered_len,
11141 LONGEST i, n, packet_len;
11170 "qXfer:%s:read:%s:%s,%s",
11171 object_name, annex ? annex :
"",
11172 phex_nz (offset,
sizeof offset),
11173 phex_nz (n,
sizeof n));
11183 if (rs->
buf[0] !=
'l' && rs->
buf[0] !=
'm')
11184 error (_(
"Unknown remote qXfer reply: %s"), rs->
buf.data ());
11189 if (rs->
buf[0] ==
'm' && packet_len == 1)
11190 error (_(
"Remote qXfer reply contained no data."));
11193 i = remote_unescape_input ((gdb_byte *) rs->
buf.data () + 1,
11194 packet_len - 1, readbuf, n);
11199 if (rs->
buf[0] ==
'l' && offset + i > 0)
11217 const char *annex, gdb_byte *readbuf,
11218 const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
11219 ULONGEST *xfered_len)
11241 if (writebuf != NULL)
11258 writebuf, offset, len, xfered_len,
11267 readbuf, offset, len, xfered_len,
11275 if (writebuf != NULL)
11297 gdb_assert (annex == NULL);
11304 (
"features", annex, readbuf, offset, len, xfered_len,
11309 (
"libraries", annex, readbuf, offset, len, xfered_len,
11314 (
"libraries-svr4", annex, readbuf, offset, len, xfered_len,
11318 gdb_assert (annex == NULL);
11327 (
"osdata", annex, readbuf, offset, len, xfered_len,
11331 gdb_assert (annex == NULL);
11337 gdb_assert (annex == NULL);
11339 (
"traceframe-info", annex, readbuf, offset, len, xfered_len,
11379 error (_(
"remote query is only available after target open"));
11381 gdb_assert (annex != NULL);
11382 gdb_assert (readbuf != NULL);
11384 p2 = rs->
buf.data ();
11386 *p2++ = query_type;
11397 gdb_assert (isprint (annex[i]) && annex[i] !=
'$' && annex[i] !=
'#');
11402 gdb_assert (annex[i] ==
'\0');
11409 strcpy ((
char *) readbuf, rs->
buf.data ());
11411 *xfered_len = strlen ((
char *) readbuf);
11425 const gdb_byte *pattern, ULONGEST pattern_len,
11426 CORE_ADDR *found_addrp)
11435 int escaped_pattern_len;
11437 int used_pattern_len;
11440 ULONGEST found_addr;
11442 auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result,
size_t len)
11452 if (pattern_len > search_space_len)
11454 if (pattern_len == 0)
11456 *found_addrp = start_addr;
11467 return simple_search_memory (
read_memory, start_addr, search_space_len,
11468 pattern, pattern_len, found_addrp);
11475 i = snprintf (rs->
buf.data (), max_size,
11476 "qSearch:memory:%s;%s;",
11477 phex_nz (start_addr, addr_size),
11478 phex_nz (search_space_len,
sizeof (search_space_len)));
11479 max_size -= (i + 1);
11482 escaped_pattern_len =
11483 remote_escape_output (pattern, pattern_len, 1,
11484 (gdb_byte *) rs->
buf.data () + i,
11485 &used_pattern_len, max_size);
11488 if (used_pattern_len != pattern_len)
11489 error (_(
"Pattern is too large to transmit to remote target."));
11499 return simple_search_memory (
read_memory, start_addr, search_space_len,
11500 pattern, pattern_len, found_addrp);
11505 if (rs->
buf[0] ==
'0')
11507 else if (rs->
buf[0] ==
'1')
11510 if (rs->
buf[1] !=
',')
11511 error (_(
"Unknown qSearch:memory reply: %s"), rs->
buf.data ());
11512 unpack_varlen_hex (&rs->
buf[2], &found_addr);
11513 *found_addrp = found_addr;
11516 error (_(
"Unknown qSearch:memory reply: %s"), rs->
buf.data ());
11525 char *p = rs->
buf.data ();
11528 error (_(
"remote rcmd is only available after target open"));
11531 if (command == NULL)
11535 strcpy (rs->
buf.data (),
"qRcmd,");
11536 p = strchr (rs->
buf.data (),
'\0');
11538 if ((strlen (rs->
buf.data ()) + strlen (command) * 2 + 8)
11540 error (_(
"\"monitor\" command ``%s'' is too long."), command);
11543 bin2hex ((
const gdb_byte *) command, p, strlen (command));
11546 error (_(
"Communication problem with target."));
11565 buf = rs->
buf.data ();
11566 if (buf[0] ==
'\0')
11567 error (_(
"Target does not support this command."));
11568 if (buf[0] ==
'O' && buf[1] !=
'K')
11573 if (strcmp (buf,
"OK") == 0)
11575 if (strlen (buf) == 3 && buf[0] ==
'E'
11576 && isxdigit (buf[1]) && isxdigit (buf[2]))
11578 error (_(
"Protocol error with Rcmd"));
11580 for (p = buf; p[0] !=
'\0' && p[1] !=
'\0'; p += 2)
11582 char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
11590std::vector<mem_region>
11593 std::vector<mem_region> result;
11594 gdb::optional<gdb::char_vector> text
11611 void sending (gdb::array_view<const char> &buf)
override
11620 void received (gdb::array_view<const char> &buf)
override
11637 for (
int i = 0; i < buf.size (); ++i)
11639 gdb_byte c = buf[i];
11643 gdb_printf (&stb,
"\\x%02x", (
unsigned char) c);
11656 if (buf.size () == 0 || buf.data ()[0] ==
'\0')
11657 error (_(
"a remote packet must not be empty"));
11660 if (remote ==
nullptr)
11661 error (_(
"packets can only be sent to a remote target"));
11670 error (_(
"error while fetching packet from remote target"));
11672 gdb::array_view<const char> view (&rs->
buf[0], bytes);
11682 gdb::array_view<const char> view
11683 = gdb::make_array_view (args, args ==
nullptr ? 0 : strlen (args));
11692static void threadset_test_cmd (
char *cmd,
int tty);
11694static void threadalive_test (
char *cmd,
int tty);
11696static void threadlist_test_cmd (
char *cmd,
int tty);
11698int get_and_display_threadinfo (
threadref *ref);
11700static void threadinfo_test_cmd (
char *cmd,
int tty);
11702static int thread_display_step (
threadref *ref,
void *context);
11704static void threadlist_update_test_cmd (
char *cmd,
int tty);
11706static void init_remote_threadtests (
void);
11708#define SAMPLE_THREAD 0x05060708
11711threadset_test_cmd (
const char *cmd,
int tty)
11713 int sample_thread = SAMPLE_THREAD;
11716 set_general_thread (sample_thread);
11721threadalive_test (
const char *cmd,
int tty)
11723 int sample_thread = SAMPLE_THREAD;
11725 ptid_t ptid = ptid_t (
pid, sample_thread, 0);
11727 if (remote_thread_alive (ptid))
11733void output_threadid (
char *title,
threadref *ref);
11736output_threadid (
char *title,
threadref *ref)
11746threadlist_test_cmd (
const char *cmd,
int tty)
11750 int done, result_count;
11754 if (!remote_get_threadlist (startflag, &nextthread, 3, &done,
11755 &result_count, &threadlist[0]))
11762 while (
scan < limit)
11763 output_threadid (
" thread ",
scan++);
11770 output_threadid (
"Threadid: ", &
info->threadid);
11777get_and_display_threadinfo (
threadref *ref)
11785 if (0 != (result = remote_get_threadinfo (ref, set, &threadinfo)))
11786 display_thread_info (&threadinfo);
11791threadinfo_test_cmd (
const char *cmd,
int tty)
11793 int athread = SAMPLE_THREAD;
11799 if (!get_and_display_threadinfo (&thread))
11800 gdb_printf (
"FAIL cannot get thread info\n");
11804thread_display_step (
threadref *ref,
void *context)
11807 return get_and_display_threadinfo (ref);
11811threadlist_update_test_cmd (
const char *cmd,
int tty)
11813 gdb_printf (
"Remote Threadlist update test\n");
11818init_remote_threadtests (
void)
11821 _(
"Fetch and print the remote list of "
11822 "thread identifiers, one pkt only."));
11824 _(
"Fetch and display info about one thread."));
11826 _(
"Test setting to a different thread."));
11828 _(
"Iterate through updating all remote thread info."));
11830 _(
"Remote thread alive test."));
11842 if (ptid == null_ptid)
11844 else if (ptid.is_pid ())
11858 return "Remote target";
11865 return "Thread <main>";
11867 if (ptid.lwp () == 0)
11870 return string_printf (
"Thread %d.%ld",
11871 ptid.pid (), ptid.lwp ());
11873 return string_printf (
"Thread %ld", ptid.lwp ());
11887 char *p = rs->
buf.data ();
11891 strcpy (p,
"qGetTLSAddr:");
11908 unpack_varlen_hex (rs->
buf.data (), &addr);
11912 throw_error (TLS_GENERIC_ERROR,
11913 _(
"Remote target doesn't support qGetTLSAddr packet"));
11915 throw_error (TLS_GENERIC_ERROR,
11916 _(
"Remote target failed to process qGetTLSAddr request"));
11919 throw_error (TLS_GENERIC_ERROR,
11920 _(
"TLS not supported or disabled on this target"));
11934 char *p = rs->
buf.data ();
11938 strcpy (p,
"qGetTIBAddr:");
11950 unpack_varlen_hex (rs->
buf.data (), &val);
11952 *addr = (CORE_ADDR) val;
11956 error (_(
"Remote target doesn't support qGetTIBAddr packet"));
11958 error (_(
"Remote target failed to process qGetTIBAddr request"));
11961 error (_(
"qGetTIBAddr not supported or disabled on this target"));
11986 std::vector<remote_g_packet_guess>
guesses;
11997 if (data ==
nullptr)
12008 gdb_assert (tdesc != NULL);
12011 if (guess.bytes == bytes)
12012 internal_error (_(
"Duplicate g packet description added for size %d"),
12015 data->guesses.emplace_back (bytes, tdesc);
12026 return !data->guesses.empty ();
12039 if (!data->guesses.empty ())
12044 if (guess.bytes == bytes)
12045 return guess.tdesc;
12065 int len = strlen (
string);
12068 error (_(
"Packet too long for target."));
12070 memcpy (*buffer,
string, len);
12088 if (2 * len > *left)
12089 error (_(
"Packet too long for target."));
12091 bin2hex (bytes, *buffer, len);
12092 *buffer += 2 * len;
12111 error (_(
"Packet too long for target."));
12134 fileio_error *remote_errno,
const char **attachment)
12138 *remote_errno = FILEIO_SUCCESS;
12139 *attachment = NULL;
12141 if (buffer[0] !=
'F')
12145 *retcode = strtol (&buffer[1], &p, 16);
12146 if (errno != 0 || p == &buffer[1])
12153 *remote_errno = (fileio_error) strtol (p + 1, &p2, 16);
12154 if (errno != 0 || p + 1 == p2)
12163 *attachment = p + 1;
12166 else if (*p ==
'\0')
12190 fileio_error *remote_errno,
const char **attachment,
12191 int *attachment_len)
12194 int ret, bytes_read;
12195 const char *attachment_tmp;
12199 *remote_errno = FILEIO_ENOSYS;
12208 if (bytes_read < 0)
12210 *remote_errno = FILEIO_EINVAL;
12217 *remote_errno = FILEIO_EINVAL;
12220 *remote_errno = FILEIO_ENOSYS;
12229 *remote_errno = FILEIO_EINVAL;
12234 if ((attachment_tmp == NULL && attachment != NULL)
12235 || (attachment_tmp != NULL && attachment == NULL))
12237 *remote_errno = FILEIO_EINVAL;
12243 if (attachment_tmp != NULL)
12245 *attachment = attachment_tmp;
12246 *attachment_len = bytes_read - (*attachment - rs->
buf.data ());
12265 if (this->fd ==
fd)
12275 fileio_error *remote_errno)
12278 int required_pid = (
inf == NULL ||
inf->fake_pid_p) ? 0 :
inf->
pid;
12279 char *p = rs->
buf.data ();
12292 xsnprintf (arg,
sizeof (arg),
"%x", required_pid);
12296 remote_errno, NULL, NULL);
12302 rs->
fs_pid = required_pid;
12311 int flags,
int mode,
int warn_if_slow,
12312 fileio_error *remote_errno)
12315 char *p = rs->
buf.data ();
12320 static int warning_issued = 0;
12322 gdb_printf (_(
"Reading %s from remote target...\n"),
12325 if (!warning_issued)
12327 warning (_(
"File transfers from remote targets can be slow."
12328 " Use \"set sysroot\" to access files locally"
12330 warning_issued = 1;
12340 strlen (filename));
12349 remote_errno, NULL, NULL);
12354 int flags,
int mode,
int warn_if_slow,
12355 fileio_error *remote_errno)
12365 ULONGEST offset, fileio_error *remote_errno)
12368 char *p = rs->
buf.data ();
12382 p += remote_escape_output (write_buf, len, 1, (gdb_byte *) p, &out_len,
12384 - (p - rs->
buf.data ())));
12387 remote_errno, NULL, NULL);
12392 ULONGEST offset, fileio_error *remote_errno)
12402 ULONGEST offset, fileio_error *remote_errno)
12405 char *p = rs->
buf.data ();
12406 const char *attachment;
12408 int ret, attachment_len;
12422 remote_errno, &attachment,
12428 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12430 if (read_len != ret)
12431 error (_(
"Read returned %d, but %d bytes."), ret, (
int) read_len);
12443 && this->offset <=
offset
12446 ULONGEST max = this->offset + this->
bufsize;
12448 if (offset + len > max)
12451 memcpy (read_buf, this->
buf + offset - this->offset, len);
12462 ULONGEST offset, fileio_error *remote_errno)
12468 ret = cache->
pread (fd, read_buf, len, offset);
12489 cache->
offset, remote_errno);
12497 return cache->
pread (fd, read_buf, len, offset);
12502 ULONGEST offset, fileio_error *remote_errno)
12513 char *p = rs->
buf.data ();
12523 remote_errno, NULL, NULL);
12536 fileio_error *remote_errno)
12539 char *p = rs->
buf.data ();
12548 strlen (filename));
12551 remote_errno, NULL, NULL);
12556 fileio_error *remote_errno)
12563gdb::optional<std::string>
12565 fileio_error *remote_errno)
12568 char *p = rs->
buf.data ();
12569 const char *attachment;
12571 int len, attachment_len;
12580 strlen (filename));
12583 remote_errno, &attachment,
12589 std::string ret (len,
'\0');
12591 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12592 (gdb_byte *) &ret[0], len);
12593 if (read_len != len)
12594 error (_(
"Readlink returned %d, but %d bytes."), len, read_len);
12605 char *p = rs->
buf.data ();
12607 int attachment_len, ret;
12608 const char *attachment;
12609 struct fio_stat fst;
12617 remote_errno, &attachment,
12621 if (*remote_errno != FILEIO_ENOSYS)
12637 memset (st, 0,
sizeof (
struct stat));
12642 read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
12643 (gdb_byte *) &fst,
sizeof (fst));
12645 if (read_len != ret)
12646 error (_(
"vFile:fstat returned %d, but %d bytes."), ret, read_len);
12648 if (read_len !=
sizeof (fst))
12649 error (_(
"vFile:fstat returned %d bytes, but expecting %d."),
12650 read_len, (
int)
sizeof (fst));
12675 fileio_error remote_errno;
12681 FILEIO_O_RDONLY, 0700, 0,
12692 static int warning_issued = 0;
12694 if (!warning_issued)
12696 warning (_(
"remote target does not support file"
12697 " transfer, attempting to access files"
12698 " from local filesystem."));
12699 warning_issued = 1;
12712 int host_error = fileio_error_to_host (errnum);
12714 if (host_error == -1)
12715 error (_(
"Unknown remote I/O error %d"), errnum);
12717 error (_(
"Remote I/O error: %s"), safe_strerror (host_error));
12736 fileio_error remote_errno;
12751 ATTRIBUTE_UNUSED_RESULT
int release () noexcept
12759 int get () const noexcept
12773remote_file_put (
const char *local_file,
const char *remote_file,
int from_tty)
12777 if (remote ==
nullptr)
12778 error (_(
"command can only be used with remote target"));
12787 int retcode, bytes, io_size;
12788 fileio_error remote_errno;
12789 int bytes_in_buffer;
12793 gdb_file_up file = gdb_fopen_cloexec (local_file,
"rb");
12799 remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
12801 0700, 0, &remote_errno));
12802 if (fd.
get () == -1)
12808 gdb::byte_vector buffer (io_size);
12810 bytes_in_buffer = 0;
12813 while (bytes_in_buffer || !saw_eof)
12817 bytes = fread (buffer.data () + bytes_in_buffer, 1,
12818 io_size - bytes_in_buffer,
12822 if (ferror (file.get ()))
12823 error (_(
"Error reading %s."), local_file);
12829 if (bytes_in_buffer == 0)
12837 bytes += bytes_in_buffer;
12838 bytes_in_buffer = 0;
12841 offset, &remote_errno);
12845 else if (retcode == 0)
12846 error (_(
"Remote write of %d bytes returned 0!"), bytes);
12847 else if (retcode < bytes)
12851 bytes_in_buffer = bytes - retcode;
12852 memmove (buffer.data (), buffer.data () + retcode, bytes_in_buffer);
12862 gdb_printf (_(
"Successfully sent file \"%s\".\n"), local_file);
12866remote_file_get (
const char *remote_file,
const char *local_file,
int from_tty)
12870 if (remote ==
nullptr)
12871 error (_(
"command can only be used with remote target"));
12880 fileio_error remote_errno;
12881 int bytes, io_size;
12886 remote_file, FILEIO_O_RDONLY, 0, 0,
12888 if (fd.
get () == -1)
12891 gdb_file_up file = gdb_fopen_cloexec (local_file,
"wb");
12898 gdb::byte_vector buffer (io_size);
12913 bytes = fwrite (buffer.data (), 1, bytes, file.get ());
12922 gdb_printf (_(
"Successfully fetched file \"%s\".\n"), remote_file);
12930 if (remote ==
nullptr)
12931 error (_(
"command can only be used with remote target"));
12940 fileio_error remote_errno;
12947 gdb_printf (_(
"Successfully deleted file \"%s\".\n"), remote_file);
12956 gdb_argv argv (args);
12957 if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
12958 error (_(
"Invalid parameters to remote put"));
12969 gdb_argv argv (args);
12970 if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
12971 error (_(
"Invalid parameters to remote get"));
12982 gdb_argv argv (args);
12983 if (argv[0] == NULL || argv[1] != NULL)
12984 error (_(
"Invalid parameters to remote delete"));
13076 if (strcmp (rs->
buf.data (),
"OK") != 0)
13077 error (_(
"Target does not support this command."));
13090 for (cmd = cmds; cmd; cmd = cmd->
next)
13093 strcpy (rs->
buf.data (),
"QTDPsrc:");
13095 rs->
buf.data () + strlen (rs->
buf.data ()),
13096 rs->
buf.size () - strlen (rs->
buf.data ()));
13099 if (strcmp (rs->
buf.data (),
"OK"))
13100 warning (_(
"Target does not support source download."));
13108 strcpy (rs->
buf.data (),
"QTDPsrc:");
13110 rs->
buf.data () + strlen (rs->
buf.data ()),
13111 rs->
buf.size () - strlen (rs->
buf.data ()));
13114 if (strcmp (rs->
buf.data (),
"OK"))
13115 warning (_(
"Target does not support source download."));
13125 std::vector<std::string> tdp_actions;
13126 std::vector<std::string> stepping_actions;
13132 const char *err_msg = _(
"Tracepoint packet too large for target.");
13142 tpaddr =
loc->address;
13143 strcpy (addrbuf, phex (tpaddr,
sizeof (CORE_ADDR)));
13144 ret = snprintf (buf.data (), buf.size (),
"QTDP:%x:%s:%c:%lx:%x",
13149 if (ret < 0 || ret >= buf.size ())
13150 error (
"%s", err_msg);
13164 size_left = buf.size () - strlen (buf.data ());
13165 ret = snprintf (buf.data () + strlen (buf.data ()),
13169 if (ret < 0 || ret >= size_left)
13170 error (
"%s", err_msg);
13175 internal_error (_(
"Fast tracepoint not valid during download"));
13181 warning (_(
"Target does not support fast tracepoints, "
13182 "downloading %d as regular tracepoint"), b->
number);
13195 size_left = buf.size () - strlen (buf.data ());
13196 ret = snprintf (buf.data () + strlen (buf.data ()),
13199 if (ret < 0 || ret >= size_left)
13200 error (
"%s", err_msg);
13203 error (_(
"Static tracepoint not valid during download"));
13209 error (_(
"Target does not support static tracepoints"));
13222 size_left = buf.size () - strlen (buf.data ());
13224 ret = snprintf (buf.data () + strlen (buf.data ()),
13225 size_left,
":X%x,", aexpr->len);
13227 if (ret < 0 || ret >= size_left)
13228 error (
"%s", err_msg);
13230 size_left = buf.size () - strlen (buf.data ());
13234 if (aexpr->len * 2 + 1 > size_left)
13235 error (
"%s", err_msg);
13237 pkt = buf.data () + strlen (buf.data ());
13239 for (
int ndx = 0; ndx < aexpr->len; ++ndx)
13240 pkt = pack_hex_byte (pkt, aexpr->buf[ndx]);
13244 warning (_(
"Target does not support conditional tracepoints, "
13245 "ignoring tp %d cond"), b->
number);
13250 size_left = buf.size () - strlen (buf.data ());
13252 ret = snprintf (buf.data () + strlen (buf.data ()),
13255 if (ret < 0 || ret >= size_left)
13256 error (
"%s", err_msg);
13261 if (strcmp (rs->
buf.data (),
"OK"))
13262 error (_(
"Target does not support tracepoints."));
13265 for (
auto action_it = tdp_actions.begin ();
13266 action_it != tdp_actions.end (); action_it++)
13270 bool has_more = ((action_it + 1) != tdp_actions.end ()
13271 || !stepping_actions.empty ());
13273 ret = snprintf (buf.data (), buf.size (),
"QTDP:-%x:%s:%s%c",
13275 action_it->c_str (),
13276 has_more ?
'-' : 0);
13278 if (ret < 0 || ret >= buf.size ())
13279 error (
"%s", err_msg);
13283 if (strcmp (rs->
buf.data (),
"OK"))
13284 error (_(
"Error on target while setting tracepoints."));
13287 for (
auto action_it = stepping_actions.begin ();
13288 action_it != stepping_actions.end (); action_it++)
13292 bool is_first = action_it == stepping_actions.begin ();
13293 bool has_more = (action_it + 1) != stepping_actions.end ();
13295 ret = snprintf (buf.data (), buf.size (),
"QTDP:-%x:%s:%s%s%s",
13297 is_first ?
"S" :
"",
13298 action_it->c_str (),
13299 has_more ?
"-" :
"");
13301 if (ret < 0 || ret >= buf.size ())
13302 error (
"%s", err_msg);
13306 if (strcmp (rs->
buf.data (),
"OK"))
13307 error (_(
"Error on target while setting tracepoints."));
13314 ret = snprintf (buf.data (), buf.size (),
"QTDPsrc:");
13316 if (ret < 0 || ret >= buf.size ())
13317 error (
"%s", err_msg);
13319 const char *str = b->
locspec->to_string ();
13321 buf.data () + strlen (buf.data ()),
13322 buf.size () - strlen (buf.data ()));
13325 if (strcmp (rs->
buf.data (),
"OK"))
13326 warning (_(
"Target does not support source download."));
13330 ret = snprintf (buf.data (), buf.size (),
"QTDPsrc:");
13332 if (ret < 0 || ret >= buf.size ())
13333 error (
"%s", err_msg);
13337 buf.data () + strlen (buf.data ()),
13338 buf.size () - strlen (buf.data ()));
13341 if (strcmp (rs->
buf.data (),
"OK"))
13342 warning (_(
"Target does not support source download."));
13386 p = rs->
buf.data () + strlen (rs->
buf.data ());
13387 if ((p - rs->
buf.data ()) + tsv.
name.length () * 2
13389 error (_(
"Trace state variable name too long for tsv definition packet"));
13390 p += 2 * bin2hex ((gdb_byte *) (tsv.
name.data ()), p, tsv.
name.length ());
13394 if (rs->
buf[0] ==
'\0')
13395 error (_(
"Target does not support this command."));
13396 if (strcmp (rs->
buf.data (),
"OK") != 0)
13397 error (_(
"Error on target while downloading trace state variable."));
13407 phex (location->
address, sizeof (CORE_ADDR)));
13410 if (rs->
buf[0] ==
'\0')
13411 error (_(
"Target does not support enabling tracepoints while a trace run is ongoing."));
13412 if (strcmp (rs->
buf.data (),
"OK") != 0)
13413 error (_(
"Error on target while enabling tracepoint."));
13423 phex (location->
address, sizeof (CORE_ADDR)));
13426 if (rs->
buf[0] ==
'\0')
13427 error (_(
"Target does not support disabling tracepoints while a trace run is ongoing."));
13428 if (strcmp (rs->
buf.data (),
"OK") != 0)
13429 error (_(
"Error on target while disabling tracepoint."));
13436 bfd_size_type
size;
13447 strcpy (rs->
buf.data (),
"QTro");
13448 offset = strlen (rs->
buf.data ());
13449 for (s = abfd->sections; s; s = s->next)
13451 char tmp1[40], tmp2[40];
13454 if ((s->flags & SEC_LOAD) == 0
13456 || (s->flags & SEC_READONLY) == 0)
13460 vma = bfd_section_vma (s);
13461 size = bfd_section_size (s);
13462 bfd_sprintf_vma (abfd, tmp1, vma);
13463 bfd_sprintf_vma (abfd, tmp2, vma +
size);
13464 sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2);
13465 if (offset + sec_length + 1 > rs->
buf.size ())
13469Too many sections for read-only sections definition packet."));
13472 xsnprintf (rs->
buf.data () + offset, rs->
buf.size () - offset,
":%s,%s",
13474 offset += sec_length;
13490 if (rs->
buf[0] ==
'\0')
13491 error (_(
"Target does not support this command."));
13492 if (strcmp (rs->
buf.data (),
"OK") != 0)
13493 error (_(
"Bogus reply from target: %s"), rs->
buf.data ());
13517 catch (
const gdb_exception_error &ex)
13519 if (ex.error != TARGET_CLOSE_ERROR)
13537 error (_(
"Bogus trace status reply from target: %s"), rs->
buf.data ());
13566 phex_nz (
loc->address, 0));
13569 if (reply && *reply)
13580 xsnprintf (rs->
buf.data (),
size,
"qTP:%x:%s", utp->
number,
13581 phex_nz (utp->
addr, 0));
13584 if (reply && *reply)
13599 if (rs->
buf[0] ==
'\0')
13600 error (_(
"Target does not support this command."));
13601 if (strcmp (rs->
buf.data (),
"OK") != 0)
13602 error (_(
"Bogus reply from target: %s"), rs->
buf.data ());
13607 CORE_ADDR addr1, CORE_ADDR addr2,
13613 int target_frameno = -1, target_tracept = -1;
13621 p = rs->
buf.data ();
13622 strcpy (p,
"QTFrame:");
13623 p = strchr (p,
'\0');
13627 xsnprintf (p, endbuf - p,
"%x", num);
13630 xsnprintf (p, endbuf - p,
"pc:%s", phex_nz (addr1, 0));
13633 xsnprintf (p, endbuf - p,
"tdp:%x", num);
13636 xsnprintf (p, endbuf - p,
"range:%s:%s", phex_nz (addr1, 0),
13637 phex_nz (addr2, 0));
13640 xsnprintf (p, endbuf - p,
"outside:%s:%s", phex_nz (addr1, 0),
13641 phex_nz (addr2, 0));
13644 error (_(
"Unknown trace find type %d"),
type);
13649 if (*reply ==
'\0')
13650 error (_(
"Target does not support this command."));
13652 while (reply && *reply)
13657 target_frameno = (int) strtol (p, &reply, 16);
13659 error (_(
"Unable to parse trace frame number"));
13662 if (target_frameno == -1)
13667 target_tracept = (int) strtol (p, &reply, 16);
13669 error (_(
"Unable to parse tracepoint number"));
13672 if (reply[1] ==
'K' && reply[2] ==
'\0')
13675 error (_(
"Bogus reply from target: %s"), reply);
13678 error (_(
"Bogus reply from target: %s"), reply);
13681 *tpp = target_tracept;
13684 return target_frameno;
13699 if (reply && *reply)
13703 unpack_varlen_hex (reply + 1, &uval);
13704 *val = (LONGEST) uval;
13717 p = rs->
buf.data ();
13718 strcpy (p,
"QTSave:");
13720 if ((p - rs->
buf.data ()) + strlen (filename) * 2
13722 error (_(
"Remote file name too long for trace save packet"));
13723 p += 2 * bin2hex ((gdb_byte *) filename, p, strlen (filename));
13727 if (*reply ==
'\0')
13728 error (_(
"Target does not support this command."));
13729 if (strcmp (reply,
"OK") != 0)
13730 error (_(
"Bogus reply from target: %s"), reply);
13747 p = rs->
buf.data ();
13748 strcpy (p,
"qTBuffer:");
13757 if (reply && *reply)
13769 rslt = hex2bin (reply, buf, len);
13787 "QTDisconnected:%x", val);
13790 if (*reply ==
'\0')
13791 error (_(
"Target does not support this command."));
13792 if (strcmp (reply,
"OK") != 0)
13793 error (_(
"Bogus reply from target: %s"), reply);
13796 warning (_(
"Target does not support disconnected tracing."));
13804 if (
info != NULL &&
info->priv != NULL)
13817 "QTBuffer:circular:%x", val);
13820 if (*reply ==
'\0')
13821 error (_(
"Target does not support this command."));
13822 if (strcmp (reply,
"OK") != 0)
13823 error (_(
"Bogus reply from target: %s"), reply);
13829 gdb::optional<gdb::char_vector> text
13861 if (*reply ==
'\0')
13865 ULONGEST min_insn_len;
13867 unpack_varlen_hex (reply, &min_insn_len);
13869 return (
int) min_insn_len;
13879 char *buf = rs->
buf.data ();
13883 gdb_assert (val >= 0 || val == -1);
13884 buf += xsnprintf (buf, endbuf - buf,
"QTBuffer:size:");
13889 buf +=
hexnumstr (buf, (ULONGEST) -val);
13892 buf +=
hexnumstr (buf, (ULONGEST) val);
13900 warning (_(
"Bogus reply from target: %s"), rs->
buf.data ());
13906 const char *stop_notes)
13910 char *buf = rs->
buf.data ();
13914 buf += xsnprintf (buf, endbuf - buf,
"QTNotes:");
13917 buf += xsnprintf (buf, endbuf - buf,
"user:");
13918 nbytes = bin2hex ((gdb_byte *) user, buf, strlen (user));
13924 buf += xsnprintf (buf, endbuf - buf,
"notes:");
13925 nbytes = bin2hex ((gdb_byte *) notes, buf, strlen (notes));
13931 buf += xsnprintf (buf, endbuf - buf,
"tstop:");
13932 nbytes = bin2hex ((gdb_byte *) stop_notes, buf, strlen (stop_notes));
13941 if (*reply ==
'\0')
13944 if (strcmp (reply,
"OK") != 0)
13945 error (_(
"Bogus reply from target: %s"), reply);
13962 if (strcmp (rs->
buf.data (),
"OK") == 0)
13984 struct btrace_config
conf;
14002 char *buf, *pos, *endbuf;
14005 buf = rs->
buf.data ();
14013 pos += xsnprintf (pos, endbuf - pos,
"%s=0x%x", packet->
name,
14021 if (buf[0] ==
'E' && buf[1] ==
'.')
14022 error (_(
"Failed to configure the BTS buffer size: %s"), buf + 2);
14024 error (_(
"Failed to configure the BTS buffer size."));
14035 pos += xsnprintf (pos, endbuf - pos,
"%s=0x%x", packet->
name,
14043 if (buf[0] ==
'E' && buf[1] ==
'.')
14044 error (_(
"Failed to configure the trace buffer size: %s"), buf + 2);
14046 error (_(
"Failed to configure the trace buffer size."));
14062 gdb::optional<gdb::char_vector> xml
14075 int btrace_target_pushed = 0;
14076#if !defined (HAVE_LIBIPT)
14087 memset (&rs->
btrace_config, 0x00, sizeof (
struct btrace_config));
14093#if !defined (HAVE_LIBIPT)
14099 warning (_(
"Target is recording using Intel Processor Trace "
14100 "but support was disabled at compile time."));
14110 if (!btrace_target_pushed)
14112 btrace_target_pushed = 1;
14114 gdb_printf (_(
"Target is recording using %s.\n"),
14119 tp->btrace.target->ptid = tp->ptid;
14128 const struct btrace_config *
conf)
14133 char *buf = rs->
buf.data ();
14136 switch (conf->format)
14138 case BTRACE_FORMAT_BTS:
14142 case BTRACE_FORMAT_PT:
14148 error (_(
"Target does not support branch tracing."));
14152 ptid_t ptid = tp->
ptid;
14155 buf += xsnprintf (buf, endbuf - buf,
"%s", packet->
name);
14161 if (rs->
buf[0] ==
'E' && rs->
buf[1] ==
'.')
14162 error (_(
"Could not enable branch tracing for %s: %s"),
14165 error (_(
"Could not enable branch tracing for %s."),
14170 tinfo->
ptid = ptid;
14178 catch (
const gdb_exception_error &
err)
14180 if (
err.message != NULL)
14181 warning (
"%s",
err.what ());
14194 char *buf = rs->
buf.data ();
14198 error (_(
"Target does not support branch tracing."));
14202 buf += xsnprintf (buf, endbuf - buf,
"%s", packet->
name);
14208 if (rs->
buf[0] ==
'E' && rs->
buf[1] ==
'.')
14209 error (_(
"Could not disable branch tracing for %s: %s"),
14212 error (_(
"Could not disable branch tracing for %s."),
14233 enum btrace_read_type
type)
14239 error (_(
"Target does not support branch tracing."));
14241#if !defined(HAVE_LIBEXPAT)
14242 error (_(
"Cannot process branch tracing result. XML parsing not supported."));
14247 case BTRACE_READ_ALL:
14250 case BTRACE_READ_NEW:
14253 case BTRACE_READ_DELTA:
14257 internal_error (_(
"Bad branch tracing read type: %u."),
14258 (
unsigned int)
type);
14261 gdb::optional<gdb::char_vector> xml
14265 return BTRACE_ERR_UNKNOWN;
14269 return BTRACE_ERR_NONE;
14272const struct btrace_config *
14275 return &tinfo->
conf;
14300 static gdb::optional<gdb::char_vector> filename;
14301 char *annex = NULL;
14308 internal_error (_(
"not currently attached to process %d"),
pid);
14310 if (!
inf->fake_pid_p)
14312 const int annex_size = 9;
14314 annex = (
char *) alloca (annex_size);
14315 xsnprintf (annex, annex_size,
"%x",
pid);
14321 return filename ? filename->data () :
nullptr;
14370 if (tp->inf ==
inf && priv != NULL)
14373 error (_(
"Thread handle size mismatch: %d vs %zu (from remote)"),
14481 xsnprintf (rs->
buf.data (),
size,
"QThreadEvents:%x",
enable ? 1 : 0);
14489 if (strcmp (rs->
buf.data (),
"OK") != 0)
14490 error (_(
"Remote refused setting thread events: %s"), rs->
buf.data ());
14493 warning (_(
"Remote failure reply: %s"), rs->
buf.data ());
14509 for (; list != NULL; list = list->
next)
14510 if (strcmp (list->
name,
"Z-packet") == 0)
14521 uiout->
text (
": ");
14542 if (
inf->pspace != pspace)
14547 if (remote ==
nullptr)
14562 if (
inf->in_initial_library_scan)
14576 if (thread !=
nullptr)
14599 p = rs->
buf.data ();
14600 while (*p && *p !=
'l')
14606 p = rs->
buf.data ();
14620 p = rs->
buf.data ();
14621 while (*p && *p !=
'l')
14627 p = rs->
buf.data ();
14640 _(
"Debugger's willingness to use range stepping "
14641 "is %s.\n"),
value);
14670 warning (_(
"Range stepping is not supported by the current target"));
14678 gdb_printf (file, _(
"Debugging of remote protocol is %s.\n"),
14687 _(
"Timeout limit to wait for target to respond is %s.\n"),
14703 size_t len,
int type)
14707 std::string request = string_printf (
"qMemTags:%s,%s:%s",
14708 phex_nz (address, addr_size),
14709 phex_nz (len,
sizeof (len)),
14712 strcpy (packet.data (), request.c_str ());
14721 gdb::byte_vector &tags)
14723 if (reply.empty () || reply[0] ==
'E' || reply[0] !=
'm')
14727 tags = hex2bin (reply.data () + 1);
14736 size_t len,
int type,
14737 const gdb::byte_vector &tags)
14742 std::string request = string_printf (
"QMemTags:%s,%s:%s:",
14743 phex_nz (address, addr_size),
14744 phex_nz (len,
sizeof (len)),
14746 request += bin2hex (tags.data (), tags.size ());
14749 if (packet.size () < request.length ())
14750 error (_(
"Contents too big for packet QMemTags."));
14752 strcpy (packet.data (), request.c_str ());
14759 gdb::byte_vector &tags,
int type)
14763 gdb_assert_not_reached (
"remote fetch_memtags called with packet disabled");
14779 const gdb::byte_vector &tags,
int type)
14783 gdb_assert_not_reached (
"remote store_memtags called with packet disabled");
14812test_memory_tagging_functions ()
14819 scoped_restore restore_memtag_support_
14820 = make_scoped_restore (&config->
support);
14831 gdb::char_vector packet;
14832 gdb::byte_vector tags, bv;
14833 std::string expected, reply;
14834 packet.resize (32000);
14838 expected =
"qMemTags:0,0:0";
14840 SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
14842 expected =
"qMemTags:deadbeef,10:1";
14844 SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
14850 strcpy (packet.data (), reply.c_str ());
14853 SELF_CHECK (tags.size () == 0);
14859 for (
int i = 0; i < 5; i++)
14862 reply =
"m" + bin2hex (bv.data (), bv.size ());
14863 strcpy (packet.data (), reply.c_str ());
14866 SELF_CHECK (tags.size () == 5);
14868 for (
int i = 0; i < 5; i++)
14869 SELF_CHECK (tags[i] == i);
14875 expected =
"QMemTags:0,0:0:";
14877 SELF_CHECK (memcmp (packet.data (), expected.c_str (),
14878 expected.length ()) == 0);
14882 for (
int i = 0; i < 5; i++)
14883 tags.push_back (i);
14884 expected =
"QMemTags:deadbeef,ff:1:0001020304";
14886 SELF_CHECK (memcmp (packet.data (), expected.c_str (),
14887 expected.length ()) == 0);
14904 init_remote_threadtests ();
14910Remote protocol specific variables.\n\
14911Configure various remote-protocol specific variables such as\n\
14912the packets being used."),
14916Remote protocol specific variables.\n\
14917Configure various remote-protocol specific variables such as\n\
14918the packets being used."),
14923Compare section data on target to the exec file.\n\
14924Argument is a single section name (default: all loaded sections).\n\
14925To compare only read-only loaded sections, specify the -r option."),
14929Send an arbitrary packet to a remote target.\n\
14930 maintenance packet TEXT\n\
14931If GDB is talking to an inferior via the GDB serial protocol, then\n\
14932this command sends the string TEXT to the inferior, and displays the\n\
14933response packet. GDB supplies the initial `$' character, and the\n\
14934terminating `#' character and checksum."),
14939Set whether to send break if interrupted."), _(
"\
14940Show whether to send break if interrupted."), _(
"\
14941If set, a break, instead of a cntrl-c, is sent to the remote target."),
14950Set interrupt sequence to remote target."), _(
"\
14951Show interrupt sequence to remote target."), _(
"\
14952Valid value is \"Ctrl-C\", \"BREAK\" or \"BREAK-g\". The default is \"Ctrl-C\"."),
14959Set whether interrupt-sequence is sent to remote target when gdb connects to."), _(
"\
14960Show whether interrupt-sequence is sent to remote target when gdb connects to."), _(
"\
14961If set, interrupt sequence is sent to remote target."),
14968Set the maximum number of bytes per memory write packet (deprecated)."),
14971Show the maximum number of bytes per memory write packet (deprecated)."),
14975Set the maximum number of bytes per memory-write packet.\n\
14976Specify the number of bytes in a packet or 0 (zero) for the\n\
14977default packet size. The actual limit is further reduced\n\
14978dependent on the target. Specify ``fixed'' to disable the\n\
14979further restriction and ``limit'' to enable that restriction."),
14983Set the maximum number of bytes per memory-read packet.\n\
14984Specify the number of bytes in a packet or 0 (zero) for the\n\
14985default packet size. The actual limit is further reduced\n\
14986dependent on the target. Specify ``fixed'' to disable the\n\
14987further restriction and ``limit'' to enable that restriction."),
14991 _(
"Show the maximum number of bytes per memory-write packet."),
14995 _(
"Show the maximum number of bytes per memory-read packet."),
15000Set the maximum number of target hardware watchpoints."), _(
"\
15001Show the maximum number of target hardware watchpoints."), _(
"\
15002Specify \"unlimited\" for unlimited hardware watchpoints."),
15009Set the maximum length (in bytes) of a target hardware watchpoint."), _(
"\
15010Show the maximum length (in bytes) of a target hardware watchpoint."), _(
"\
15011Specify \"unlimited\" to allow watchpoints of unlimited size."),
15016Set the maximum number of target hardware breakpoints."), _(
"\
15017Show the maximum number of target hardware breakpoints."), _(
"\
15018Specify \"unlimited\" for unlimited hardware breakpoints."),
15024Set the maximum size of the address (in bits) in a memory packet."), _(
"\
15025Show the maximum size of the address (in bits) in a memory packet."), NULL,
15033 "X",
"binary-download", 1);
15036 "vCont",
"verbose-resume", 0);
15039 "QPassSignals",
"pass-signals", 0);
15042 "QCatchSyscalls",
"catch-syscalls", 0);
15045 "QProgramSignals",
"program-signals", 0);
15048 "QSetWorkingDir",
"set-working-dir", 0);
15051 "QStartupWithShell",
"startup-with-shell", 0);
15055 "QEnvironmentHexEncoded",
"environment-hex-encoded",
15059 "QEnvironmentReset",
"environment-reset",
15063 "QEnvironmentUnset",
"environment-unset",
15067 "qSymbol",
"symbol-lookup", 0);
15070 "P",
"set-register", 1);
15073 "p",
"fetch-register", 1);
15076 "Z0",
"software-breakpoint", 0);
15079 "Z1",
"hardware-breakpoint", 0);
15082 "Z2",
"write-watchpoint", 0);
15085 "Z3",
"read-watchpoint", 0);
15088 "Z4",
"access-watchpoint", 0);
15091 "qXfer:auxv:read",
"read-aux-vector", 0);
15094 "qXfer:exec-file:read",
"pid-to-exec-file", 0);
15097 "qXfer:features:read",
"target-features", 0);
15100 "qXfer:libraries:read",
"library-info", 0);
15103 "qXfer:libraries-svr4:read",
"library-info-svr4", 0);
15106 "qXfer:memory-map:read",
"memory-map", 0);
15109 "qXfer:osdata:read",
"osdata", 0);
15112 "qXfer:threads:read",
"threads", 0);
15115 "qXfer:siginfo:read",
"read-siginfo-object", 0);
15118 "qXfer:siginfo:write",
"write-siginfo-object", 0);
15122 "qXfer:traceframe-info:read",
"traceframe-info", 0);
15125 "qXfer:uib:read",
"unwind-info-block", 0);
15128 "qGetTLSAddr",
"get-thread-local-storage-address",
15132 "qGetTIBAddr",
"get-thread-information-block-address",
15136 "bc",
"reverse-continue", 0);
15139 "bs",
"reverse-step", 0);
15142 "qSupported",
"supported-packets", 0);
15145 "qSearch:memory",
"search-memory", 0);
15148 "qTStatus",
"trace-status", 0);
15151 "vFile:setfs",
"hostio-setfs", 0);
15154 "vFile:open",
"hostio-open", 0);
15157 "vFile:pread",
"hostio-pread", 0);
15160 "vFile:pwrite",
"hostio-pwrite", 0);
15163 "vFile:close",
"hostio-close", 0);
15166 "vFile:unlink",
"hostio-unlink", 0);
15169 "vFile:readlink",
"hostio-readlink", 0);
15172 "vFile:fstat",
"hostio-fstat", 0);
15175 "vAttach",
"attach", 0);
15181 "QStartNoAckMode",
"noack", 0);
15184 "vKill",
"kill", 0);
15187 "qAttached",
"query-attached", 0);
15190 "ConditionalTracepoints",
15191 "conditional-tracepoints", 0);
15194 "ConditionalBreakpoints",
15195 "conditional-breakpoints", 0);
15198 "BreakpointCommands",
15199 "breakpoint-commands", 0);
15202 "FastTracepoints",
"fast-tracepoints", 0);
15205 "TracepointSource",
"TracepointSource", 0);
15208 "QAllow",
"allow", 0);
15211 "StaticTracepoints",
"static-tracepoints", 0);
15214 "InstallInTrace",
"install-in-trace", 0);
15217 "qXfer:statictrace:read",
"read-sdata-object", 0);
15220 "qXfer:fdpic:read",
"read-fdpic-loadmap", 0);
15223 "QDisableRandomization",
"disable-randomization", 0);
15226 "QAgent",
"agent", 0);
15229 "QTBuffer:size",
"trace-buffer-size", 0);
15232 "Qbtrace:off",
"disable-btrace", 0);
15235 "Qbtrace:bts",
"enable-btrace-bts", 0);
15238 "Qbtrace:pt",
"enable-btrace-pt", 0);
15241 "qXfer:btrace",
"read-btrace", 0);
15244 "qXfer:btrace-conf",
"read-btrace-conf", 0);
15247 "Qbtrace-conf:bts:size",
"btrace-conf-bts-size", 0);
15250 "multiprocess-feature",
"multiprocess-feature", 0);
15253 "swbreak-feature",
"swbreak-feature", 0);
15256 "hwbreak-feature",
"hwbreak-feature", 0);
15259 "fork-event-feature",
"fork-event-feature", 0);
15262 "vfork-event-feature",
"vfork-event-feature", 0);
15265 "Qbtrace-conf:pt:size",
"btrace-conf-pt-size", 0);
15268 "vContSupported",
"verbose-resume-supported", 0);
15271 "exec-event-feature",
"exec-event-feature", 0);
15274 "vCtrlC",
"ctrl-c", 0);
15277 "QThreadEvents",
"thread-events", 0);
15280 "N stop reply",
"no-resumed-stop-reply", 0);
15283 "memory-tagging-feature",
"memory-tagging-feature", 0);
15325Set use of remote protocol `Z' packets."), _(
"\
15326Show use of remote protocol `Z' packets."), _(
"\
15327When set, GDB will attempt to use the remote breakpoint and watchpoint\n\
15336Manipulate files on the remote system.\n\
15337Transfer files to and from the remote target system."),
15342 _(
"Copy a local file to the remote system."),
15346 _(
"Copy a remote file to the local system."),
15350 _(
"Delete a remote file."),
15355Set the remote pathname for \"run\"."), _(
"\
15356Show the remote pathname for \"run\"."), NULL,
15364Enable or disable range stepping."), _(
"\
15365Show whether target-assisted range stepping is enabled."), _(
"\
15366If on, and the target supports it, when stepping a source line, GDB\n\
15367tells the target to step the corresponding range of addresses itself instead\n\
15368of issuing multiple single-steps. This speeds up source level\n\
15369stepping. If off, GDB always issues single-steps, even if range\n\
15370stepping is supported by the target. The default is on."),
15377Set watchdog timer."), _(
"\
15378Show watchdog timer."), _(
"\
15379When non-zero, this timeout is used instead of waiting forever for a target\n\
15380to finish a low-level step or continue operation. If the specified amount\n\
15381of time passes without a response from the target, an error occurs."),
15388Set the maximum number of characters to display for each remote packet."), _(
"\
15389Show the maximum number of characters to display for each remote packet."), _(
"\
15390Specify \"unlimited\" to display all the characters."),
15395 _(
"Set debugging of remote protocol."),
15396 _(
"Show debugging of remote protocol."),
15398When enabled, each packet sent or received with the remote target\n\
15406Set timeout limit to wait for target to respond."), _(
"\
15407Show timeout limit to wait for target to respond."), _(
"\
15408This value is used to set the time limit for gdb to wait for a response\n\
15418 selftests::register_test (
"remote_memory_tagging",
15419 selftests::test_memory_tagging_functions);
static struct @4 attributes[]
void * xrealloc(void *ptr, size_t size)
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
void parse_xml_btrace(struct btrace_data *btrace, const char *buffer)
void parse_xml_btrace_conf(struct btrace_config *conf, const char *xml)
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
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 use_threadinfo_query
bool use_threadextra_query
bool supports_vCont_probed
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
int wait_forever_enabled_p
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
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()
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()
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
target_xfer_status remote_read_qxfer(const char *object_name, const char *annex, gdb_byte *readbuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, struct packet_config *packet)
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)
void get_tracepoint_status(struct breakpoint *tp, struct uploaded_tp *utp) override
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
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::byte_vector thread_info_to_thread_handle(struct thread_info *tp) override
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
int getpkt_sane(gdb::char_vector *buf, int forever)
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)
target_xfer_status remote_write_qxfer(const char *object_name, const char *annex, const gdb_byte *writebuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, struct packet_config *packet)
bool stopped_by_watchpoint() override
void extended_remote_environment_support()
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 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
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)
int getpkt_or_notif_sane_1(gdb::char_vector *buf, int forever, int expecting_notif, int *is_notif)
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 getpkt_or_notif_sane(gdb::char_vector *buf, int forever, int *is_notif)
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
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()
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 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 remote_notif_get_pending_events(notif_client *nc)
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 getpkt(gdb::char_vector *buf, int forever)
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)
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)
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)
std::unique_ptr< private_thread_info > priv
bool has_pending_waitstatus() const
void clear_pending_waitstatus()
struct target_waitstatus pending_follow
const target_waitstatus & pending_waitstatus() const
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)
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)
thread_info * find_thread_ptid(inferior *inf, ptid_t ptid)
struct thread_info * first_thread_of_inferior(inferior *inf)
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 delete_thread(struct thread_info *thread)
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)
int signal_print_state(int signo)
void set_last_target_status(process_stratum_target *target, ptid_t ptid, const target_waitstatus &status)
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< struct bpstat *, int > normal_stop
observable< enum gdb_signal > signal_received
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, struct notif_client *except)
struct notif_event * remote_notif_parse(remote_target *remote, struct notif_client *nc, const char *buf)
void remote_notif_ack(remote_target *remote, struct 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 const struct protocol_feature remote_protocol_features[]
static int remote_supports_fast_tracepoints()
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 enum packet_support packet_config_support(struct packet_config *config)
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 int remote_notif_stop_can_get_pending_events(remote_target *remote, struct notif_client *self)
static unsigned int remote_address_size
static struct memory_packet_config memory_write_packet_config
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 void reset_all_packet_configs_support(void)
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 enum auto_boolean packet_set_cmd_state(int packet)
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)
@ 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
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 char * remote_support_xml
#define MIN_MEMORY_PACKET_SIZE
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 char * remote_hostio_error(fileio_error errnum)
static void set_pspace_remote_exec_file(struct program_space *pspace, const char *remote_exec_file)
static int strprefix(const char *p, const char *pend, const char *prefix)
static void add_packet_config_cmd(struct packet_config *config, const char *name, const char *title, int legacy)
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)
static void btrace_read_config(thread_info *tp, struct btrace_config *conf)
static int map_regcache_remote_table(struct gdbarch *gdbarch, struct packet_reg *regs)
static void show_remote_cmd(const char *args, int from_tty)
static int remote_newthread_step(threadref *ref, void *context)
static int remote_supports_install_in_trace()
static void remote_new_objfile(struct objfile *objfile)
#define CRAZY_MAX_THREADS
static int remote_exec_event_p(struct remote_state *rs)
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 int remote_vfork_event_p(struct remote_state *rs)
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 int remote_fork_event_p(struct remote_state *rs)
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)
struct notif_client notif_client_stop
static bool interrupt_on_connect
static int remote_multi_process_p(struct remote_state *rs)
static void compare_sections_command(const char *args, int from_tty)
static void show_memory_packet_size(struct memory_packet_config *config)
static void show_hardware_watchpoint_limit(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static struct memory_packet_config memory_read_packet_config
static std::string escape_buffer(const char *buf, int n)
static char * pack_threadlist_request(char *pkt, int startflag, int threadcount, threadref *nextthread)
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_supports_static_tracepoints()
static int remote_hw_watchpoint_limit
static bool remote_memory_tagging_p()
static char * pack_threadinfo_request(char *pkt, int mode, threadref *id)
static remote_thread_info * get_remote_thread_info(thread_info *thread)
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 struct packet_config remote_protocol_packets[PACKET_MAX]
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)
const char interrupt_sequence_break[]
#define OPAQUETHREADBYTES
static void set_remotebreak(const char *args, int from_tty, struct cmd_list_element *c)
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 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 int remote_supports_cond_tracepoints()
static void set_memory_write_packet_size(const char *args, int from_tty)
static void remote_notif_stop_ack(remote_target *remote, struct notif_client *self, const char *buf, struct notif_event *event)
static void set_remote_protocol_Z_packet_cmd(const char *args, int from_tty, struct cmd_list_element *c)
void remote_notif_get_pending_events(remote_target *remote, notif_client *nc)
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 remote_notif_stop_parse(remote_target *remote, struct notif_client *self, const char *buf, struct notif_event *event)
static void cli_packet_command(const char *args, int from_tty)
static const char * get_remote_exec_file(void)
#define MAXTHREADLISTRESULTS
int(* rmt_thread_action)(threadref *ref, void *context)
static serial_event_ftype remote_async_serial_handler
#define DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED
static void show_packet_config_cmd(ui_file *file, struct packet_config *config)
static enum packet_result packet_ok(const char *buf, struct packet_config *config)
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 set_memory_packet_size(const char *args, struct memory_packet_config *config)
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
struct btrace_config conf
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
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, struct notif_client *self, const char *buf, struct notif_event *event)
::section_offsets section_offsets
cmd_list_element * show_cmd
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
std::vector< remote_g_packet_guess > guesses
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
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::byte_vector 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
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)
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_status(const char *p, struct breakpoint *bp, struct uploaded_tp *utp)
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
void perror_with_name(const char *string)
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 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