aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-07 09:38:43 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-05-28 16:57:35 +0100
commit4dabe747af0a6bd66a86c2c7879f1882bec43c33 (patch)
treef9553c1bf1325d00be0d8a1c9fbeca6485d6573a
parent070949f39ee96bd16654e6623ab4ff627d918ba6 (diff)
gdbstub: Introduce an is is_query_packet helper
This helper supports parsing of query packets with optional extensions. The separator can be specified so that we can use it already for both qqemu.sstep[=] and qSupported[:feature]. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--gdbstub.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gdbstub.c b/gdbstub.c
index 86772d0257..6c0db4f87d 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -769,6 +769,14 @@ static CPUState *find_cpu(uint32_t thread_id)
return NULL;
}
+static int is_query_packet(const char *p, const char *query, char separator)
+{
+ unsigned int query_len = strlen(query);
+
+ return strncmp(p, query, query_len) == 0 &&
+ (p[query_len] == '\0' || p[query_len] == separator);
+}
+
static int gdb_handle_packet(GDBState *s, const char *line_buf)
{
CPUState *cpu;
@@ -1062,7 +1070,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
SSTEP_NOTIMER);
put_packet(s, buf);
break;
- } else if (strncmp(p,"qemu.sstep",10) == 0) {
+ } else if (is_query_packet(p, "qemu.sstep", '=')) {
/* Display or change the sstep_flags */
p += 10;
if (*p != '=') {
@@ -1135,7 +1143,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
break;
}
#endif /* !CONFIG_USER_ONLY */
- if (strncmp(p, "Supported", 9) == 0) {
+ if (is_query_packet(p, "Supported", ':')) {
snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH);
cc = CPU_GET_CLASS(first_cpu);
if (cc->gdb_core_xml_file != NULL) {