Skip to contentSkip to conversation

HMP roll up

PATCH In review [email protected] 2 participants 7 messages May 4 – May 5

lore
Share & tools
lore
#0 lore raw

cover HMP roll up

From: "Dr. David Alan Gilbert" <[email protected]>

Hi Markus,
Can you merge this little set through your monitor set?

Dave

[email protected] (1):
monitor: Add clear command

Dr. David Alan Gilbert (3):
hmp*hx: Move info docs
hxtool: Split srst/erst add checks
hxtool: Error on missing docs

 hmp-commands-info.hx  |  9 +--------
 hmp-commands.hx       | 41 +++++++++++++++++++++++++++++++----------
 include/monitor/hmp.h |  1 +
 monitor/hmp-cmds.c    | 11 +++++++++++
 scripts/hxtool        | 39 ++++++++++++++++++++++++++++++++++++---
 5 files changed, 80 insertions(+), 21 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/4 hmp*hx: Move info docs

From: "Dr. David Alan Gilbert" <[email protected]>

Move the docs for the info subcommand from the separate hx into the top level file next to the 'info' command itself. That makes every command in the top level file have a RST section.

---
 hmp-commands-info.hx |  9 +--------
 hmp-commands.hx      | 27 +++++++++++++++++----------
 2 files changed, 18 insertions(+), 18 deletions(-)
hmp-commands-info.hx +1 -8
index 74c741f80e..964eed004c 100644
@@ -8,14 +8,7 @@ HXCOMM
 HXCOMM In this file, generally SRST fragments should have two extra
 HXCOMM spaces of indent, so that the documentation list item for "info foo"
 HXCOMM appears inside the documentation list item for the top level
-HXCOMM "info" documentation entry. The exception is the first SRST
-HXCOMM fragment that defines that top level entry.
-
-SRST
-``info`` *subcommand*
-  Show various information about the system state.
-
-ERST
+HXCOMM "info" documentation entry.
 
     {
         .name       = "version",
hmp-commands.hx +17 -10
index 5cc4788f12..f4a6eeda93 100644
@@ -1814,16 +1814,6 @@ SRST
   command.
 ERST
 
-    {
-        .name       = "info",
-        .args_type  = "item:s?",
-        .params     = "[subcommand]",
-        .help       = "show various information about the system state",
-        .cmd        = hmp_info_help,
-        .sub_table  = hmp_info_cmds,
-        .flags      = "p",
-    },
-
 #if defined(CONFIG_FDT)
     {
         .name       = "dumpdtb",
@@ -1867,3 +1857,20 @@ SRST
   List event channels in the guest
 ERST
 #endif
+
+HXCOMM *** MUST BE LAST ENTRY **
+    {
+        .name       = "info",
+        .args_type  = "item:s?",
+        .params     = "[subcommand]",
+        .help       = "show various information about the system state",
+        .cmd        = hmp_info_help,
+        .sub_table  = hmp_info_cmds,
+        .flags      = "p",
+    },
+
+SRST
+``info`` *subcommand*
+  Show various information about the system state.
+ERST
+HXCOMM *** MUST BE LAST ENTRY **
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/4 hxtool: Split srst/erst add checks

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

Split the SRST/ERST case and add some checks.
This is mainly to make it easier to add some checks in following patches.

---
 scripts/hxtool | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
scripts/hxtool +17 -3
index 80516b9437..51dc841479 100755
@@ -2,15 +2,29 @@
 
 hxtoh()
 {
-    flag=1
+    in_rst=0
     while read -r str; do
         case $str in
             HXCOMM*)
             ;;
-            SRST*|ERST*) flag=$(($flag^1))
+            SRST*)
+              if [ $in_rst -eq 1 ]
+              then
+                echo "Error: SRST inside another RST" >&2
+                exit 1
+              fi
+              in_rst=1
+            ;;
+            ERST*)
+              if [ $in_rst -eq 0 ]
+              then
+                echo "Error: ERST already outside RST" >&2
+                exit 1
+              fi
+              in_rst=0
             ;;
             *)
-            test $flag -eq 1 && printf "%s\n" "$str"
+            test $in_rst -eq 0 && printf "%s\n" "$str"
             ;;
         esac
     done
Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/4 hxtool: Error on missing docs

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

Error if a '.name' is seen after another '.name' without an intervening SRST, this normally indicates missing or misplaced docs.

We can't check DEF (as used in command line options) because those often have multiple DEF per doc.

With the two minor tidy ups from Thomas's review

---
 scripts/hxtool | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
scripts/hxtool +20 -1
index 51dc841479..617a694eaf 100755
@@ -1,8 +1,15 @@
 #!/bin/sh
 
+print_if_not_rst()
+{
+    test $in_rst -eq 0 && printf "%s\n" "$str"
+}
+
 hxtoh()
 {
     in_rst=0
+    # .name for HMP
+    seen_name=0
     while read -r str; do
         case $str in
             HXCOMM*)
@@ -13,6 +20,8 @@ hxtoh()
                 echo "Error: SRST inside another RST" >&2
                 exit 1
               fi
+              # consume the name
+              seen_name=0
               in_rst=1
             ;;
             ERST*)
@@ -23,8 +32,18 @@ hxtoh()
               fi
               in_rst=0
             ;;
+            # Note the space at the start - we need to exclude something.name
+            ( .name*)
+              if [ $seen_name -eq 1 ]
+              then
+                echo "Error: Seen another .name, maybe missing docs?" >&2
+                exit 1
+              fi
+              seen_name=1
+              print_if_not_rst
+            ;;
             *)
-            test $in_rst -eq 0 && printf "%s\n" "$str"
+            print_if_not_rst
             ;;
         esac
     done
Signature · 1 line
2.54.0
#4 lore raw

PATCH 4/4 monitor: Add `clear` command

In reply to [email protected]

From: "[email protected]" <[email protected]>

The monitor screen can be cluttered after executing commands like info qtree. It is useful to have a command to clear current screen, just like linux clear command do.

This patch has been tested under monitors using stdio, vc, tcp socket, unix socket and serial interfaces.

---
 hmp-commands.hx       | 14 ++++++++++++++
 include/monitor/hmp.h |  1 +
 monitor/hmp-cmds.c    | 11 +++++++++++
 3 files changed, 26 insertions(+)
hmp-commands.hx +14 -0
index f4a6eeda93..b806ec5635 100644
@@ -20,6 +20,20 @@ SRST
   Show the help for all commands or just for command *cmd*.
 ERST
 
+    {
+        .name       = "clear",
+        .args_type  = "",
+        .params     = "",
+        .help       = "clear the monitor screen",
+        .cmd        = hmp_clear,
+        .flags      = "p",
+    },
+
+SRST
+``clear``
+  Clear the monitor screen.
+ERST
+
     {
         .name       = "commit",
         .args_type  = "device:B",
include/monitor/hmp.h +1 -0
index e222bea60c..9b66458d21 100644
@@ -165,6 +165,7 @@ void hmp_trace_event(Monitor *mon, const QDict *qdict);
 void hmp_trace_file(Monitor *mon, const QDict *qdict);
 void hmp_info_trace_events(Monitor *mon, const QDict *qdict);
 void hmp_help(Monitor *mon, const QDict *qdict);
+void hmp_clear(Monitor *mon, const QDict *qdict);
 void hmp_info_help(Monitor *mon, const QDict *qdict);
 void hmp_info_sync_profile(Monitor *mon, const QDict *qdict);
 void hmp_info_history(Monitor *mon, const QDict *qdict);
monitor/hmp-cmds.c +11 -0
index afa7b709a6..1b44d07c18 100644
@@ -219,6 +219,17 @@ void hmp_help(Monitor *mon, const QDict *qdict)
     hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
 }
 
+void hmp_clear(Monitor *mon, const QDict *qdict)
+{
+    /*
+     * Send an ANSI escape sequence:
+     * "\x1b[H" - move cursor to top-left
+     * "\x1b[2J" - clear visible screen
+     * "\x1b[3J" - clear scrollback
+     */
+    monitor_printf(mon, "\x1b[H\x1b[2J\x1b[3J");
+}
+
 void hmp_info_help(Monitor *mon, const QDict *qdict)
 {
     hmp_help_cmd(mon, "info");
Signature · 1 line
2.54.0
#6 lore raw
Quoted 8 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 4 lines · [email protected] writes:

From: "Dr. David Alan Gilbert" <[email protected]>

Hi Markus,
Can you merge this little set through your monitor set?

Sure! PR sent: "[PULL 0/4] Monitor patches for 2026-05-05".

Thanks!

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/