From nobody Mon Nov 10 12:57:20 2025 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=1556200586; cv=none; d=zoho.com; s=zohoarc; b=NU6Nq/IVgnf9e3dp/4Gf+Sb9e3k4TMvmG2PhhYzuntUpys59we7/DkdL+SohSqthDyMW0/Nl9NzBTCfwEsFWkaMe+NdXf1No9r5pDSvHGff/hrJMzlXXVKefeCVBj8REySYEgjVPXQKnNX5KgBdof6HoMynrfoj4ueDQ8FaBM7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556200586; 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=TENOL3r5yUJno6/S+4IYhfkNIUwUbfzGmKX97CyU0qA=; b=c3AuuwUVl7MTJzr7QkIn/l0tCKa+fom5cGBQhr0pXjWEys9Vi3tb5EsL2NsFK7uqWJn0slNa3cKd/yEZpRpyOSUqJjnqGvdi6mDP/OhGBOQuGiWgrjKN8kyDMCb/vS8L1BkkZ6nPb5A68z84g7LEsiUTN3W6sU6Sm7IILFgxEOU= 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 1556200586463508.04682323615555; Thu, 25 Apr 2019 06:56:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:57653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJerP-0007kG-CU for importer@patchew.org; Thu, 25 Apr 2019 09:56:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJePk-0008Mi-VP for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJePj-00016q-UA for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:48 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:38318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJePj-00015o-NU for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:27:47 -0400 Received: by mail-wm1-x344.google.com with SMTP id w15so263317wmc.3 for ; Thu, 25 Apr 2019 06:27:47 -0700 (PDT) Received: from localhost.localdomain (bzq-79-178-247-46.red.bezeqint.net. [79.178.247.46]) by smtp.gmail.com with ESMTPSA id y4sm2316540wrt.34.2019.04.25.06.27.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 06:27:43 -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=TENOL3r5yUJno6/S+4IYhfkNIUwUbfzGmKX97CyU0qA=; b=vJiHJxToCoPm5r3cfhYGfH2xqOxJaX3HRI7OsCRXpO66a4kjQdcaBBbPv8Hs0+Ujms 4O6VwOODJLm0zx7iT642r2ytnwTklpOfXwMytpOw4vCiphBnB4OCRcMrKtaUMsq3RBPn xMWL0VpLIk8pQwWzjDg4CDwzQZJeaYS64ZWRcOUJehgS/GC7ULY7HZCkl6LvIkDYXRf9 /0ddt1PAZBjlhnCqeQYYArrHJ5O3HETRuOzIgEi81zN4NKH2wyntapTJm5qyLgfY2f/g f2ZFrYFDj2JmEucDgyhci18x/LGhYPdNSBJwb/gtBxhldmFZm7A0ecuSdZ6DLvb4QwKH qNyw== 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=TENOL3r5yUJno6/S+4IYhfkNIUwUbfzGmKX97CyU0qA=; b=a0bII53+xwNkF5OH2oKuhELT+qIxG3Wynl90G3WYm0+qNQIvNfUMNGb1zeJ1DziqJW xytjbWAxTYO6QKei9hO3SpOePBbRO6AfhP5GQsyfp8joKIgsOEl5wcIefMzS5LnnZiGf fW2YxdwQQSluHNc0dhLm9GVGN0KvODIhSlRyOhdeQE+u4gxyQ/GBFa6Jf60KfIdOj8oT wY8zmU7H10Id+CZEfiKOQacERBe9mUNgq8zzBMRPz48Jnj/K5elJ4QmqV0WHJ8wyT8r9 vJ+KCZplydRR7xD0DhXIeaI9I2/m2exA/VKE+8MseJ8xcUBztRj2Pu22rYF7FTeWmO4J NdwQ== X-Gm-Message-State: APjAAAVck/rqDKdvOm3QWDpHMHsaNpYTnOtPCsJMPBX6JPUphlxtSadM ZwsmqLDF1gKcrCDn8mHrgs0PMiUG X-Google-Smtp-Source: APXvYqxL1ISXMH43hYmRmUQlxFcCFh82cuJfFWz8mkp0s8lHM9BLaqGm29eIfuXrVlXd3gdHip4GWQ== X-Received: by 2002:a7b:c844:: with SMTP id c4mr3522248wml.108.1556198865451; Thu, 25 Apr 2019 06:27:45 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 25 Apr 2019 16:26:26 +0300 Message-Id: <20190425132636.31636-12-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190425132636.31636-1-arilou@gmail.com> References: <20190425132636.31636-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::344 Subject: [Qemu-devel] [PATCH v6 11/21] gdbstub: Implement write 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: 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 | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c439b8e796..4522c93fa2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1686,6 +1686,31 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, v= oid *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 +static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* hextomem() reads 2*len bytes */ + if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, + gdb_ctx->params[1].val_ull); + 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, true)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1894,24 +1919,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'M': - addr =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ',') - p++; - len =3D strtoull(p, (char **)&p, 16); - if (*p =3D=3D ':') - p++; - - /* hextomem() reads 2*len bytes */ - if (len > strlen(p) / 2) { - put_packet (s, "E22"); - break; - } - hextomem(mem_buf, p, len); - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, - true) !=3D 0) { - put_packet(s, "E14"); - } else { - put_packet(s, "OK"); + { + static const GdbCmdParseEntry write_mem_cmd_desc =3D { + .handler =3D handle_write_mem, + .cmd =3D "M", + .cmd_startswith =3D 1, + .schema =3D "L,L:s0" + }; + cmd_parser =3D &write_mem_cmd_desc; } break; case 'p': --=20 2.20.1