Date: Thu, 17 Oct 2019 23:22:00 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353704 - stable/12/usr.sbin/bhyve Message-ID: <201910172322.x9HNM0Yb032344@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Thu Oct 17 23:22:00 2019 New Revision: 353704 URL: https://svnweb.freebsd.org/changeset/base/353704 Log: MFC 348253: Add initial support for 'qSupported' to the debug server. This doesn't recognize any features yet, but does parse the features string. It advertises an arbitrary packet size of 4k. Modified: stable/12/usr.sbin/bhyve/gdb.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/bhyve/gdb.c ============================================================================== --- stable/12/usr.sbin/bhyve/gdb.c Thu Oct 17 23:17:56 2019 (r353703) +++ stable/12/usr.sbin/bhyve/gdb.c Thu Oct 17 23:22:00 2019 (r353704) @@ -991,13 +991,72 @@ command_equals(const uint8_t *data, size_t len, const } static void +check_features(const uint8_t *data, size_t len) +{ + char *feature, *next_feature, *str, *value; + bool supported; + + str = malloc(len + 1); + memcpy(str, data, len); + str[len] = '\0'; + next_feature = str; + + while ((feature = strsep(&next_feature, ";")) != NULL) { + /* + * Null features shouldn't exist, but skip if they + * do. + */ + if (strcmp(feature, "") == 0) + continue; + + /* + * Look for the value or supported / not supported + * flag. + */ + value = strchr(feature, '='); + if (value != NULL) { + *value = '\0'; + value++; + supported = true; + } else { + value = feature + strlen(feature) - 1; + switch (*value) { + case '+': + supported = true; + break; + case '-': + supported = false; + break; + default: + /* + * This is really a protocol error, + * but we just ignore malformed + * features for ease of + * implementation. + */ + continue; + } + value = NULL; + } + + /* No currently supported features. */ + } + free(str); + + start_packet(); + + /* This is an arbitrary limit. */ + append_string("PacketSize=4096"); + finish_packet(); +} + +static void gdb_query(const uint8_t *data, size_t len) { /* * TODO: * - qSearch - * - qSupported */ if (command_equals(data, len, "qAttached")) { start_packet(); @@ -1035,6 +1094,10 @@ gdb_query(const uint8_t *data, size_t len) start_packet(); append_char('l'); finish_packet(); + } else if (command_equals(data, len, "qSupported")) { + data += strlen("qSupported"); + len -= strlen("qSupported"); + check_features(data, len); } else if (command_equals(data, len, "qThreadExtraInfo")) { char buf[16]; int tid;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910172322.x9HNM0Yb032344>