aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/hostio.c12
-rw-r--r--gdb/gdbserver/linux-low.c4
-rw-r--r--gdb/gdbserver/linux-x86-low.c2
-rw-r--r--gdb/gdbserver/notif.c2
-rw-r--r--gdb/gdbserver/remote-utils.c6
-rw-r--r--gdb/gdbserver/server.c59
-rw-r--r--gdb/gdbserver/tracepoint.c63
-rw-r--r--gdb/gdbserver/win32-low.c2
8 files changed, 68 insertions, 82 deletions
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index e6b7754..ec29eb9 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -511,17 +511,17 @@ handle_readlink (char *own_buf, int *new_packet_len)
int
handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
{
- if (strncmp (own_buf, "vFile:open:", 11) == 0)
+ if (startswith (own_buf, "vFile:open:"))
handle_open (own_buf);
- else if (strncmp (own_buf, "vFile:pread:", 12) == 0)
+ else if (startswith (own_buf, "vFile:pread:"))
handle_pread (own_buf, new_packet_len);
- else if (strncmp (own_buf, "vFile:pwrite:", 13) == 0)
+ else if (startswith (own_buf, "vFile:pwrite:"))
handle_pwrite (own_buf, packet_len);
- else if (strncmp (own_buf, "vFile:close:", 12) == 0)
+ else if (startswith (own_buf, "vFile:close:"))
handle_close (own_buf);
- else if (strncmp (own_buf, "vFile:unlink:", 13) == 0)
+ else if (startswith (own_buf, "vFile:unlink:"))
handle_unlink (own_buf);
- else if (strncmp (own_buf, "vFile:readlink:", 15) == 0)
+ else if (startswith (own_buf, "vFile:readlink:"))
handle_readlink (own_buf, new_packet_len);
else
return 0;
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4da11c6..48d905b 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5903,9 +5903,9 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
break;
len = sep - annex;
- if (len == 5 && strncmp (annex, "start", 5) == 0)
+ if (len == 5 && startswith (annex, "start"))
addrp = &lm_addr;
- else if (len == 4 && strncmp (annex, "prev", 4) == 0)
+ else if (len == 4 && startswith (annex, "prev"))
addrp = &lm_prev;
else
{
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 3a10e61..72478d8 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -1523,7 +1523,7 @@ x86_linux_process_qsupported (const char *query)
with "i386" in qSupported query, it supports x86 XML target
descriptions. */
use_xml = 0;
- if (query != NULL && strncmp (query, "xmlRegisters=", 13) == 0)
+ if (query != NULL && startswith (query, "xmlRegisters="))
{
char *copy = xstrdup (query + 13);
char *p;
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index ba2af77..436c1b8 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -86,7 +86,7 @@ handle_notif_ack (char *own_buf, int packet_len)
{
const char *ack_name = notifs[i]->ack_name;
- if (strncmp (own_buf, ack_name, strlen (ack_name)) == 0
+ if (startswith (own_buf, ack_name)
&& packet_len == strlen (ack_name))
break;
}
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 02c40f5..1de86be 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -531,7 +531,7 @@ hex_or_minus_one (char *buf, char **obuf)
{
ULONGEST ret;
- if (strncmp (buf, "-1", 2) == 0)
+ if (startswith (buf, "-1"))
{
ret = (ULONGEST) -1;
buf += 2;
@@ -1447,7 +1447,7 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
return -1;
}
- if (strncmp (own_buf, "qSymbol:", strlen ("qSymbol:")) != 0)
+ if (!startswith (own_buf, "qSymbol:"))
{
warning ("Malformed response to qSymbol, ignoring: %s\n", own_buf);
return -1;
@@ -1556,7 +1556,7 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
return -1;
}
- if (strncmp (own_buf, "qRelocInsn:", strlen ("qRelocInsn:")) != 0)
+ if (!startswith (own_buf, "qRelocInsn:"))
{
warning ("Malformed response to qRelocInsn, ignoring: %s\n",
own_buf);
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 83529ff..4189877 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -429,7 +429,7 @@ handle_btrace_general_set (char *own_buf)
const char *err;
char *op;
- if (strncmp ("Qbtrace:", own_buf, strlen ("Qbtrace:")) != 0)
+ if (!startswith (own_buf, "Qbtrace:"))
return 0;
op = own_buf + strlen ("Qbtrace:");
@@ -473,7 +473,7 @@ handle_btrace_conf_general_set (char *own_buf)
struct thread_info *thread;
char *op;
- if (strncmp ("Qbtrace-conf:", own_buf, strlen ("Qbtrace-conf:")) != 0)
+ if (!startswith (own_buf, "Qbtrace-conf:"))
return 0;
op = own_buf + strlen ("Qbtrace-conf:");
@@ -492,7 +492,7 @@ handle_btrace_conf_general_set (char *own_buf)
return -1;
}
- if (strncmp (op, "bts:size=", strlen ("bts:size=")) == 0)
+ if (startswith (op, "bts:size="))
{
unsigned long size;
char *endp = NULL;
@@ -522,7 +522,7 @@ handle_btrace_conf_general_set (char *own_buf)
static void
handle_general_set (char *own_buf)
{
- if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0)
+ if (startswith (own_buf, "QPassSignals:"))
{
int numsigs = (int) GDB_SIGNAL_LAST, i;
const char *p = own_buf + strlen ("QPassSignals:");
@@ -547,7 +547,7 @@ handle_general_set (char *own_buf)
return;
}
- if (strncmp ("QProgramSignals:", own_buf, strlen ("QProgramSignals:")) == 0)
+ if (startswith (own_buf, "QProgramSignals:"))
{
int numsigs = (int) GDB_SIGNAL_LAST, i;
const char *p = own_buf + strlen ("QProgramSignals:");
@@ -587,7 +587,7 @@ handle_general_set (char *own_buf)
return;
}
- if (strncmp (own_buf, "QNonStop:", 9) == 0)
+ if (startswith (own_buf, "QNonStop:"))
{
char *mode = own_buf + 9;
int req = -1;
@@ -624,8 +624,7 @@ handle_general_set (char *own_buf)
return;
}
- if (strncmp ("QDisableRandomization:", own_buf,
- strlen ("QDisableRandomization:")) == 0)
+ if (startswith (own_buf, "QDisableRandomization:"))
{
char *packet = own_buf + strlen ("QDisableRandomization:");
ULONGEST setting;
@@ -649,7 +648,7 @@ handle_general_set (char *own_buf)
&& handle_tracepoint_general_set (own_buf))
return;
- if (strncmp ("QAgent:", own_buf, strlen ("QAgent:")) == 0)
+ if (startswith (own_buf, "QAgent:"))
{
char *mode = own_buf + strlen ("QAgent:");
int req = 0;
@@ -1072,8 +1071,7 @@ handle_monitor_command (char *mon, char *own_buf)
remote_debug = 0;
monitor_output ("Protocol debug output disabled.\n");
}
- else if (strncmp (mon, "set debug-format ",
- sizeof ("set debug-format ") - 1) == 0)
+ else if (startswith (mon, "set debug-format "))
{
char *error_msg
= parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
@@ -1661,7 +1659,7 @@ handle_qxfer (char *own_buf, int packet_len, int *new_packet_len_p)
char *annex;
char *offset;
- if (strncmp (own_buf, "qXfer:", 6) != 0)
+ if (!startswith (own_buf, "qXfer:"))
return 0;
/* Grab the object, r/w and annex. */
@@ -1935,7 +1933,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
}
/* Protocol features query. */
- if (strncmp ("qSupported", own_buf, 10) == 0
+ if (startswith (own_buf, "qSupported")
&& (own_buf[10] == ':' || own_buf[10] == '\0'))
{
char *p = &own_buf[10];
@@ -2089,7 +2087,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
/* Thread-local storage support. */
if (the_target->get_tls_address != NULL
- && strncmp ("qGetTLSAddr:", own_buf, 12) == 0)
+ && startswith (own_buf, "qGetTLSAddr:"))
{
char *p = own_buf + 12;
CORE_ADDR parts[2], address = 0;
@@ -2154,7 +2152,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
/* Windows OS Thread Information Block address support. */
if (the_target->get_tib_address != NULL
- && strncmp ("qGetTIBAddr:", own_buf, 12) == 0)
+ && startswith (own_buf, "qGetTIBAddr:"))
{
char *annex;
int n;
@@ -2176,7 +2174,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
}
/* Handle "monitor" commands. */
- if (strncmp ("qRcmd,", own_buf, 6) == 0)
+ if (startswith (own_buf, "qRcmd,"))
{
char *mon = malloc (PBUFSIZ);
int len = strlen (own_buf + 6);
@@ -2207,8 +2205,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return;
}
- if (strncmp ("qSearch:memory:", own_buf,
- sizeof ("qSearch:memory:") - 1) == 0)
+ if (startswith (own_buf, "qSearch:memory:"))
{
require_running (own_buf);
handle_search_memory (own_buf, packet_len);
@@ -2216,7 +2213,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
}
if (strcmp (own_buf, "qAttached") == 0
- || strncmp (own_buf, "qAttached:", sizeof ("qAttached:") - 1) == 0)
+ || startswith (own_buf, "qAttached:"))
{
struct process_info *process;
@@ -2242,7 +2239,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return;
}
- if (strncmp ("qCRC:", own_buf, 5) == 0)
+ if (startswith (own_buf, "qCRC:"))
{
/* CRC check (compare-section). */
char *comma;
@@ -2672,14 +2669,14 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
{
if (!disable_packet_vCont)
{
- if (strncmp (own_buf, "vCont;", 6) == 0)
+ if (startswith (own_buf, "vCont;"))
{
require_running (own_buf);
handle_v_cont (own_buf);
return;
}
- if (strncmp (own_buf, "vCont?", 6) == 0)
+ if (startswith (own_buf, "vCont?"))
{
strcpy (own_buf, "vCont;c;C;s;S;t");
if (target_supports_range_stepping ())
@@ -2691,11 +2688,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
}
}
- if (strncmp (own_buf, "vFile:", 6) == 0
+ if (startswith (own_buf, "vFile:")
&& handle_vFile (own_buf, packet_len, new_packet_len))
return;
- if (strncmp (own_buf, "vAttach;", 8) == 0)
+ if (startswith (own_buf, "vAttach;"))
{
if ((!extended_protocol || !multi_process) && target_running ())
{
@@ -2707,7 +2704,7 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
return;
}
- if (strncmp (own_buf, "vRun;", 5) == 0)
+ if (startswith (own_buf, "vRun;"))
{
if ((!extended_protocol || !multi_process) && target_running ())
{
@@ -2719,7 +2716,7 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
return;
}
- if (strncmp (own_buf, "vKill;", 6) == 0)
+ if (startswith (own_buf, "vKill;"))
{
if (!target_running ())
{
@@ -3211,9 +3208,7 @@ captured_main (int argc, char *argv[])
}
else if (strcmp (*next_arg, "--debug") == 0)
debug_threads = 1;
- else if (strncmp (*next_arg,
- "--debug-format=",
- sizeof ("--debug-format=") - 1) == 0)
+ else if (startswith (*next_arg, "--debug-format="))
{
char *error_msg
= parse_debug_format_options ((*next_arg)
@@ -3232,9 +3227,7 @@ captured_main (int argc, char *argv[])
gdbserver_show_disableable (stdout);
exit (0);
}
- else if (strncmp (*next_arg,
- "--disable-packet=",
- sizeof ("--disable-packet=") - 1) == 0)
+ else if (startswith (*next_arg, "--disable-packet="))
{
char *packets, *tok;
@@ -3533,7 +3526,7 @@ process_point_options (struct breakpoint *bp, char **packet)
if (!add_breakpoint_condition (bp, &dataptr))
skip_to_semicolon (&dataptr);
}
- else if (strncmp (dataptr, "cmds:", strlen ("cmds:")) == 0)
+ else if (startswith (dataptr, "cmds:"))
{
dataptr += strlen ("cmds:");
if (debug_threads)
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 6fcd0b0..27fcf03 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3551,14 +3551,14 @@ cmd_qtframe (char *own_buf)
packet += strlen ("QTFrame:");
- if (strncmp (packet, "pc:", strlen ("pc:")) == 0)
+ if (startswith (packet, "pc:"))
{
packet += strlen ("pc:");
unpack_varlen_hex (packet, &pc);
trace_debug ("Want to find next traceframe at pc=0x%s", paddress (pc));
tframe = find_next_traceframe_in_range (pc, pc, 1, &tfnum);
}
- else if (strncmp (packet, "range:", strlen ("range:")) == 0)
+ else if (startswith (packet, "range:"))
{
packet += strlen ("range:");
packet = unpack_varlen_hex (packet, &lo);
@@ -3568,7 +3568,7 @@ cmd_qtframe (char *own_buf)
paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 1, &tfnum);
}
- else if (strncmp (packet, "outside:", strlen ("outside:")) == 0)
+ else if (startswith (packet, "outside:"))
{
packet += strlen ("outside:");
packet = unpack_varlen_hex (packet, &lo);
@@ -3579,7 +3579,7 @@ cmd_qtframe (char *own_buf)
paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 0, &tfnum);
}
- else if (strncmp (packet, "tdp:", strlen ("tdp:")) == 0)
+ else if (startswith (packet, "tdp:"))
{
packet += strlen ("tdp:");
unpack_varlen_hex (packet, &num);
@@ -3653,7 +3653,7 @@ cmd_qtstatus (char *packet)
/* The user visible error string in terror needs to be hex encoded.
We leave it as plain string in `tracing_stop_reason' to ease
debugging. */
- if (strncmp (stop_reason_rsp, "terror:", strlen ("terror:")) == 0)
+ if (startswith (stop_reason_rsp, "terror:"))
{
const char *result_name;
int hexstr_len;
@@ -4106,7 +4106,7 @@ cmd_qtnotes (char *own_buf)
while (*packet)
{
- if (strncmp ("user:", packet, strlen ("user:")) == 0)
+ if (startswith (packet, "user:"))
{
packet += strlen ("user:");
saved = packet;
@@ -4120,7 +4120,7 @@ cmd_qtnotes (char *own_buf)
xfree (tracing_user_name);
tracing_user_name = user;
}
- else if (strncmp ("notes:", packet, strlen ("notes:")) == 0)
+ else if (startswith (packet, "notes:"))
{
packet += strlen ("notes:");
saved = packet;
@@ -4134,7 +4134,7 @@ cmd_qtnotes (char *own_buf)
xfree (tracing_notes);
tracing_notes = notes;
}
- else if (strncmp ("tstop:", packet, strlen ("tstop:")) == 0)
+ else if (startswith (packet, "tstop:"))
{
packet += strlen ("tstop:");
saved = packet;
@@ -4163,32 +4163,32 @@ handle_tracepoint_general_set (char *packet)
cmd_qtinit (packet);
return 1;
}
- else if (strncmp ("QTDP:", packet, strlen ("QTDP:")) == 0)
+ else if (startswith (packet, "QTDP:"))
{
cmd_qtdp (packet);
return 1;
}
- else if (strncmp ("QTDPsrc:", packet, strlen ("QTDPsrc:")) == 0)
+ else if (startswith (packet, "QTDPsrc:"))
{
cmd_qtdpsrc (packet);
return 1;
}
- else if (strncmp ("QTEnable:", packet, strlen ("QTEnable:")) == 0)
+ else if (startswith (packet, "QTEnable:"))
{
cmd_qtenable_disable (packet, 1);
return 1;
}
- else if (strncmp ("QTDisable:", packet, strlen ("QTDisable:")) == 0)
+ else if (startswith (packet, "QTDisable:"))
{
cmd_qtenable_disable (packet, 0);
return 1;
}
- else if (strncmp ("QTDV:", packet, strlen ("QTDV:")) == 0)
+ else if (startswith (packet, "QTDV:"))
{
cmd_qtdv (packet);
return 1;
}
- else if (strncmp ("QTro:", packet, strlen ("QTro:")) == 0)
+ else if (startswith (packet, "QTro:"))
{
cmd_qtro (packet);
return 1;
@@ -4203,28 +4203,27 @@ handle_tracepoint_general_set (char *packet)
cmd_qtstop (packet);
return 1;
}
- else if (strncmp ("QTDisconnected:", packet,
- strlen ("QTDisconnected:")) == 0)
+ else if (startswith (packet, "QTDisconnected:"))
{
cmd_qtdisconnected (packet);
return 1;
}
- else if (strncmp ("QTFrame:", packet, strlen ("QTFrame:")) == 0)
+ else if (startswith (packet, "QTFrame:"))
{
cmd_qtframe (packet);
return 1;
}
- else if (strncmp ("QTBuffer:circular:", packet, strlen ("QTBuffer:circular:")) == 0)
+ else if (startswith (packet, "QTBuffer:circular:"))
{
cmd_bigqtbuffer_circular (packet);
return 1;
}
- else if (strncmp ("QTBuffer:size:", packet, strlen ("QTBuffer:size:")) == 0)
+ else if (startswith (packet, "QTBuffer:size:"))
{
cmd_bigqtbuffer_size (packet);
return 1;
}
- else if (strncmp ("QTNotes:", packet, strlen ("QTNotes:")) == 0)
+ else if (startswith (packet, "QTNotes:"))
{
cmd_qtnotes (packet);
return 1;
@@ -4241,7 +4240,7 @@ handle_tracepoint_query (char *packet)
cmd_qtstatus (packet);
return 1;
}
- else if (strncmp ("qTP:", packet, strlen ("qTP:")) == 0)
+ else if (startswith (packet, "qTP:"))
{
cmd_qtp (packet);
return 1;
@@ -4266,12 +4265,12 @@ handle_tracepoint_query (char *packet)
cmd_qtsv (packet);
return 1;
}
- else if (strncmp ("qTV:", packet, strlen ("qTV:")) == 0)
+ else if (startswith (packet, "qTV:"))
{
cmd_qtv (packet);
return 1;
}
- else if (strncmp ("qTBuffer:", packet, strlen ("qTBuffer:")) == 0)
+ else if (startswith (packet, "qTBuffer:"))
{
cmd_qtbuffer (packet);
return 1;
@@ -4286,7 +4285,7 @@ handle_tracepoint_query (char *packet)
cmd_qtsstm (packet);
return 1;
}
- else if (strncmp ("qTSTMat:", packet, strlen ("qTSTMat:")) == 0)
+ else if (startswith (packet, "qTSTMat:"))
{
cmd_qtstmat (packet);
return 1;
@@ -6123,7 +6122,7 @@ tracepoint_send_agent (struct tracepoint *tpoint)
if (ret)
return ret;
- if (strncmp (buf, "OK", 2) != 0)
+ if (!startswith (buf, "OK"))
return 1;
/* The value of tracepoint's target address is stored in BUF. */
@@ -7202,7 +7201,7 @@ gdb_agent_helper_thread (void *arg)
if (cmd_buf[0])
{
- if (strncmp ("close", cmd_buf, 5) == 0)
+ if (startswith (cmd_buf, "close"))
{
stop_loop = 1;
}
@@ -7215,21 +7214,15 @@ gdb_agent_helper_thread (void *arg)
{
cmd_qtsstm (cmd_buf);
}
- else if (strncmp ("unprobe_marker_at:",
- cmd_buf,
- sizeof ("unprobe_marker_at:") - 1) == 0)
+ else if (startswith (cmd_buf, "unprobe_marker_at:"))
{
unprobe_marker_at (cmd_buf);
}
- else if (strncmp ("probe_marker_at:",
- cmd_buf,
- sizeof ("probe_marker_at:") - 1) == 0)
+ else if (startswith (cmd_buf, "probe_marker_at:"))
{
probe_marker_at (cmd_buf);
}
- else if (strncmp ("qTSTMat:",
- cmd_buf,
- sizeof ("qTSTMat:") - 1) == 0)
+ else if (startswith (cmd_buf, "qTSTMat:"))
{
cmd_qtstmat (cmd_buf);
}
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 2b24c87..6c86765 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -778,7 +778,7 @@ handle_output_debug_string (struct target_waitstatus *ourstatus)
return;
}
- if (strncmp (s, "cYg", 3) != 0)
+ if (!startswith (s, "cYg"))
{
if (!server_waiting)
{