From nobody Sun Feb 8 22:57:58 2026 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=1559113287; cv=none; d=zoho.com; s=zohoarc; b=Xhs5BEJOd51G0ORVNFhacsiydxXEIx0MyNNr3o4xvcUo5JBwMVVxaOkOOz258oPDIb4nByaDuENClYKubYR6F+w+3S9nsM0ria4ZaEtGKKUYMF3vQpMubsLHzwcM+nBPE+rvvJjEaaDtgCASgUT62Ypj2SGvWHXtSwDg3hsoGf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559113287; h=Content-Type: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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=CerI8GCPxg94NERoQ3sIZx+OHPCALv/uZ0cqU2zN3p/pmRWD7z38OebRD0/SXRQqMEVIPNAV9GTTGVH0ncHpZpDLUZqFYqiPeyk+cY2uaY9WCldntE1MOkJ9mqjjKDFpbSGFkhZj99p0Py9xh6PLSnbRXUmpC2n52BtaChkdTOA= 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 155911328785675.2753654819436; Wed, 29 May 2019 00:01:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:48519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsaL-0000S5-NT for importer@patchew.org; Wed, 29 May 2019 03:01:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsHt-00014T-PF for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsHs-0001gS-Nu for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsHs-0001VX-HB for qemu-devel@nongnu.org; Wed, 29 May 2019 02:42:12 -0400 Received: by mail-wr1-x441.google.com with SMTP id t4so785334wrx.7 for ; Tue, 28 May 2019 23:42:12 -0700 (PDT) Received: from linux.local ([31.154.166.148]) by smtp.gmail.com with ESMTPSA id f2sm6831168wme.12.2019.05.28.23.42.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 23:42: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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=UB2/o5Yi7r6ntVxzzE+03McbIm48XlBPtVIhl1h8MBpwGLgDDiNY2aYr9Kr4UR3Efm K61LncmU2ckf5BrleGFQjVs3Vzd36zRluVhOhQFOrXTBhKtbhkS0ofq9+R6lRy0zmZyg kR666K6vc5nWklAEfHMCseAP1Ehi/fVoOQfnTa00BkQ6s42y6m+PP4WpA71Za4aZbvF6 FBxMVNIJxVCVJu0pEAn0XQB3deoPYa5jEe1myehLwzYHUR0sGWRoFI+K7joRfOivtqWh Q5ULJ8ClzXZJk2QL42HH6vod7ppcshIDNjZLPTY7vm4E5BP+Ikh+wCAQRuX8yOk/o96x 63iA== 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=8ICssjH6IZyanWlXmi8fQqHEPU1P+hXRIPq59SDpKSI=; b=CbvD93T/bxr5wyUWSQLtSdaGnlEU3Tky2lBIZ90APv1aGUaE2EyC58dGtYv8p1HVw7 zM2OGn/+U6iLdKTPdvjdZooizWoGsk2CexCa70H2ETK6D+NPdWygCDZspX0N17ZKsbiB 13q5ZdpfpUdsQDVirAuaa0FomSdPDGXV+i/JZ8XbjOzuZwqCIk9iqGbEVmGgn1QrkLVg N5vJoY8om1dgry+bgqlQoVI3exhArVsfuC5MRp6E9LQI47Lp2rTxq74oQp7b84pFYACN uJJ4yyBk/l8qO27gNaaNUVS59TT6/Ifhsj5tUGX2FaA8I57mpL3UyrHw1bzt1gDyV8sx 97kA== X-Gm-Message-State: APjAAAWLsLRzLPkQdf9OMgVGbKNtX63MoFTM9TIWgKYuXEKncK7hcg9L LREe16Mi++Otvf36CqppI0D/RT+d X-Google-Smtp-Source: APXvYqx62EDUHnSY2+Zb9cODZrCyQu0tdHHBGqtc7E/6bRROICPIBVC3Y5fi/+3qgi2ZR3AwowDjDA== X-Received: by 2002:adf:8307:: with SMTP id 7mr69120734wrd.86.1559112131346; Tue, 28 May 2019 23:42:11 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 09:41:39 +0300 Message-Id: <20190529064148.19856-12-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190529064148.19856-1-arilou@gmail.com> References: <20190529064148.19856-1-arilou@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::441 Subject: [Qemu-devel] [PATCH v12 11/20] gdbstub: Implement read memory (m 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: 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) Signed-off-by: Jon Doron Reviewed-by: Alex Benn=C3=A9e --- gdbstub.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f2ea5bdd5c..3d8c2f8f42 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1727,6 +1727,30 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx,= void *user_ctx) put_packet(gdb_ctx->s, "OK"); } =20 +static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params !=3D 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* memtohex() doubles the required space */ + if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_u= ll, + gdb_ctx->mem_buf, + gdb_ctx->params[1].val_ull, false)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ul= l); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1916,22 +1940,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "OK"); break; case 'm': - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoull(p, NULL, 16); - - /* memtohex() doubles the required space */ - if (len > MAX_PACKET_LENGTH / 2) { - put_packet (s, "E22"); - break; - } - - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, false) != =3D 0) { - put_packet (s, "E14"); - } else { - memtohex(buf, mem_buf, len); - put_packet(s, buf); + { + static const GdbCmdParseEntry read_mem_cmd_desc =3D { + .handler =3D handle_read_mem, + .cmd =3D "m", + .cmd_startswith =3D 1, + .schema =3D "L,L0" + }; + cmd_parser =3D &read_mem_cmd_desc; } break; case 'M': --=20 2.21.0