From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2412 invoked by alias); 27 Apr 2011 18:15:22 -0000 Received: (qmail 2403 invoked by uid 22791); 27 Apr 2011 18:15:20 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Apr 2011 18:15:05 +0000 Received: (qmail 21119 invoked from network); 27 Apr 2011 18:15:04 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Apr 2011 18:15:04 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [commit] Re: [rfc][1/2] Signal delivery + software single-step is broken Date: Wed, 27 Apr 2011 18:15:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.2; x86_64; ; ) Cc: "Ulrich Weigand" References: <201104271717.p3RHHPEL005251@d06av02.portsmouth.uk.ibm.com> In-Reply-To: <201104271717.p3RHHPEL005251@d06av02.portsmouth.uk.ibm.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201104271915.05190.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00521.txt.bz2 On Wednesday 27 April 2011 18:17:25, Ulrich Weigand wrote: > + /* Stepping over a breakpoint while at the same time delivering a signal > + has a problem: we cannot use displaced stepping, but we also cannot > + use software single-stepping, because we do not know where execution > + will continue if a signal handler is installed. > + > + On the other hand, if there is a signal handler we'd have to step > + over it anyway. So what we do instead is to install a step-resume > + handler at the current address right away, deliver the signal without > + stepping, and once we arrive back at the step-resume breakpoint, step > + once more over the original breakpoint we wanted to step over. */ > + if (oneproc && tp->suspend.stop_signal != TARGET_SIGNAL_0 > + && execution_direction != EXEC_REVERSE) > + { > + insert_step_resume_breakpoint_at_frame (get_current_frame ()); > + tp->step_after_step_resume_breakpoint = 1; > + oneproc = 0; > + } This unfortunately somewhat breaks hardware-step archs: (the below is a simple program that writes to 0, and has a SIGSEGV handler installed) Program received signal SIGSEGV, Segmentation fault. 0x00000000004008ca in main2 () at siginfo.c:104 104 *(int *)p = 0; (gdb) b Breakpoint 1 at 0x4008ca: file siginfo.c, line 104. (gdb) si Program received signal SIGTRAP, Trace/breakpoint trap. handler (sig=0, info=0xffffefbd5a360000, context=0xffffffffb4400000) at siginfo.c:69 69 { (gdb) Same with debug output (next, step or stepi, same thing): (gdb) set debug infrun 1 (gdb) s infrun: clear_proceed_status_thread (Thread 0x7ffff7fd5700 (LWP 18800)) infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1) infrun: inserting step-resume breakpoint at 0x4008ca infrun: resume (step=1, signal=11), trap_expected=0 infrun: wait_for_inferior (treat_exec_as_sigtrap=0) infrun: target_wait (-1, status) = infrun: 18800 [Thread 0x7ffff7fd5700 (LWP 18800)], infrun: status->kind = stopped, signal = SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x4007a7 infrun: random signal 5 Program received signal SIGTRAP, Trace/breakpoint trap. infrun: stop_stepping handler (sig=0, info=0xffffefbd5a360000, context=0xffffffffb4400000) at siginfo.c:69 69 { (gdb) We'd previously step into the installed handler without that spurious SIGTRAP: Program received signal SIGSEGV, Segmentation fault. infrun: stop_stepping 0x00000000004008ca in main2 () at siginfo.c:104 104 *(int *)p = 0; (gdb) b Breakpoint 2 at 0x4008ca: file siginfo.c, line 104. (gdb) s infrun: clear_proceed_status_thread (Thread 0x7ffff7fd5700 (LWP 18970)) infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1) infrun: resume (step=1, signal=11), trap_expected=1 infrun: wait_for_inferior (treat_exec_as_sigtrap=0) infrun: target_wait (-1, status) = infrun: 18970 [Thread 0x7ffff7fd5700 (LWP 18970)], infrun: status->kind = stopped, signal = SIGTRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x4007a7 infrun: stepped to a different line infrun: stop_stepping handler (sig=32767, info=0xffffffffbe600000, context=0x7ffff7bb8b40) at siginfo.c:69 69 { (gdb) -- Pedro Alves