aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog15
-rw-r--r--gdb/gdbserver/ax.c4
-rw-r--r--gdb/gdbserver/ax.h2
-rw-r--r--gdb/gdbserver/mem-break.c8
-rw-r--r--gdb/gdbserver/mem-break.h5
-rw-r--r--gdb/gdbserver/remote-utils.c8
-rw-r--r--gdb/gdbserver/remote-utils.h2
-rw-r--r--gdb/gdbserver/server.c28
-rw-r--r--gdb/gdbserver/tracepoint.c30
9 files changed, 57 insertions, 45 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 0dbcae2..6027c7f 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,20 @@
2017-09-29 Pedro Alves <palves@redhat.com>
+ * ax.c (gdb_parse_agent_expr): Constify.
+ * ax.h (gdb_parse_agent_expr): Constify.
+ * mem-break.c (add_breakpoint_condition, add_breakpoint_commands):
+ Constify.
+ * mem-break.h (add_breakpoint_condition, add_breakpoint_commands): Constify.
+ * remote-utils.c (hex_or_minus_one, read_ptid): Constify.
+ * remote-utils.h (read_ptid): Constify.
+ * server.c (handle_qxfer_exec_file, handle_query, handle_v_cont)
+ (process_point_options, process_serial_event): Constify.
+ * tracepoint.c (add_tracepoint_action, cmd_qtdp, cmd_qtdpsrc)
+ (cmd_qtdv, cmd_qtenable_disable, cmd_qtro, cmd_qtframe, cmd_qtp)
+ (cmd_qtbuffer): Constify.
+
+2017-09-29 Pedro Alves <palves@redhat.com>
+
* proc-service.c (ps_pdread): Return PS_ERR if reading memory
fails.
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index 87b9359..35ed2c6 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -95,9 +95,9 @@ gdb_agent_op_name (int op)
of bytes in expression, a comma, and then the bytes. */
struct agent_expr *
-gdb_parse_agent_expr (char **actparm)
+gdb_parse_agent_expr (const char **actparm)
{
- char *act = *actparm;
+ const char *act = *actparm;
ULONGEST xlen;
struct agent_expr *aexpr;
diff --git a/gdb/gdbserver/ax.h b/gdb/gdbserver/ax.h
index b400cb9..6f4612b 100644
--- a/gdb/gdbserver/ax.h
+++ b/gdb/gdbserver/ax.h
@@ -55,7 +55,7 @@ struct agent_expr
/* The packet form of an agent expression consists of an 'X', number
of bytes in expression, a comma, and then the bytes. */
-struct agent_expr *gdb_parse_agent_expr (char **actparm);
+struct agent_expr *gdb_parse_agent_expr (const char **actparm);
/* Release an agent expression. */
void gdb_free_agent_expr (struct agent_expr *aexpr);
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 6e6926a..d836177 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -1269,9 +1269,9 @@ add_condition_to_breakpoint (struct gdb_breakpoint *bp,
/* Add a target-side condition CONDITION to a breakpoint. */
int
-add_breakpoint_condition (struct gdb_breakpoint *bp, char **condition)
+add_breakpoint_condition (struct gdb_breakpoint *bp, const char **condition)
{
- char *actparm = *condition;
+ const char *actparm = *condition;
struct agent_expr *cond;
if (condition == NULL)
@@ -1367,10 +1367,10 @@ add_commands_to_breakpoint (struct gdb_breakpoint *bp,
/* Add a target-side command COMMAND to the breakpoint at ADDR. */
int
-add_breakpoint_commands (struct gdb_breakpoint *bp, char **command,
+add_breakpoint_commands (struct gdb_breakpoint *bp, const char **command,
int persist)
{
- char *actparm = *command;
+ const char *actparm = *command;
struct agent_expr *cmd;
if (command == NULL)
diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h
index b14d2be..54f0983 100644
--- a/gdb/gdbserver/mem-break.h
+++ b/gdb/gdbserver/mem-break.h
@@ -114,14 +114,15 @@ void clear_breakpoint_conditions_and_commands (struct gdb_breakpoint *bp);
Returns false on failure. On success, advances CONDITION pointer
past the condition and returns true. */
-int add_breakpoint_condition (struct gdb_breakpoint *bp, char **condition);
+int add_breakpoint_condition (struct gdb_breakpoint *bp,
+ const char **condition);
/* Set target-side commands COMMANDS to the breakpoint at ADDR.
Returns false on failure. On success, advances COMMANDS past the
commands and returns true. If PERSIST, the commands should run
even while GDB is disconnected. */
-int add_breakpoint_commands (struct gdb_breakpoint *bp, char **commands,
+int add_breakpoint_commands (struct gdb_breakpoint *bp, const char **commands,
int persist);
int any_persistent_commands (void);
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 7616046..66e0652 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -533,7 +533,7 @@ write_ptid (char *buf, ptid_t ptid)
}
static ULONGEST
-hex_or_minus_one (char *buf, char **obuf)
+hex_or_minus_one (const char *buf, const char **obuf)
{
ULONGEST ret;
@@ -554,10 +554,10 @@ hex_or_minus_one (char *buf, char **obuf)
/* Extract a PTID from BUF. If non-null, OBUF is set to the to one
passed the last parsed char. Returns null_ptid on error. */
ptid_t
-read_ptid (char *buf, char **obuf)
+read_ptid (const char *buf, const char **obuf)
{
- char *p = buf;
- char *pp;
+ const char *p = buf;
+ const char *pp;
ULONGEST pid = 0, tid = 0;
if (*p == 'p')
diff --git a/gdb/gdbserver/remote-utils.h b/gdb/gdbserver/remote-utils.h
index b3eab3b..b45a725 100644
--- a/gdb/gdbserver/remote-utils.h
+++ b/gdb/gdbserver/remote-utils.h
@@ -28,7 +28,7 @@ int gdb_connected (void);
#define STDIO_CONNECTION_NAME "stdio"
int remote_connection_is_stdio (void);
-ptid_t read_ptid (char *buf, char **obuf);
+ptid_t read_ptid (const char *buf, const char **obuf);
char *write_ptid (char *buf, ptid_t ptid);
int putpkt (char *buf);
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index f3eee31..c4f1e8d 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1427,7 +1427,7 @@ handle_qxfer_auxv (const char *annex,
/* Handle qXfer:exec-file:read. */
static int
-handle_qxfer_exec_file (const char *const_annex,
+handle_qxfer_exec_file (const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, LONGEST len)
{
@@ -1438,7 +1438,7 @@ handle_qxfer_exec_file (const char *const_annex,
if (the_target->pid_to_exec_file == NULL || writebuf != NULL)
return -2;
- if (const_annex[0] == '\0')
+ if (annex[0] == '\0')
{
if (current_thread == NULL)
return -1;
@@ -1447,11 +1447,7 @@ handle_qxfer_exec_file (const char *const_annex,
}
else
{
- char *annex = (char *) alloca (strlen (const_annex) + 1);
-
- strcpy (annex, const_annex);
annex = unpack_varlen_hex (annex, &pid);
-
if (annex[0] != '\0')
return -1;
}
@@ -2535,7 +2531,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (the_target->get_tib_address != NULL
&& startswith (own_buf, "qGetTIBAddr:"))
{
- char *annex;
+ const char *annex;
int n;
CORE_ADDR tlb;
ptid_t ptid = read_ptid (own_buf + 12, &annex);
@@ -2623,7 +2619,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (startswith (own_buf, "qCRC:"))
{
/* CRC check (compare-section). */
- char *comma;
+ const char *comma;
ULONGEST base;
int len;
unsigned long long crc;
@@ -2732,7 +2728,7 @@ handle_pending_status (const struct thread_resume *resumption,
static void
handle_v_cont (char *own_buf)
{
- char *p, *q;
+ const char *p;
int n = 0, i = 0;
struct thread_resume *resume_info;
struct thread_resume default_action { null_ptid };
@@ -2771,8 +2767,8 @@ handle_v_cont (char *own_buf)
if (p[0] == 'S' || p[0] == 'C')
{
- int sig;
- sig = strtol (p + 1, &q, 16);
+ char *q;
+ int sig = strtol (p + 1, &q, 16);
if (p == q)
goto err;
p = q;
@@ -2809,6 +2805,7 @@ handle_v_cont (char *own_buf)
}
else if (p[0] == ':')
{
+ const char *q;
ptid_t ptid = read_ptid (p + 1, &q);
if (p == q)
@@ -4009,9 +4006,9 @@ main (int argc, char *argv[])
after the last processed option. */
static void
-process_point_options (struct gdb_breakpoint *bp, char **packet)
+process_point_options (struct gdb_breakpoint *bp, const char **packet)
{
- char *dataptr = *packet;
+ const char *dataptr = *packet;
int persist;
/* Check if data has the correct format. */
@@ -4273,7 +4270,7 @@ process_serial_event (void)
char type = own_buf[1];
int res;
const int insert = ch == 'Z';
- char *p = &own_buf[3];
+ const char *p = &own_buf[3];
p = unpack_varlen_hex (p, &addr);
kind = strtol (p + 1, &dataptr, 16);
@@ -4293,7 +4290,8 @@ process_serial_event (void)
is telling us to drop that list and use this one
instead. */
clear_breakpoint_conditions_and_commands (bp);
- process_point_options (bp, &dataptr);
+ const char *options = dataptr;
+ process_point_options (bp, &options);
}
}
else
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 0f41ff4..8ec8010 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -1910,9 +1910,9 @@ find_next_tracepoint_by_number (struct tracepoint *prev_tp, int num)
/* Append another action to perform when the tracepoint triggers. */
static void
-add_tracepoint_action (struct tracepoint *tpoint, char *packet)
+add_tracepoint_action (struct tracepoint *tpoint, const char *packet)
{
- char *act;
+ const char *act;
if (*packet == 'S')
{
@@ -1924,7 +1924,7 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet)
while (*act)
{
- char *act_start = act;
+ const char *act_start = act;
struct tracepoint_action *action = NULL;
switch (*act)
@@ -2485,8 +2485,7 @@ cmd_qtdp (char *own_buf)
ULONGEST addr;
ULONGEST count;
struct tracepoint *tpoint;
- char *actparm;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTDP:");
@@ -2546,9 +2545,7 @@ cmd_qtdp (char *own_buf)
}
else if (*packet == 'X')
{
- actparm = (char *) packet;
- tpoint->cond = gdb_parse_agent_expr (&actparm);
- packet = actparm;
+ tpoint->cond = gdb_parse_agent_expr (&packet);
}
else if (*packet == '-')
break;
@@ -2657,8 +2654,9 @@ cmd_qtdpsrc (char *own_buf)
{
ULONGEST num, addr, start, slen;
struct tracepoint *tpoint;
- char *packet = own_buf;
- char *saved, *srctype, *src;
+ const char *packet = own_buf;
+ const char *saved;
+ char *srctype, *src;
size_t nbytes;
struct source_string *last, *newlast;
@@ -2720,7 +2718,7 @@ cmd_qtdv (char *own_buf)
char *varname;
size_t nbytes;
struct trace_state_variable *tsv;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTDV:");
@@ -2748,7 +2746,7 @@ cmd_qtdv (char *own_buf)
static void
cmd_qtenable_disable (char *own_buf, int enable)
{
- char *packet = own_buf;
+ const char *packet = own_buf;
ULONGEST num, addr;
struct tracepoint *tp;
@@ -2870,7 +2868,7 @@ cmd_qtro (char *own_buf)
{
ULONGEST start, end;
struct readonly_region *roreg;
- char *packet = own_buf;
+ const char *packet = own_buf;
trace_debug ("Want to mark readonly regions");
@@ -3557,7 +3555,7 @@ cmd_qtframe (char *own_buf)
ULONGEST frame, pc, lo, hi, num;
int tfnum, tpnum;
struct traceframe *tframe;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTFrame:");
@@ -3712,7 +3710,7 @@ cmd_qtp (char *own_buf)
{
ULONGEST num, addr;
struct tracepoint *tpoint;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("qTP:");
@@ -4005,7 +4003,7 @@ cmd_qtbuffer (char *own_buf)
{
ULONGEST offset, num, tot;
unsigned char *tbp;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("qTBuffer:");