From patchwork Wed Apr 20 06:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1619363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VcFEhRdC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kjrty37Rwz9sG0 for ; Wed, 20 Apr 2022 16:51:54 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Kjrty210wz2yn2 for ; Wed, 20 Apr 2022 16:51:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VcFEhRdC; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::42c; helo=mail-pf1-x42c.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VcFEhRdC; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Kjrtv1lx8z2xKT for ; Wed, 20 Apr 2022 16:51:51 +1000 (AEST) Received: by mail-pf1-x42c.google.com with SMTP id b15so1104534pfm.5 for ; Tue, 19 Apr 2022 23:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mJ4jaj4OaMBOd/HMo4RFcrdg+m/WGmjloNOiqpL7Akc=; b=VcFEhRdC4al7Uu3tgG92ZUz1YVpHGhoknXMKLW5nhxmL8MAnsSuoF1vBfDy0r54w2/ ZpflYdEgv0A6pzyePtSiQeLASi4jBlrsCLvXx9J58ZUC2kod30ZhuBfB9AkomZIO85bZ cx4BL3NQEtyiAcFDt1chRpMyIbMRV+tsUBSkPeyQPQPheWW0kJ8FdizKlclaWlsGD7KP 8atEP9tNp9ozZQ+4Zmfnn9SuIaicrdRWzbe8H3mxZZ6W25rtGl0ZLRLH/Pgc/BWDTlWU CMyEXKDQ/CIWghYe04nHnPmXmtAKBvF3vcvSgESZ1NUgwUDp/w6NMJVpUj+uWKRWLzia iNjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mJ4jaj4OaMBOd/HMo4RFcrdg+m/WGmjloNOiqpL7Akc=; b=FvEm40kkRU2o4Gfl9tlT3s6idJvH5XLgm9eCjaTYReyayTqGQR0BP8Biidut237ctw H0/+he3FEuGXOdcB3KkfyR7tVZoaxwqCG1ETpw+fRlgklvIgAmWVPLU111q4UKKWpCdy 7ioqS7Na0amEEp8lKoFJPoOk8A12FFSZdfPvt0BdgDCQePqNbpn5iJVGi58Hrr4AzddV UaMHXq93eSJOohZRbkaz89sPQTiJhKUduP51e/r6G1N9EcM06hDr2XqYIsfjx4S6tBvX EpVHCEeMxwejgggIupINQ/8L6m3ANqGWR29qAvbEdZWO40oyofZOoQ8BQYL2fPZv6S4K uxAQ== X-Gm-Message-State: AOAM531KaOBIAibUWCyHm5N6ABdff16PNw8EZFsoMYrZs8nBjGUJ27UN AtlYx9uZL4LBEDc5sYywtu1UHAZHtE7f6w== X-Google-Smtp-Source: ABdhPJwz9yipPAPJDkI7oBmw0Aiod1lLYVnkCkrtl/dIGDWIvMMYB8GDdXGislkOI3osVetzTnQEHQ== X-Received: by 2002:a65:6bd6:0:b0:39d:4f85:9ecf with SMTP id e22-20020a656bd6000000b0039d4f859ecfmr18386776pgw.336.1650437509039; Tue, 19 Apr 2022 23:51:49 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.221.203.144]) by smtp.gmail.com with ESMTPSA id x20-20020aa79574000000b005061f4782c5sm18481235pfq.183.2022.04.19.23.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 23:51:48 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 20 Apr 2022 16:50:10 +1000 Message-Id: <20220420065013.222816-37-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420065013.222816-1-npiggin@gmail.com> References: <20220420065013.222816-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 36/39] gdbserver: send regs with stop reason X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The gdb protocol allows sending register values of the stopped thread with the stop-reason packet. This reduces round-trips because the client doesn't have to get registers after stopping. This is a significant win because getting registers requires multiple commands so it saves about 10 commands (round-trips). Signed-off-by: Nicholas Piggin Reviewed-by: Joel Stanley --- src/pdbgproxy.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 6b9bdf90..d50121c0 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -202,7 +202,11 @@ static void send_stop_for_thread(struct pdbg_target *target) uint64_t pir = gdb_thread->pir; char data[MAX_RESP_LEN]; size_t s = 0; + struct thread_regs regs; + uint64_t value; + uint32_t value32; int sig; + int i; if (gdb_thread->stop_attn) sig = 5; /* TRAP */ @@ -213,6 +217,39 @@ static void send_stop_for_thread(struct pdbg_target *target) s += snprintf(data + s, sizeof(data) - s, "T%02uthread:%04" PRIx64 ";%s", sig, pir, sig == 5 ? "swbreak:;" : ""); + if (thread_getregs(target, ®s)) + PR_ERROR("Error reading gprs\n"); + + for (i = 0; i < 32; i++) + s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", i, be64toh(regs.gprs[i])); + + thread_getnia(target, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x40, be64toh(value)); + + thread_getmsr(target, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x41, be64toh(value)); + + thread_getcr(target, &value32); + s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x42, be32toh(value32)); + + thread_getspr(target, SPR_LR, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x43, be64toh(value)); + + thread_getspr(target, SPR_CTR, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x44, be64toh(value)); + + thread_getspr(target, SPR_XER, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x45, be32toh(value)); + + thread_getspr(target, SPR_FPSCR, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x46, be32toh(value)); + + thread_getspr(target, SPR_VSCR, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x67, be32toh(value)); + + thread_getspr(target, SPR_VRSAVE, &value); + s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x68, be32toh(value)); + send_response(fd, data); }