From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaR0X-0007eR-Lw for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaR0Q-0003A6-PX for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:31:09 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:33098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaR0Q-00039l-Gc for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:31:02 -0400 Received: by eekd41 with SMTP id d41so1174789eek.4 for ; Fri, 01 Jun 2012 05:31:00 -0700 (PDT) Message-ID: <4FC8B5D2.1030204@gmail.com> Date: Fri, 01 Jun 2012 14:30:10 +0200 From: Davide Ferraretto MIME-Version: 1.0 References: <4FC8A49C.9020901@gmail.com> <4FC8AE3A.20303@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Filippov Cc: qemu-devel@nongnu.org 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 > 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 > 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 >>> 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. >>>