[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure |
Date: |
Mon, 31 Jul 2023 15:34:34 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 31/7/23 10:43, Akihiko Odaki wrote:
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.
Great idea!
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
MAINTAINERS | 2 +-
meson.build | 2 +-
include/exec/gdbstub.h | 9 ++++--
gdbstub/gdbstub.c | 4 +--
stubs/gdbstub.c | 6 ++--
scripts/feature_to_c.py | 44 ++++++++++++++++++++++++++
scripts/feature_to_c.sh | 69 -----------------------------------------
7 files changed, 58 insertions(+), 78 deletions(-)
create mode 100755 scripts/feature_to_c.py
delete mode 100644 scripts/feature_to_c.sh
diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py
new file mode 100755
index 0000000000..5a5b49367b
--- /dev/null
+++ b/scripts/feature_to_c.py
@@ -0,0 +1,44 @@
SPDX-License-Identifier: GPL-2.0-or-later ?
+#!/usr/bin/env python3
+
+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\nconst
GDBFeature gdb_features[] = {\n')
Preferably split in 3 calls for readability, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
- [RFC PATCH 00/24] plugins: Allow to read registers, Akihiko Odaki, 2023/07/31
- [RFC PATCH 01/24] contrib/plugins: Use GRWLock in execlog, Akihiko Odaki, 2023/07/31
- [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure, Akihiko Odaki, 2023/07/31
- [RFC PATCH 03/24] gdbstub: Add num_regs member to GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 04/24] gdbstub: Introduce gdb_find_static_feature(), Akihiko Odaki, 2023/07/31
- [RFC PATCH 05/24] target/arm: Move the reference to arm-core.xml, Akihiko Odaki, 2023/07/31
- [RFC PATCH 06/24] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 08/24] target/ppc: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/07/31