From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3798 invoked by alias); 2 Jan 2008 22:30:50 -0000 Received: (qmail 3768 invoked by uid 367); 2 Jan 2008 22:30:48 -0000 Date: Wed, 02 Jan 2008 22:30:00 -0000 Message-ID: <20080102223048.3753.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Make DeadProc stateless. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: e846581652b7eb203c8f0e2d798ea566b1542fbc X-Git-Newrev: 5d087b7b9f72f72791cc1349f384bf963c0599e5 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-q1/txt/msg00003.txt.bz2 The branch, master has been updated via 5d087b7b9f72f72791cc1349f384bf963c0599e5 (commit) via caaa597537f3777ed532359c78134051db966e56 (commit) via 3623261019ca113a4989c60d570ce6247169694a (commit) from e846581652b7eb203c8f0e2d798ea566b1542fbc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 5d087b7b9f72f72791cc1349f384bf963c0599e5 Author: Andrew Cagney Date: Wed Jan 2 17:29:40 2008 -0500 Make DeadProc stateless. commit caaa597537f3777ed532359c78134051db966e56 Author: Andrew Cagney Date: Wed Jan 2 16:58:41 2008 -0500 Have DeadProc implement state[less] actions. frysk-core/frysk/proc/ChangeLog 2008-01-02 Andrew Cagney * ProcEvent.java (ProcEvent(Proc)): Make public. frysk-core/frysk/proc/dead/ChangeLog 2008-01-02 Andrew Cagney * LinuxProcState.java (handleDetach(Proc,boolean)): Delete. (handleTaskDetachCompleted(Proc,Task)): Delete. (handleRemoval(Proc)): Delete. (handleRefresh(Proc)): Delete. (handleDeleteObservation(Proc,Observation)): Delete. * DeadProc.java: Simplify. commit 3623261019ca113a4989c60d570ce6247169694a Author: Andrew Cagney Date: Wed Jan 2 16:14:08 2008 -0500 Make Proc.handleAddObservation package-private to frysk.proc.live.LiveProc. frysk-core/frysk/proc/ChangeLog 2008-01-02 Andrew Cagney * Proc.java (handleAddObservation(TaskObservation observation)): Delete. * Task.java (Task(Proc,TaskObserver,TaskState)): Delete call. frysk-core/frysk/proc/dead/ChangeLog 2008-01-02 Andrew Cagney * LinuxProcState.java (handleAddObservation(Proc,Observation)): Delete. * DeadProc.java (handleAddObservation(TaskObservation)): Delete. frysk-core/frysk/proc/live/ChangeLog 2008-01-02 Andrew Cagney * LinuxTask.java (LinuxTask(LiveProc,Attached)): Rename LinuxTask(Proc,TaskObserver.Attached). * LiveProc.java (handleAddObservation(TaskObservation)): Make package private. * LiveTask.java (LiveTask(LiveProc,Attached,TaskState)): Rename LiveTask(Proc,Attached,TaskState); call LiveProc.handleAddObservation. * LinuxHost.java: Update. * LinuxWaitBuilder.java: Update. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/ChangeLog | 5 + frysk-core/frysk/proc/Proc.java | 6 - frysk-core/frysk/proc/ProcEvent.java | 3 +- frysk-core/frysk/proc/Task.java | 9 - frysk-core/frysk/proc/dead/ChangeLog | 17 ++ frysk-core/frysk/proc/dead/DeadProc.java | 326 ++++------------------ frysk-core/frysk/proc/dead/LinuxProcState.java | 62 +---- frysk-core/frysk/proc/live/ChangeLog | 10 + frysk-core/frysk/proc/live/LinuxHost.java | 2 +- frysk-core/frysk/proc/live/LinuxTask.java | 3 +- frysk-core/frysk/proc/live/LinuxWaitBuilder.java | 3 +- frysk-core/frysk/proc/live/LiveProc.java | 2 +- frysk-core/frysk/proc/live/LiveTask.java | 11 +- 13 files changed, 109 insertions(+), 350 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index fe16ce0..ae939b5 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,5 +1,10 @@ 2008-01-02 Andrew Cagney + * ProcEvent.java (ProcEvent(Proc)): Make public. + + * Proc.java (handleAddObservation(TaskObservation observation)): Delete. + * Task.java (Task(Proc,TaskObserver,TaskState)): Delete call. + * ProcEvent.java: Make public. * BreakpointAddresses.java (getCodeObservers(long)): Make public. * Proc.java (oldState, newState): Delete. diff --git a/frysk-core/frysk/proc/Proc.java b/frysk-core/frysk/proc/Proc.java index 85ad4df..49bb795 100644 --- a/frysk-core/frysk/proc/Proc.java +++ b/frysk-core/frysk/proc/Proc.java @@ -407,12 +407,6 @@ public abstract class Proc { } /** - * (internal) Tell the process to add the specified Observation, - * attaching the process if necessary. - */ - protected abstract void handleAddObservation(TaskObservation observation); - - /** * (Internal) Tell the process to add the specified Observation, * attaching to the process if necessary. * diff --git a/frysk-core/frysk/proc/ProcEvent.java b/frysk-core/frysk/proc/ProcEvent.java index 713f33c..79f95f4 100644 --- a/frysk-core/frysk/proc/ProcEvent.java +++ b/frysk-core/frysk/proc/ProcEvent.java @@ -51,8 +51,7 @@ public abstract class ProcEvent protected TaskId taskId; // Random task within Proc. public ProcEvent () { } - ProcEvent (Proc proc) - { + public ProcEvent(Proc proc) { logger.log (Level.FINE, "", this); this.proc = proc; } diff --git a/frysk-core/frysk/proc/Task.java b/frysk-core/frysk/proc/Task.java index 0fd7e35..0005dfc 100644 --- a/frysk-core/frysk/proc/Task.java +++ b/frysk-core/frysk/proc/Task.java @@ -194,15 +194,6 @@ public abstract class Task { */ protected Task(Proc proc, TaskObserver.Attached attached, TaskState state) { this(new TaskId(proc.getPid()), proc, proc.creator, state); - if (attached != null) { - TaskObservation ob = new TaskObservation(this, attachedObservers, - attached, true) { - public void execute() { - throw new RuntimeException("oops!"); - } - }; - proc.handleAddObservation(ob); - } } // Send operation to corresponding underlying [kernel] task. The diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog index 2ddcfb0..f285d46 100644 --- a/frysk-core/frysk/proc/dead/ChangeLog +++ b/frysk-core/frysk/proc/dead/ChangeLog @@ -1,5 +1,22 @@ 2008-01-02 Andrew Cagney + * DeadProc.java (oldState, newState): Delete. + (getStateFIXME()): Simplify. + (oldState()): Delete. + (InstructionAction): Delete; replace with panic. + (BreakpointAction): Ditto. + (SyscallAction): Ditto. + + * LinuxProcState.java (handleDetach(Proc,boolean)): Delete. + (handleTaskDetachCompleted(Proc,Task)): Delete. + (handleRemoval(Proc)): Delete. + (handleRefresh(Proc)): Delete. + (handleDeleteObservation(Proc,Observation)): Delete. + * DeadProc.java: Simplify. + + * LinuxProcState.java (handleAddObservation(Proc,Observation)): Delete. + * DeadProc.java (handleAddObservation(TaskObservation)): Delete. + * DeadProc.java (getStateFIXME()): New. (handleAddObservation(TaskObservation)): New. (oldState()): New. diff --git a/frysk-core/frysk/proc/dead/DeadProc.java b/frysk-core/frysk/proc/dead/DeadProc.java index 4dfa333..2ec4a04 100644 --- a/frysk-core/frysk/proc/dead/DeadProc.java +++ b/frysk-core/frysk/proc/dead/DeadProc.java @@ -48,8 +48,6 @@ import frysk.proc.TaskObserver; import frysk.proc.TaskObservable; import frysk.proc.Manager; import frysk.proc.TaskObservation; -import frysk.proc.Action; -import frysk.proc.Breakpoint; import frysk.proc.ProcEvent; import frysk.proc.ProcState; @@ -65,38 +63,13 @@ abstract class DeadProc extends Proc { } /** - * The current state of this Proc, during a state transition - * newState is null. - */ - private ProcState oldState; - private ProcState newState; - - /** * Return the current state as a string. */ protected String getStateFIXME() { - if (newState != null) - return newState.toString(); - else - return oldState.toString(); + return "dead"; } protected void setStateFIXME(ProcState state) { - newState = state; - } - - /** - * Return the current state while at the same time marking that - * the state is in flux. If a second attempt to change state - * occurs before the current state transition has completed, - * barf. XXX: Bit of a hack, but at least this prevents state - * transition code attempting a second recursive state transition. - */ - private ProcState oldState() { - if (newState == null) - throw new RuntimeException(this + " double state transition"); - oldState = newState; - newState = null; - return oldState; + // ignore } /** @@ -105,9 +78,9 @@ abstract class DeadProc extends Proc { */ public void requestRefresh() { logger.log(Level.FINE, "{0} requestRefresh\n", this); - Manager.eventLoop.add(new ProcEvent() { + Manager.eventLoop.add(new ProcEvent(this) { public void execute() { - newState = oldState().handleRefresh(DeadProc.this); + proc.sendRefresh (); } }); } @@ -120,11 +93,9 @@ abstract class DeadProc extends Proc { */ public void performRemoval() { logger.log(Level.FINEST, "{0} performRemoval -- no longer in /proc\n", this); - Manager.eventLoop.add(new ProcEvent() { - public void execute() { - newState = oldState().handleRemoval(DeadProc.this); - } - }); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** @@ -133,15 +104,8 @@ abstract class DeadProc extends Proc { * * XXX: Should not be public. */ - public void performTaskAttachCompleted (final Task theTask) { - logger.log(Level.FINE, "{0} performTaskAttachCompleted\n", this); - Manager.eventLoop.add(new ProcEvent() { - Task task = theTask; - - public void execute() { - newState = oldState().handleTaskAttachCompleted(DeadProc.this, task); - } - }); + public void performTaskAttachCompleted (Task theTask) { + throw new RuntimeException("the process is already dead"); } /** @@ -150,48 +114,29 @@ abstract class DeadProc extends Proc { * * XXX: Should not be public. */ - public void performTaskDetachCompleted(final Task theTask) { + public void performTaskDetachCompleted(Task theTask) { logger.log(Level.FINE, "{0} performTaskDetachCompleted\n", this); - Manager.eventLoop.add(new ProcEvent() { - Task task = theTask; - public void execute() { - newState = oldState().handleTaskDetachCompleted(DeadProc.this, task); - } - }); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** * (Internal) Tell the process that the corresponding task has * completed its detach. */ - protected void performTaskDetachCompleted(final Task theTask, final Task theClone) { + protected void performTaskDetachCompleted(Task theTask, Task theClone) { logger.log(Level.FINE, "{0} performTaskDetachCompleted/clone\n", this); - Manager.eventLoop.add(new ProcEvent() { - Task task = theTask; - - Task clone = theClone; - - public void execute() { - newState = oldState().handleTaskDetachCompleted(DeadProc.this, task, clone); - } - }); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } protected void performDetach() { logger.log(Level.FINE, "{0} performDetach\n", this); - Manager.eventLoop.add(new ProcEvent() { - public void execute() { - newState = oldState().handleDetach(DeadProc.this, true); - } - }); - } - - /** - * (internal) Tell the process to add the specified Observation, - * attaching the process if necessary. - */ - protected void handleAddObservation(TaskObservation observation) { - newState = oldState().handleAddObservation(this, observation); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** @@ -201,39 +146,11 @@ abstract class DeadProc extends Proc { * XXX: Should not be public. */ public void requestAddObserver(Task task, TaskObservable observable, - TaskObserver observer) { - logger.log(Level.FINE, "{0} requestAddObservation\n", this); - Manager.eventLoop.add(new TaskObservation(task, observable, observer, true) { - public void execute() { - handleAddObservation(this); - } - }); - } - - /** - * Class describing the action to take on the suspended Task - * before adding or deleting a Syscall observer. - */ - final class SyscallAction implements Runnable { - private final Task task; - - private final boolean addition; - - SyscallAction(Task task, boolean addition) { - this.task = task; - this.addition = addition; - } - - public void run() { - int syscallobs = task.syscallObservers.numberOfObservers(); - if (addition) { - if (syscallobs == 0) - task.startTracingSyscalls(); - } else { - if (syscallobs == 0) - task.stopTracingSyscalls(); - } - } + TaskObserver observer) { + logger.log(Level.FINE, "{0} requestAddObserver\n", this); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** @@ -243,20 +160,13 @@ abstract class DeadProc extends Proc { * * XXX: Should not be public. */ - public void requestAddSyscallObserver(final Task task, TaskObservable observable, - TaskObserver observer) { + public void requestAddSyscallObserver(Task task, + TaskObservable observable, + TaskObserver observer) { logger.log(Level.FINE, "{0} requestAddSyscallObserver\n", this); - SyscallAction sa = new SyscallAction(task, true); - TaskObservation to = new TaskObservation(task, observable, observer, sa, - true) { - public void execute() { - handleAddObservation(this); - } - public boolean needsSuspendedAction() { - return task.syscallObservers.numberOfObservers() == 0; - } - }; - Manager.eventLoop.add(to); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** @@ -272,7 +182,9 @@ abstract class DeadProc extends Proc { Manager.eventLoop.add(new TaskObservation(task, observable, observer, false) { public void execute() { - newState = oldState().handleDeleteObservation(DeadProc.this, this); + // Must be bogus; if there were observations then + // the Proc wouldn't be in this state. + fail(new RuntimeException ("not attached")); } }); } @@ -283,63 +195,10 @@ abstract class DeadProc extends Proc { * * XXX: Should not be public. */ - public void requestDeleteSyscallObserver(final Task task, - TaskObservable observable, - TaskObserver observer) { - logger.log(Level.FINE, "{0} requestDeleteSyscallObserver\n", this); - SyscallAction sa = new SyscallAction(task, false); - TaskObservation to = new TaskObservation(task, observable, observer, sa, - false) { - public void execute() { - newState = oldState().handleDeleteObservation(DeadProc.this, - this); - } - - public boolean needsSuspendedAction() { - return task.syscallObservers.numberOfObservers() == 1; - } - }; - Manager.eventLoop.add(to); - } - - /** - * Class describing the action to take on the suspended Task - * before adding or deleting a Code observer. - */ - final class BreakpointAction implements Runnable { - private final TaskObserver.Code code; - - private final Task task; - - private final long address; - - private final boolean addition; - - BreakpointAction(TaskObserver.Code code, Task task, long address, - boolean addition) { - this.code = code; - this.task = task; - this.address = address; - this.addition = addition; - } - - public void run() { - if (addition) { - boolean mustInstall = breakpoints.addBreakpoint(code, address); - if (mustInstall) { - Breakpoint breakpoint; - breakpoint = Breakpoint.create(address, DeadProc.this); - breakpoint.install(task); - } - } else { - boolean mustRemove = breakpoints.removeBreakpoint(code, address); - if (mustRemove) { - Breakpoint breakpoint; - breakpoint = Breakpoint.create(address, DeadProc.this); - breakpoint.remove(task); - } - } - } + public void requestDeleteSyscallObserver(Task task, + TaskObservable observable, + TaskObserver observer) { + throw new RuntimeException("the process is already dead"); } /** @@ -351,20 +210,12 @@ abstract class DeadProc extends Proc { * XXX: Should not be public. */ public void requestAddCodeObserver(Task task, TaskObservable observable, - TaskObserver.Code observer, - final long address) { + TaskObserver.Code observer, + long address) { logger.log(Level.FINE, "{0} requestAddCodeObserver\n", this); - BreakpointAction bpa = new BreakpointAction(observer, task, address, true); - TaskObservation to; - to = new TaskObservation(task, observable, observer, bpa, true) { - public void execute() { - handleAddObservation(this); - } - public boolean needsSuspendedAction() { - return breakpoints.getCodeObservers(address) == null; - } - }; - Manager.eventLoop.add(to); + // XXX: Fake out for now. What kind of observers would you put + // on a core file? Might need a brain dead attached state in + // this scenario for compataibility. } /** @@ -374,43 +225,9 @@ abstract class DeadProc extends Proc { * XXX: Should not be public. */ public void requestDeleteCodeObserver(Task task, TaskObservable observable, - TaskObserver.Code observer, - final long address) { - logger.log(Level.FINE, "{0} requestDeleteCodeObserver\n", this); - BreakpointAction bpa = new BreakpointAction(observer, task, address, false); - TaskObservation to; - to = new TaskObservation(task, observable, observer, bpa, false) { - public void execute() { - newState = oldState().handleDeleteObservation(DeadProc.this, this); - } - - public boolean needsSuspendedAction() { - return breakpoints.getCodeObservers(address).size() == 1; - } - }; - - Manager.eventLoop.add(to); - } - - /** - * Class describing the action to take on the suspended Task - * before adding or deleting an Instruction observer. No - * particular actions are needed, but we must make sure the Task - * is suspended. - */ - final static class InstructionAction implements Runnable { - public void run() - { - // There is nothing in particular we need to do. We just want - // to make sure the Task is stopped so we can send it a step - // instruction or, when deleted, start resuming the process - // normally. - - // We do want an explicit updateExecuted() call, after adding - // the observer, but while still suspended. This is done by - // overriding the add() method in the TaskObservation - // below. No such action is required on deletion. - } + TaskObserver.Code observer, + long address) { + throw new RuntimeException("the process is already dead"); } /** @@ -422,33 +239,13 @@ abstract class DeadProc extends Proc { * * XXX: Should not be public. */ - public void requestAddInstructionObserver(final Task task, - TaskObservable observable, - TaskObserver.Instruction observer) { + public void requestAddInstructionObserver(Task task, + TaskObservable observable, + TaskObserver.Instruction observer) { logger.log(Level.FINE, "{0} requestAddInstructionObserver\n", this); - TaskObservation to; - InstructionAction ia = new InstructionAction(); - to = new TaskObservation(task, observable, observer, ia, true) { - public void execute() { - handleAddObservation(this); - } - - public boolean needsSuspendedAction() { - return task.instructionObservers.numberOfObservers() == 0; - } - - // Makes sure that the observer is properly added and then, - // while the Task is still suspended, updateExecuted() is hooks/post-receive -- frysk system monitor/debugger