From patchwork Sun Sep 3 04:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=DOjlg1TB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf520vGvz1yfm for ; Sun, 3 Sep 2023 14:32:38 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem0-0002Ec-9o; Sun, 03 Sep 2023 00:31:45 -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 1qcelf-0002Ap-HY for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:23 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qceld-0006nx-2Y for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:23 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c0bae4da38so2111675ad.0 for ; Sat, 02 Sep 2023 21:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715478; x=1694320278; 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=2Hs61unU0rT5Xs/IozPbclEmnlWYOJEOWqFw7vuLJvQ=; b=DOjlg1TBOFZIDvwJEWHFTRR6o4M5Ed67nbauoNcPKe2sbNTJRxQl8g4g1ygqq+WY3a N5NUcm+Q61NsVLeWMmV4gZMGublAvBdvg0QV99pGGsUQBTRuwMoyxU7p3RU7ZoNohGxp dHu2fHzBCQwGfD8rUIIeeEzfcoX9or0ZcRBDff6ywhDbeH8UPk+M9DDSObtNIV7nDIf/ KYffO8COlFEEKm40w5PsCmg13o1VZyBJKeP04SXZcZzBix3vpTw8DDSHq+PabuMdJLeZ Uopv7U1AUGF3YYqrs9OcPzZL0FaDWOFFWxd/iUiPR4YlFRpGvpo2f7u7ljsAn36qlxWf 5CEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715478; x=1694320278; 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=2Hs61unU0rT5Xs/IozPbclEmnlWYOJEOWqFw7vuLJvQ=; b=ORba22sWC65VOfleKUqUUYdMP4AuRuKd6Deu2+kUH/UsfibBnC6TjC8aftGPnDfOm9 RdvkGGK7wgHas/Fx1laTQYJbUtyiZLrLFRW4MZjamGIF51nqQ7w/acDykGM9+UV6iPYV AUP6L5Qc+ubGD4OcXTqGQ+Q8GoT4GH2q+djQ/JpgyIiiqeslZrbq8e7yPRUMsAROY70I D0lNaSMIRuPIlX/avKj/iXWTavrOgQ/bT0BHzlkYVlp1kQ2UM/tmYfvfHEmXOwVppRC4 ZVfJozghQG9/Ywazank20k6zWJHdaxVn/UcT++CXx/pVSqTpAIMjPNZyYVcrqUozi03s DkLg== X-Gm-Message-State: AOJu0YzdC568SwOA7gKtwtlfZ4hdJkR+Ti0Ck7mKeKYEJb3Ha1XnOJ61 UTAw0fyEKSDI88gkrHHMxJv+Sg== X-Google-Smtp-Source: AGHT+IH8qzb6UjiEf5BGZdY1AOhxyxpCLqDSifqBg4gw201nEsKgoxM2C5hJnacsoXhsjaS/PWhCTQ== X-Received: by 2002:a17:902:b782:b0:1b5:674d:2aa5 with SMTP id e2-20020a170902b78200b001b5674d2aa5mr7081958pls.13.1693715478525; Sat, 02 Sep 2023 21:31:18 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:18 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH 1/8] contrib/plugins: Use GRWLock in execlog Date: Sun, 3 Sep 2023 13:30:11 +0900 Message-ID: <20230903043030.20708-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org execlog had the following comment: > As we could have multiple threads trying to do this we need to > serialise the expansion under a lock. Threads accessing already > created entries can continue without issue even if the ptr array > gets reallocated during resize. However, when the ptr array gets reallocated, the other threads may have a stale reference to the old buffer. This results in use-after-free. Use GRWLock to properly fix this issue. Fixes: 3d7caf145e ("contrib/plugins: add execlog to log instruction execution and memory access") Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée --- contrib/plugins/execlog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 7129d526f8..82dc2f584e 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -19,7 +19,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; /* Store last executed instruction on each vCPU as a GString */ static GPtrArray *last_exec; -static GMutex expand_array_lock; +static GRWLock expand_array_lock; static GPtrArray *imatches; static GArray *amatches; @@ -28,18 +28,16 @@ static GArray *amatches; * Expand last_exec array. * * As we could have multiple threads trying to do this we need to - * serialise the expansion under a lock. Threads accessing already - * created entries can continue without issue even if the ptr array - * gets reallocated during resize. + * serialise the expansion under a lock. */ static void expand_last_exec(int cpu_index) { - g_mutex_lock(&expand_array_lock); + g_rw_lock_writer_lock(&expand_array_lock); while (cpu_index >= last_exec->len) { GString *s = g_string_new(NULL); g_ptr_array_add(last_exec, s); } - g_mutex_unlock(&expand_array_lock); + g_rw_lock_writer_unlock(&expand_array_lock); } /** @@ -51,8 +49,10 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info, GString *s; /* Find vCPU in array */ + g_rw_lock_reader_lock(&expand_array_lock); g_assert(cpu_index < last_exec->len); s = g_ptr_array_index(last_exec, cpu_index); + g_rw_lock_reader_unlock(&expand_array_lock); /* Indicate type of memory access */ if (qemu_plugin_mem_is_store(info)) { @@ -80,10 +80,14 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) GString *s; /* Find or create vCPU in array */ + g_rw_lock_reader_lock(&expand_array_lock); if (cpu_index >= last_exec->len) { + g_rw_lock_reader_unlock(&expand_array_lock); expand_last_exec(cpu_index); + g_rw_lock_reader_lock(&expand_array_lock); } s = g_ptr_array_index(last_exec, cpu_index); + g_rw_lock_reader_unlock(&expand_array_lock); /* Print previous instruction in cache */ if (s->len) { From patchwork Sun Sep 3 04:30:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=1y4j/zxK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf4d3L06z1ynJ for ; Sun, 3 Sep 2023 14:32:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcell-0002By-0e; Sun, 03 Sep 2023 00:31:29 -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 1qceli-0002BG-Oq for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:27 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcelf-0006pn-Tb for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:26 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-56b0c5a140dso297625a12.0 for ; Sat, 02 Sep 2023 21:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715482; x=1694320282; 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=RZQXbCNxDHIujONx3PLPXTvpqp/0QLYa35wG6AhFq4M=; b=1y4j/zxKlsPs+vsDl8OUgVk97V+GOQFfWU8g0TMUdI5tYhL4apHStJf+Wj6cg+xkbF macjTrcngLcP8GxVPCn2bQBcNczBVV4/69GO/jNOMRSE02YN1siplfGe5BcX3PWy1l8F UQtbKuor1lTAhGbRzqcpQqrGJT2VwHn8fL35cRQmPlhRuL5RDw2D82+D8a3TdAt+8ZgW Mm2lthYwxZT+ZZKJjXv8fn7Veqq02xbNukcJnt1xDCuUdbFoNnyQw5b95+JLS+NA5tiQ 5YBe89aE5/qR+he+oDu/kh2jAWgrDwqJpvySLhOfFAtIMIJviiEEZ+IiR8fqtS8lx1ct K03A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715482; x=1694320282; 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=RZQXbCNxDHIujONx3PLPXTvpqp/0QLYa35wG6AhFq4M=; b=ipbVDLZHxuYU0sB1eoVHshCMtibwL4QfWiPoqGZgKUXTnMuowoFNjYXumbnWLJV5hd +JlYBCb1tw51UM3cW/FiTnmDE/82+3XK9UnlPYnhf7FvT6J5N5Ofuz+f8fttrnuc+PEP AOCi2jT6U2TFl8k+EwJsVrIXRD3T1YA2okGqc/z8NkhkPgFnLlAFLXUmWviemYQ/qo/5 KmmRCmGlod+E0HbqWlheOSIwvL4Uzh/bkKOIxX9XjlJYc/lFGTaKyAobE9X38EOpt0Wv vSr+L4r5WPzhXsntevKEmvEEzA/kMuH9dNiYZPU6wEksrTjI/7GTnv3IdOzQ0p5FU1pa rRbQ== X-Gm-Message-State: AOJu0YyeVbq65EJdAt0LHaT/WFzcUsbdEq/4X5QUue2MOCUqln8OfdnT DV5RbYJB8eBfo18nyvQFDRdCuQ== X-Google-Smtp-Source: AGHT+IHqmdC0JxIJB8jQgrGWCbh5/umNdna0LCQ+NXzF0UoZ6LOqfVkAGWhW31oZG+ppaxLYRBHMnw== X-Received: by 2002:a17:902:7449:b0:1c1:fe87:f550 with SMTP id e9-20020a170902744900b001c1fe87f550mr6903294plt.7.1693715482232; Sat, 02 Sep 2023 21:31:22 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:21 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , John Snow , Cleber Rosa Subject: [PATCH 2/8] gdbstub: Introduce GDBFeature structure Date: Sun, 3 Sep 2023 13:30:12 +0900 Message-ID: <20230903043030.20708-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::52c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Before this change, the information from a XML file was stored in an array that is not descriptive. Introduce a dedicated structure type to make it easier to understand and to extend with more fields. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- MAINTAINERS | 2 +- meson.build | 2 +- include/exec/gdbstub.h | 9 ++++-- gdbstub/gdbstub.c | 4 +-- stubs/gdbstub.c | 6 ++-- scripts/feature_to_c.py | 48 ++++++++++++++++++++++++++++ scripts/feature_to_c.sh | 69 ----------------------------------------- 7 files changed, 62 insertions(+), 78 deletions(-) create mode 100755 scripts/feature_to_c.py delete mode 100644 scripts/feature_to_c.sh diff --git a/MAINTAINERS b/MAINTAINERS index 12e59b6b27..514ac74101 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2826,7 +2826,7 @@ F: include/exec/gdbstub.h F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ -F: scripts/feature_to_c.sh +F: scripts/feature_to_c.py F: scripts/probe-gdb-support.py Memory API diff --git a/meson.build b/meson.build index 98e68ef0b1..5c633f7e01 100644 --- a/meson.build +++ b/meson.build @@ -3683,7 +3683,7 @@ common_all = static_library('common', dependencies: common_all.dependencies(), name_suffix: 'fa') -feature_to_c = find_program('scripts/feature_to_c.sh') +feature_to_c = find_program('scripts/feature_to_c.py') if targetos == 'darwin' entitlement = find_program('scripts/entitlement.sh') diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 7d743fe1e9..3f08093321 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -10,6 +10,11 @@ #define GDB_WATCHPOINT_READ 3 #define GDB_WATCHPOINT_ACCESS 4 +typedef struct GDBFeature { + const char *xmlname; + const char *xml; +} GDBFeature; + /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -38,7 +43,7 @@ void gdb_set_stop_cpu(CPUState *cpu); */ extern bool gdb_has_xml; -/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ -extern const char *const xml_builtin[][2]; +/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ +extern const GDBFeature gdb_static_features[]; #endif diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6911b73c07..2772f07bbe 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -407,11 +407,11 @@ static const char *get_feature_xml(const char *p, const char **newp, } } for (i = 0; ; i++) { - name = xml_builtin[i][0]; + name = gdb_static_features[i].xmlname; if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len)) break; } - return name ? xml_builtin[i][1] : NULL; + return name ? gdb_static_features[i].xml : NULL; } static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) diff --git a/stubs/gdbstub.c b/stubs/gdbstub.c index 2b7aee50d3..580e20702b 100644 --- a/stubs/gdbstub.c +++ b/stubs/gdbstub.c @@ -1,6 +1,6 @@ #include "qemu/osdep.h" -#include "exec/gdbstub.h" /* xml_builtin */ +#include "exec/gdbstub.h" /* gdb_static_features */ -const char *const xml_builtin[][2] = { - { NULL, NULL } +const GDBFeature gdb_static_features[] = { + { NULL } }; diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py new file mode 100755 index 0000000000..bcbcb83beb --- /dev/null +++ b/scripts/feature_to_c.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later + +import os, sys + +def writeliteral(indent, bytes): + sys.stdout.write(' ' * indent) + sys.stdout.write('"') + quoted = True + + for c in bytes: + if not quoted: + sys.stdout.write('\n') + sys.stdout.write(' ' * indent) + sys.stdout.write('"') + quoted = True + + if c == b'"'[0]: + sys.stdout.write('\\"') + elif c == b'\\'[0]: + sys.stdout.write('\\\\') + elif c == b'\n'[0]: + sys.stdout.write('\\n"') + quoted = False + elif c >= 32 and c < 127: + sys.stdout.write(c.to_bytes(1, 'big').decode()) + else: + sys.stdout.write(f'\{c:03o}') + + if quoted: + sys.stdout.write('"') + +sys.stdout.write('#include "qemu/osdep.h"\n' \ + '#include "exec/gdbstub.h"\n' \ + '\n' + 'const GDBFeature gdb_static_features[] = {\n') + +for input in sys.argv[1:]: + with open(input, 'rb') as file: + read = file.read() + + sys.stdout.write(' {\n') + writeliteral(8, bytes(os.path.basename(input), 'utf-8')) + sys.stdout.write(',\n') + writeliteral(8, read) + sys.stdout.write('\n },\n') + +sys.stdout.write(' { NULL }\n};\n') diff --git a/scripts/feature_to_c.sh b/scripts/feature_to_c.sh deleted file mode 100644 index c1f67c8f6a..0000000000 --- a/scripts/feature_to_c.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# Convert text files to compilable C arrays. -# -# Copyright (C) 2007 Free Software Foundation, Inc. -# -# This file is part of GDB. -# -# 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 . - -if test -z "$1"; then - echo "Usage: $0 INPUTFILE..." - exit 1 -fi - -for input; do - arrayname=xml_feature_$(echo $input | sed 's,.*/,,; s/[-.]/_/g') - - ${AWK:-awk} 'BEGIN { n = 0 - printf "#include \"qemu/osdep.h\"\n" - print "static const char '$arrayname'[] = {" - for (i = 0; i < 255; i++) - _ord_[sprintf("%c", i)] = i - } { - split($0, line, ""); - printf " " - for (i = 1; i <= length($0); i++) { - c = line[i] - if (c == "'\''") { - printf "'\''\\'\'''\'', " - } else if (c == "\\") { - printf "'\''\\\\'\'', " - } else if (_ord_[c] >= 32 && _ord_[c] < 127) { - printf "'\''%s'\'', ", c - } else { - printf "'\''\\%03o'\'', ", _ord_[c] - } - if (i % 10 == 0) - printf "\n " - } - printf "'\''\\n'\'', \n" - } END { - print " 0 };" - }' < $input -done - -echo -echo '#include "exec/gdbstub.h"' -echo "const char *const xml_builtin[][2] = {" - -for input; do - basename=$(echo $input | sed 's,.*/,,') - arrayname=xml_feature_$(echo $input | sed 's,.*/,,; s/[-.]/_/g') - echo " { \"$basename\", $arrayname }," -done - -echo " { (char *)0, (char *)0 }" -echo "};" From patchwork Sun Sep 3 04:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=kA4M3398; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf4d2W4sz1yfm for ; Sun, 3 Sep 2023 14:32:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcelp-0002Ch-4n; Sun, 03 Sep 2023 00:31:33 -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 1qcelk-0002Bb-9H for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:28 -0400 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 1qceli-0006qH-40 for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:28 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf11b1c7d0so7491685ad.0 for ; Sat, 02 Sep 2023 21:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715485; x=1694320285; 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=f1OoGlAFSrsHe5yxYX+ZMvZlZQ825ETdOqmrQ0CIV6k=; b=kA4M3398WlSF5p2S3z6dHSLu+W19S67s9Sj/c15Cooqx4EdWUdXHOC12zULCKXbsyh PExPSTTEYWRJh/8DHD46f5bkOhV3SqLhiPPod05aWrK8F5Dvp/Wop/YQZRNyJTRt6/Fi TSNN53U3MW8ju2BsqP9YW4ybLiEeQhoYCxLUKebUw4EeZ+syuLaJJ4fUM9aipIJCWBPs mwTNze8OCLnLBAbMPsJrXvqs9DezF54rkAkchP1fqDwfAtK+6gRG7/MdctmXmtAiMKCk WTE3IXZ/uvDa0AWtHB7a4JH2Ol6RkVM/e9AnfK/phCWFnekrvdZxlqbL7yQ6i8Zd9Vg/ u8DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715485; x=1694320285; 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=f1OoGlAFSrsHe5yxYX+ZMvZlZQ825ETdOqmrQ0CIV6k=; b=jzHlHpKekEALbncjmJhnf8p6ygjQ+c0E7UY8e9YDhnQ9Ub4LFbSqbcp+MUa+6vKU91 jOnej/tjo6UQ24DcTRVuLXmvCxUGBFBUbcEzmhsAt+ocD8dYsmjIphTAtksVpM6XkJgs uZ8z6qziR5QKRmkhDnXZOmmKNyK7+Ug3bjZeTai2QeYvddPC9aYCD0jS4kA15kE1AWbK oQbqXey1lYaaP+W/bxAlUmQUBbC4QMzmFGGV2frSNFUL2cGYphyt7Fw4YojvSzkuLdAn 6CGGkJZF1+K9ldnrdsStr/Udixpm6JCBe79FesKQZpTKQUVyLxuU9P0zyi6scyr57Fz1 VLlA== X-Gm-Message-State: AOJu0YzKUk19usVJ4m6X5wITlDElMLkq/Rt0RrxdU+tsz/w3Z2uVVYvX BIA2uv+CeCGEyQNk2ZaXD9CRYg== X-Google-Smtp-Source: AGHT+IGdm0kRAJURqufTgnNRidPox8bHlYkKt/8voSC1xGfWCJaCI3aeIWpP1XeXTFJk5XvdAstKBQ== X-Received: by 2002:a17:902:d2c5:b0:1c2:193e:1126 with SMTP id n5-20020a170902d2c500b001c2193e1126mr8068868plc.28.1693715484818; Sat, 02 Sep 2023 21:31:24 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:24 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , Richard Henderson , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH 3/8] target/arm: Move the reference to arm-core.xml Date: Sun, 3 Sep 2023 13:30:13 +0900 Message-ID: <20230903043030.20708-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::636; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Some subclasses overwrite gdb_core_xml_file member but others don't. Always initialize the member in the subclasses for consistency. This especially helps for AArch64; in a following change, the file specified by gdb_core_xml_file is always looked up even if it's going to be overwritten later. Looking up arm-core.xml results in an error as it will not be embedded in the AArch64 build. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson --- target/arm/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 93c28d50e5..d71a162070 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2354,7 +2354,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->sysemu_ops = &arm_sysemu_ops; #endif cc->gdb_num_core_regs = 26; - cc->gdb_core_xml_file = "arm-core.xml"; cc->gdb_arch_name = arm_gdb_arch_name; cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true; @@ -2376,8 +2375,10 @@ static void arm_cpu_instance_init(Object *obj) static void cpu_register_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); + CPUClass *cc = CPU_CLASS(acc); acc->info = data; + cc->gdb_core_xml_file = "arm-core.xml"; } void arm_cpu_register(const ARMCPUInfo *info) From patchwork Sun Sep 3 04:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=Qz3j31K/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf6h4nbHz1yfm for ; Sun, 3 Sep 2023 14:34:04 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem6-0002Hv-RF; Sun, 03 Sep 2023 00:31:50 -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 1qcelt-0002D3-Ns for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:41 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcelo-0006uO-Pi for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:36 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-56c2e840e70so268691a12.3 for ; Sat, 02 Sep 2023 21:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715491; x=1694320291; 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=frehclFszcwfB9vSGB44IhmZy3iPQA9K18ZglgMoRmU=; b=Qz3j31K/vxqitUpXQPsJDk+rEfW2IOSPiK/DEqTE29YTGYFLUGKyPP5AG+Tc1ghUWy cXhfm9VVicK750iCIlw8T8C0iOjsHNiyDrHg5QWGP7NDbKuLOGuDBZFSbacFHBJj6Pwk yHbTXF6lHONB9y8T49/8IGC8scxYMw9pWWIfbi9oH9cBIObrJpmdbj99FFHxxnW8ujzh wNr2Wq7Mke80uYE4eTqyKY8g/b1fUdMicF4Ph28foVIMc/a3P5bTNjtVi1mW76DsyW6F TeKvD7UN0Jrsbqau9ZyuFKBDZzU0/megEMuYUmd6jG9VUdutCYnt9UWIRRihkx4EKvWd vLNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715491; x=1694320291; 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=frehclFszcwfB9vSGB44IhmZy3iPQA9K18ZglgMoRmU=; b=bbVJWMSAyS/cgdZ35OfVWn++r87N/fw1MLJcm2FP6kCluwa40uS6WZl4p/HgFJiD8/ PsWxaPxjxvhhCF+ytNw+Dm1B79ua6XdyxYGjVxdbzmMAI3dSAz5AoVt4bOM+JL+3Zql8 g/wRsuF1oLsFVQOEFqHgZ2xFrDWU4pRHTxYEvHnBCgIv4v98eawSiai9WrwHkduztf0T a8ZflT1ZmUeBhCU1en0/1yrHa0L/VzUBqW/XZnl2ebdkDCtqIJbdWw9ip4Ub572QD22c G8fKPpiQRX5KsrRxYKdf4z/KYVWElFUeCQ2r2P/GKkBslojPP7ZS88QpwTgBf9Zld5U9 30dQ== X-Gm-Message-State: AOJu0Yy6XuZea+sE80pXGjxM+0RNayqQUwEUagU36ITO0ItsHe6l5IRq f5so4yLjP9/44svG5E5la549fw== X-Google-Smtp-Source: AGHT+IFqi74KMZZIJBsU51vq7BtAop99Ju4EwXVlAvsyYxpn7DYQpdQxhwjWybwpk4U+0C5PCDmdoQ== X-Received: by 2002:a17:902:748a:b0:1c0:e014:90c1 with SMTP id h10-20020a170902748a00b001c0e01490c1mr7192189pll.48.1693715491599; Sat, 02 Sep 2023 21:31:31 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:31 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Peter Maydell , Song Gao , Xiaojuan Yang , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Bastian Koppelmann , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs), qemu-s390x@nongnu.org (open list:S390 TCG CPUs) Subject: [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Date: Sun, 3 Sep 2023 13:30:14 +0900 Message-ID: <20230903043030.20708-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::52d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org All implementations of gdb_arch_name() returns dynamic duplicates of static strings. It's also unlikely that there will be an implementation of gdb_arch_name() that returns a truly dynamic value due to the nature of the function returning a well-known identifiers. Qualify the value gdb_arch_name() with const and make all of its implementations return static strings. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-By: Michael Tokarev --- include/hw/core/cpu.h | 2 +- target/ppc/internal.h | 2 +- gdbstub/gdbstub.c | 4 +--- target/arm/cpu.c | 6 +++--- target/arm/cpu64.c | 4 ++-- target/i386/cpu.c | 6 +++--- target/loongarch/cpu.c | 4 ++-- target/ppc/gdbstub.c | 6 +++--- target/riscv/cpu.c | 6 +++--- target/s390x/cpu.c | 4 ++-- target/tricore/cpu.c | 4 ++-- 11 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fdcbe87352..4f5c7eb04e 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -164,7 +164,7 @@ struct CPUClass { vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); const char *gdb_core_xml_file; - gchar * (*gdb_arch_name)(CPUState *cpu); + const gchar * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname); void (*disas_set_info)(CPUState *cpu, disassemble_info *info); diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 57acb3212c..974b37aa60 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -221,7 +221,7 @@ void destroy_ppc_opcodes(PowerPCCPU *cpu); /* gdbstub.c */ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *ppc); -gchar *ppc_gdb_arch_name(CPUState *cs); +const gchar *ppc_gdb_arch_name(CPUState *cs); /** * prot_for_access_type: diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2772f07bbe..78711801db 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -379,11 +379,9 @@ static const char *get_feature_xml(const char *p, const char **newp, "" ""); if (cc->gdb_arch_name) { - gchar *arch = cc->gdb_arch_name(cpu); pstrcat(buf, buf_sz, ""); - pstrcat(buf, buf_sz, arch); + pstrcat(buf, buf_sz, cc->gdb_arch_name(cpu)); pstrcat(buf, buf_sz, ""); - g_free(arch); } pstrcat(buf, buf_sz, "gdb_core_xml_file); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d71a162070..4147c19597 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2281,15 +2281,15 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; -static gchar *arm_gdb_arch_name(CPUState *cs) +static const gchar *arm_gdb_arch_name(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - return g_strdup("iwmmxt"); + return "iwmmxt"; } - return g_strdup("arm"); + return "arm"; } #ifndef CONFIG_USER_ONLY diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 96158093cc..6b91aab6b7 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -743,9 +743,9 @@ static void aarch64_cpu_finalizefn(Object *obj) { } -static gchar *aarch64_gdb_arch_name(CPUState *cs) +static const gchar *aarch64_gdb_arch_name(CPUState *cs) { - return g_strdup("aarch64"); + return "aarch64"; } static void aarch64_cpu_class_init(ObjectClass *oc, void *data) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97ad229d8b..68bea8d3f0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5910,12 +5910,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model) memset(&env->user_features, 0, sizeof(env->user_features)); } -static gchar *x86_gdb_arch_name(CPUState *cs) +static const gchar *x86_gdb_arch_name(CPUState *cs) { #ifdef TARGET_X86_64 - return g_strdup("i386:x86-64"); + return "i386:x86-64"; #else - return g_strdup("i386"); + return "i386"; #endif } diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index ad93ecac92..49565da3fa 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -692,9 +692,9 @@ static const struct SysemuCPUOps loongarch_sysemu_ops = { }; #endif -static gchar *loongarch_gdb_arch_name(CPUState *cs) +static const gchar *loongarch_gdb_arch_name(CPUState *cs) { - return g_strdup("loongarch64"); + return "loongarch64"; } static void loongarch_cpu_class_init(ObjectClass *c, void *data) diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ca39efdc35..72df36ca06 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -589,12 +589,12 @@ static int gdb_set_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -gchar *ppc_gdb_arch_name(CPUState *cs) +const gchar *ppc_gdb_arch_name(CPUState *cs) { #if defined(TARGET_PPC64) - return g_strdup("powerpc:common64"); + return "powerpc:common64"; #else - return g_strdup("powerpc:common"); + return "powerpc:common"; #endif } diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6b93b04453..ef8faaaff5 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1939,17 +1939,17 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static gchar *riscv_gdb_arch_name(CPUState *cs) +static const gchar *riscv_gdb_arch_name(CPUState *cs) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; switch (riscv_cpu_mxl(env)) { case MXL_RV32: - return g_strdup("riscv:rv32"); + return "riscv:rv32"; case MXL_RV64: case MXL_RV128: - return g_strdup("riscv:rv64"); + return "riscv:rv64"; default: g_assert_not_reached(); } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index df167493c3..cf4b5e43f2 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -284,9 +284,9 @@ static void s390_cpu_initfn(Object *obj) #endif } -static gchar *s390_gdb_arch_name(CPUState *cs) +static const gchar *s390_gdb_arch_name(CPUState *cs) { - return g_strdup("s390:64-bit"); + return "s390:64-bit"; } static Property s390x_cpu_properties[] = { diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 133a9ac70e..44e3ba6f0e 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -29,9 +29,9 @@ static inline void set_feature(CPUTriCoreState *env, int feature) env->features |= 1ULL << feature; } -static gchar *tricore_gdb_arch_name(CPUState *cs) +static const gchar *tricore_gdb_arch_name(CPUState *cs) { - return g_strdup("tricore"); + return "tricore"; } static void tricore_cpu_set_pc(CPUState *cs, vaddr value) From patchwork Sun Sep 3 04:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=0npzz2Ob; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf6W2ff3z1yhH for ; Sun, 3 Sep 2023 14:33:55 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem2-0002Eu-9n; Sun, 03 Sep 2023 00:31:46 -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 1qcelu-0002DJ-UW for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:42 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcelr-0006va-4K for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:38 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-26f3975ddd4so270213a91.1 for ; Sat, 02 Sep 2023 21:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715493; x=1694320293; 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=z/aZ16AuCEo7wpubooP4JHdg7IKFA98mYu/To/TblDc=; b=0npzz2ObQNRkZi4Eh38hHblL59dVrtwiw2oQClBOrUmpDWuqBo/47ygOCJ3Ab9J5O5 DX2SZMekHBClpSlGIR5qOQPqAbpsXGz4QXS16Y2gVG5GTbzmd2AVfd878z0goGzkGW2V IrhpQ5BmTILRwMDlHtMsIDl77O7+FmE7BcTvwSmr1GZRfY94cqVKKqqbW1d7oGw7cnSf 8BENLVoMPQDJSurPCEraZzg6IIZs/wBcyvsaOseLkuintGhHpBrgc5wbSwV8ONdPORit 8uL5kx1sBmy1mbvpfTNzZXcUy49PsF8U6yYRA27cHpBNRFeEE8W/IVMZW/s7CmKcJsLu 301w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715493; x=1694320293; 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=z/aZ16AuCEo7wpubooP4JHdg7IKFA98mYu/To/TblDc=; b=XKBLeM8el1JH7GXPcZPUvXiGcuimPe4FuYuOnSAGRHn6K+eLeFwPSZiChTtnfHOVCy 5pQfAy5QIIljurO/0+u9xLG+YM05+HdlEgEefYfbZ32xp4W8cSubbC9/ETUnxHH7SBJh PKJoZUXGtvUx2WcRDfBvjZjIP6Zkb/v6yLiKMA+mLc7CpcDncGr05xeec3bEdT/lbkGC 4YIB76o4/X3fyVb10sqUD0coOlHp8Z+/RWWGdwuBq4rQ7agXDY7HbsrUnUBJk43vp3CM EQrbikzUdneMyTpICOO1Fu9rI6XRyhN9kTZ7XxTz1nDi4jMDk769NdhJas31/PXj2wj+ 0nqQ== X-Gm-Message-State: AOJu0YwPksWtG4YzI7LIRcwfZ2kWVE+AfN6jR/te02L3RQuB7HZICr55 /pdFJWRKKt4fAZQrefuBUC6+Ew== X-Google-Smtp-Source: AGHT+IGpUlqXdUGU543EtzTNpwbZyZkf86NKdkwWU8r8yW+vJCJ61u2R3VbTHYN/X8Ykc9YUKIDPgg== X-Received: by 2002:a17:90b:33d1:b0:25e:a8ab:9157 with SMTP id lk17-20020a17090b33d100b0025ea8ab9157mr5715886pjb.22.1693715493660; Sat, 02 Sep 2023 21:31:33 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:33 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 5/8] gdbstub: Dynamically allocate target.xml buffer Date: Sun, 3 Sep 2023 13:30:15 +0900 Message-ID: <20230903043030.20708-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There is no guarantee that target.xml fits in 1024 bytes, and the fixed buffer length requires tedious buffer overflow check. Dynamically allocate the target.xml buffer to resolve these problems. Suggested-by: Alex Bennée Signed-off-by: Akihiko Odaki --- gdbstub/internals.h | 2 +- gdbstub/gdbstub.c | 44 ++++++++++++++++++++++++-------------------- gdbstub/softmmu.c | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index f2b46cce41..4876ebd74f 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -33,7 +33,7 @@ typedef struct GDBProcess { uint32_t pid; bool attached; - char target_xml[1024]; + char *target_xml; } GDBProcess; enum RSState { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 78711801db..3f97dc66e5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -367,33 +367,37 @@ static const char *get_feature_xml(const char *p, const char **newp, name = NULL; if (strncmp(p, "target.xml", len) == 0) { - char *buf = process->target_xml; - const size_t buf_sz = sizeof(process->target_xml); - /* Generate the XML description for this CPU. */ - if (!buf[0]) { + if (!process->target_xml) { + g_autoptr(GPtrArray) a = g_ptr_array_new_with_free_func(g_free); GDBRegisterState *r; - pstrcat(buf, buf_sz, - "" - "" - ""); + g_ptr_array_add( + a, + g_strdup("" + "" + "")); if (cc->gdb_arch_name) { - pstrcat(buf, buf_sz, ""); - pstrcat(buf, buf_sz, cc->gdb_arch_name(cpu)); - pstrcat(buf, buf_sz, ""); + g_ptr_array_add( + a, + g_markup_printf_escaped("%s", + cc->gdb_arch_name(cpu))); } - pstrcat(buf, buf_sz, "gdb_core_xml_file); - pstrcat(buf, buf_sz, "\"/>"); + g_ptr_array_add( + a, + g_markup_printf_escaped("", + cc->gdb_core_xml_file)); for (r = cpu->gdb_regs; r; r = r->next) { - pstrcat(buf, buf_sz, "xml); - pstrcat(buf, buf_sz, "\"/>"); + g_ptr_array_add( + a, + g_markup_printf_escaped("", + r->xml)); } - pstrcat(buf, buf_sz, ""); + g_ptr_array_add(a, g_strdup("")); + g_ptr_array_add(a, NULL); + process->target_xml = g_strjoinv(NULL, (void *)a->pdata); } - return buf; + return process->target_xml; } if (cc->gdb_get_dynamic_xml) { char *xmlname = g_strndup(p, len); @@ -2199,6 +2203,6 @@ void gdb_create_default_process(GDBState *s) process = &s->processes[s->process_num - 1]; process->pid = pid; process->attached = false; - process->target_xml[0] = '\0'; + process->target_xml = NULL; } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index f509b7285d..5282324764 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -293,7 +293,7 @@ static int find_cpu_clusters(Object *child, void *opaque) assert(cluster->cluster_id != UINT32_MAX); process->pid = cluster->cluster_id + 1; process->attached = false; - process->target_xml[0] = '\0'; + process->target_xml = NULL; return 0; } From patchwork Sun Sep 3 04:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=ZOaqrIgY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf6V53CLz1yfm for ; Sun, 3 Sep 2023 14:33:54 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem5-0002HE-UH; Sun, 03 Sep 2023 00:31:49 -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 1qcelw-0002DS-Br for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:43 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcelt-0006yb-7O for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:40 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bf11b1c7d0so7491945ad.0 for ; Sat, 02 Sep 2023 21:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715496; x=1694320296; 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=imQ9qzdcJDtD/a1jypCsLu37Mc6AwMqkJVAfloEAGmU=; b=ZOaqrIgYfOjAUpmEYR1gPQ6qKUahRgpXYvqaRVD8DfDjXIhbCLYS1FFLzR48cIp+oC H2JLDVkys11YHcx7tQbtlgA+IAGsC939pHnLd/+e20HQ/yIJvBzqt+J1VxrRAbM+MMqu v3dzO6Wn8A4yXPdBAzQxEO5pm37F/4FrDXnVLA1K++4pT2F51V8+1/NBPUDkaAEfWY6c G71cg2r6nYLqCTJORV342pGFKlFc9HmEciV0+SfrHu/VEV9iSumKpF8pMxqlUKdYbg18 tzDDtxrfX8ERqx/3lrjBOh61fWe7zdZcmGOAVya5/O0mDp3BbzwC3ceWNOK2Vs9IOslo STsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715496; x=1694320296; 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=imQ9qzdcJDtD/a1jypCsLu37Mc6AwMqkJVAfloEAGmU=; b=LLJ7S2yKxwxZ/0xKNYpd98HTm6aI7cEOjYHGz79gk7kuMPlwjtAWGxzL5CiQmr2NkW LgCajPnTeHLbcqYSmeGkqa9PoFfwTUtO1YAxtkuytkvkwF/ld1MFdpvkR18+nnWfp0O/ YQqq2jw+OCSq5hu9SVavkjuo5W0G6RVXnfYZFRRKeAUf9AJ0hkh/H/xF1EjfjhFaqyJX kN/P5u2bLNlpXGWMnd97+rQa2MGusSJlndw61GxQk1ssBZCS8ndEusIJT37k3lJOd/x4 SuSqEe8OVD1aAmbLXLW/au0IycVlA7BRaxxb6b0sYGmhcZ6bDKI7jA0XkDkZQouLrpWP hIdA== X-Gm-Message-State: AOJu0YxQvGTWjceVW9zgpCfRK0+v8Wwu/BAnuJutGeojL9a6u+my12Uy NGAKYD7ZtyQ1vN9ChEpTu3K7BCa5G7i4B5qKcHQ= X-Google-Smtp-Source: AGHT+IGMbfp+G5QcVXO4jcvTYCcJ830aRAKEId2e0w6AbOvdHewaqNTukLG+W6rYVP9xPtXB7o9eTQ== X-Received: by 2002:a17:902:ec84:b0:1bf:7aeb:c488 with SMTP id x4-20020a170902ec8400b001bf7aebc488mr9373299plg.29.1693715495898; Sat, 02 Sep 2023 21:31:35 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:35 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH 6/8] target/arm: Remove references to gdb_has_xml Date: Sun, 3 Sep 2023 13:30:16 +0900 Message-ID: <20230903043030.20708-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support. Signed-off-by: Akihiko Odaki Acked-by: Alex Bennée --- target/arm/gdbstub.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index f421c5d041..b7ace24bfc 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -46,21 +46,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) /* Core integer register. */ return gdb_get_reg32(mem_buf, env->regs[n]); } - if (n < 24) { - /* FPA registers. */ - if (gdb_has_xml) { - return 0; - } - return gdb_get_zeroes(mem_buf, 12); - } - switch (n) { - case 24: - /* FPA status register. */ - if (gdb_has_xml) { - return 0; - } - return gdb_get_reg32(mem_buf, 0); - case 25: + if (n == 25) { /* CPSR, or XPSR for M-profile */ if (arm_feature(env, ARM_FEATURE_M)) { return gdb_get_reg32(mem_buf, xpsr_read(env)); @@ -100,21 +86,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->regs[n] = tmp; return 4; } - if (n < 24) { /* 16-23 */ - /* FPA registers (ignored). */ - if (gdb_has_xml) { - return 0; - } - return 12; - } - switch (n) { - case 24: - /* FPA status register (ignored). */ - if (gdb_has_xml) { - return 0; - } - return 4; - case 25: + if (n == 25) { /* CPSR, or XPSR for M-profile */ if (arm_feature(env, ARM_FEATURE_M)) { /* From patchwork Sun Sep 3 04:30:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=nh0ZP+w7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf5S2tXVz1yfm for ; Sun, 3 Sep 2023 14:33:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem4-0002GB-UV; Sun, 03 Sep 2023 00:31:49 -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 1qcem1-0002Et-JV for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:45 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcelv-0006zr-UR for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:45 -0400 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6bcb5df95c5so383727a34.1 for ; Sat, 02 Sep 2023 21:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715499; x=1694320299; 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=JGIx5VmKC+qEqkrX7A0VzIiIuVMOabzMZ9XhVHygWtw=; b=nh0ZP+w7OjM1poJUNbqrJZ0QpD6tk/yYiQX4QHgzsMSUMRXw4+NONJH81DMqEaxYdU +ELScZmISITmQ+S+ebT5a6esJyInG+XSZfWb9ZNkTLetuAg90KDEe5l8KAKWU5Nss973 e4ysDPBFLIEEcGN0udrssKOjyQc59WDWIuZYkh1tmwP7g7o5C1yISda5lUdpTLPf1C58 L7XWs5Sj1g4RaJSAwsN6E4cnaKW9u7zffMDICUi301vmpnno0AjTYduEA8IM0EXqcx2r UwmcNfmWMOne93TB6+5H1CR6ZYF/hNYhk7zkvGgNiokvHII6OLaja2r+krpgwVPGYxIn XMxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715499; x=1694320299; 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=JGIx5VmKC+qEqkrX7A0VzIiIuVMOabzMZ9XhVHygWtw=; b=EL/afcrGHgPq9+hcEYSyFmUFKiY9TSiMJ0tUuaJHl7UImMDLXNjO4tlB3Rba6H4GeK jtcQ8DL+aPQZ5iF64AKKPRPuCe7GAEORAuYo8t5m8kkNuIizWhHFY67J1hG6wF6g9877 92bhCU70nqhz2EQvYtpjZD6vdI6gLlH9byc7tltaaePBSsuKZ6pClLGrZbh2wHJHJiKL Y/BGnVJ2uRJ9540XEOiieHy7+mEW4N7gqaAWoBNjJDDpU8JabkOv6nmOL9nUsmaXctnr yc1wsWxdDM4SFJCEsmJG01Bes5M/0HlNOdma22a+lubFqUTBslifCXgA/OIrAZa0leFN RHTg== X-Gm-Message-State: AOJu0YzAkxL4DwpQpboIcVgek7HITTo7XhH8lW26rNDwhCaviUHtn1pf hY2qlDT3Lgyb6+rCvLonqsgHbg== X-Google-Smtp-Source: AGHT+IFQkakJ8PSvZSCptRrZmoLdXYWhZchavzY3Bbjb9riKNDi8Uw0rJR7gGrV4tpZInEngFR6ecg== X-Received: by 2002:a54:4e81:0:b0:3a7:2570:dcfc with SMTP id c1-20020a544e81000000b003a72570dcfcmr7919345oiy.43.1693715498840; Sat, 02 Sep 2023 21:31:38 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:38 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Greg Kurz , Nicholas Piggin , qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) Subject: [PATCH 7/8] target/ppc: Remove references to gdb_has_xml Date: Sun, 3 Sep 2023 13:30:17 +0900 Message-ID: <20230903043030.20708-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::330; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support. Signed-off-by: Akihiko Odaki --- target/ppc/gdbstub.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 72df36ca06..ec5731e5d6 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -54,12 +54,6 @@ static int ppc_gdb_register_len(int n) case 0 ... 31: /* gprs */ return sizeof(target_ulong); - case 32 ... 63: - /* fprs */ - if (gdb_has_xml) { - return 0; - } - return 8; case 66: /* cr */ case 69: @@ -74,12 +68,6 @@ static int ppc_gdb_register_len(int n) case 68: /* ctr */ return sizeof(target_ulong); - case 70: - /* fpscr */ - if (gdb_has_xml) { - return 0; - } - return sizeof(target_ulong); default: return 0; } @@ -132,9 +120,6 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) if (n < 32) { /* gprs */ gdb_get_regl(buf, env->gpr[n]); - } else if (n < 64) { - /* fprs */ - gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); } else { switch (n) { case 64: @@ -158,9 +143,6 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) case 69: gdb_get_reg32(buf, cpu_read_xer(env)); break; - case 70: - gdb_get_reg32(buf, env->fpscr); - break; } } mem_buf = buf->data + buf->len - r; From patchwork Sun Sep 3 04:30:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1829158 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=piHSXw+4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rdf5n0q8pz1yfm for ; Sun, 3 Sep 2023 14:33:17 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcem8-0002IB-Ne; Sun, 03 Sep 2023 00:31:52 -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 1qcem0-0002Ep-RP for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:45 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcely-00070G-BH for qemu-devel@nongnu.org; Sun, 03 Sep 2023 00:31:44 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-56c2e840e70so268747a12.3 for ; Sat, 02 Sep 2023 21:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1693715501; x=1694320301; 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=VEpkefa+vwrcbEzUpVuiGVWFL+7pW2dZSw9F43I190M=; b=piHSXw+43F7E7TGvLNqsL84Tg8UAHzpuxPzUuyBQSAPvdXkj1AbZf55qxtQwqCcM1z nB1QODNUHV86by+FPyPulWdQsYwnbEswq+PKbGQzsvg+b+hjFEsXEQb96WbGyLR13h8g Jz+vNt9u7CrUjbBsAkb5Yba8ruhDz9APRg/PiVqSVUWXj0YTbzqplhoCa3NT8VJq+hGA y49j7mYtV8eHWYjMh/KiEWKiLGJrsq79as31PfGXqEJ8pCCuXtMFzw52SeC/HMwB7bPa ZYaJXuVKA/SLIaa36aNpg/CUgLl4x36un5ATbHBYkzZFkh01CGMjNffM+gQ7uG/goAKm Ch2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693715501; x=1694320301; 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=VEpkefa+vwrcbEzUpVuiGVWFL+7pW2dZSw9F43I190M=; b=JTGxcsK2QuCOmmJYraWVcz3Pc5iXE+7NuavYWWpHaWC7JKT4n7omPfSfHZ1RQeLlkN t2nPZ0cudc69UjCq/dUJGYh6yH1TFhFbyC5tVguGQy03f/JwzUE5hQHIlsPTtT7ZjnC7 a9l48mBj24ILSRtyWxj2dMyASD8/qecH4K9AaZaleoJ39ZT5Twg/4bXXWLvScfeD4lJG mNrk/5gGaPmR0Vwc1aoU9cZv/O2A1Q/MGLDo6evMBvZUjThCmPhBTnhe5YN+VTSdkPE4 CV9JTEmajwVEXk4dcRfyEBl2laEcR1KdZeMSexPlqjunTmfvVfFoQot5MrzDylC+aayC Nv5Q== X-Gm-Message-State: AOJu0YxRnUN4/EXoam6gavqQDvvvR5Z0HErxlAWeSe1bgD08PcTRPeqL J6o1gAGHRip0Sfzhv5QhBzwLrw== X-Google-Smtp-Source: AGHT+IGgh+1VfKLQaHmCsegaxJ/N/F1rIFb0Lzv4WKdJJBl902/x/DzzoZawowmQ7cAg86Skg0i2QA== X-Received: by 2002:a17:902:d3d5:b0:1b6:c229:c350 with SMTP id w21-20020a170902d3d500b001b6c229c350mr7414253plb.18.1693715501143; Sat, 02 Sep 2023 21:31:41 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001bb9f104328sm5295792plb.146.2023.09.02.21.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 21:31:40 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 8/8] gdbstub: Remove gdb_has_xml variable Date: Sun, 3 Sep 2023 13:30:18 +0900 Message-ID: <20230903043030.20708-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230903043030.20708-1-akihiko.odaki@daynix.com> References: <20230903043030.20708-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::532; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 8 -------- gdbstub/gdbstub.c | 13 ------------- gdbstub/softmmu.c | 1 - gdbstub/user.c | 1 - 4 files changed, 23 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 3f08093321..ecbc60a934 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -35,14 +35,6 @@ int gdbserver_start(const char *port_or_device); void gdb_set_stop_cpu(CPUState *cpu); -/** - * gdb_has_xml: - * This is an ugly hack to cope with both new and old gdb. - * If gdb sends qXfer:features:read then assume we're talking to a newish - * gdb that understands target descriptions. - */ -extern bool gdb_has_xml; - /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ extern const GDBFeature gdb_static_features[]; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 3f97dc66e5..61c811f42b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -75,8 +75,6 @@ void gdb_init_gdbserver_state(void) gdbserver_state.sstep_flags &= gdbserver_state.supported_sstep_flags; } -bool gdb_has_xml; - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -1054,11 +1052,6 @@ static void handle_set_reg(GArray *params, void *user_ctx) { int reg_size; - if (!gdb_has_xml) { - gdb_put_packet(""); - return; - } - if (params->len != 2) { gdb_put_packet("E22"); return; @@ -1075,11 +1068,6 @@ static void handle_get_reg(GArray *params, void *user_ctx) { int reg_size; - if (!gdb_has_xml) { - gdb_put_packet(""); - return; - } - if (!params->len) { gdb_put_packet("E14"); return; @@ -1542,7 +1530,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) return; } - gdb_has_xml = true; p = get_param(params, 0)->data; xml = get_feature_xml(p, &p, process); if (!xml) { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 5282324764..42645d2220 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -97,7 +97,6 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) vm_stop(RUN_STATE_PAUSED); replay_gdb_attached(); - gdb_has_xml = false; break; default: break; diff --git a/gdbstub/user.c b/gdbstub/user.c index 5b375be1d9..7ab6e5d975 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -198,7 +198,6 @@ static void gdb_accept_init(int fd) gdbserver_state.c_cpu = gdb_first_attached_cpu(); gdbserver_state.g_cpu = gdbserver_state.c_cpu; gdbserver_user_state.fd = fd; - gdb_has_xml = false; } static bool gdb_accept_socket(int gdb_fd)