* [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr
@ 2010-06-25 15:44 Christophe LYON
2010-08-19 15:11 ` Christophe Lyon
0 siblings, 1 reply; 4+ messages in thread
From: Christophe LYON @ 2010-06-25 15:44 UTC (permalink / raw)
To: qemu-devel
Hello,
I propose this small patch so that ARM semi-hosting handles stderr as
expected when linking with Newlib/libgloss.
diff --git a/arm-semi.c b/arm-semi.c
index 9549e6c..6874036 100644
--- a/arm-semi.c
+++ b/arm-semi.c
@@ -211,8 +211,11 @@ uint32_t do_arm_semihosting(CPUState *env)
if (strcmp(s, ":tt") == 0) {
if (ARG(1) < 4)
return STDIN_FILENO;
- else
+ else if (ARG(1) == 4)
return STDOUT_FILENO;
+ else
+ return STDERR_FILENO; /* See newlib/libgloss
+ implementation. */
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
Christophe
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr
2010-06-25 15:44 [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr Christophe LYON
@ 2010-08-19 15:11 ` Christophe Lyon
2010-11-14 17:50 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Christophe Lyon @ 2010-08-19 15:11 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Ping?
On 25.06.2010 17:44, Christophe LYON wrote:
> Hello,
>
> I propose this small patch so that ARM semi-hosting handles stderr as
> expected when linking with Newlib/libgloss.
>
> diff --git a/arm-semi.c b/arm-semi.c
> index 9549e6c..6874036 100644
> --- a/arm-semi.c
> +++ b/arm-semi.c
> @@ -211,8 +211,11 @@ uint32_t do_arm_semihosting(CPUState *env)
> if (strcmp(s, ":tt") == 0) {
> if (ARG(1)< 4)
> return STDIN_FILENO;
> - else
> + else if (ARG(1) == 4)
> return STDOUT_FILENO;
> + else
> + return STDERR_FILENO; /* See newlib/libgloss
> + implementation. */
> }
> if (use_gdb_syscalls()) {
> gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
>
>
> Christophe
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr
2010-08-19 15:11 ` Christophe Lyon
@ 2010-11-14 17:50 ` Peter Maydell
2010-11-15 12:27 ` Christophe Lyon
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2010-11-14 17:50 UTC (permalink / raw)
To: Christophe Lyon; +Cc: qemu-devel@nongnu.org
On 19 August 2010 16:11, Christophe Lyon <christophe.lyon@st.com> wrote:
> On 25.06.2010 17:44, Christophe LYON wrote:
>> I propose this small patch so that ARM semi-hosting handles stderr as
>> expected when linking with Newlib/libgloss.
Apologies for this rather belated reply, but I only recently managed
to confirm the relevant information...
Unfortunately there is no means in the semihosting ABI to distinguish
app stdout from stderr. Effectively semihosting defines a single input
channel and a single output channel, not three stdin/stdout/stderr
channels. All the implementations of semihosting that I am aware
of work this way, so it's not just an omission from the semihosting
documentation.
Although newlib/libgloss use different modes for opening stdout
and stderr, the ARM C library implementation does not, for
instance; so your patch is relying on a detail of implementation of
a particular semihosting user. So I don't think we can apply this
patch, because it could break other (nonlibgloss) users of
semihosting.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr
2010-11-14 17:50 ` Peter Maydell
@ 2010-11-15 12:27 ` Christophe Lyon
0 siblings, 0 replies; 4+ messages in thread
From: Christophe Lyon @ 2010-11-15 12:27 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel@nongnu.org
On 14.11.2010 18:50, Peter Maydell wrote:
> Although newlib/libgloss use different modes for opening stdout
> and stderr, the ARM C library implementation does not, for
> instance; so your patch is relying on a detail of implementation of
> a particular semihosting user. So I don't think we can apply this
> patch, because it could break other (nonlibgloss) users of
> semihosting.
>
Thanks for your answer.
I think we could argue it's a bug in the ARM semihosting spec, so maybe
we could request them to change this. However, I am unsure how to do
this efficiently, as I recently tried with little success to have them
change the "angel_SWIreason_ReportException" such that at least
ADP_Stopped_AplicationExit can have the program return code as an extra
parameter... (anyway I have another small Qemu patch to handle this
situation by returning the contents of r0 when the program entered
exit(). I can submit it if someone is willing to review it).
Christophe.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-15 12:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-25 15:44 [Qemu-devel] [PATCH] ARM: semi-hosting support for stderr Christophe LYON
2010-08-19 15:11 ` Christophe Lyon
2010-11-14 17:50 ` Peter Maydell
2010-11-15 12:27 ` Christophe Lyon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).