qemu-ppc
[Top][All Lists]
Advanced

[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>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]