Received: from eggs.gnu.org ([2001:4830:134:3::10]:55700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJIVc-0004FB-1D for qemu-devel@nongnu.org; Mon, 18 Aug 2014 04:41:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJIVW-00058U-Km for qemu-devel@nongnu.org; Mon, 18 Aug 2014 04:41:43 -0400 Received: from eos.fwall.u-szeged.hu ([160.114.120.248]:56483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJIVW-00057Q-8d for qemu-devel@nongnu.org; Mon, 18 Aug 2014 04:41:38 -0400 Received: from [192.168.105.4] (helo=esym.fwall.u-szeged.hu) by eos.fwall.u-szeged.hu with esmtp (Exim 4.63) (envelope-from ) id 1XJIVR-00066M-8y for qemu-devel@nongnu.org; Mon, 18 Aug 2014 10:41:33 +0200 Received: from mail.inf.u-szeged.hu ([160.114.37.227]) by eos.fwall.u-szeged.hu with esmtp (Exim 4.63) (envelope-from ) id 1XJIVR-00066w-2C for qemu-devel@nongnu.org; Mon, 18 Aug 2014 10:41:33 +0200 Received: from sed.inf.u-szeged.hu (sed.inf.u-szeged.hu [160.114.36.230]) by mail.inf.u-szeged.hu (Postfix) with ESMTPS id 0B6BC62F67 for ; Mon, 18 Aug 2014 10:41:33 +0200 (CEST) Received: from pkortve.inf.u-szeged.hu ([160.114.36.131]) by sed.inf.u-szeged.hu with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XJIVQ-0008VP-SI for qemu-devel@nongnu.org; Mon, 18 Aug 2014 10:41:32 +0200 Message-ID: <53F1BC37.9030206@inf.u-szeged.hu> Date: Mon, 18 Aug 2014 10:41:27 +0200 From: Akos Kiss MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010306020102040204050509" Subject: [Qemu-devel] single-stepping issue in aarch64 full-system emulation 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. --------------010306020102040204050509 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit Hi, I've "stock" Ubuntu 14.04.1 running under an aarch64-qemu (built from mainline git) in full-system emulation [1]. Everything worked fine until I tried to find a bug in an application built for aarch64 (that bug most likely being not the fault of qemu but the app itself). When I started debugging, strange things happened: breakpoints in gdb did not behave as they should. First, together with gdb developers, we speculated that it's a bug in gdb (which still may hold, at least partially) [2], but then I traced back the problem to a point where it has led out of gdb. It seems that PTRACE_SINGLESTEP is not working as it should, it does not stop the execution of the child after a step but lets it run indefinitely. I validated the problem with a pair of simple programs (attached: executing ezptrace on x86_64 prints 93010 steps before end, but inside the aarch64 emulation all I get is "step 0 / 56 / end".) I'm still not sure that it's a qemu problem but I already figured out that the aarch64 kernel does support single stepping [3]. I'd thank for any hints. Best regards, Akos [1] http://webkit.sed.hu/blog/20140816/quickndirty-set-aarch64-ubuntu-1404-vm-qemu [2] https://sourceware.org/bugzilla/show_bug.cgi?id=17280 [3] https://github.com/torvalds/linux/blob/e1a08b855f56d6528e7f85aae9ca8123f4c3ae04/arch/arm64/include/asm/ptrace.h#L114 -- Ákos Kiss, PhD assistant professor Department of Software Engineering, University of Szeged Dugonics tér 13., 6720 Szeged, Hungary Phone: +36-62-544143 Fax: +36-62-546723 akiss@inf.u-szeged.hu --------------010306020102040204050509 Content-Type: text/plain; charset=windows-1250; name="ezptrace.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ezptrace.c" // ezptrace.c // source: http://stackoverflow.com/questions/7697344/why-doesnt-ptrace-singlestep-work-properly #include #include #include #include #include #include int main() { pid_t child; child = fork(); if (child == 0) { char *argv[] = { "ezptraceme", NULL }; ptrace(PTRACE_TRACEME, 0, NULL, NULL); execv(argv[0], argv); } else { int status; wait(&status); // struct user_regs_struct regs; int stepno = 0; while (1) { // ptrace(PTRACE_GETREGS, child, NULL, ®s); // printf("eip: %x\n", (unsigned int) regs.eip); printf("step %d\n", stepno++); ptrace(PTRACE_SINGLESTEP, child, NULL, NULL); waitpid(child, &status, 0); if(WIFEXITED(status)) break; } printf("end\n"); } return 0; } --------------010306020102040204050509 Content-Type: text/plain; charset=windows-1250; name="ezptraceme.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ezptraceme.c" #include int main() { int sum = 1; int i; for (i = 1; i <= 10; i++) sum += i; printf("%d\n", sum); return 0; } --------------010306020102040204050509--