From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaPrU-0003gx-Vy for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:17:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaPrO-0003Xh-Rz for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:17:44 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:64956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaPrO-0003XQ-Im for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:17:38 -0400 Received: by eekd41 with SMTP id d41so1139923eek.4 for ; Fri, 01 Jun 2012 04:17:35 -0700 (PDT) Message-ID: <4FC8A49C.9020901@gmail.com> Date: Fri, 01 Jun 2012 13:16:44 +0200 From: Davide Ferraretto MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------040503080106000603060203" Subject: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------040503080106000603060203 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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"?? --------------040503080106000603060203 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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"??
--------------040503080106000603060203-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQGY-0000ME-Eq for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaQGW-0000iJ-Sl for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:38 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:39457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQGW-0000ht-KH for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:43:36 -0400 Received: by obbwd20 with SMTP id wd20so3044612obb.4 for ; Fri, 01 Jun 2012 04:43:32 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FC8A49C.9020901@gmail.com> References: <4FC8A49C.9020901@gmail.com> Date: Fri, 1 Jun 2012 15:43:32 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Davide Ferraretto Cc: qemu-devel@nongnu.org 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. -- Thanks. -- Max From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQVB-0003ba-3g for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:58:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaQV5-0003v3-0k for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:58:44 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:56903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQV4-0003uc-Nq for qemu-devel@nongnu.org; Fri, 01 Jun 2012 07:58:38 -0400 Received: by eekd41 with SMTP id d41so1159746eek.4 for ; Fri, 01 Jun 2012 04:58:36 -0700 (PDT) Message-ID: <4FC8AE3A.20303@gmail.com> Date: Fri, 01 Jun 2012 13:57:46 +0200 From: Davide Ferraretto MIME-Version: 1.0 References: <4FC8A49C.9020901@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [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 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 > 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. > From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQtf-0006NU-FB for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:24:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaQtd-0001Vb-Nf for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:24:03 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:54031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaQtd-0001VQ-Fa for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:24:01 -0400 Received: by obbwd20 with SMTP id wd20so3093149obb.4 for ; Fri, 01 Jun 2012 05:23:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FC8AE3A.20303@gmail.com> References: <4FC8A49C.9020901@gmail.com> <4FC8AE3A.20303@gmail.com> Date: Fri, 1 Jun 2012 16:23:59 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Davide Ferraretto Cc: qemu-devel@nongnu.org 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 monito= r. 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 >> =A0wrote: >>> >>> In arm user mode, where does qemu exit? Where is last qemu's instructio= n? >>> >>> 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. >> > --=20 Thanks. -- Max 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. >>> From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRBz-0002Vt-7P for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaRBu-0006Nt-LA for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:42:58 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:61171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRBu-0006Ng-Dr for qemu-devel@nongnu.org; Fri, 01 Jun 2012 08:42:54 -0400 Received: by obbwd20 with SMTP id wd20so3115037obb.4 for ; Fri, 01 Jun 2012 05:42:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FC8B5D2.1030204@gmail.com> References: <4FC8A49C.9020901@gmail.com> <4FC8AE3A.20303@gmail.com> <4FC8B5D2.1030204@gmail.com> Date: Fri, 1 Jun 2012 16:42:52 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Davide Ferraretto Cc: qemu-devel@nongnu.org On Fri, Jun 1, 2012 at 4:30 PM, Davide Ferraretto 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRf6-0008BW-9W for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:13:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaRez-0005ij-Rk for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:13:03 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:56585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRez-0005iW-Lc for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:12:57 -0400 Received: by ghrr11 with SMTP id r11so2409136ghr.33 for ; Fri, 01 Jun 2012 06:12:56 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FC8BD42.6080209@gmail.com> References: <4FC8A49C.9020901@gmail.com> <4FC8AE3A.20303@gmail.com> <4FC8B5D2.1030204@gmail.com> <4FC8BD42.6080209@gmail.com> Date: Fri, 1 Jun 2012 17:12:55 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Davide Ferraretto Cc: qemu-devel On Fri, Jun 1, 2012 at 5:01 PM, Davide Ferraretto 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRsC-0001e1-Bc for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SaRs6-0000To-8o for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:26:35 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:47538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SaRs6-0000SY-1F for qemu-devel@nongnu.org; Fri, 01 Jun 2012 09:26:30 -0400 Received: by yhoo21 with SMTP id o21so1810089yho.4 for ; Fri, 01 Jun 2012 06:26:28 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FC8C03A.2000902@gmail.com> References: <4FC8A49C.9020901@gmail.com> <4FC8AE3A.20303@gmail.com> <4FC8B5D2.1030204@gmail.com> <4FC8BD42.6080209@gmail.com> <4FC8C03A.2000902@gmail.com> Date: Fri, 1 Jun 2012 17:26:28 +0400 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] arm return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Davide Ferraretto Cc: qemu-devel On Fri, Jun 1, 2012 at 5:14 PM, Davide Ferraretto 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