qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Enable monitor commands in GDB stub


From: Julian Stecklina
Subject: [Qemu-devel] [PATCH] Enable monitor commands in GDB stub
Date: Wed, 10 Dec 2008 23:36:51 +0100

Hello,

I have added support for the qRcmd packet to the GDB stub. This lets
you issue "monitor foo" in GDB and have it executed in qemu's monitor.

A quick test suggests that it works fine, but I am quite new to the
qemu codebase, so I don't know if calling 'monitor_handle_command'
directly from the GDB stub violates any assumptions.

Please keep me CC'd.

Regards,
-- 
Julian Stecklina

Well, take it from an old hand: the only reason it would be easier to
program in C is that you can't easily express complex problems in C,
so you don't. - Erik Naggum (in comp.lang.lisp)

diff --git a/console.h b/console.h
index 6ee40cc..3ae4f86 100644
--- a/console.h
+++ b/console.h
@@ -192,6 +192,7 @@ extern uint8_t _translate_keycode(const int key);
    does not need to include console.h  */
 /* monitor.c */
 void monitor_init(CharDriverState *hd, int show_banner);
+void monitor_handle_command(const char *cmdline);
 void term_puts(const char *str);
 void term_vprintf(const char *fmt, va_list ap);
 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 
1, 2)));
diff --git a/gdbstub.c b/gdbstub.c
index 72feac6..a1ad53d 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1290,6 +1290,7 @@ static int gdb_handle_packet(GDBState *s, const char 
*line_buf)
     char buf[MAX_PACKET_LENGTH];
     uint8_t mem_buf[MAX_PACKET_LENGTH];
     uint8_t *registers;
+    char *monitor_cmd;
     target_ulong addr, len;
 
 #ifdef DEBUG_GDB
@@ -1529,7 +1530,16 @@ static int gdb_handle_packet(GDBState *s, const char 
*line_buf)
     case 'q':
     case 'Q':
         /* parse any 'q' packets here */
-        if (!strcmp(p,"qemu.sstepbits")) {
+        if (strncmp(p, "Rcmd,", 5) == 0) {
+            p += 5;
+            len = strlen(p) / 2;
+            monitor_cmd = mem_buf;
+            hextomem((uint8_t *)monitor_cmd, p, len);
+            monitor_cmd[len] = 0;
+            monitor_handle_command(monitor_cmd);
+            put_packet(s, "OK");
+            break;
+        } else if (!strcmp(p,"qemu.sstepbits")) {
             /* Query Breakpoint bit definitions */
             snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x",
                      SSTEP_ENABLE,
diff --git a/monitor.c b/monitor.c
index 0d55433..fc21ae3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2215,7 +2215,7 @@ static int default_fmt_size = 4;
 
 #define MAX_ARGS 16
 
-static void monitor_handle_command(const char *cmdline)
+void monitor_handle_command(const char *cmdline)
 {
     const char *p, *pstart, *typestr;
     char *q;

reply via email to

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