From patchwork Tue Mar 12 11:25:30 2024 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: 779704 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1966289wrt; Tue, 12 Mar 2024 04:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWt8jn4ikv+NmvIZTq5rsifqBQfuWh1ND3hMyb+fvBL3cz1gqhGsJ/p/o2pXmjiReuOvY1iSkQDVGAS2H625Auj X-Google-Smtp-Source: AGHT+IFKytGyfHLsac38IDJlXjy3rwcYvDplg5DctORY+Va0YD/XfE6AcnLquWZQGaiuiS8aPngH X-Received: by 2002:a05:6808:2a77:b0:3c2:2f9a:5aab with SMTP id fu23-20020a0568082a7700b003c22f9a5aabmr7755619oib.56.1710242832158; Tue, 12 Mar 2024 04:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710242832; cv=none; d=google.com; s=arc-20160816; b=ylxGSISbvjRjq/JbQHdtSqWZJbVDfWmaeHqeXXCUVBi8wqVuiPqXmWiI8hhct6c5vQ QBR7bblcCCuZkoP7vF1EPB8iPQ4eGVkElTPFd2LUxWhv+0AKuZ7t5z30BA9KKAkZp0Xa 3loXgNRYPdmbsJd9Becj6Ue29MGI8d5Jh69ThB0stV6z+EZLUDoW5jwWKDD5Uju7Pas2 pqjfsvoAklXjPPq6MrbtMAfRZXndQKh+CmLkRwLwTnUzGBT67bipKT/SiCuQN8S6qr5g 783EcqiOfbPcExXN/WIaCNFvuyKvM+ntvpCZd/QHPnHZ5n8xRmX0TJ+JVE+OpHuhSqFa 39xg== 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=JghslLQsXVIk5PSECh3p0uuw1fQ6K0uFHf3q1DuTSXA=; fh=8Mm9BQmeLpRTl6qJya1IDznvLrd/qBiwVIi7B51sjeA=; b=Jm1I8K9Q4bKvZyYflDMLj4dcTW+Q8/HrJV6mlmRLM7KM3zYbUTEeoCHPm4/hM5YJAN gaRdJ8NCV8xR3ftCP+PkEDzQwwJHJ+aViEo85A6qfBE3BrCC+jQftKlP6ZasZhsNDYH+ SZA0qh1cyXLp74GVnhIe2LijzAHxT7ccfSIyPLoima/em0ijbx8jENlCokHn4Masiou2 P063wRMXwlJp0dc1hQHVugbTGLVQvFFPs3205RpHInL7SrwwNowpFUMqvaTYyZi0qiUt aHFhfAO1/z/u/5PYQDdbNypdeem+TzB8MZ3+K3nVo7x7srORfwPrdIaKUNtcwh+TQAWi lc+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=or6ziAC3; 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 j18-20020ac85f92000000b0042f212bb553si7211143qta.273.2024.03.12.04.27.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 04:27:12 -0700 (PDT) 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=or6ziAC3; 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 1rk0GX-0002yU-3C; Tue, 12 Mar 2024 07:25:53 -0400 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 1rk0GS-0002vy-Pt for qemu-devel@nongnu.org; Tue, 12 Mar 2024 07:25:48 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk0GL-0000lC-Qo for qemu-devel@nongnu.org; Tue, 12 Mar 2024 07:25:45 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-41329a665d8so15408825e9.2 for ; Tue, 12 Mar 2024 04:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710242738; x=1710847538; 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=JghslLQsXVIk5PSECh3p0uuw1fQ6K0uFHf3q1DuTSXA=; b=or6ziAC3VtY9LPM0xv/0n/RHsLCBK9ix7GVtYswtwLwYxje4QZeJ6w0VZ/Ui0XWBfJ r2huwQ8klCcAtwsuMv2utpWnOsb16EBIQ4ewvcNhJ1gOCkaYrskJg1blwE+SCN04HS64 wuE8OiT5uWuvRUIRzkIlGH3vbIPHtGNREqWxE8JQSnoFWgomjEjDywNzNXWE5g5qslmh Nxt9OS6y17AQRgc8dJt2sVUsR4wKCf9JFZ+IKJfcPWdFFMrGmioIrvX8qtS0an/r3bbu I+bvrsuoK9SFqws7Mj7rXmteiEgPdSPXgyfVoFBcgQHzhb5qlXIJ0IuWRasYhHisvrSE L3lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710242738; x=1710847538; 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=JghslLQsXVIk5PSECh3p0uuw1fQ6K0uFHf3q1DuTSXA=; b=wDjKcAIjb6r9KDqBpOifT1DjFDmSIzs9MYkyoq3ixrTImXG2+5dXzOD+fi5SJZCqAY d503inOCSq9S1yNvAhIFPFahuM9neQfO06xGpftei9CfhOVsnQf4n3AkCut7VQ48q+g4 PC0rilCs80tNHzQfV7StFrDiE63BQSUAlMdML+F2mCEdc3icEGqKBYX9Oid5OgcUljvY j/fGxjdsjmL6i0usQUjPS8QDprHLoml/nNv1YvdXKxh09WsqZANPaHPB7K0YjxOhcU3v OMoAadmHKXnhgd/H+uUh/H4JbYup3pyPGAJQeKsknmNK4K3fCg2ggZCTdNysa3k31iaf oT5w== X-Gm-Message-State: AOJu0YzMd+LCsqNAN3DwdvyqYpQK6ZUNq2IiUmdIYXc5LGMYe9/wzWE2 m3KwhqbKNFIwRn4VL+0qDn5qo+Okk5wmPjWhrnriFPVvuRdRrYmXOU3sly2xOcE= X-Received: by 2002:a05:600c:1f81:b0:413:1dcd:b39 with SMTP id je1-20020a05600c1f8100b004131dcd0b39mr6894975wmb.38.1710242738307; Tue, 12 Mar 2024 04:25:38 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h12-20020a05600c350c00b0041312d21a35sm16982948wmq.7.2024.03.12.04.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 04:25:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3F7C65F8E1; Tue, 12 Mar 2024 11:25:33 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Gustavo Romero , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 6/8] gdbstub: Add Xfer:siginfo:read stub Date: Tue, 12 Mar 2024 11:25:30 +0000 Message-Id: <20240312112532.1558319-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312112532.1558319-1-alex.bennee@linaro.org> References: <20240312112532.1558319-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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 From: Gustavo Romero 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 Message-Id: <20240309030901.1726211-5-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b472459838..e83b179920 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -190,6 +190,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/gdbstub.c b/gdbstub/gdbstub.c index 17efcae0d0..9c23d44baf 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1664,6 +1664,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 @@ -1818,6 +1820,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/user.c b/gdbstub/user.c index cf693bfbc4..2005f3312b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -852,3 +852,26 @@ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx) err: gdb_put_packet("E00"); } + +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 > gdbserver_user_state.siginfo_len) { + /* Invalid offset and/or requested length. */ + gdb_put_packet("E01"); + return; + } + + siginfo_offset = (uint8_t *)gdbserver_user_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); +}