Patchwork [006/111] linux-user: define new environment variables

login
register
mail settings
Submitter Bryce Lanham
Date Aug. 17, 2011, 8:46 p.m.
Message ID <1313614076-28878-7-git-send-email-blanham@gmail.com>
Download mbox | patch
Permalink /patch/110390/
State New
Headers show

Comments

Bryce Lanham - Aug. 17, 2011, 8:46 p.m.
From: Laurent Vivier <Laurent@Vivier.EU>

QEMU_GDB=port allows to define gdb server port to wait on.
QEMU_DEBUG=options allows to activate log file (like -d options)

Signed-off-by: Laurent Vivier <Laurent@Vivier.EU>
---
 linux-user/main.c |   14 +++++++++++---
 qemu-doc.texi     |    4 ++++
 2 files changed, 15 insertions(+), 3 deletions(-)

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index 68b5681..62aa983 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2815,8 +2815,10 @@  static void usage(void)
            "-strace      log system calls\n"
            "\n"
            "Environment variables:\n"
-           "QEMU_STRACE       Print system calls and arguments similar to the\n"
-           "                  'strace' program.  Enable by setting to any value.\n"
+           "QEMU_STRACE        Print system calls and arguments similar to the\n"
+           "                   'strace' program.  Enable by setting to any value.\n"
+           "QEMU_DEBUG=options Activate log. Use same options as '-d' options\n"
+           "QEMU_GDB=port      Wait gdb connection to port\n"
            "You can use -E and -U options to set/unset environment variables\n"
            "for target process.  It is possible to provide several variables\n"
            "by repeating the option.  For example:\n"
@@ -2872,7 +2874,7 @@  int main(int argc, char **argv, char **envp)
     const char *filename;
     const char *cpu_model;
     const char *log_file = DEBUG_LOGFILE;
-    const char *log_mask = NULL;
+    const char *log_mask = getenv("QEMU_DEBUG");
     struct target_pt_regs regs1, *regs = &regs1;
     struct image_info info1, *info = &info1;
     struct linux_binprm bprm;
@@ -2919,6 +2921,12 @@  int main(int argc, char **argv, char **envp)
 #if defined(cpudef_setup)
     cpudef_setup(); /* parse cpu definitions in target config file (TBD) */
 #endif
+    if (getenv("QEMU_GDB")) {
+      gdbstub_port = atoi(getenv("QEMU_GDB"));
+    }
+    /* don't propagate QEMU_DEBUG and _GDB to children */
+    unsetenv("QEMU_DEBUG");
+    unsetenv("QEMU_GDB");
 
     optind = 1;
     for(;;) {
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 31199f6..2193463 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2293,6 +2293,10 @@  space emulator hasn't implemented ptrace).  At the moment this is
 incomplete.  All system calls that don't have a specific argument
 format are printed with information for six arguments.  Many
 flag-style arguments don't have decoders and will show up as numbers.
+@item QEMU_DEBUG=options
+Activate log. Use same options as '-d' options.
+@item QEMU_GDB=port
+Wait gdb connection to port.
 @end table
 
 @node Other binaries