From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3770 invoked by alias); 20 Sep 2011 19:54:50 -0000 Received: (qmail 3758 invoked by uid 22791); 20 Sep 2011 19:54:49 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Sep 2011 19:54:32 +0000 Received: from eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id p8KJsUQT002003 for ; Tue, 20 Sep 2011 14:54:31 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.120]) by eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) with mapi; Tue, 20 Sep 2011 15:54:25 -0400 From: Marc Khouzam To: "'gdb@sourceware.org'" Date: Tue, 20 Sep 2011 19:54:00 -0000 Subject: Displaced stepping not always working as expected Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00073.txt.bz2 Hi, I just need a hint on where next to look... I've been asked to look into problems with non-stop on=20 a user-mode-linux virtual machine (http://user-mode-linux.sourceforge.net/) On that AMD 64bit machine, I cannot step or resume past a breakpoint when using non-stop with a multi-threaded program _if_ any of the threads is still running. If I interrupt all threads, then displaced stepping works. During the failure case, I confirmed that the displaced instruction does _not_ get executed (the memory it should have=20 changed stays the same). So, the PC stays in the same place and the step does not move forward. I tried to turn on 'set debug infrun 1', but I get the exact same logs during the failure as during a success case. Sometimes, if I keep trying to step, it will finally work (could be after 3 attempts, could be after 100 attempts or more). It seems related to what the other running thread is doing at the time. Can someone let me know where in GDB I can look to see why a displaced instruction is not being executed? Or maybe other debug logs to enable? For more details, below are stripped logs showing the problem as concisely as possible. Thanks a lot for any guidance Marc Displaced logs showing PC stuck: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D displaced: stepping Thread 0x40b21940 (LWP 763) now displaced: saved 0x4006d2: 49 89 d1 5e 48 89 e2 48 83 e4 f0 50 54 49 c7 c0= =20 displaced: copy 0x40083e->0x4006d2: 83 6d fc 01 8b 75 fc bf 8c 09 40 00 b8 = 00 00 00=20 =3D=3D=3D=3D> PC being displaced displaced: displaced pc to 0x4006d2 =3D=3D=3D=3D> Instruction being run displaced: run 0x4006d2: 83 6d fc 01 ^^^^^^^^ displaced: restored 0x4006d2 displaced: fixup (0x40083e, 0x4006d2), insn =3D 0x83 0x6d ... =3D=3D=3D=3D> PC being relocated from the same address=20 =3D=3D=3D=3D> as the displaced instruction! displaced: relocated %rip from 0x4006d2 to 0x40083e ^^^^^^^^ 'next' operation stuck at line 9 of my program: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (gdb) n infrun: clear_proceed_status_thread (Thread 0x40b21940 (LWP 763)) infrun: proceed (addr=3D0xffffffffffffffff, signal=3D144, step=3D1) infrun: resume (step=3D1, signal=3D0), trap_expected=3D1 displaced: stepping Thread 0x40b21940 (LWP 763) now displaced: saved 0x4006d2: 49 89 d1 5e 48 89 e2 48 83 e4 f0 50 54 49 c7 c0= =20 displaced: copy 0x40083e->0x4006d2: 83 6d fc 01 8b 75 fc bf 8c 09 40 00 b8 = 00 00 00=20 displaced: displaced pc to 0x4006d2 displaced: run 0x4006d2: 83 6d fc 01=20 infrun: target_wait (-1, status) =3D infrun: 760 [Thread 0x40b21940 (LWP 763)], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: Switching context from Thread 0x40b21940 (LWP 763) to Thread 0x40b2= 1940 (LWP 763) infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED displaced: restored 0x4006d2 displaced: fixup (0x40083e, 0x4006d2), insn =3D 0x83 0x6d ... displaced: relocated %rip from 0x4006d2 to 0x40083e infrun: stop_pc =3D 0x40083e infrun: BPSTAT_WHAT_STOP_NOISY infrun: stop_stepping Breakpoint 2, thread_exec1 (ptr=3D0x40095c) at multithread.c:9 9 i--; (gdb) infrun: target_wait (-1, status) =3D infrun: -1 [process -1], infrun: status->kind =3D ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait 'next' operation that finally gets to line 10: (exact same output as failure except PC gets incremented) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D (gdb) n infrun: clear_proceed_status_thread (Thread 0x40b21940 (LWP 763)) infrun: proceed (addr=3D0xffffffffffffffff, signal=3D144, step=3D1) infrun: resume (step=3D1, signal=3D0), trap_expected=3D1 displaced: stepping Thread 0x40b21940 (LWP 763) now displaced: saved 0x4006d2: 49 89 d1 5e 48 89 e2 48 83 e4 f0 50 54 49 c7 c0= =20 displaced: copy 0x40083e->0x4006d2: 83 6d fc 01 8b 75 fc bf 8c 09 40 00 b8 = 00 00 00=20 displaced: displaced pc to 0x4006d2 displaced: run 0x4006d2: 83 6d fc 01=20 infrun: target_wait (-1, status) =3D infrun: 760 [Thread 0x40b21940 (LWP 763)], infrun: status->kind =3D stopped, signal =3D SIGTRAP infrun: Switching context from Thread 0x40b21940 (LWP 763) to Thread 0x40b2= 1940 (LWP 763) infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED displaced: restored 0x4006d2 displaced: fixup (0x40083e, 0x4006d2), insn =3D 0x83 0x6d ... displaced: relocated %rip from 0x4006d6 to 0x400842 infrun: stop_pc =3D 0x400842 infrun: stepped to a different line infrun: stop_stepping 10 printf("in the second thread %d\n", i); (gdb) infrun: target_wait (-1, status) =3D infrun: -1 [process -1], infrun: status->kind =3D ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait