From patchwork Thu Mar 7 18:26:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778514 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951151wrx; Thu, 7 Mar 2024 10:28:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWYC5HkPy0lmfMk2DqVe+MVFXtHfVXOgQKIL/lC74dSwwGfZq4Fs/aNuI5GKy+H/yOPezoQ+cXr+RJvqLrX69Pt X-Google-Smtp-Source: AGHT+IGEzs6I3dXpyqAieGeLfKM4BIMtJ3yVd1AEs6L/DnkM0bNF2bh7H2jjYdtV1NaVex/PDRsD X-Received: by 2002:a05:6808:314:b0:3c0:3189:d9e2 with SMTP id i20-20020a056808031400b003c03189d9e2mr7960806oie.20.1709836082196; Thu, 07 Mar 2024 10:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836082; cv=none; d=google.com; s=arc-20160816; b=zhue4tUKsnC9LmsWVEjGjvm5vB3BGQra4v7LeazDWzvJywHNDJXCRM8PaQ+4kV3zp1 gZmJAHM1MER+Z+cWs6mpM2g7OGS0JdExOHf2jNsa9Gz2hPPR71cFlhyLrJwDdag3UzTM OyT2vzgypwMuEExmrSdZfDS9QWyM/mCdbxFnl2hd6svtv8VMeV2kQzPiqrBRcOPs06gQ b6tE1tfLp19u56qQvks3LP1rADrbNBIDqq1qxOIWb4C9ydveyE+YNLQkRjspGnCYxx8s C0lxP0OH/GQa0eKKToIIAgdxRXiL5J+2GyA3WN50hrAxm3AEvUTg5fM6Ng9kOaDVuHxf zuHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=RmgdbDZjFLoBDmB5Y0+Wpkh3uESrqWg+uaS439AO9CPhgGCfVj4SeIO8EAAz54mRZu 4SrKt/LNmQQIi913mYB+ZrOOohzlU0cnDrrYd+bDdJrgy9PhE35R/1VuIAWoDAqAWLO0 A0dVyBzJ7WwXGrDwZd+vAD905jpJk5mEQzqYmTI7N0hGSRQl6Dk3SD5KW1T/ck1X+iUd 4W9qQhl89IE4pwHv/ykS5D2/YeSqZ6XRkzbYEJBzJ6i+nIM5XKxB7A6rpa3LIeC2FTWv MlqrFJ/faCBzd/Ld1znQhhLsBo98KDlhJjRIzgXEtAyWKVMDpL7Hn7bWXjnvhpTjgAki PqBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUexHbdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id wi8-20020a05620a570800b0078822280e7bsi11002897qkn.361.2024.03.07.10.28.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUexHbdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riISd-0001DQ-TT; Thu, 07 Mar 2024 13:27:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riISc-0001DF-AW for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:18 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISa-0000c4-QB for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:18 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dc96f64c10so9846065ad.1 for ; Thu, 07 Mar 2024 10:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836034; x=1710440834; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; b=QUexHbdV1wdtv7uCUBTYyxayRa4ROypRl26nyLk8hVVasWw785NWfg0tYA4T7QXFOb R6Uxx2XDX4PxAF/n6plSal+gBHYyJjLYtlgoRkN4/LcqPu2xvqvoG1dBTazoqDupmakS J9gZFBKZSraZO+1ST8A4/ts85aiK5yjwoCCUyfDdINZojJX1Bt6fTXuSlm8vYCLwofoM ssp2qFkyOIxOnBKmW1FkwGRbUWnGCZsYxtF0fp/wPWe2PVRzE0QCVcni27LpnFw7BnE4 tZ9T3FxaQwxy5AglP/uG+N8gOGwiI1q3xkl1GzPtiL9+wAJftahKjyultxrP34cqlSnT zViA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836034; x=1710440834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; b=c+YPxJ3SkYMLjpZ4BRt/U9zm8qc7v8o8fwoA3ls49+2+MKLzRjqrgviT8WIe8PQ7pB UEVY8kN1S7qKCP9ubKFO9zqDGeaabQ0oDi2z7/O9dHoSG0r89c2gq6RzaTzhygw6ykWq AUC5xZOu2CKMvZfCSvAjUnu25aE5DDPK9LMLvaFmUsIrkKsugiyi5zSda+8lNFP/vSB7 g+g8QajQUtp9u1GReyux/zKlsSxmZs6l5tOzVo/yllSOT6SIibHUUUqJjJYqEeyHFK7Q 12s+UmwG8d1iZUCd1eS9mobrSfXkW12N7a5EjmRc5C3U2a3oULrKcgnryiqjxNfYYB/l dI3Q== X-Gm-Message-State: AOJu0Yyo2FkZCZQs21vrmE8v3ki/Xq7wMiXHawNooCB8s0qUy1Mi1enP o4fSEkUUV/TRAWVsAwnuPOiB3TYFC1t727pB0CgoIc0KQfCoTvr98Hwiusf+4D9N4Pw05cAu2bG yIDE= X-Received: by 2002:a17:902:9009:b0:1db:f965:470d with SMTP id a9-20020a170902900900b001dbf965470dmr8035885plp.24.1709836033942; Thu, 07 Mar 2024 10:27:13 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:13 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 4/5] gdbstub: Add Xfer:siginfo:read stub Date: Thu, 7 Mar 2024 18:26:22 +0000 Message-Id: <20240307182623.1450717-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307182623.1450717-1-gustavo.romero@linaro.org> References: <20240307182623.1450717-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add stub to handle Xfer:siginfo:read packet query that requests the machine's siginfo data. This is used when GDB user executes 'print $_siginfo' and when the machine stops due to a signal, for instance, on SIGSEGV. The information in siginfo allows GDB to determiner further details on the signal, like the fault address/insn when the SIGSEGV is caught. Signed-off-by: Gustavo Romero --- gdbstub/gdbstub.c | 8 ++++++++ gdbstub/internals.h | 1 + gdbstub/user-target.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2909bc8c69..ab38cea46b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1651,6 +1651,8 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+"); } g_string_append(gdbserver_state.str_buf, ";QCatchSyscalls+"); + + g_string_append(gdbserver_state.str_buf, ";qXfer:siginfo:read+"); #endif g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif @@ -1799,6 +1801,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "l,l0" }, + { + .handler = gdb_handle_query_xfer_siginfo, + .cmd = "Xfer:siginfo:read::", + .cmd_startswith = 1, + .schema = "l,l0" + }, #endif { .handler = gdb_handle_query_xfer_exec_file, diff --git a/gdbstub/internals.h b/gdbstub/internals.h index a7cc69dab3..15c01c525a 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -193,6 +193,7 @@ typedef union GdbCmdVariant { void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx); /*user */ void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_close(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_pread(GArray *params, void *user_ctx); /* user */ diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index 215bf33ab3..93739852b0 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -285,6 +285,29 @@ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx) gdb_put_packet_binary(gdbserver_state.str_buf->str, gdbserver_state.str_buf->len, true); } + +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx) +{ + unsigned long offset, len; + uint8_t *siginfo_offset; + + offset = get_param(params, 0)->val_ul; + len = get_param(params, 1)->val_ul; + + if (offset + len > sizeof(target_siginfo_t)) { + /* Invalid offset and/or requested length. */ + gdb_put_packet("E01"); + return; + } + + siginfo_offset = (uint8_t *)gdbserver_state.siginfo + offset; + + /* Reply */ + g_string_assign(gdbserver_state.str_buf, "l"); + gdb_memtox(gdbserver_state.str_buf, (const char *)siginfo_offset, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} #endif static const char *get_filename_param(GArray *params, int i)