* [Qemu-devel] arm return
@ 2012-06-01 11:16 Davide Ferraretto
2012-06-01 11:43 ` Max Filippov
0 siblings, 1 reply; 8+ messages in thread
From: Davide Ferraretto @ 2012-06-01 11:16 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 143 bytes --]
In arm user mode, where does qemu exit? Where is last qemu's instruction?
I.E.
int main (){return 0;}
in what file does qemu run "return 0"??
[-- Attachment #2: Type: text/html, Size: 415 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
2012-06-01 11:16 [Qemu-devel] arm return Davide Ferraretto
@ 2012-06-01 11:43 ` Max Filippov
2012-06-01 11:57 ` Davide Ferraretto
0 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2012-06-01 11:43 UTC (permalink / raw)
To: Davide Ferraretto; +Cc: qemu-devel
On Fri, Jun 1, 2012 at 3:16 PM, Davide Ferraretto
<femudevelopment@gmail.com> wrote:
> In arm user mode, where does qemu exit? Where is last qemu's instruction?
>
> I.E.
> int main (){return 0;}
> in what file does qemu run "return 0"??
Simulated code reaches the point where libc calls 'exit' or 'exit_group' syscall
and then QEMU goes to the do_syscall in the linux-user/syscall.c to terminate
the process.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] arm return
2012-06-01 11:43 ` Max Filippov
@ 2012-06-01 11:57 ` Davide Ferraretto
2012-06-01 12:23 ` Max Filippov
0 siblings, 1 reply; 8+ messages in thread
From: Davide Ferraretto @ 2012-06-01 11:57 UTC (permalink / raw)
To: Max Filippov; +Cc: qemu-devel
I tried to insert " printf("exit\n"); ", but qemu dosen't write to monitor.
On 06/01/12 13:43, Max Filippov wrote:
> On Fri, Jun 1, 2012 at 3:16 PM, Davide Ferraretto
> <femudevelopment@gmail.com> wrote:
>> In arm user mode, where does qemu exit? Where is last qemu's instruction?
>>
>> I.E.
>> int main (){return 0;}
>> in what file does qemu run "return 0"??
> Simulated code reaches the point where libc calls 'exit' or 'exit_group' syscall
> and then QEMU goes to the do_syscall in the linux-user/syscall.c to terminate
> the process.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
2012-06-01 11:57 ` Davide Ferraretto
@ 2012-06-01 12:23 ` Max Filippov
2012-06-01 12:30 ` Davide Ferraretto
0 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2012-06-01 12:23 UTC (permalink / raw)
To: Davide Ferraretto; +Cc: qemu-devel
On Fri, Jun 1, 2012 at 3:57 PM, Davide Ferraretto
<femudevelopment@gmail.com> wrote:
> I tried to insert " printf("exit\n"); ", but qemu dosen't write to monitor.
printf should not write to monitor (if you mean QEMU monitor), it
should go to stdout.
I don't have ARM compiler set up ATM, but x86_64 with the following
patch does what I describe:
$ git diff
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 20d2a74..ccb71dc 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5052,6 +5052,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
switch(num) {
case TARGET_NR_exit:
+ fprintf(stderr, "TARGET_NR_exit\n");
#ifdef CONFIG_USE_NPTL
/* In old applications this may be used to implement _exit(2).
However in threaded applictions it is used for thread termination,
@@ -6833,6 +6834,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#ifdef __NR_exit_group
/* new thread calls */
case TARGET_NR_exit_group:
+ fprintf(stderr, "TARGET_NR_exit_group\n");
#ifdef TARGET_GPROF
_mcleanup();
#endif
$ cat a.c
#include <stdio.h>
int main()
{
printf("Hello, world\n");
return 0;
}
$ gcc -static a.c -o a
$ qemu-all/root/bin/qemu-x86_64 ./a
Hello, world
TARGET_NR_exit_group
> On 06/01/12 13:43, Max Filippov wrote:
>>
>> On Fri, Jun 1, 2012 at 3:16 PM, Davide Ferraretto
>> <femudevelopment@gmail.com> wrote:
>>>
>>> In arm user mode, where does qemu exit? Where is last qemu's instruction?
>>>
>>> I.E.
>>> int main (){return 0;}
>>> in what file does qemu run "return 0"??
>>
>> Simulated code reaches the point where libc calls 'exit' or 'exit_group'
>> syscall
>> and then QEMU goes to the do_syscall in the linux-user/syscall.c to
>> terminate
>> the process.
>>
>
--
Thanks.
-- Max
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
2012-06-01 12:23 ` Max Filippov
@ 2012-06-01 12:30 ` Davide Ferraretto
2012-06-01 12:42 ` Max Filippov
0 siblings, 1 reply; 8+ messages in thread
From: Davide Ferraretto @ 2012-06-01 12:30 UTC (permalink / raw)
To: Max Filippov; +Cc: qemu-devel
I'm in "arm user space" with "sigle step mode". I want write "exit\n" in
linux shell (no QEMU monitor) when emulate code arrives to "return 0"
On 06/01/12 14:23, Max Filippov wrote:
> On Fri, Jun 1, 2012 at 3:57 PM, Davide Ferraretto
> <femudevelopment@gmail.com> wrote:
>> I tried to insert " printf("exit\n"); ", but qemu dosen't write to monitor.
> printf should not write to monitor (if you mean QEMU monitor), it
> should go to stdout.
> I don't have ARM compiler set up ATM, but x86_64 with the following
> patch does what I describe:
>
> $ git diff
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 20d2a74..ccb71dc 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -5052,6 +5052,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>
> switch(num) {
> case TARGET_NR_exit:
> + fprintf(stderr, "TARGET_NR_exit\n");
> #ifdef CONFIG_USE_NPTL
> /* In old applications this may be used to implement _exit(2).
> However in threaded applictions it is used for thread termination,
> @@ -6833,6 +6834,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> #ifdef __NR_exit_group
> /* new thread calls */
> case TARGET_NR_exit_group:
> + fprintf(stderr, "TARGET_NR_exit_group\n");
> #ifdef TARGET_GPROF
> _mcleanup();
> #endif
>
> $ cat a.c
> #include<stdio.h>
> int main()
> {
> printf("Hello, world\n");
> return 0;
> }
>
> $ gcc -static a.c -o a
> $ qemu-all/root/bin/qemu-x86_64 ./a
> Hello, world
> TARGET_NR_exit_group
>
>> On 06/01/12 13:43, Max Filippov wrote:
>>> On Fri, Jun 1, 2012 at 3:16 PM, Davide Ferraretto
>>> <femudevelopment@gmail.com> wrote:
>>>> In arm user mode, where does qemu exit? Where is last qemu's instruction?
>>>>
>>>> I.E.
>>>> int main (){return 0;}
>>>> in what file does qemu run "return 0"??
>>> Simulated code reaches the point where libc calls 'exit' or 'exit_group'
>>> syscall
>>> and then QEMU goes to the do_syscall in the linux-user/syscall.c to
>>> terminate
>>> the process.
>>>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
2012-06-01 12:30 ` Davide Ferraretto
@ 2012-06-01 12:42 ` Max Filippov
[not found] ` <4FC8BD42.6080209@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2012-06-01 12:42 UTC (permalink / raw)
To: Davide Ferraretto; +Cc: qemu-devel
On Fri, Jun 1, 2012 at 4:30 PM, Davide Ferraretto
<femudevelopment@gmail.com> wrote:
> I'm in "arm user space" with "sigle step mode". I want write "exit\n" in
> linux shell (no QEMU monitor) when emulate code arrives to "return 0"
Ok, what do you execute and where? Is it qemu-arm or qemu-system-arm?
In the latter case do you use -semihosting?
What is "ARM user space"?
How is it all related to single step mode?
Which linux shell do you mean, guest or host?
Please, don't top-post.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
[not found] ` <4FC8BD42.6080209@gmail.com>
@ 2012-06-01 13:12 ` Max Filippov
[not found] ` <4FC8C03A.2000902@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2012-06-01 13:12 UTC (permalink / raw)
To: Davide Ferraretto; +Cc: qemu-devel
On Fri, Jun 1, 2012 at 5:01 PM, Davide Ferraretto
<femudevelopment@gmail.com> wrote:
> I run qemu-arm -singlestep prog
>
> Linux shell --> host.
Ok, and you build 'prog' as a static linux ELF for ARM?
What does
qemu-arm -strace prog
print?
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] arm return
[not found] ` <4FC8C03A.2000902@gmail.com>
@ 2012-06-01 13:26 ` Max Filippov
0 siblings, 0 replies; 8+ messages in thread
From: Max Filippov @ 2012-06-01 13:26 UTC (permalink / raw)
To: Davide Ferraretto; +Cc: qemu-devel
On Fri, Jun 1, 2012 at 5:14 PM, Davide Ferraretto
<femudevelopment@gmail.com> wrote:
> I compile so:
> arm-elf-gcc-4.0.2 prog -o prog
As its name suggests, arm-elf-gcc builds bare-metal ELF that wouldn't
run on linux, doesn't it?
And what about the other question, what does qemu-arm -strace prog print?
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-06-01 13:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-01 11:16 [Qemu-devel] arm return Davide Ferraretto
2012-06-01 11:43 ` Max Filippov
2012-06-01 11:57 ` Davide Ferraretto
2012-06-01 12:23 ` Max Filippov
2012-06-01 12:30 ` Davide Ferraretto
2012-06-01 12:42 ` Max Filippov
[not found] ` <4FC8BD42.6080209@gmail.com>
2012-06-01 13:12 ` Max Filippov
[not found] ` <4FC8C03A.2000902@gmail.com>
2012-06-01 13:26 ` Max Filippov
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).