From patchwork Thu Nov 20 15:39:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 412757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BB76E140170 for ; Fri, 21 Nov 2014 02:40:20 +1100 (AEDT) Received: from localhost ([::1]:35948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrTqD-0000nY-Aj for incoming@patchwork.ozlabs.org; Thu, 20 Nov 2014 10:40:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrTpp-0000OV-Ep for qemu-devel@nongnu.org; Thu, 20 Nov 2014 10:39:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrTpk-0007zF-Ty for qemu-devel@nongnu.org; Thu, 20 Nov 2014 10:39:53 -0500 Received: from mail-la0-f47.google.com ([209.85.215.47]:38321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrTpk-0007z7-Mk for qemu-devel@nongnu.org; Thu, 20 Nov 2014 10:39:48 -0500 Received: by mail-la0-f47.google.com with SMTP id hz20so2656246lab.34 for ; Thu, 20 Nov 2014 07:39:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=EKkbzyPDWzdB8WYAIrkYh7LhbFyoVei2oulog7/m3IY=; b=jTtMkGmvq7CmHiZ9gVgzVrBewGY3T2JYskZbDqTJOYI33G22TDGs+yMeQ/kVTRFjvp sLj4af6C8aCNCb6SrrH4+8ZgAmTxyyB96yA31vmxwuFCPJAtXB6VnCSZL+gWMrWG+2vx KirKLT9lvIyzUm1DeGXGWegpOKYNTMdgQtJUIdrtxA2kNAydvztMWiNNT5doFvTN9J9E 70kmrmAXAyAfDEWyOF3EqjnuIQ9E78GSNSVESa+6bp97BIKLgtFI6Upoewtk0ra8R2XH o4jzhyz1iNK48sl3slN0tSlwrXWJ8ijTqgdr6SJrJOw2+zY38VOBpII/gyiS5NazKeMj U4KQ== X-Gm-Message-State: ALoCoQkjPwLUGo7sEYtkmWfm5e77MbHXrtO6K4yZQGJ5Avfm+KA3kbv27qTIISMqiaBPf/iCCHyQ X-Received: by 10.112.14.69 with SMTP id n5mr11891357lbc.34.1416497987851; Thu, 20 Nov 2014 07:39:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.150.135 with HTTP; Thu, 20 Nov 2014 07:39:27 -0800 (PST) In-Reply-To: References: <1416434723-59406-1-git-send-email-ilg@livius.net> <7D3B134A-17E9-440D-8ACE-7CAC6215C487@livius.net> From: Peter Maydell Date: Thu, 20 Nov 2014 15:39:27 +0000 Message-ID: To: Liviu Ionescu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.47 Cc: QEMU Developers Subject: Re: [Qemu-devel] [PATCH] Add -semihosting-config ....cmdline=string. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 20 November 2014 15:17, Liviu Ionescu wrote: > > On 20 Nov 2014, at 17:10, Peter Maydell 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 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 */ } },