From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23925 invoked by alias); 8 Apr 2008 14:46:26 -0000 Received: (qmail 23899 invoked by uid 9514); 8 Apr 2008 14:46:26 -0000 Date: Tue, 08 Apr 2008 14:46:00 -0000 Message-ID: <20080408144626.23884.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Resequence Running and Stepping handleTrappedEvents to better flow with multiple events happening on one sigtrap. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5f4e88713844da0810ba5d1eeaea572f7b5d9c2a X-Git-Newrev: cbb50856fe829fa9491ad30a89cd6ce846969693 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q2/txt/msg00063.txt.bz2 The branch, master has been updated via cbb50856fe829fa9491ad30a89cd6ce846969693 (commit) from 5f4e88713844da0810ba5d1eeaea572f7b5d9c2a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit cbb50856fe829fa9491ad30a89cd6ce846969693 Author: Phil Muldoon Date: Tue Apr 8 15:45:04 2008 +0100 Resequence Running and Stepping handleTrappedEvents to better flow with multiple events happening on one sigtrap. 2008-04-08 Phil Muldoon Mark Wielaard * LinuxPtraceTaskState.java (Running.checkWatchpoint): New. (Running.handleTrappedEvent): Rewrite sequence to accumulate blockers for all sigtrap events, then return. (Stepping.handleTrappedEvent): Ditto. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/live/ChangeLog | 8 + .../frysk/proc/live/LinuxPtraceTaskState.java | 172 +++++++++++--------- 2 files changed, 104 insertions(+), 76 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/live/ChangeLog b/frysk-core/frysk/proc/live/ChangeLog index edbc1ad..99e9c3a 100644 --- a/frysk-core/frysk/proc/live/ChangeLog +++ b/frysk-core/frysk/proc/live/ChangeLog @@ -1,3 +1,11 @@ +2008-04-08 Phil Muldoon + Mark Wielaard + + * LinuxPtraceTaskState.java (Running.checkWatchpoint): New. + (Running.handleTrappedEvent): Rewrite sequence to accumulate + blockers for all sigtrap events, then return. + (Stepping.handleTrappedEvent): Ditto. + 2008-04-07 Stan Cox * LinuxPtraceHost.java (requestCreateAttachedProc): Add libs parameter. diff --git a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java index 8f35740..3e590c4 100644 --- a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java +++ b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java @@ -929,8 +929,32 @@ abstract class LinuxPtraceTaskState extends State { return blockedContinue(); return sendContinue(task, Signal.NONE); } + /** + * Returns the number of blockers if a watchpoint was hit, or -1 when no watchpoint + * was hit for this Task. + */ + int checkWatchpoint(LinuxPtraceTask task) { + int blockers = -1; + // First test if this is a watchpoint event. + WatchpointFunctions watchpointFunction = WatchpointFunctionFactory. + getWatchpointFunctions(task.getISA()); + for (int i=0; i= 0) { - // Prepare for stepping the breakpoint - setupSteppingBreakpoint(task, address); - - if (blockers == 0) - return sendContinue(task, Signal.NONE); - else - return blockedContinue(); - } else { - // This is not a trap event generated by us. And we - // also didn't send a step request. Deliver the - // real Trap event to the Task. - return handleSignaledEvent(task, Signal.TRAP); + throw new RuntimeException("Whoa! Wrong state for stepping: " + + this); } } + + // Check if a watchpoint triggered. + int blockers = checkWatchpoint(task); + boolean isTrapHandled; + if (blockers != -1) + isTrapHandled = true; + else { + isTrapHandled = false; + blockers = 0; + } + + // Do we have a breakpoint installed here? + long address = isa.getBreakpointAddress(task); + int stepBlockers = task.notifyCodeBreakpoint(address); + if (stepBlockers >= 0) { + // Prepare for stepping the breakpoint + setupSteppingBreakpoint(task, address); + blockers += stepBlockers; + isTrapHandled = true; + } + + if (!isTrapHandled) + // This is not a trap event generated by us. And we + // also didn't send a step request. Deliver the + // real Trap event to the Task. + return handleSignaledEvent(task, Signal.TRAP); + + // Otherwise return a blocked or continue depending + // on whether something blocked. + if (blockers == 0) + return sendContinue(task, Signal.NONE); + else + return blockedContinue; } LinuxPtraceTaskState handleAddObservation(LinuxPtraceTask task, TaskObservation observation) { @@ -1080,25 +1103,19 @@ abstract class LinuxPtraceTaskState extends State { fine.log("handleTrappedEvent", task); // First test if this is a watchpoint event. - WatchpointFunctions watchpointFunction = WatchpointFunctionFactory.getWatchpointFunctions(task.getISA()); - for (int i=0; i 0) - return blockedContinue(); - else - return sendContinue(task, Signal.NONE); + blockers += task.notifyInstruction(); + isTrapHandled = true; } else { // Do we have a breakpoint installed here? long address = isa.getBreakpointAddress(task); - int blockers = task.notifyCodeBreakpoint(address); - if (blockers >= 0) { + int breakpointBlockers = task.notifyCodeBreakpoint(address); + if (breakpointBlockers >= 0) { // Sanity check if (task.steppingBreakpoint != null) throw new RuntimeException("Already breakpoint stepping: " @@ -1135,11 +1150,8 @@ abstract class LinuxPtraceTaskState extends State { // Prepare for stepping the breakpoint setupSteppingBreakpoint(task, address); - if (blockers == 0) - return sendContinue(task, Signal.NONE); - else - return blockedContinue(); - + blockers += breakpointBlockers; + isTrapHandled = true; } else { // This is not a trap event generated by us. @@ -1158,20 +1170,28 @@ abstract class LinuxPtraceTaskState extends State { // made so we should notify any instruction observers. if ((task.sigSendXXX != Signal.NONE || task.syscallSigretXXX - || isa.hasExecutedSpuriousTrap(task))) - if (task.notifyInstruction() > 0) - return blockedContinue(); - else - return sendContinue(task, Signal.NONE); - - // Deliver the real Trap event to the Task. This is - // somewhat weird, we are either stepping a trapping - // instruction (breakpoint) that we didn't install, or - // something is sending this process an explicit trap - // signal. - return handleSignaledEvent(task, Signal.TRAP); + || isa.hasExecutedSpuriousTrap(task))) { + blockers += task.notifyInstruction(); + isTrapHandled = true; + } } } + + if (!isTrapHandled) + // Deliver the real Trap event to the Task. This is + // somewhat weird, we are either stepping a trapping + // instruction (breakpoint) that we didn't install, or + // something is sending this process an explicit trap + // signal. + return handleSignaledEvent(task, Signal.TRAP); + + // Otherwise return a blocked or continue depending + // on whether something blocked. + if (blockers == 0) + return sendContinue(task, Signal.NONE); + else + return blockedContinue; + } private void checkBreakpointStepping(LinuxPtraceTask task) { hooks/post-receive -- frysk system monitor/debugger