From patchwork Thu Apr 6 19:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95A06C76196 for ; Thu, 6 Apr 2023 19:30:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVJi-00089d-Qz; Thu, 06 Apr 2023 15:30:42 -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 1pkVJh-00087h-3B for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:41 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJc-0002HW-SZ for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:38 -0400 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336IxolA026564; Thu, 6 Apr 2023 19:30:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=h66j6eZ+I80USXh0GrYgRS1QgD8Txh3yUiMfM2aguDc=; b=k3NaIIZ9XnEJQ9mD5jqhq/sFGpdtKHFt/hfxOA8VezHSmniOhujCYVr4OqZOk5497Dml +fkfSROqONQpUK6cdL+3ROlrqE5mwBYUNS8vw7jP9u1GOrbSNZlkYTLSw1g7HYZO05f0 7z1T5iz7iP57gzEHPLb48XK3JKJPyFB6+OzlJr7eD5eFPEkxfXnI7im3mBmQZKNQYywb FLXqNu2HKm6hru4gyJLdM55LQ0fjGvgA34rjFv47WFQP+vyUe4ICOOXKJuikiabbOWll O+++OM8CM96fZlN754GZQWCHOpMJyLFkCkZK+VFv6cddJpYM5S9LosG3gaNkdmxK8J4G FA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psmyx2750-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:32 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUVcM018594 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:31 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:29 -0700 From: Matheus Tavares Bernardino To: CC: , , , , , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= Subject: [PATCH 1/7] gdbstub: only send stop-reply packets when allowed to Date: Thu, 6 Apr 2023 16:29:43 -0300 Message-ID: <48bce1b417f9701be26d737b596ccbd3dc2db573.1680808943.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: -axWKKILaxyytaEu9zX2d3ENeQVceC1d X-Proofpoint-ORIG-GUID: -axWKKILaxyytaEu9zX2d3ENeQVceC1d X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 impostorscore=0 adultscore=0 clxscore=1011 mlxlogscore=999 bulkscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.168.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org GDB's remote serial protocol allows stop-reply messages to be sent by the stub either as a notification packet or as a reply to a GDB command (provided that the cmd accepts such a response). QEMU currently does not implement notification packets, so it should only send stop-replies synchronously and when requested. Nevertheless, it still issues unsolicited stop messages through gdb_vm_state_change(). Although this behavior doesn't seem to cause problems with GDB itself (the messages are just ignored), it can impact other debuggers that implement the GDB remote serial protocol, like hexagon-lldb. Let's change the gdbstub to send stop messages only as a response to a previous GDB command that accepts such a reply. Signed-off-by: Matheus Tavares Bernardino --- gdbstub/internals.h | 5 +++++ gdbstub/gdbstub.c | 37 ++++++++++++++++++++++++++++--------- gdbstub/softmmu.c | 13 +++++++++++-- gdbstub/user.c | 17 +++++++++++------ 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 94ddff4495..33d21d6488 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -65,6 +65,11 @@ typedef struct GDBState { GByteArray *mem_buf; int sstep_flags; int supported_sstep_flags; + /* + * Whether we are allowed to send a stop reply packet at this moment. + * Must be set off after sending the stop reply itself. + */ + bool allow_stop_reply; } GDBState; /* lives in main gdbstub.c */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2a66371aa5..9d326a1d2d 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -777,6 +777,10 @@ typedef void (*GdbCmdHandler)(GArray *params, void *user_ctx); /* * cmd_startswith -> cmd is compared using startswith * + * allow_stop_reply -> true iff the gdbstub can respond to this command with a + * "stop reply" packet. The list of commands that accept such response is + * defined at the GDB Remote Serial Protocol documentation. see: + * https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets. * * schema definitions: * Each schema parameter entry consists of 2 chars, @@ -802,6 +806,7 @@ typedef struct GdbCmdParseEntry { const char *cmd; bool cmd_startswith; const char *schema; + bool allow_stop_reply; } GdbCmdParseEntry; static inline int startswith(const char *string, const char *pattern) @@ -835,6 +840,7 @@ static int process_string_cmd(void *user_ctx, const char *data, } } + gdbserver_state.allow_stop_reply = cmd->allow_stop_reply; cmd->handler(params, user_ctx); return 0; } @@ -1283,11 +1289,14 @@ static void handle_v_attach(GArray *params, void *user_ctx) gdbserver_state.g_cpu = cpu; gdbserver_state.c_cpu = cpu; - g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdbserver_state.allow_stop_reply = false; cleanup: - gdb_put_strbuf(); + gdb_put_strbuf(); + } } static void handle_v_kill(GArray *params, void *user_ctx) @@ -1310,12 +1319,14 @@ static const GdbCmdParseEntry gdb_v_commands_table[] = { .handler = handle_v_cont, .cmd = "Cont", .cmd_startswith = 1, + .allow_stop_reply = true, .schema = "s0" }, { .handler = handle_v_attach, .cmd = "Attach;", .cmd_startswith = 1, + .allow_stop_reply = true, .schema = "l0" }, { @@ -1698,10 +1709,13 @@ static void handle_gen_set(GArray *params, void *user_ctx) static void handle_target_halt(GArray *params, void *user_ctx) { - g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); - gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - gdb_put_strbuf(); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); + gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdb_put_strbuf(); + gdbserver_state.allow_stop_reply = false; + } /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -1725,7 +1739,8 @@ static int gdb_handle_packet(const char *line_buf) static const GdbCmdParseEntry target_halted_cmd_desc = { .handler = handle_target_halt, .cmd = "?", - .cmd_startswith = 1 + .cmd_startswith = 1, + .allow_stop_reply = true, }; cmd_parser = &target_halted_cmd_desc; } @@ -1736,6 +1751,7 @@ static int gdb_handle_packet(const char *line_buf) .handler = handle_continue, .cmd = "c", .cmd_startswith = 1, + .allow_stop_reply = true, .schema = "L0" }; cmd_parser = &continue_cmd_desc; @@ -1747,6 +1763,7 @@ static int gdb_handle_packet(const char *line_buf) .handler = handle_cont_with_sig, .cmd = "C", .cmd_startswith = 1, + .allow_stop_reply = true, .schema = "l0" }; cmd_parser = &cont_with_sig_cmd_desc; @@ -1785,6 +1802,7 @@ static int gdb_handle_packet(const char *line_buf) .handler = handle_step, .cmd = "s", .cmd_startswith = 1, + .allow_stop_reply = true, .schema = "L0" }; cmd_parser = &step_cmd_desc; @@ -1976,6 +1994,7 @@ void gdb_read_byte(uint8_t ch) { uint8_t reply; + gdbserver_state.allow_stop_reply = false; #ifndef CONFIG_USER_ONLY if (gdbserver_state.last_packet->len) { /* Waiting for a response to the last packet. If we see the start diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 22ecd09d04..99d994e6bf 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -43,6 +43,7 @@ static void reset_gdbserver_state(void) g_free(gdbserver_state.processes); gdbserver_state.processes = NULL; gdbserver_state.process_num = 0; + gdbserver_state.allow_stop_reply = false; } /* @@ -139,6 +140,10 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) return; } + if (!gdbserver_state.allow_stop_reply) { + return; + } + gdb_append_thread_id(cpu, tid); switch (state) { @@ -205,6 +210,7 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) send_packet: gdb_put_packet(buf->str); + gdbserver_state.allow_stop_reply = false; /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -422,8 +428,11 @@ void gdb_exit(int code) trace_gdbstub_op_exiting((uint8_t)code); - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - gdb_put_packet(buf); + if (gdbserver_state.allow_stop_reply) { + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + gdb_put_packet(buf); + gdbserver_state.allow_stop_reply = false; + } qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); } diff --git a/gdbstub/user.c b/gdbstub/user.c index 80488b6bb9..bb03622c83 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -127,11 +127,14 @@ int gdb_handlesig(CPUState *cpu, int sig) if (sig != 0) { gdb_set_stop_cpu(cpu); - g_string_printf(gdbserver_state.str_buf, - "T%02xthread:", gdb_target_signal_to_gdb(sig)); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - gdb_put_strbuf(); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, + "T%02xthread:", gdb_target_signal_to_gdb(sig)); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdb_put_strbuf(); + gdbserver_state.allow_stop_reply = false; + } } /* * gdb_put_packet() might have detected that the peer terminated the @@ -174,12 +177,14 @@ void gdb_signalled(CPUArchState *env, int sig) { char buf[4]; - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0 || + !gdbserver_state.allow_stop_reply) { return; } snprintf(buf, sizeof(buf), "X%02x", gdb_target_signal_to_gdb(sig)); gdb_put_packet(buf); + gdbserver_state.allow_stop_reply = false; } static void gdb_accept_init(int fd) From patchwork Thu Apr 6 19:29:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD59DC7618D for ; Thu, 6 Apr 2023 19:30:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVJk-0008AZ-Oo; Thu, 06 Apr 2023 15:30:44 -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 1pkVJi-00089g-Vn for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:42 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJf-0002I3-Tt for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:42 -0400 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3368LIQU013218; Thu, 6 Apr 2023 19:30:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=9l+W59dDDb8fNHeexhqSHDYcEIc2aqK9wXJVbckN0Os=; b=biasyct8fogSzWj5xfeFECEMoRW9w+7SzrQ214eSzdHVLkXDZMRbaRyKjhLEIf/MHPch NLtI3q3ynJNMqRuXnljXwKRhXX2RpHb42H1lxiX7EPlVXSGmh4c71t542DROr1IC5LGO OYhuj8wQFVTypsfBlXPsQDUJ83uFNBGqzfoY5OYQ8cdwDbUkP6wK46KORWaoYdJju6Pa smDlBZ8q96pAPtMQE+fHErd8dHU7Q5NJQZtRaiBtAdIm+ibCH7txIzELeo6XVljkXmZY foIsKlFCn1zYbOUzDHUXDscqoI9e3qRfAM0r3yJVvCVM0jRIyDrdgqvTsrsJzkjqiUkQ 9g== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psr261tw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:34 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUYFM007212 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:34 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:32 -0700 From: Matheus Tavares Bernardino To: CC: , , , , Subject: [PATCH 2/7] gdbstub: add test for untimely stop-reply packets Date: Thu, 6 Apr 2023 16:29:44 -0300 Message-ID: <873070efd7d1e7b13fcee9c4fed5f1e813cf5a43.1680808943.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: lG-KKtXIkxCS3SepG3JmMymWPoa-8J4X X-Proofpoint-ORIG-GUID: lG-KKtXIkxCS3SepG3JmMymWPoa-8J4X X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.168.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In the previous commit, we modified gdbstub.c to only send stop-reply packets as a response to GDB commands that accept it. Now, let's add a test for this intended behavior. Running this test before the fix from the previous commit fails as QEMU sends a stop-reply packet asynchronously, when GDB was in fact waiting an ACK. Signed-off-by: Matheus Tavares Bernardino --- tests/guest-debug/run-test.py | 16 ++++++++++++---- .../tcg/multiarch/system/Makefile.softmmu-target | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index d865e46ecd..de6106a5e5 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -26,11 +26,12 @@ def get_args(): parser.add_argument("--qargs", help="Qemu arguments for test") parser.add_argument("--binary", help="Binary to debug", required=True) - parser.add_argument("--test", help="GDB test script", - required=True) + parser.add_argument("--test", help="GDB test script") parser.add_argument("--gdb", help="The gdb binary to use", default=None) + parser.add_argument("--gdb-args", help="Additional gdb arguments") parser.add_argument("--output", help="A file to redirect output to") + parser.add_argument("--stderr", help="A file to redirect stderr to") return parser.parse_args() @@ -58,6 +59,10 @@ def log(output, msg): output = open(args.output, "w") else: output = None + if args.stderr: + stderr = open(args.stderr, "w") + else: + stderr = None socket_dir = TemporaryDirectory("qemu-gdbstub") socket_name = os.path.join(socket_dir.name, "gdbstub.socket") @@ -77,6 +82,8 @@ def log(output, msg): # Now launch gdb with our test and collect the result gdb_cmd = "%s %s" % (args.gdb, args.binary) + if args.gdb_args: + gdb_cmd += " %s" % (args.gdb_args) # run quietly and ignore .gdbinit gdb_cmd += " -q -n -batch" # disable prompts in case of crash @@ -84,13 +91,14 @@ def log(output, msg): # connect to remote gdb_cmd += " -ex 'target remote %s'" % (socket_name) # finally the test script itself - gdb_cmd += " -x %s" % (args.test) + if args.test: + gdb_cmd += " -x %s" % (args.test) sleep(1) log(output, "GDB CMD: %s" % (gdb_cmd)) - result = subprocess.call(gdb_cmd, shell=True, stdout=output) + result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr) # A result of greater than 128 indicates a fatal signal (likely a # crash due to gdb internal failure). That's a problem for GDB and diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg/multiarch/system/Makefile.softmmu-target index 5f432c95f3..fe40195d39 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -27,6 +27,20 @@ run-gdbstub-memory: memory "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ softmmu gdbstub support) + +run-gdbstub-untimely-packet: hello + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --gdb-args "-ex 'set debug remote 1'" \ + --output untimely-packet.gdb.out \ + --stderr untimely-packet.gdb.err \ + --qemu $(QEMU) \ + --bin $< --qargs \ + "-monitor none -display none -chardev file$(COMMA)path=untimely-packet.out$(COMMA)id=output $(QEMU_OPTS)", \ + "softmmu gdbstub untimely packets") + $(call quiet-command, \ + (! grep -Fq 'Packet instead of Ack, ignoring it' untimely-packet.gdb.err), \ + "GREP", "file untimely-packet.gdb.err") else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "no guest arch support") @@ -36,4 +50,4 @@ run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") endif -MULTIARCH_RUNS += run-gdbstub-memory +MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-untimely-packet From patchwork Thu Apr 6 19:29:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 033D0C77B6C for ; Thu, 6 Apr 2023 19:31:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVK1-0008Mh-Eb; Thu, 06 Apr 2023 15:31:03 -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 1pkVJo-0008EF-07 for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:51 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJm-0002K9-5v for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:47 -0400 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336HQecu006001; Thu, 6 Apr 2023 19:30:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=3vsVkznEep5VIpHeowV6gclHsICpwOfAno179LDrwGs=; b=bTT5ynWgkyN79Dm3R0pNards7caRp0UXbPjleI9cSwuJpPionXzXHY2SQUFUjRfc+tAB AfKu64J4CSX97TP55fsesKrixeSYiBmQ/iVa1OEbtQJR/U2cKkS5++ZcGaOmK+kSErQq RBOWcp7bfV9jLYq1tKKMetrzNd+Zidl/ACiFzESivHf540Z5HI5UyV1ur5lFC73geRjA juDn4bcodw9SRmMYyUF/WHpqEoOyssffGmrHAeacmxRGDTQTsr1J8irh8huN8bjQ7ps4 s0leb/fAhXX1A7APUd/nmkSQUiQIvnkVDCeNBscJD/D8H1SKAVnqpBeyDfPQIi9uCJD4 zA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psuj7sbyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:39 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUbag007233 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:37 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:34 -0700 From: Matheus Tavares Bernardino To: CC: , , , , , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , "Eduardo Habkost" , Marcel Apfelbaum , Yanan Wang Subject: [PATCH 3/7] gdbstub: add support for the qRegisterInfo query Date: Thu, 6 Apr 2023 16:29:45 -0300 Message-ID: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: cOa0ior71S19itFbMtxvJzu1aGBkcP6E X-Proofpoint-GUID: cOa0ior71S19itFbMtxvJzu1aGBkcP6E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1011 spamscore=0 mlxlogscore=874 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060171 Received-SPF: pass client-ip=205.220.180.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0b-0031df01.pphosted.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Brian Cain Signed-off-by: Brian Cain Signed-off-by: Matheus Tavares Bernardino --- include/hw/core/cpu.h | 4 ++++ gdbstub/gdbstub.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 821e937020..b16b4e0de5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -124,6 +124,8 @@ struct SysemuCPUOps; * its Harvard architecture split code and data. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. + * @gdb_qreg_info_lines: Array of lines of registers qRegisterInfo description. + * @gdb_qreg_info_line_count: Count of lines for @gdb_qreg_info_lines. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop * before the insn which triggers a watchpoint rather than after it. * @gdb_arch_name: Optional callback that returns the architecture name known @@ -159,6 +161,8 @@ struct CPUClass { vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); const char *gdb_core_xml_file; + const char **gdb_qreg_info_lines; + int gdb_qreg_info_line_count; gchar * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 9d326a1d2d..2edd7d6d88 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1409,6 +1409,27 @@ static void handle_query_curr_tid(GArray *params, void *user_ctx) gdb_put_strbuf(); } +static void handle_query_regs(GArray *params, void *user_ctx) +{ + if (!params->len) { + return; + } + + CPUClass *cc = CPU_GET_CLASS(gdbserver_state.g_cpu); + if (!cc->gdb_qreg_info_lines) { + gdb_put_packet(""); + return; + } + + int reg_num = get_param(params, 0)->val_ul; + if (reg_num >= cc->gdb_qreg_info_line_count) { + gdb_put_packet(""); + return; + } + + gdb_put_packet(cc->gdb_qreg_info_lines[reg_num]); +} + static void handle_query_threads(GArray *params, void *user_ctx) { if (!gdbserver_state.query_cpu) { @@ -1578,6 +1599,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_curr_tid, .cmd = "C", }, + { + .handler = handle_query_regs, + .cmd = "RegisterInfo", + .cmd_startswith = 1, + .schema = "l0" + }, { .handler = handle_query_threads, .cmd = "sThreadInfo", From patchwork Thu Apr 6 19:29:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF649C76196 for ; Thu, 6 Apr 2023 19:31:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVKM-0001KG-CQ; Thu, 06 Apr 2023 15:31:22 -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 1pkVKK-00018c-Qd for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:31:20 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVKH-0002WQ-Qe for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:31:20 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336C0562004077; Thu, 6 Apr 2023 19:31:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=Mtps1fz9KB5WjAS1S2MkhjPGT5pOYKykFU9pgzEBJI0=; b=FzSRBEWsFjX1Oum2rVrJTALDjDXXuPAyTvW5G0WCVVMJ62HJD0VPQS0i/1byW4o5uaeR YA2qwzW8eFceuIQBbfjHfPZRlOT77eCBc/3mUGBLCr1hlgcp2DuNvWgdVpN2l2pEASqZ ZgoRBX97p5C0MBALsFQRUOjqhbTd16n81DUluFwzm+Q103WAWCuOnhDXtmplN4uUgRkK 13ANoGyqrMrMoBUpk66kyvyYfQ2WHw5Kv2NkrEiYnUsjSBDdTUI47eTXO/KaiQ1YKY8h xGD1LX7OfHWUWzymTlsfgMQAO5lnoAsJBNovChBZx+vvLYKvQ63IbcCuZbcHUuWNEIdN +A== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pss7e9nd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:31:15 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUeQI026160 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:40 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:37 -0700 From: Matheus Tavares Bernardino To: CC: , , , , Subject: [PATCH 4/7] Hexagon: support qRegisterInfo at gdbstub Date: Thu, 6 Apr 2023 16:29:46 -0300 Message-ID: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: EDFFQXg_RAqPO3zY_eypeuj-ZMjjzm-q X-Proofpoint-ORIG-GUID: EDFFQXg_RAqPO3zY_eypeuj-ZMjjzm-q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 mlxlogscore=839 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.180.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0b-0031df01.pphosted.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Brian Cain Signed-off-by: Brian Cain Signed-off-by: Matheus Tavares Bernardino --- target/hexagon/gdb_qreginfo.h | 124 ++++++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 3 + 2 files changed, 127 insertions(+) create mode 100644 target/hexagon/gdb_qreginfo.h diff --git a/target/hexagon/gdb_qreginfo.h b/target/hexagon/gdb_qreginfo.h new file mode 100644 index 0000000000..64631ddd58 --- /dev/null +++ b/target/hexagon/gdb_qreginfo.h @@ -0,0 +1,124 @@ +/* + * Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef HEXAGON_GDB_QREGINFO_H +#define HEXAGON_GDB_QREGINFO_H + +const char * const hexagon_qreg_descs[] = { + "name:r00;alt-name:r0;bitsize:32;offset=0;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:0;generic:r00;", + "name:r01;alt-name:r1;bitsize:32;offset=4;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:1;generic:r01;", + "name:r02;alt-name:r2;bitsize:32;offset=8;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:2;generic:r02;", + "name:r03;alt-name:r3;bitsize:32;offset=12;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:3;generic:r03;", + "name:r04;alt-name:r4;bitsize:32;offset=16;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:4;generic:r04;", + "name:r05;alt-name:r5;bitsize:32;offset=20;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:5;generic:r05;", + "name:r06;alt-name:r6;bitsize:32;offset=24;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:6;generic:r06;", + "name:r07;alt-name:r7;bitsize:32;offset=28;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:7;generic:r07;", + "name:r08;alt-name:r8;bitsize:32;offset=32;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:8;generic:r08;", + "name:r09;alt-name:r9;bitsize:32;offset=36;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:9;generic:r09;", + "name:r10;alt-name:;bitsize:32;offset=40;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:10;generic:;", + "name:r11;alt-name:;bitsize:32;offset=44;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:11;generic:;", + "name:r12;alt-name:;bitsize:32;offset=48;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:12;generic:;", + "name:r13;alt-name:;bitsize:32;offset=52;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:13;generic:;", + "name:r14;alt-name:;bitsize:32;offset=56;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:14;generic:;", + "name:r15;alt-name:;bitsize:32;offset=60;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:15;generic:;", + "name:r16;alt-name:;bitsize:32;offset=64;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:16;generic:;", + "name:r17;alt-name:;bitsize:32;offset=68;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:17;generic:;", + "name:r18;alt-name:;bitsize:32;offset=72;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:18;generic:;", + "name:r19;alt-name:;bitsize:32;offset=76;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:19;generic:;", + "name:r20;alt-name:;bitsize:32;offset=80;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:20;generic:;", + "name:r21;alt-name:;bitsize:32;offset=84;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:21;generic:;", + "name:r22;alt-name:;bitsize:32;offset=88;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:22;generic:;", + "name:r23;alt-name:;bitsize:32;offset=92;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:23;generic:;", + "name:r24;alt-name:;bitsize:32;offset=96;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:24;generic:;", + "name:r25;alt-name:;bitsize:32;offset=100;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:25;generic:;", + "name:r26;alt-name:;bitsize:32;offset=104;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:26;generic:;", + "name:r27;alt-name:;bitsize:32;offset=108;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:27;generic:;", + "name:r28;alt-name:;bitsize:32;offset=112;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:28;generic:;", + "name:r29;alt-name:sp;bitsize:32;offset=116;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:29;generic:sp;", + "name:r30;alt-name:fp;bitsize:32;offset=120;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:30;generic:fp;", + "name:r31;alt-name:ra;bitsize:32;offset=124;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:31;generic:ra;", + "name:sa0;alt-name:;bitsize:32;offset=128;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:32;generic:;", + "name:lc0;alt-name:;bitsize:32;offset=132;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:33;generic:;", + "name:sa1;alt-name:;bitsize:32;offset=136;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:34;generic:;", + "name:lc1;alt-name:;bitsize:32;offset=140;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:35;generic:;", + "name:p3_0;alt-name:;bitsize:32;offset=144;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:36;generic:;", + "name:c5;alt-name:;bitsize:32;offset=148;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:37;generic:;", + "name:m0;alt-name:;bitsize:32;offset=152;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:38;generic:;", + "name:m1;alt-name:;bitsize:32;offset=156;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:39;generic:;", + "name:usr;alt-name:;bitsize:32;offset=160;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:40;generic:;", + "name:pc;alt-name:pc;bitsize:32;offset=164;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:41;generic:pc;", + "name:ugp;alt-name:;bitsize:32;offset=168;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:42;generic:;", + "name:gp;alt-name:;bitsize:32;offset=172;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:43;generic:;", + "name:cs0;alt-name:;bitsize:32;offset=176;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:44;generic:;", + "name:cs1;alt-name:;bitsize:32;offset=180;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:45;generic:;", + "name:upcyclelo;alt-name:;bitsize:32;offset=184;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:46;generic:;", + "name:upcyclehi;alt-name:;bitsize:32;offset=188;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:47;generic:;", + "name:framelimit;alt-name:;bitsize:32;offset=192;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:48;generic:;", + "name:framekey;alt-name:;bitsize:32;offset=196;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:49;generic:;", + "name:pktcountlo;alt-name:;bitsize:32;offset=200;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:50;generic:;", + "name:pktcounthi;alt-name:;bitsize:32;offset=204;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:51;generic:;", + "name:pkt_cnt;alt-name:;bitsize:32;offset=208;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:52;generic:;", + "name:insn_cnt;alt-name:;bitsize:32;offset=212;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:53;generic:;", + "name:hvx_cnt;alt-name:;bitsize:32;offset=216;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:54;generic:;", + "name:c23;alt-name:;bitsize:32;offset=220;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:55;generic:;", + "name:c24;alt-name:;bitsize:32;offset=224;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:56;generic:;", + "name:c25;alt-name:;bitsize:32;offset=228;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:57;generic:;", + "name:c26;alt-name:;bitsize:32;offset=232;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:58;generic:;", + "name:c27;alt-name:;bitsize:32;offset=236;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:59;generic:;", + "name:c28;alt-name:;bitsize:32;offset=240;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:60;generic:;", + "name:c29;alt-name:;bitsize:32;offset=244;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:61;generic:;", + "name:utimerlo;alt-name:;bitsize:32;offset=248;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:62;generic:;", + "name:utimerhi;alt-name:;bitsize:32;offset=252;variable-size:0;encoding:uint;format:hex;set:Thread Registers;dwarf:63;generic:;", + "name:v0;alt-name:;bitsize:1024;offset=256;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:88;generic:;", + "name:v1;alt-name:;bitsize:1024;offset=384;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:89;generic:;", + "name:v2;alt-name:;bitsize:1024;offset=512;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:90;generic:;", + "name:v3;alt-name:;bitsize:1024;offset=640;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:91;generic:;", + "name:v4;alt-name:;bitsize:1024;offset=768;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:92;generic:;", + "name:v5;alt-name:;bitsize:1024;offset=896;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:93;generic:;", + "name:v6;alt-name:;bitsize:1024;offset=1024;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:94;generic:;", + "name:v7;alt-name:;bitsize:1024;offset=1152;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:95;generic:;", + "name:v8;alt-name:;bitsize:1024;offset=1280;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:96;generic:;", + "name:v9;alt-name:;bitsize:1024;offset=1408;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:97;generic:;", + "name:v10;alt-name:;bitsize:1024;offset=1536;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:98;generic:;", + "name:v11;alt-name:;bitsize:1024;offset=1664;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:99;generic:;", + "name:v12;alt-name:;bitsize:1024;offset=1792;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:100;generic:;", + "name:v13;alt-name:;bitsize:1024;offset=1920;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:101;generic:;", + "name:v14;alt-name:;bitsize:1024;offset=2048;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:102;generic:;", + "name:v15;alt-name:;bitsize:1024;offset=2176;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:103;generic:;", + "name:v16;alt-name:;bitsize:1024;offset=2304;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:104;generic:;", + "name:v17;alt-name:;bitsize:1024;offset=2432;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:105;generic:;", + "name:v18;alt-name:;bitsize:1024;offset=2560;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:106;generic:;", + "name:v19;alt-name:;bitsize:1024;offset=2688;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:107;generic:;", + "name:v20;alt-name:;bitsize:1024;offset=2816;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:108;generic:;", + "name:v21;alt-name:;bitsize:1024;offset=2944;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:109;generic:;", + "name:v22;alt-name:;bitsize:1024;offset=3072;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:110;generic:;", + "name:v23;alt-name:;bitsize:1024;offset=3200;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:111;generic:;", + "name:v24;alt-name:;bitsize:1024;offset=3328;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:112;generic:;", + "name:v25;alt-name:;bitsize:1024;offset=3456;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:113;generic:;", + "name:v26;alt-name:;bitsize:1024;offset=3584;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:114;generic:;", + "name:v27;alt-name:;bitsize:1024;offset=3712;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:115;generic:;", + "name:v28;alt-name:;bitsize:1024;offset=3840;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:116;generic:;", + "name:v29;alt-name:;bitsize:1024;offset=3968;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:117;generic:;", + "name:v30;alt-name:;bitsize:1024;offset=4096;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:118;generic:;", + "name:v31;alt-name:;bitsize:1024;offset=4224;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:119;generic:;", + "name:q0;alt-name:;bitsize:128;offset=4352;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:120;generic:;", + "name:q1;alt-name:;bitsize:128;offset=4368;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:121;generic:;", + "name:q2;alt-name:;bitsize:128;offset=4384;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:122;generic:;", + "name:q3;alt-name:;bitsize:128;offset=4400;variable-size:1;encoding:vector;format:hex;set:HVX Vector Registers;dwarf:123;generic:;", +}; + +#endif /* HEXAGON_GDB_QREGINFO_H */ diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index ab40cfc283..aa470d9ee4 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -19,6 +19,7 @@ #include "qemu/qemu-print.h" #include "cpu.h" #include "internal.h" +#include "gdb_qreginfo.h" #include "exec/exec-all.h" #include "qapi/error.h" #include "hw/qdev-properties.h" @@ -358,6 +359,8 @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data) cc->get_pc = hexagon_cpu_get_pc; cc->gdb_read_register = hexagon_gdb_read_register; cc->gdb_write_register = hexagon_gdb_write_register; + cc->gdb_qreg_info_lines = (const char **)hexagon_qreg_descs; + cc->gdb_qreg_info_line_count = ARRAY_SIZE(hexagon_qreg_descs); cc->gdb_num_core_regs = TOTAL_PER_THREAD_REGS + NUM_VREGS + NUM_QREGS; cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = hexagon_cpu_disas_set_info; From patchwork Thu Apr 6 19:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED983C7618D for ; Thu, 6 Apr 2023 19:31:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVKE-0000Vu-62; Thu, 06 Apr 2023 15:31:14 -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 1pkVJp-0008EL-SP for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:51 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJn-0002KS-3f for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:49 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336HjAA8020277; Thu, 6 Apr 2023 19:30:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=hEfqexmGOCBPDiChjWLJ/94Ej8FabRepKjvVwNuAL0k=; b=lEMVC/Z/1WDLcXDLLRnx/ko/B9HhhOxi8APBD/17i9YAfNEbzdl/nJ5LwfOF5d2+uFze y3rxypOGWxFard37M02xixxxcgnbZiHqInACTQz3i3o+ab6hkIqGb1U2gXeH8QfWv76x kN5PzxWZTfl1ls7SGaB5ICZ/huJ50AJzsrwJagbvzP/wKIooJNWfvBHAT81xJeNpuNFN oClDkDmz6wC+UuS5H4fkIsfInzsHoTrCQfX7JpjIIOo3Fo1nDxFAX6tINyXlutj6wxf7 dWq3lpblORbTiMNw/T4VA9cdaeAX+qTQ0ydA4e36PrMkCHjrAxLNEHn145nb2Drlw0j6 rw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psnmj26cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:43 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUgFR019070 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:42 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:40 -0700 From: Matheus Tavares Bernardino To: CC: , , , , , Sid Manning Subject: [PATCH 5/7] Hexagon (gdbstub): fix p3:0 read and write via stub Date: Thu, 6 Apr 2023 16:29:47 -0300 Message-ID: <7ea9a493960213e35b61906f86001bb9aade2b99.1680808943.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 2KU5T9sNKiqA7Sdx2XGYGcNubQGKpNVA X-Proofpoint-ORIG-GUID: 2KU5T9sNKiqA7Sdx2XGYGcNubQGKpNVA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=633 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.168.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Brian Cain Co-authored-by: Sid Manning Signed-off-by: Sid Manning Signed-off-by: Brian Cain Co-authored-by: Matheus Tavares Bernardino Signed-off-by: Matheus Tavares Bernardino Reviewed-by: Taylor Simpson --- target/hexagon/gdbstub.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index 46083da620..a06fed9f18 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -25,6 +25,14 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) HexagonCPU *cpu = HEXAGON_CPU(cs); CPUHexagonState *env = &cpu->env; + if (n == HEX_REG_P3_0_ALIASED) { + uint32_t p3_0 = 0; + for (int i = 0; i < NUM_PREGS; i++) { + p3_0 = deposit32(p3_0, i * 8, 8, env->pred[i]); + } + return gdb_get_regl(mem_buf, p3_0); + } + if (n < TOTAL_PER_THREAD_REGS) { return gdb_get_regl(mem_buf, env->gpr[n]); } @@ -37,6 +45,14 @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) HexagonCPU *cpu = HEXAGON_CPU(cs); CPUHexagonState *env = &cpu->env; + if (n == HEX_REG_P3_0_ALIASED) { + uint32_t p3_0 = ldtul_p(mem_buf); + for (int i = 0; i < NUM_PREGS; i++) { + env->pred[i] = extract32(p3_0, i * 8, 8); + } + return sizeof(target_ulong); + } + if (n < TOTAL_PER_THREAD_REGS) { env->gpr[n] = ldtul_p(mem_buf); return sizeof(target_ulong); From patchwork Thu Apr 6 19:29:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CD11C76196 for ; Thu, 6 Apr 2023 19:31:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVKC-0000NT-KR; Thu, 06 Apr 2023 15:31:12 -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 1pkVJr-0008Fh-E5 for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:51 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJp-0002L8-Ci for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:51 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336IN2VP023851; Thu, 6 Apr 2023 19:30:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=RrqJDb68COrmEDpVxeUL/BjMz3Co6Gpvkr0HbSwIGXQ=; b=D0kV8y4/WZq0nU+eywHxxOAXubOmoo6ogTPCjUEJM1/qFej8tx7+EuuH9TEsH65aujkB mIZwFmwnzT6njS6QUsfuVcoroIdpUrOGQvxhWsB2nFCa+s/wbl782MahviR2ioM14XmZ i1EzePx3O3ntAIDrp2p7554/FqQzD5vvv2f+soKJU8Lr0scWvgjn3Dg3Yubvmly2UzIU ffrBG74SzYFkggPT5aJnutM9UMgT0qWADVgnyRGu30/dg8umdPJxK4nfeCDf2xucKgLB GOApYBW/HWReNfrpVQUVaCcTxO24x1FrnDaV6fFfYBMR+EYETX/kyd9C+40ZWv8G9xNo aQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psnmj26d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:45 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUjYR019087 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:45 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:42 -0700 From: Matheus Tavares Bernardino To: CC: , , , , Subject: [PATCH 6/7] Hexagon (gdbstub): add HVX support Date: Thu, 6 Apr 2023 16:29:48 -0300 Message-ID: <993c65e6b8c5625243dc185cfdb1c941e9e6e511.1680808943.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: UIcMMlpXPf9A9l9CqEr0MCWOu8_GX_s_ X-Proofpoint-ORIG-GUID: UIcMMlpXPf9A9l9CqEr0MCWOu8_GX_s_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=521 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.168.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Taylor Simpson Co-authored-by: Brian Cain Signed-off-by: Brian Cain Signed-off-by: Taylor Simpson Co-authored-by: Matheus Tavares Bernardino Signed-off-by: Matheus Tavares Bernardino --- target/hexagon/gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index a06fed9f18..6c5a15da68 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -20,6 +20,26 @@ #include "cpu.h" #include "internal.h" +static int gdb_get_vreg(CPUHexagonState *env, GByteArray *mem_buf, int n) +{ + int total = 0; + int i; + for (i = 0; i < ARRAY_SIZE(env->VRegs[n].uw); i++) { + total += gdb_get_regl(mem_buf, env->VRegs[n].uw[i]); + } + return total; +} + +static int gdb_get_qreg(CPUHexagonState *env, GByteArray *mem_buf, int n) +{ + int total = 0; + int i; + for (i = 0; i < ARRAY_SIZE(env->QRegs[n].uw); i++) { + total += gdb_get_regl(mem_buf, env->QRegs[n].uw[i]); + } + return total; +} + int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { HexagonCPU *cpu = HEXAGON_CPU(cs); @@ -36,10 +56,40 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) if (n < TOTAL_PER_THREAD_REGS) { return gdb_get_regl(mem_buf, env->gpr[n]); } + n -= TOTAL_PER_THREAD_REGS; + + if (n < NUM_VREGS) { + return gdb_get_vreg(env, mem_buf, n); + } + n -= NUM_VREGS; + + if (n < NUM_QREGS) { + return gdb_get_qreg(env, mem_buf, n); + } g_assert_not_reached(); } +static int gdb_put_vreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int i; + for (i = 0; i < ARRAY_SIZE(env->VRegs[n].uw); i++) { + env->VRegs[n].uw[i] = ldtul_p(mem_buf); + mem_buf += 4; + } + return MAX_VEC_SIZE_BYTES; +} + +static int gdb_put_qreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int i; + for (i = 0; i < ARRAY_SIZE(env->QRegs[n].uw); i++) { + env->QRegs[n].uw[i] = ldtul_p(mem_buf); + mem_buf += 4; + } + return MAX_VEC_SIZE_BYTES / 8; +} + int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { HexagonCPU *cpu = HEXAGON_CPU(cs); @@ -57,6 +107,16 @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->gpr[n] = ldtul_p(mem_buf); return sizeof(target_ulong); } + n -= TOTAL_PER_THREAD_REGS; + + if (n < NUM_VREGS) { + return gdb_put_vreg(env, mem_buf, n); + } + n -= NUM_VREGS; + + if (n < NUM_QREGS) { + return gdb_put_qreg(env, mem_buf, n); + } g_assert_not_reached(); } From patchwork Thu Apr 6 19:29:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares Bernardino X-Patchwork-Id: 13203948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A8DFC7618D for ; Thu, 6 Apr 2023 19:31:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkVKC-0000Fo-LM; Thu, 06 Apr 2023 15:31:12 -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 1pkVJt-0008MM-SU for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:54 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkVJr-0002M4-P8 for qemu-devel@nongnu.org; Thu, 06 Apr 2023 15:30:53 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336J0M5A022182; Thu, 6 Apr 2023 19:30:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=l+PakLmISjH8ZXiG9fvj+CGW8xYCbPmP0sFZ3X9jV8g=; b=ZT1SHeJ5SWmhjuZaaN9ixDuCKDUlW8UXLsfARxs5NbWOnJuUyIX6XtCBzuWO4wtouN+P ioxnXkP9Df4SorFAZe1F4WDKzN+sh+9VBr/MDTSaMnyPmpoMMCPg9Mv2b1me+jwNA5sr /YargEddKPgbT36ojVkJHLGERBUxC7QDt8F3KRua6WQgIlD+0gMrJ8o8CZMdOVYb8t19 ROn9ZWh5nBT+5FszWWvWyVcTeED9Io1KJDU9nK8llexjrSzPv44+8crCa+d98uEvCOEb kew9kUiU47LJaVCiENwni8p9lGwahE+3/E9B4wjsFbuygOGFmiWJHKDKeQv82oUHkOpH qw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pss0rsrdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 19:30:48 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 336JUmGN002888 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 19:30:48 GMT Received: from NASANPPMTA02.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 6 Apr 2023 12:30:45 -0700 From: Matheus Tavares Bernardino To: CC: , , , , , Laurent Vivier Subject: [PATCH 7/7] Hexagon (linux-user/hexagon): handle breakpoints Date: Thu, 6 Apr 2023 16:29:49 -0300 Message-ID: <88959c36398b9685ad6602ef5d149f7cb5bdfc6f.1680808943.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nY0TJeOku4k2SmriDy0h0LaCL5SIZXnK X-Proofpoint-ORIG-GUID: nY0TJeOku4k2SmriDy0h0LaCL5SIZXnK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=721 clxscore=1011 phishscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060172 Received-SPF: pass client-ip=205.220.168.131; envelope-from=quic_mathbern@quicinc.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Taylor Simpson This enables LLDB to work with hexagon linux-user mode through the GDB remote protocol. Signed-off-by: Taylor Simpson Signed-off-by: Matheus Tavares Bernardino --- linux-user/hexagon/cpu_loop.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c index b84e25bf71..00c12bbb55 100644 --- a/linux-user/hexagon/cpu_loop.c +++ b/linux-user/hexagon/cpu_loop.c @@ -33,6 +33,7 @@ void cpu_loop(CPUHexagonState *env) target_ulong ret; for (;;) { + target_siginfo_t info; cpu_exec_start(cs); trapnr = cpu_exec(cs); cpu_exec_end(cs); @@ -63,6 +64,15 @@ void cpu_loop(CPUHexagonState *env) case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; + case EXCP_DEBUG: + info = (target_siginfo_t) { + .si_signo = TARGET_SIGTRAP, + .si_errno = 0, + .si_code = TARGET_TRAP_BRKPT, + ._sifields._sigfault._addr = 0 + }; + queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); + break; default: EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n", trapnr);