From patchwork Fri Jun 7 09:05:42 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: 166107 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp417531ili; Fri, 7 Jun 2019 02:52:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDblvnp5KNZDWN4I/EtHqoT+LXe5u6rrd8LRtZqq4o+gfs9pAail7erln/+oz8jmRfeJIq X-Received: by 2002:a0c:b659:: with SMTP id q25mr41429032qvf.29.1559901138919; Fri, 07 Jun 2019 02:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559901138; cv=none; d=google.com; s=arc-20160816; b=F498MThJkMVn8mOga1MgV0cNZGRWkJRz7LdgGCZxTC7EZWK5FFGnqMFGxChISo/LZ2 pzWlkrTronQ2sp96pa9rlYD1Y3oyICM85uKL0jpi4eWeSnlcKO1Dmhg7abtPC8BeDpLg WNH+5+47zvw7VncVqPJYIesqp5C09mofZj7ZGZhLwn93t6O5G3GhtqsYSRGbVsxNdMwE LmzzlMxYE1fHJeFjC6IrfS/FUOxBwFFdRZrIU8CykjHMrVZQM5RzsfvFyK7IpfOCaMyw GZ7af1lszakBUrO25tcCoGJ43qu0Pgwhh6qPNQ+z2H+sm6kelj/rk+c0J3/K4oUX4q2D OzyA== 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=HpSzE7CRb/eTzWpNX5jhhMANtC+sz7VcxjFAzL6p7RU=; b=QRqOfdTBDQcW4YVn2/UCDT6LCh2IgV/am0IcLt2HnvxE3XYW4uQyM+dD4ej10vtRmx M8Y9oywbvS5sz2aA45mr4fDcZ2PloarpEvo8gOrfD6jUBMTaSY0lTGx0GGKaNdhsnLDn zldNsvWewcX9PcovN4NqLrf87BfmPB1pHNniiEbUhiLFmRu2pYTkjR4rwkbZ93NM7vMO po2CAqgAiEmmpOok2mfBJHl/wQAgYtAua9Ho3b70UHnKEqk9wuvnuf4YEyax+0cC8oAc uXsts+nkF/xFzw57tPgBO4AVWRcAgY3ff4c0FkKYTFHEYEFqaB37txVl8t5UyCB9h5tb CSeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EMXahHkm; 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 k14si827276qkg.36.2019.06.07.02.52.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 02:52:18 -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=EMXahHkm; 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]:47658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBXm-0000Xb-GP for patch@linaro.org; Fri, 07 Jun 2019 05:52:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42213) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fj-CU for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004yK-H9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:37478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004u1-8R for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x42a.google.com with SMTP id v14so1370430wrr.4 for ; Fri, 07 Jun 2019 02:12:39 -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=HpSzE7CRb/eTzWpNX5jhhMANtC+sz7VcxjFAzL6p7RU=; b=EMXahHkm/lYzmnDZ4m+7jNA0Wckplr5O2W/TMPEy5U9x5UeyTxZKGMW6jCQvjD6syn u26n19W82p+tMxMG1xljUy2xVzJNkb5/8HVwwHgmCbgviJ7n3SjUxvYYeMGZYGsvIxAH Caxdcrs9ycDtl14FPmU7pV4pzne9/Hv36XkDnp0djuebva7rPuxOs0B2bsAgqP4i+pjU 6HYAA+Fook6yGgfgccufNBEBMaaqyGipXAhcCEtKIMsHbdGVEphCMi5Vw4GtdkjjafvY n1LrC2cIjVx6MeRzOlqd2nD50Tx+JDiI3fmreDCCaLDH8eiFWH3L0nH4s3b8p7jW4ozn 2Erw== 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=HpSzE7CRb/eTzWpNX5jhhMANtC+sz7VcxjFAzL6p7RU=; b=hJHFkH3w/mWPSkejfg8rFCs3i59qCGIyVYL0g5r11Plt+7GNPKnVpkdHcpiMNqJ/6b u8OIpcHXLYzYAl94ksPacTs7abl+aHxVG9nK03ydrHAk7+VQGE0+yKZJWKsMboQBI2kS pOjb04wsxReOwqDTIv2AEg1ZQ07Ak90RrChQzAnrYVZcrsRNxz3Xp14bIjIWN8yyDRYN hI87mYY/gvJDpW6jmT17lhL5tuhbP7wFVMnP5OFXKGCzB4ONlipbqGwUvCR1HxQPXuDl W4lLqkryccA2jggx1346ELiUcP8mdMitISm3hWaHY0F+g29jVq8nN59ZkrtRXgZXolNg TxIA== X-Gm-Message-State: APjAAAVwtZx1Ky3GXUsCC8E6rdwfyACnRb2RslNPpO6tnAExabCem2Qk Tch1h6bph3j5pHMIlvdVZv0/xQ== X-Received: by 2002:a5d:638e:: with SMTP id p14mr3203837wru.238.1559898758476; Fri, 07 Jun 2019 02:12:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u205sm1279667wmu.47.2019.06.07.02.12.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 713591FFC2; 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:42 +0100 Message-Id: <20190607090552.12434-44-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::42a Subject: [Qemu-devel] [PULL 43/52] gdbstub: Implement read memory (m 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 Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-12-arilou@gmail.com> Signed-off-by: Alex Bennée -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 681a0c8550..ceaa47d184 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"); } +static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params != 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_ull, + 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_ull); + 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 char *line_buf) put_packet(s, "OK"); break; case 'm': - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = 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) != 0) { - put_packet (s, "E14"); - } else { - memtohex(buf, mem_buf, len); - put_packet(s, buf); + { + static const GdbCmdParseEntry read_mem_cmd_desc = { + .handler = handle_read_mem, + .cmd = "m", + .cmd_startswith = 1, + .schema = "L,L0" + }; + cmd_parser = &read_mem_cmd_desc; } break; case 'M':