From patchwork Fri Jun 7 09:05:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166117 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp438111ili; Fri, 7 Jun 2019 03:12:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBMciXiftSWFxJ84ag7cnBRgMl9DtvolNZJmnyow7hCjzHlX5NvZwD/fdYT676wQCZvPGk X-Received: by 2002:ac8:1b64:: with SMTP id p33mr46200024qtk.62.1559902347393; Fri, 07 Jun 2019 03:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559902347; cv=none; d=google.com; s=arc-20160816; b=ODLLjAl2jF0TUDgWYtUCwgxnrPLB0lKQdl+S2c5k8+5NTF5bwKSSNz2aQQN7PI8KrQ NrmPTcyK0LUtUC3zcgP6I0MTcU5coIf4i76BXl0CJ++vB9vVfaugmrkSfj7Ej5jFT9YF u2kOEMkgWYZL8Uuafrqob7fmjTxopJLhZPp9MtRy2LNZjBx6/7FH1ydI41UKQjuMYQDQ oSH5xMRJkb7JCJATImK+oB1ftDX/XwQbHwaZfpaT1vV0caPOyA91ch1Xq5X8IPB07Ixx 9oztF7Sx63J838MHxmn06mbtzEagQ/JK5NBsQhddqyUK3bQ8UJ9HBtn0UssJhoXC/aY7 mpSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6ItlL8HIelf+krBS9v4fi6BpYYbdu3JhklvwiNP6ff4=; b=fuE/KOoVNLr1MsJmLeZLeAbx2bY9dn0/JZfGrdtBN+kxIuVO8KItpUvbRm2CNjMX8T CO7szsAZ3R/XR5jfvnItAVsfKD73uCG4vfi9YBQCYL0KMXHSjhSfxmzYl5qW4yS68t+y Vf3BcftQCF/vzb3yNvg1a5BBCU0yzZbQaQyfsWAotkVUeidbFw61jMSRo1Sfqx18tUQu B4NYCc5L2BPMb6HX3e7wMfj0YESY0W2FPS2lHj/u68VKZT5KWt6fvDTJbs4GxjQwA4ZT IHvsxoA3tsakKunVZxpAVDD+ajcWcnTR/1nlmBVuImeCYWsshxm9S3YMvLRKfibsIQm7 bxLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x+6+TyO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.47]) by mx.google.com with ESMTPS id x1si1016791qtj.159.2019.06.07.03.12.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 03:12:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x+6+TyO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBrG-00011Q-Vi for patch@linaro.org; Fri, 07 Jun 2019 06:12:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44957) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB4z-00085k-LQ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005p9-Au for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:47043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4y-0005mA-1u for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:32 -0400 Received: by mail-wr1-x435.google.com with SMTP id n4so1372140wrw.13 for ; Fri, 07 Jun 2019 02:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6ItlL8HIelf+krBS9v4fi6BpYYbdu3JhklvwiNP6ff4=; b=x+6+TyO88zsLJFCXpdRp1Rjin74r2YvB1iOoyZDly6fqezu/e4E7kbHna2yv+Vrf5s sgg20+w1NSUWgo0ULRwusjZpQ1QoeWgXy0x2Nu2VzM09rfJc8YKKJjFLvIdyuNrLqDMt qeSrlstyvAzaw8Hwq68Nk/oBy9lvLSUBJaih+omjbGTYEsu+tY/Pmvi6KlVrhEXq+Zk6 7EHdURlGF5hiyfXqPv8HwhyUo3F6Ssl4CabFL245heL7rykmEMkIDTxuQbmuVrBa4DLC CZsdouEAgeUKyp80m9xlOFxL7sahcrFtqOVf8DCTFLkajS9yP23oof0zGz41RkMR20p6 4Wog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6ItlL8HIelf+krBS9v4fi6BpYYbdu3JhklvwiNP6ff4=; b=ngpCxVTiHbnyop6F4VE8qLkzxl/szjoIpbPdi9gFZO7M4SeQTkMJ8aOk4ld+26fCHO CWhoURYqhPl6hEKYhSqZw0WVHpGHtVS6Kjy78cF8qfOSiM6JKHjpyH6hzE9oA1fqvLCm DocX0vFAVPt0b/ZjyXXcFB45ax8zs8pARyOUdhqh+pOMYol8Ki+M16bYRNVRest3XYt6 Edx9isZiHfUmuZRfVdIm1jGVoHiU4gQsu3hQxjRfnUZZUOh7Kar0lIJoE9bZtVkvZ9PN nirk36DgANci9BnT7y/tfqpXVmz/DTbGCw0t8FC4YlCjqPAnlaqkN9wn7rzK/dqm5EaW Iy7Q== X-Gm-Message-State: APjAAAVbUYHDQcD9+7h4qXwNAIk7biPvOsdTpxfl7qYm905/mT5zL+HA YSAVscFu7GhsD1mRKy6MwZgWdQ== X-Received: by 2002:a5d:4949:: with SMTP id r9mr16425976wrs.289.1559899350160; Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p190sm1254631wmp.48.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4C1BA1FFC0; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:40 +0100 Message-Id: <20190607090552.12434-42-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 41/52] gdbstub: Implement get register (p pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-10-arilou@gmail.com> Signed-off-by: Alex Bennée -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 630f931765..63809b2ab9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1672,6 +1672,36 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + /* + * Older gdb are really dumb, and don't use 'g' if 'p' is avaialable. + * This works, but can be very slow. Anything new enough to + * understand XML also knows how to use this properly. + */ + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, ""); + return; + } + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + reg_size = gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_ctx->params[0].val_ull); + if (!reg_size) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1901,18 +1931,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'p': - /* Older gdb are really dumb, and don't use 'g' if 'p' is avaialable. - This works, but can be very slow. Anything new enough to - understand XML also knows how to use this properly. */ - if (!gdb_has_xml) - goto unknown_command; - addr = strtoull(p, (char **)&p, 16); - reg_size = gdb_read_register(s->g_cpu, mem_buf, addr); - if (reg_size) { - memtohex(buf, mem_buf, reg_size); - put_packet(s, buf); - } else { - put_packet(s, "E14"); + { + static const GdbCmdParseEntry get_reg_cmd_desc = { + .handler = handle_get_reg, + .cmd = "p", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &get_reg_cmd_desc; } break; case 'P':