From patchwork Tue Mar 29 15:49:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1610717 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=Ntc23Kiw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 4KSYv52mmQz9sFk for ; Wed, 30 Mar 2022 02:50:57 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSYv51tgbz2yNF for ; Wed, 30 Mar 2022 02:50:57 +1100 (AEDT) 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=Ntc23Kiw; 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::62e; helo=mail-pl1-x62e.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=Ntc23Kiw; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 4KSYv21gbYz2xYG for ; Wed, 30 Mar 2022 02:50:54 +1100 (AEDT) Received: by mail-pl1-x62e.google.com with SMTP id i11so18040331plr.1 for ; Tue, 29 Mar 2022 08:50:54 -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=tpNJJEIm06PYfVGgnVzpK1YVYgMiU+HShYrg3LBBVDg=; b=Ntc23KiwEe04Ud/oYU9jTAd25fVSQCm0AjHkCtUY5D2xmo2VHnN5ZsCKBVX8vQ3Evi uNuRZ0buVMrRWNZAT6yNKnyREM1tX+PKtw+CzSxOQdiq+3VN86zbONxmrBR7Zw99EOrI O+esvj+EMDRFfw6unG8+l9oHKZL4hqMbr6k5l5O9dcQ1rBbHurTq6aB4qJ7eevOj2MXa YqRugz6L1Q/bY2vNEWmB6FmlgJom9p6QiwH4dIVgpudDE8jnZfxE5gWV0UwMEJghIacg Hw0KuvhhJibEOdkjBYhISJBhE6uBGDm6x6VFOV5CoRP2C0P0Gp368Yvj1A78U/9BEIjy D+4A== 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=tpNJJEIm06PYfVGgnVzpK1YVYgMiU+HShYrg3LBBVDg=; b=BAwufCIj1Qsq5KU2WjqAewWa5I+qXximM4vpxrxB6aKGlGbbWnGr0bvplD+hUTHDur iejrzyqXkY5E38aHcpyUrrwpZV5vPadzFe6hAoHqCkWfI+94k2EIkjR8Zc/n2UdLSORy Me29qaSzNQqJJSTlm/JL5fPH3+GA8MltkCgl0AgKiIlGif9p06pm1IrQrelArWX8T9x8 mrlUOtTtP4yMZTTatf4vQedPHYt4tgOfWXgJlx2ZLwhV//5uCNftnJVzEMK4Tczv9Iz9 m3zykC5UjHXrVBIed9PZSgTgQ7yuuxAV1h3Q66it2eypx2Oij3hE4Cwei5O3g/Q5sfJN luXg== X-Gm-Message-State: AOAM533CF/PGufGXaoz308uefN5NFEBt6ZYpz7jMy3B0h954AfpDjNeb XVea6adpbN8FYAzzQnE6oCnG7Xsnids= X-Google-Smtp-Source: ABdhPJxP0eAFfNzCRJtFKUcTYxn5XCi8QH5bFd4h6yeSCI0uP4nQnRi3f5RNfJNmwg7EHKAEc9LADA== X-Received: by 2002:a17:90a:bb0e:b0:1c7:e8bf:5561 with SMTP id u14-20020a17090abb0e00b001c7e8bf5561mr256987pjr.18.1648569052242; Tue, 29 Mar 2022 08:50:52 -0700 (PDT) Received: from bobo.ibm.com (58-6-255-110.tpgi.com.au. [58.6.255.110]) by smtp.gmail.com with ESMTPSA id s35-20020a056a001c6300b004fb20b5d6c1sm14163564pfw.40.2022.03.29.08.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 08:50:52 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 30 Mar 2022 01:49:28 +1000 Message-Id: <20220329154931.493851-36-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220329154931.493851-1-npiggin@gmail.com> References: <20220329154931.493851-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 35/38] 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" This reduces round-trip time getting registers after stopping. Signed-off-by: Nicholas Piggin --- src/pdbgproxy.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 7dc0555..b34dec5 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); }