aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2016-01-28 10:28:56 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2016-01-28 10:28:56 -0500
commit8424cc978c8c76aca7945d50408762de65646095 (patch)
tree3525c71e308de0a6e4eab6ea409ac6fe67a5f94b /gdb/remote.c
parent7fe8399de97e50f631ce28ceb42515862a927556 (diff)
downloadgdb-8424cc978c8c76aca7945d50408762de65646095.zip
gdb-8424cc978c8c76aca7945d50408762de65646095.tar.gz
gdb-8424cc978c8c76aca7945d50408762de65646095.tar.bz2
Import strchrnul from gnulib and use it
For a forthcoming patch, I need a "skip_to_colon" function. I noticed there are two skip_to_semicolon (one in gdb and one in gdbserver). I thought we could put it in common/, and generalize it for any character. It turns out that the strchrnul function does exactly that. I imported the corresponding module from gnulib, for those systems that do not have it. There are probably more places where this function can be used instead of doing the work by hand (I am looking at remote-utils.c::look_up_one_symbol). gdb/ChangeLog: * remote.c (skip_to_semicolon): Remove. (remote_parse_stop_reply): Use strchrnul instead of skip_to_semicolon. * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strchrnul. * gnulib/aclocal.m4: Regenerate. * gnulib/config.in: Regenerate. * gnulib/configure: Regenerate. * gnulib/import/Makefile.am: Regenerate. * gnulib/import/Makefile.in: Regenerate. * gnulib/import/m4/gnulib-cache.m4: Regenerate. * gnulib/import/m4/gnulib-comp.m4: Regenerate. * gnulib/import/m4/rawmemchr.m4: New file. * gnulib/import/m4/strchrnul.m4: New file. * gnulib/import/rawmemchr.c: New file. * gnulib/import/rawmemchr.valgrind: New file. * gnulib/import/strchrnul.c: New file. * gnulib/import/strchrnul.valgrind: New file. gdb/gdbserver/ChangeLog: * server.c (skip_to_semicolon): Remove. (process_point_options): Use strchrnul instead of skip_to_semicolon.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index b0303f6..8831b50 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6387,16 +6387,6 @@ peek_stop_reply (ptid_t ptid)
stop_reply_match_ptid_and_ws, &ptid);
}
-/* Skip PACKET until the next semi-colon (or end of string). */
-
-static char *
-skip_to_semicolon (char *p)
-{
- while (*p != '\0' && *p != ';')
- p++;
- return p;
-}
-
/* Helper for remote_parse_stop_reply. Return nonzero if the substring
starting with P and ending with PEND matches PREFIX. */
@@ -6499,7 +6489,7 @@ Packet: '%s'\n"),
/* The value part is documented as "must be empty",
though we ignore it, in case we ever decide to make
use of it in a backward compatible way. */
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else if (strprefix (p, p1, "hwbreak"))
{
@@ -6511,19 +6501,19 @@ Packet: '%s'\n"),
error (_("Unexpected hwbreak stop reason"));
/* See above. */
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else if (strprefix (p, p1, "library"))
{
event->ws.kind = TARGET_WAITKIND_LOADED;
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else if (strprefix (p, p1, "replaylog"))
{
event->ws.kind = TARGET_WAITKIND_NO_HISTORY;
/* p1 will indicate "begin" or "end", but it makes
no difference for now, so ignore it. */
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else if (strprefix (p, p1, "core"))
{
@@ -6545,7 +6535,7 @@ Packet: '%s'\n"),
else if (strprefix (p, p1, "vforkdone"))
{
event->ws.kind = TARGET_WAITKIND_VFORK_DONE;
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else if (strprefix (p, p1, "exec"))
{
@@ -6574,7 +6564,7 @@ Packet: '%s'\n"),
else if (strprefix (p, p1, "create"))
{
event->ws.kind = TARGET_WAITKIND_THREAD_CREATED;
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
else
{
@@ -6583,7 +6573,7 @@ Packet: '%s'\n"),
if (skipregs)
{
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
p++;
continue;
}
@@ -6620,7 +6610,7 @@ Packet: '%s'\n"),
{
/* Not a number. Silently skip unknown optional
info. */
- p = skip_to_semicolon (p1 + 1);
+ p = strchrnul (p1 + 1, ';');
}
}