* [PATCH 0/8] gdbstub and TCG plugin improvements
@ 2023-09-03 4:30 Akihiko Odaki
2023-09-03 4:30 ` [PATCH 1/8] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki
This series extracts fixes and refactorings that can be applied
independently from "[PATCH RESEND v5 00/26] plugins: Allow to read
registers" as suggested by Nicholas Piggin.
Patch "target/ppc: Remove references to gdb_has_xml" is also updated to
remove some dead code I missed earlier and thus the Reviewed-by tag is
dropped.
Akihiko Odaki (8):
contrib/plugins: Use GRWLock in execlog
gdbstub: Introduce GDBFeature structure
target/arm: Move the reference to arm-core.xml
hw/core/cpu: Return static value with gdb_arch_name()
gdbstub: Dynamically allocate target.xml buffer
target/arm: Remove references to gdb_has_xml
target/ppc: Remove references to gdb_has_xml
gdbstub: Remove gdb_has_xml variable
MAINTAINERS | 2 +-
meson.build | 2 +-
gdbstub/internals.h | 2 +-
include/exec/gdbstub.h | 17 ++++------
include/hw/core/cpu.h | 2 +-
target/ppc/internal.h | 2 +-
contrib/plugins/execlog.c | 16 +++++----
gdbstub/gdbstub.c | 63 +++++++++++++++--------------------
gdbstub/softmmu.c | 3 +-
gdbstub/user.c | 1 -
stubs/gdbstub.c | 6 ++--
target/arm/cpu.c | 9 ++---
target/arm/cpu64.c | 4 +--
target/arm/gdbstub.c | 32 ++----------------
target/i386/cpu.c | 6 ++--
target/loongarch/cpu.c | 4 +--
target/ppc/gdbstub.c | 24 ++------------
target/riscv/cpu.c | 6 ++--
target/s390x/cpu.c | 4 +--
target/tricore/cpu.c | 4 +--
scripts/feature_to_c.py | 48 +++++++++++++++++++++++++++
scripts/feature_to_c.sh | 69 ---------------------------------------
22 files changed, 124 insertions(+), 202 deletions(-)
create mode 100755 scripts/feature_to_c.py
delete mode 100644 scripts/feature_to_c.sh
--
2.42.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/8] contrib/plugins: Use GRWLock in execlog
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 2/8] gdbstub: Introduce GDBFeature structure Akihiko Odaki
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Alexandre Iooss, Mahmoud Mandour
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 <akihiko.odaki@daynix.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
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) {
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/8] gdbstub: Introduce GDBFeature structure
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
2023-09-03 4:30 ` [PATCH 1/8] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 3/8] target/arm: Move the reference to arm-core.xml Akihiko Odaki
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Philippe Mathieu-Daudé, Richard Henderson,
Paolo Bonzini, Marc-André Lureau, Daniel P. Berrangé,
Thomas Huth, John Snow, Cleber Rosa
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 <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
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 <http://www.gnu.org/licenses/>.
-
-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 "};"
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/8] target/arm: Move the reference to arm-core.xml
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
2023-09-03 4:30 ` [PATCH 1/8] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
2023-09-03 4:30 ` [PATCH 2/8] gdbstub: Introduce GDBFeature structure Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Richard Henderson, Peter Maydell,
open list:ARM TCG CPUs
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 <akihiko.odaki@daynix.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
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)
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name()
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
` (2 preceding siblings ...)
2023-09-03 4:30 ` [PATCH 3/8] target/arm: Move the reference to arm-core.xml Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-04 5:12 ` Philippe Mathieu-Daudé
2023-09-04 5:54 ` Michael Tokarev
2023-09-03 4:30 ` [PATCH 5/8] gdbstub: Dynamically allocate target.xml buffer Akihiko Odaki
` (3 subsequent siblings)
7 siblings, 2 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Philippe Mathieu-Daudé, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Peter Maydell, Song Gao,
Xiaojuan Yang, Daniel Henrique Barboza, Cédric Le Goater,
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, open list:ARM TCG CPUs,
open list:PowerPC TCG CPUs, open list:RISC-V TCG CPUs,
open list:S390 TCG CPUs
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 <akihiko.odaki@daynix.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
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,
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
"<target>");
if (cc->gdb_arch_name) {
- gchar *arch = cc->gdb_arch_name(cpu);
pstrcat(buf, buf_sz, "<architecture>");
- pstrcat(buf, buf_sz, arch);
+ pstrcat(buf, buf_sz, cc->gdb_arch_name(cpu));
pstrcat(buf, buf_sz, "</architecture>");
- g_free(arch);
}
pstrcat(buf, buf_sz, "<xi:include href=\"");
pstrcat(buf, buf_sz, cc->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)
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/8] gdbstub: Dynamically allocate target.xml buffer
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
` (3 preceding siblings ...)
2023-09-03 4:30 ` [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 6/8] target/arm: Remove references to gdb_has_xml Akihiko Odaki
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Philippe Mathieu-Daudé
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 <alex.bennee@linaro.org>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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,
- "<?xml version=\"1.0\"?>"
- "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
- "<target>");
+ g_ptr_array_add(
+ a,
+ g_strdup("<?xml version=\"1.0\"?>"
+ "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
+ "<target>"));
if (cc->gdb_arch_name) {
- pstrcat(buf, buf_sz, "<architecture>");
- pstrcat(buf, buf_sz, cc->gdb_arch_name(cpu));
- pstrcat(buf, buf_sz, "</architecture>");
+ g_ptr_array_add(
+ a,
+ g_markup_printf_escaped("<architecture>%s</architecture>",
+ cc->gdb_arch_name(cpu)));
}
- pstrcat(buf, buf_sz, "<xi:include href=\"");
- pstrcat(buf, buf_sz, cc->gdb_core_xml_file);
- pstrcat(buf, buf_sz, "\"/>");
+ g_ptr_array_add(
+ a,
+ g_markup_printf_escaped("<xi:include href=\"%s\"/>",
+ cc->gdb_core_xml_file));
for (r = cpu->gdb_regs; r; r = r->next) {
- pstrcat(buf, buf_sz, "<xi:include href=\"");
- pstrcat(buf, buf_sz, r->xml);
- pstrcat(buf, buf_sz, "\"/>");
+ g_ptr_array_add(
+ a,
+ g_markup_printf_escaped("<xi:include href=\"%s\"/>",
+ r->xml));
}
- pstrcat(buf, buf_sz, "</target>");
+ g_ptr_array_add(a, g_strdup("</target>"));
+ 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;
}
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/8] target/arm: Remove references to gdb_has_xml
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
` (4 preceding siblings ...)
2023-09-03 4:30 ` [PATCH 5/8] gdbstub: Dynamically allocate target.xml buffer Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 7/8] target/ppc: " Akihiko Odaki
2023-09-03 4:30 ` [PATCH 8/8] gdbstub: Remove gdb_has_xml variable Akihiko Odaki
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Peter Maydell, open list:ARM TCG CPUs
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 <akihiko.odaki@daynix.com>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
---
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)) {
/*
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/8] target/ppc: Remove references to gdb_has_xml
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
` (5 preceding siblings ...)
2023-09-03 4:30 ` [PATCH 6/8] target/arm: Remove references to gdb_has_xml Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
2023-09-03 4:30 ` [PATCH 8/8] gdbstub: Remove gdb_has_xml variable Akihiko Odaki
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Daniel Henrique Barboza, Cédric Le Goater,
David Gibson, Greg Kurz, Nicholas Piggin,
open list:PowerPC TCG CPUs
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 <akihiko.odaki@daynix.com>
---
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;
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/8] gdbstub: Remove gdb_has_xml variable
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
` (6 preceding siblings ...)
2023-09-03 4:30 ` [PATCH 7/8] target/ppc: " Akihiko Odaki
@ 2023-09-03 4:30 ` Akihiko Odaki
7 siblings, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-03 4:30 UTC (permalink / raw)
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Akihiko Odaki, Philippe Mathieu-Daudé
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 <akihiko.odaki@daynix.com>
---
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)
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name()
2023-09-03 4:30 ` [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
@ 2023-09-04 5:12 ` Philippe Mathieu-Daudé
2023-09-04 5:54 ` Michael Tokarev
1 sibling, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-09-04 5:12 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang, Peter Maydell,
Song Gao, Xiaojuan Yang, Daniel Henrique Barboza,
Cédric Le Goater, 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, open list:ARM TCG CPUs,
open list:PowerPC TCG CPUs, open list:RISC-V TCG CPUs,
open list:S390 TCG CPUs
On 3/9/23 06:30, Akihiko Odaki wrote:
> 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 <akihiko.odaki@daynix.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> 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(-)
Nice.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name()
2023-09-03 4:30 ` [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
2023-09-04 5:12 ` Philippe Mathieu-Daudé
@ 2023-09-04 5:54 ` Michael Tokarev
2023-09-04 6:00 ` Akihiko Odaki
2023-09-04 9:52 ` Philippe Mathieu-Daudé
1 sibling, 2 replies; 13+ messages in thread
From: Michael Tokarev @ 2023-09-04 5:54 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Yanan Wang, Peter Maydell, Song Gao, Xiaojuan Yang,
Daniel Henrique Barboza, Cédric Le Goater, 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, open list:ARM TCG CPUs,
open list:PowerPC TCG CPUs, open list:RISC-V TCG CPUs,
open list:S390 TCG CPUs
03.09.2023 07:30, Akihiko Odaki wrote:
> 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.
Why it needs to be a function, can't it be a char pointer
initialized at the cpu init time?
Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
(What a huge list of recipients in the Cc..)
/mjt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name()
2023-09-04 5:54 ` Michael Tokarev
@ 2023-09-04 6:00 ` Akihiko Odaki
2023-09-04 9:52 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 13+ messages in thread
From: Akihiko Odaki @ 2023-09-04 6:00 UTC (permalink / raw)
To: Michael Tokarev
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Yanan Wang, Peter Maydell, Song Gao, Xiaojuan Yang,
Daniel Henrique Barboza, Cédric Le Goater, 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, open list:ARM TCG CPUs,
open list:PowerPC TCG CPUs, open list:RISC-V TCG CPUs,
open list:S390 TCG CPUs
On 2023/09/04 14:54, Michael Tokarev wrote:
> 03.09.2023 07:30, Akihiko Odaki wrote:
>> 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.
>
> Why it needs to be a function, can't it be a char pointer
> initialized at the cpu init time?
There is no real reason I guess. Either is fine in my opinion.
>
> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
>
> (What a huge list of recipients in the Cc..)
>
> /mjt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name()
2023-09-04 5:54 ` Michael Tokarev
2023-09-04 6:00 ` Akihiko Odaki
@ 2023-09-04 9:52 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-09-04 9:52 UTC (permalink / raw)
To: Michael Tokarev, Akihiko Odaki
Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang, Peter Maydell,
Song Gao, Xiaojuan Yang, Daniel Henrique Barboza,
Cédric Le Goater, 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, open list:ARM TCG CPUs,
open list:PowerPC TCG CPUs, open list:RISC-V TCG CPUs,
open list:S390 TCG CPUs
On 4/9/23 07:54, Michael Tokarev wrote:
> 03.09.2023 07:30, Akihiko Odaki wrote:
>> 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.
>
> Why it needs to be a function, can't it be a char pointer
> initialized at the cpu init time?
For x86_gdb_arch_name() or ppc_gdb_arch_name() we could by
moving the #ifdef'ry, but for arm_gdb_arch_name() we'd need
to add a specific class for the iwMMXt CPU. Not sure worth
it...
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-09-04 9:53 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-03 4:30 [PATCH 0/8] gdbstub and TCG plugin improvements Akihiko Odaki
2023-09-03 4:30 ` [PATCH 1/8] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
2023-09-03 4:30 ` [PATCH 2/8] gdbstub: Introduce GDBFeature structure Akihiko Odaki
2023-09-03 4:30 ` [PATCH 3/8] target/arm: Move the reference to arm-core.xml Akihiko Odaki
2023-09-03 4:30 ` [PATCH 4/8] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
2023-09-04 5:12 ` Philippe Mathieu-Daudé
2023-09-04 5:54 ` Michael Tokarev
2023-09-04 6:00 ` Akihiko Odaki
2023-09-04 9:52 ` Philippe Mathieu-Daudé
2023-09-03 4:30 ` [PATCH 5/8] gdbstub: Dynamically allocate target.xml buffer Akihiko Odaki
2023-09-03 4:30 ` [PATCH 6/8] target/arm: Remove references to gdb_has_xml Akihiko Odaki
2023-09-03 4:30 ` [PATCH 7/8] target/ppc: " Akihiko Odaki
2023-09-03 4:30 ` [PATCH 8/8] gdbstub: Remove gdb_has_xml variable Akihiko Odaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).