From nobody Sat Sep 28 22:07:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1556782363; cv=none; d=zoho.com; s=zohoarc; b=Al1RD9m7xuuWnHxoPFr2qGGoJ+NJr7yFsIBAA4z1GVwMcEbWLB20nN3dRzQekiP8HLr4+loNa9SZa6aEFO94BKGiVoD3FcA7q1wjqWd0mnxrQGlU8MZhhrXil1CUGJwODVJSKGl/tL6qMl6yJlvFFC7WSnBXxvZO7oEy9hQVA/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556782363; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=C5wVxSSu9B3yjrVL1kbdSqghY5biwyr5/S2ykkoUubY=; b=CdU43SDM04vhewXzJ9bkBfgAZ682UjYjmCFb75DktEd0lMnxhLhdbrduDPA9R4lsMvsa1v5tggsRuLoV7AzVQqUaMUA2n2pLrLHPjbPIwHnMAAHWJzz4sSWtuJ5HXkZi9XIke25DpgztqKeDWlQaAxD/fVPuno/AFW6w3PWQRHg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556782363477920.4863988468863; Thu, 2 May 2019 00:32:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:46560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6Cr-000774-F9 for importer@patchew.org; Thu, 02 May 2019 03:32:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM68z-0003xb-As for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM68q-0001pg-VI for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42674) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM68l-0000Vw-Bm for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:27 -0400 Received: by mail-wr1-x444.google.com with SMTP id l2so1783093wrb.9 for ; Thu, 02 May 2019 00:27:12 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id z5sm8769289wre.70.2019.05.02.00.27.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 00:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C5wVxSSu9B3yjrVL1kbdSqghY5biwyr5/S2ykkoUubY=; b=reTAzNSlqYQ9gK8vh9ByDodeF+2J6IsK4yx05FXlNRzYrSZlkig6Y7jFfqx4X7vKHC FtsmZcw6Kj0PN3DuFwlCF5IsnFSebqB3eigtZfEvnUOxA+Hwqo/wlLH28sedFHs4KHnS 6SiGyzyKEbZAizI2R0cHbefN8VSZjGB7U/KglAkg9UrNIhdHf3soP0WgGW6S0AyV6O7q AlUh9s+Dt8AYIsX0fjtiopv8UxMC5Obzro2pLdk8ywyg+WXBqBTzBfSCc+hCOr8N0U4R ZxpUOALkusN97UYPZt8jvtb+yL1Gf+BUL2FjP89Xm00aPMDCnCZRg8/EiXrmHhrtFtY6 Z04Q== 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=C5wVxSSu9B3yjrVL1kbdSqghY5biwyr5/S2ykkoUubY=; b=Jspa5kneHJ41MQ1EpfexlSWKDX2VQHsDVP0jqgopzIkj4rwR0a6yr+IGJtU8DKR3T6 23Ds75hbrixfTS00WSlM1YEmKGGictpNRuXU6PvkxyG48fXDI0kgqThsCfqYP8O8tgvg gVcosu9dk8A6mHCuxF7z0mNyFc3NoBEcfh4kZYflqw81hcw3Ci3FGsKKVlFPiMyjjQXk WhkaRL/4Lb79M82L9NiHRhINVdFmsORq6mxY6S4rpxy7GUIz4dWjYrFbhiCC8zCcDveJ xl+WUh4sFGflb16QhrVowGi2C7+FV98k3V/wMXggbFgyGEJFf6Rh7e1rHPKVotBJYqvU RC5A== X-Gm-Message-State: APjAAAXIx7kwhzDoTvIwjOdsEGdxkUrWQTGtvDdo7KbEYhwT4ZAAuXhW qzSSSnC8MsgxIeTUyq8B4vsJiYDI X-Google-Smtp-Source: APXvYqzqCjgiweov8PUsJPF41vd9UltaYGRZpU4E/NU4qWt70/qpbS/7N1X/KTGKKNHRnKbireFpCw== X-Received: by 2002:adf:ed4c:: with SMTP id u12mr1658364wro.245.1556782031511; Thu, 02 May 2019 00:27:11 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 10:26:24 +0300 Message-Id: <20190502072641.4667-11-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502072641.4667-1-arilou@gmail.com> References: <20190502072641.4667-1-arilou@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v8 10/27] gdbstub: Implement get register (p pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liran.alon@oracle.com, alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jon Doron --- gdbstub.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 10e3f12a68..e9a3d0c2bc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1655,6 +1655,36 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, v= oid *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +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 =3D 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; @@ -1884,18 +1914,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'p': - /* Older gdb are really dumb, and don't use 'g' if 'p' is avaialab= le. - 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 =3D strtoull(p, (char **)&p, 16); - reg_size =3D 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 =3D { + .handler =3D handle_get_reg, + .cmd =3D "p", + .cmd_startswith =3D 1, + .schema =3D "L0" + }; + cmd_parser =3D &get_reg_cmd_desc; } break; case 'P': --=20 2.20.1