diff mbox

Add -semihosting-config ....cmdline=string.

Message ID CAFEAcA9m_gS7QEndy3Dg72ngvNzmf0f5fYRxjGEVBN=_b_TOAg@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Peter Maydell Nov. 20, 2014, 3:39 p.m. UTC
On 20 November 2014 15:17, Liviu Ionescu <ilg@livius.net> wrote:
>
> On 20 Nov 2014, at 17:10, Peter Maydell <peter.maydell@linaro.org> wrote:
>
>>> something is missing with the way options are handled, this call fails with BAD_ACCESS.
>>
>> What's this? It's not an error code in QEMU...
>
> no, it is a system condition, EXC_BAD_ACCESS, generally caused by a bad pointer. (on linux probably you get a signal).

Ah, right, SIGSEGV. Anyway, I had a quick play
and it seems to work correctly for me: with this diff:




it prints the command line string at every semihosting call,
if there is one. (I just stuck it at the top of the function
for testing since the test binary I happened to have to hand
didn't do the 'get commandline' call.)

NB: you'll want to stick this inside the !CONFIG_USER_ONLY
ifdef, because on linux-user it'll compile but the
qemu_find_opts() call will fail and then we'll segfault
because we pass a NULL to qemu_opts_find().

-- PMM

Comments

Liviu Ionescu Nov. 20, 2014, 4:42 p.m. UTC | #1
On 20 Nov 2014, at 17:39, Peter Maydell <peter.maydell@linaro.org> wrote:

> NB: you'll want to stick this inside the !CONFIG_USER_ONLY

did this.

now it works for me, but please check if it compiles properly for other targets.

regards,

Liviu
diff mbox

Patch

diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index a8b83e6..d822641 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -36,6 +36,8 @@ 
 #include "exec/gdbstub.h"
 #include "hw/arm/arm.h"
 #endif
+#include "qemu/option.h"
+#include "qemu/config-file.h"

 #define TARGET_SYS_OPEN        0x01
 #define TARGET_SYS_CLOSE       0x02
@@ -199,6 +201,11 @@  uint32_t do_arm_semihosting(CPUARMState *env)
 #else
     CPUARMState *ts = env;
 #endif
+    QemuOpts *opts;
+    const char *cmdline;
+    opts = qemu_opts_find(qemu_find_opts("semihosting-config"), NULL);
+    cmdline = qemu_opt_get(opts, "cmdline");
+    printf("got cmdline %s\n", cmdline ? cmdline : "(null)");

     nr = env->regs[0];
     args = env->regs[1];
diff --git a/vl.c b/vl.c
index 9b69dc3..97eac57 100644
--- a/vl.c
+++ b/vl.c
@@ -565,6 +565,9 @@  static QemuOptsList qemu_semihosting_config_opts = {
         }, {
             .name = "target",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "cmdline",
+            .type = QEMU_OPT_STRING,
         },
         { /* end of list */ }
     },