frysk.proc.live
Class LinuxPtraceProc

java.lang.Object
  extended by frysk.proc.Proc
      extended by frysk.proc.live.LiveProc
          extended by frysk.proc.live.LinuxPtraceProc
All Implemented Interfaces:
Comparable

public class LinuxPtraceProc
extends LiveProc

A Linux Proc tracked using PTRACE.


Nested Class Summary
(package private)  class LinuxPtraceProc.BreakpointAction
          Class describing the action to take on the suspended Task before adding or deleting a Code observer.
(package private) static class LinuxPtraceProc.InstructionAction
          Class describing the action to take on the suspended Task before adding or deleting an Instruction observer.
(package private)  class LinuxPtraceProc.SyscallAction
          Class describing the action to take on the suspended Task before adding or deleting a Syscall observer.
(package private)  class LinuxPtraceProc.WatchpointAction
          Watchpoint action class.
 
Nested classes/interfaces inherited from class frysk.proc.Proc
Proc.ObservableXXX
 
Field Summary
private  Auxv[] auxv
           
(package private)  BreakpointAddresses breakpoints
          The addresses on which we have installed breakpoints (with associated Tasks and TaskObserver.Code listeners).
private  String[] cmdLine
           
private  SysRootFile exe
          XXX: This is racy - it can miss file renames.
private static Log fine
           
private  LinuxPtraceTask mainTask
           
private  MemoryMap[] maps
           
private  LinuxPtraceProcState newState
           
private  Collection observations
          The set of observations that currently apply to this task.
private  LinuxPtraceProcState oldState
          The current state of this Proc, during a state transition newState is null.
private  ArrayList outOfLineAddresses
           
private  boolean requestedOutOfLineAddresses
           
private  Stat stat
           
private  HashMap tasks
           
protected  WatchpointAddresses watchpoints
           
 
Fields inherited from class frysk.proc.live.LiveProc
pid
 
Fields inherited from class frysk.proc.Proc
observableAttachedXXX, observableDetachedXXX, parent
 
Constructor Summary
LinuxPtraceProc(Host host, Proc parent, ProcessIdentifier pid, Stat stat)
          Create a new detached process.
LinuxPtraceProc(Task task, ProcessIdentifier fork)
          Create a new, definitely attached, definitely running fork of Task.
 
Method Summary
(package private)  boolean addObservation(Object o)
           
(package private)  void addTask(LinuxPtraceTask task)
           
(package private)  void doneOutOfLine(long address)
          Called by Breakpoint with an address returned by getOutOfLineAddress() to put it back in the pool.
(package private)  Set getAllTasks()
           
 Auxv[] getAuxv()
          The Process Auxiliary Vector.
 String[] getCmdLine()
          Return the Proc's command line argument list
 String getCommand()
          Return the basename of the program that this process is running.
 SysRootFile getExeFile()
          Return the SysRoot path of the program that this process is running.
 int getGID()
          Return the GID of the Proc.
 Task getMainTask()
           
 MemoryMap[] getMaps()
           
(package private)  long getOutOfLineAddress()
          Returns an available address for out of line stepping.
 Stat getStat()
          If it hasn't already been read, read the stat structure.
protected  String getStateFIXME()
          Return the current state as a string.
 int getUID()
          Return the UID of the Proc.
(package private)  void handleAddObservation(TaskObservation observation)
          (internal) Tell the process to add the specified Observation, attaching the process if necessary.
(package private)  Iterator observationsIterator()
           
(package private)  int observationsSize()
           
private  LinuxPtraceProcState oldState()
          Return the current state while at the same time marking that the state is in flux.
protected  void performDetach()
           
(package private)  void performRemoval()
          (Internal) Tell the process that is no longer listed in the system table remove itself.
(package private)  void performTaskAttachCompleted(Task theTask)
          (Internal) Tell the process that the corresponding task has completed its attach.
(package private)  void performTaskDetachCompleted(Task theTask)
          (Internal) Tell the process that the corresponding task has completed its detach.
(package private)  void performTaskDetachCompleted(Task theTask, Task theClone)
          (Internal) Tell the process that the corresponding task has completed its detach.
(package private)  boolean removeObservation(Object o)
           
(package private)  void removeTask(LinuxPtraceTask task)
           
(package private)  void requestAddCodeObserver(Task task, TaskObservable observable, TaskObserver.Code observer, long address)
          (Internal) Tell the process to add the specified Code Observation, attaching to the process if necessary.
(package private)  void requestAddInstructionObserver(Task task, TaskObservable observable, TaskObserver.Instruction observer)
          (Internal) Tell the process to add the specified Instruction Observation, attaching and/or suspending the process if necessary.
(package private)  void requestAddObserver(Task task, TaskObservable observable, TaskObserver observer)
          (Internal) Tell the process to add the specified Observation, attaching to the process if necessary.
(package private)  void requestAddSyscallObserver(Task task, TaskObservable observable, TaskObserver observer)
          (Internal) Tell the process to add the specified Observation, attaching to the process if necessary.
(package private)  void requestAddWatchObserver(Task task, TaskObservable observable, TaskObserver.Watch observer, long address, int length, boolean writeOnly)
          (Internal) Tell the process to add the specified Watch Observation, attaching to the process if necessary.
(package private)  void requestDeleteCodeObserver(Task task, TaskObservable observable, TaskObserver.Code observer, long address)
          (Internal) Tell the process to delete the specified Code Observation, detaching from the process if necessary.
(package private)  void requestDeleteInstructionObserver(Task task, TaskObservable observable, TaskObserver.Instruction observer)
          (Internal) Tell the process to delete the specified Instruction Observation, detaching and/or suspending from the process if necessary.
(package private)  void requestDeleteObserver(Task task, TaskObservable observable, TaskObserver observer)
          (Internal) Tell the process to delete the specified Observation, detaching from the process if necessary.
(package private)  void requestDeleteSyscallObserver(Task task, TaskObservable observable, TaskObserver observer)
          (Internal) Tell the process to delete the specified Observation, detaching from the process if necessary.
(package private)  void requestDeleteWatchObserver(Task task, TaskObservable observable, TaskObserver.Watch observer, long address, int length, boolean writeOnly)
          (Internal) Tell the process to delete the specified Watch Observation, detaching from the process if necessary.
(package private)  void requestUnblock(TaskObserver observerArg)
           
 void sendRefresh()
          Refresh the Proc.
 
Methods inherited from class frysk.proc.Proc
add, compareTo, getChildren, getHost, getMap, getParent, getPid, getTasks, remove, remove, requestAbandon, requestAbandonAndRunEvent, requestKill, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fine

private static final Log fine

tasks

private final HashMap tasks

mainTask

private LinuxPtraceTask mainTask

auxv

private Auxv[] auxv

maps

private MemoryMap[] maps

cmdLine

private String[] cmdLine

exe

private SysRootFile exe
XXX: This is racy - it can miss file renames. The alternative would be to have two methods; one returning a file descriptor and a second returning the exe as it should be (but possibly isn't :-). Better yet have utrace handle it :-)


stat

private Stat stat

oldState

private LinuxPtraceProcState oldState
The current state of this Proc, during a state transition newState is null.


newState

private LinuxPtraceProcState newState

watchpoints

protected final WatchpointAddresses watchpoints

observations

private final Collection observations
The set of observations that currently apply to this task. Note that this is a Collection that may contain the same Observer object multiple times (for possible different observations).


breakpoints

final BreakpointAddresses breakpoints
The addresses on which we have installed breakpoints (with associated Tasks and TaskObserver.Code listeners). Package private for access in LinuxPtraceTask constructor that creates a forked task and the LinuxPtraceTaskState.MainTask.wantToDetach class to clearthem. See the comments there.


outOfLineAddresses

private final ArrayList outOfLineAddresses

requestedOutOfLineAddresses

private boolean requestedOutOfLineAddresses
Constructor Detail

LinuxPtraceProc

public LinuxPtraceProc(Host host,
                       Proc parent,
                       ProcessIdentifier pid,
                       Stat stat)
Create a new detached process. RUNNING makes no sense here. Since PARENT could be NULL, also explicitly pass in the host.


LinuxPtraceProc

public LinuxPtraceProc(Task task,
                       ProcessIdentifier fork)
Create a new, definitely attached, definitely running fork of Task.

Method Detail

addTask

void addTask(LinuxPtraceTask task)

removeTask

void removeTask(LinuxPtraceTask task)

getAllTasks

Set getAllTasks()

getMainTask

public Task getMainTask()
Specified by:
getMainTask in class Proc
Returns:
The main task for this process XXX: Rather than getting the main task and manipulating that, it should be possible to instead manipulate the proc - for instance asking the proc to notify of fork/exec/clone events. At present this is implemented by ProcBlockAction.

getAuxv

public Auxv[] getAuxv()
Description copied from class: Proc
The Process Auxiliary Vector.

Specified by:
getAuxv in class Proc

getMaps

public MemoryMap[] getMaps()
Specified by:
getMaps in class Proc

getCmdLine

public String[] getCmdLine()
Description copied from class: Proc
Return the Proc's command line argument list

Specified by:
getCmdLine in class Proc

getUID

public int getUID()
Description copied from class: Proc
Return the UID of the Proc.

Specified by:
getUID in class Proc

getGID

public int getGID()
Description copied from class: Proc
Return the GID of the Proc.

Specified by:
getGID in class Proc

getExeFile

public SysRootFile getExeFile()
Description copied from class: Proc
Return the SysRoot path of the program that this process is running.

Specified by:
getExeFile in class Proc

getStat

public Stat getStat()
If it hasn't already been read, read the stat structure.


getCommand

public String getCommand()
Description copied from class: Proc
Return the basename of the program that this process is running.

Specified by:
getCommand in class Proc

sendRefresh

public void sendRefresh()
Refresh the Proc.

Overrides:
sendRefresh in class Proc

getStateFIXME

protected String getStateFIXME()
Return the current state as a string.

Specified by:
getStateFIXME in class Proc

oldState

private LinuxPtraceProcState oldState()
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.


performRemoval

void performRemoval()
(Internal) Tell the process that is no longer listed in the system table remove itself.


performTaskAttachCompleted

void performTaskAttachCompleted(Task theTask)
(Internal) Tell the process that the corresponding task has completed its attach. XXX: Should not be public.


performTaskDetachCompleted

void performTaskDetachCompleted(Task theTask)
(Internal) Tell the process that the corresponding task has completed its detach. XXX: Should not be public.


performTaskDetachCompleted

void performTaskDetachCompleted(Task theTask,
                                Task theClone)
(Internal) Tell the process that the corresponding task has completed its detach.


performDetach

protected void performDetach()
Specified by:
performDetach in class Proc

handleAddObservation

void handleAddObservation(TaskObservation observation)
(internal) Tell the process to add the specified Observation, attaching the process if necessary.


requestAddObserver

void requestAddObserver(Task task,
                        TaskObservable observable,
                        TaskObserver observer)
(Internal) Tell the process to add the specified Observation, attaching to the process if necessary.


requestDeleteObserver

void requestDeleteObserver(Task task,
                           TaskObservable observable,
                           TaskObserver observer)
(Internal) Tell the process to delete the specified Observation, detaching from the process if necessary. Removes a syscallObserver exiting the task from syscall tracing mode of necessary.


requestAddSyscallObserver

void requestAddSyscallObserver(Task task,
                               TaskObservable observable,
                               TaskObserver observer)
(Internal) Tell the process to add the specified Observation, attaching to the process if necessary. Adds a syscallObserver which changes the task to syscall tracing mode of necessary.


requestDeleteSyscallObserver

void requestDeleteSyscallObserver(Task task,
                                  TaskObservable observable,
                                  TaskObserver observer)
(Internal) Tell the process to delete the specified Observation, detaching from the process if necessary.


requestAddCodeObserver

void requestAddCodeObserver(Task task,
                            TaskObservable observable,
                            TaskObserver.Code observer,
                            long address)
(Internal) Tell the process to add the specified Code Observation, attaching to the process if necessary. Adds a TaskCodeObservation to the eventloop which instructs the task to install the breakpoint if necessary.


requestDeleteCodeObserver

void requestDeleteCodeObserver(Task task,
                               TaskObservable observable,
                               TaskObserver.Code observer,
                               long address)
(Internal) Tell the process to delete the specified Code Observation, detaching from the process if necessary.


requestAddWatchObserver

void requestAddWatchObserver(Task task,
                             TaskObservable observable,
                             TaskObserver.Watch observer,
                             long address,
                             int length,
                             boolean writeOnly)
(Internal) Tell the process to add the specified Watch Observation, attaching to the process if necessary. Adds a TaskWatchObservation to the eventloop which instructs the task to install the watchpoint if necessary.


requestDeleteWatchObserver

void requestDeleteWatchObserver(Task task,
                                TaskObservable observable,
                                TaskObserver.Watch observer,
                                long address,
                                int length,
                                boolean writeOnly)
(Internal) Tell the process to delete the specified Watch Observation, detaching from the process if necessary.


requestAddInstructionObserver

void requestAddInstructionObserver(Task task,
                                   TaskObservable observable,
                                   TaskObserver.Instruction observer)
(Internal) Tell the process to add the specified Instruction Observation, attaching and/or suspending the process if necessary. As soon as the observation is added and the task isn't blocked it will inform the Instruction observer of every step of the task.


requestDeleteInstructionObserver

void requestDeleteInstructionObserver(Task task,
                                      TaskObservable observable,
                                      TaskObserver.Instruction observer)
(Internal) Tell the process to delete the specified Instruction Observation, detaching and/or suspending from the process if necessary.


addObservation

boolean addObservation(Object o)

removeObservation

boolean removeObservation(Object o)

observationsSize

int observationsSize()

observationsIterator

Iterator observationsIterator()

requestUnblock

void requestUnblock(TaskObserver observerArg)

getOutOfLineAddress

long getOutOfLineAddress()
Returns an available address for out of line stepping. Blocks till an address is available. Queries the Isa if not done so before. Returned addresses should be returned by calling doneOutOfLine().


doneOutOfLine

void doneOutOfLine(long address)
Called by Breakpoint with an address returned by getOutOfLineAddress() to put it back in the pool.