# Interface: com.pnfsoftware.jeb.core.units.code.debug.IDebuggerUnit

Main Application Programming / Service Provider interface for JEB debugger units. Most methods in this class do not raise exceptions; they return false or null on error or if the implementation is not present or irrelevant. This interface is designed to be as generic as possible, in order to accommodate all types of debuggers \(native code, bytecode, etc.\)

## Method: attach
- parameter: `setupInformation`, type: `com.pnfsoftware.jeb.core.units.code.debug.impl.DebuggerSetupInformation`
- return type: `boolean`

Description: Attach the debugger to a target.
parameter: setupInformation: the target information
return: true if the target was successfully attached, false otherwise

## Method: canPerformOperation
- parameter: `op`, type: `com.pnfsoftware.jeb.core.units.code.debug.DebuggerOperationType`
- return type: `boolean`

Description: Indicate if performing a given operation is *likely* to be safe. This method does not provide synchronization/locking facility; its result is purely indicative and may be used by front\-ends and clients to minimize error generation.
parameter: op: 
return: 

## Method: clearBreakpoint
- parameter: `breakpoint`, type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`
- return type: `boolean`

Description: Remove an execution breakpoint.
parameter: breakpoint: 
return: 

## Method: clearBreakpoints
- return type: `boolean`

Description: Remove all execution breakpoints.
return: 

## Method: convertSymbolicAddressToMemoryToAddress
- parameter: `symbol`, type: `java.lang.String`
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- return type: `long`

Description: Convert a symbolic address, such as a register name, method symbol, string representation of a physical address, etc. to its associated physical memory address.
parameter: symbol: the symbol name
parameter: unit: optional
return: the physical address associated with the symbol, 0 on error

## Method: convertToUnitAddress
- parameter: `address`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.UnitAddress<com.pnfsoftware.jeb.core.units.code.ICodeUnit>`

Description: Convert a global address \(not specifying the unit to which it applies\) to an address explicitly relevant to a unit. The conversion may not be possible, for example if the unit is not [handled by this debugger](#getPotentialDebuggees()).
parameter: address: 
return: 

## Method: detach
- return type: `boolean`

Description: Detach from the target \(if possible\).
return: 

## Method: getBreakpoint
- parameter: `address`, type: `java.lang.String`
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Get the execution breakpoint set at the given address.
parameter: address: 
parameter: unit: 
return: the breakpoint object on success, null if none or the operation failed

## Method: getBreakpoint
- parameter: `memoryAddress`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Get the breakpoints set at the explicit memory address.
parameter: memoryAddress: 
return: the breakpoint or null on error or if not implemented

## Method: getBreakpoints
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint>`

Description: Retrieve a list of execution breakpoints.
return: a list of breakpoints, possibly empty; null on error

## Method: getDefaultThread
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerThread`

Description: Get the default thread. Note that clients may call this method very frequently.
return: 

## Method: getMemory
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerVirtualMemory`

Description: Retrieve an VM object representing the memory of the target. Operations on that object are safe and will attempt to modify the state of the debuggee if it needs to.
return: 

## Method: getModules
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.debug.IDebuggerModule>`

Description: Get the list of modules or libraries that are relevant to the target.
return: 

## Method: getPotentialDebuggees
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.ICodeUnit>`

Description: Retrieve a list of code units that could potentially be managed by this debugger. The list returned by this method is likely to change after the debugger is [attached](#attach(IDebuggerSetupInformation)) to a target. Note that a potential debuggee may not have been processed.
return: 

## Method: getProcessor
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`


## Method: getSuspendPolicy
- parameter: `eventType`, type: `com.pnfsoftware.jeb.core.units.code.debug.DebuggerEventType`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.DebuggerSuspendPolicy`

Description: Get the suspend policy.
parameter: eventType: 
return: 

## Method: getTargetApplication
- return type: `com.pnfsoftware.jeb.core.units.IUnit`

Description: Retrieve the optional target application.
return: 

## Method: getTargetEnumerator
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerTargetEnumerator`

Description: Provide an optional target enumerator.
return: 

## Method: getTargetInformation
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerTargetInformation`

Description: Retrieve information about the target being debugged.
return: 

## Method: getThreadById
- parameter: `threadId`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerThread`

Description: Get a thread by its identifier.
return: 

## Method: getThreads
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.debug.IDebuggerThread>`

Description: Get a list of threads running on the target.
return: a list of threads \(possibly, but unlikely, empty\), null on error

## Method: hasDefaultThread
- return type: `boolean`

Description: Non blocking method that checks a default thread is set.

## Method: isAttached
- return type: `boolean`

Description: Determine whether or not this debugger is attached to a target. Unless attached, most operations are likely to fail.
return: 

## Method: isPaused
- return type: `boolean`

Description: Determine if the target is paused. Generally, that is equivalent to determining that all threads are suspended.
return: true if the target is suspended

## Method: pause
- return type: `boolean`

Description: Pause the target. The debugger should stop execution of the target, as much as it possibly can. Typically, if the debugger has enough privilege to do so, this means pausing all threads currently executing within the target.
return: success indicator

## Method: readMemory
- parameter: `memoryAddress`, type: `long`
- parameter: `size`, type: `int`
- parameter: `dst`, type: `byte[]`
- parameter: `dstOffset`, type: `int`
- return type: `int`

Description: Read from memory. Optional method, supported only if the debugger allows direct memory access. If the memory cannot be read at the time of the call, the method should fail instead of attempting to modify the state of the debuggee to allow the read operation.
parameter: memoryAddress: 
parameter: size: 
parameter: dst: 
parameter: dstOffset: 
return: number of bytes read, \-1 on error

## Method: registerDebuggee
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- return type: `boolean`

Description: 
parameter: unit: 
return: 

## Method: restart
- return type: `boolean`

Description: Restart the target \(if possible\).
return: 

## Method: run
- return type: `boolean`

Description: Run or resume execution of the target.
return: success indicator

## Method: setBreakpoint
- parameter: `address`, type: `java.lang.String`
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- parameter: `flags`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Set a general breakpoint at the given address. Specific breakpoint operations \(such as enabling/disabling a breakpoint\) can be executed directly on the breakpoint object.
parameter: address: address, as defined by interactive units
parameter: unit: code unit relevant to the address
parameter: flags: optional, or a combination of `IDebuggerBreakpoint.BREAK_ON_xxx` flags
return: a breakpoint object, representing a new or existing breakpoint; null on error

## Method: setBreakpoint
- parameter: `address`, type: `java.lang.String`
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Set a general standard breakpoint at the given address. Specific breakpoint operations \(such as enabling/disabling a breakpoint\) can be executed directly on the breakpoint object.
parameter: address: address, as defined by interactive units
parameter: unit: code unit relevant to the address
return: a breakpoint object, representing a new or existing breakpoint; null on error

## Method: setBreakpoint
- parameter: `memoryAddress`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Same as [setBreakpoint\(memoryAddress, 0\)](#setBreakpoint(long, int)).

## Method: setBreakpoint
- parameter: `memoryAddress`, type: `long`
- parameter: `processorMode`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.debug.IDebuggerBreakpoint`

Description: Set a breakpoint at the explicit memory address. This method is valid only for targets supporting numerical addressing, such as physical processors.
parameter: memoryAddress: requested breakpoint address
parameter: processorMode: a [processor](IProcessor) mode \(see            `IProcessor.MODE_xxx` constant\) specifying the breakpoint. Leave to            [IProcessor#MODE_DEFAULT](IProcessor#MODE_DEFAULT) is unknown.
return: the breakpoint or null on error or if not implemented

## Method: setDefaultThread
- parameter: `threadId`, type: `long`
- return type: `boolean`

Description: Set the default thread.
parameter: threadId: 
return: true on success, false if the thread cannot be set as the default thread

## Method: setSuspendPolicy
- parameter: `eventType`, type: `com.pnfsoftware.jeb.core.units.code.debug.DebuggerEventType`
- parameter: `suspendPolicy`, type: `com.pnfsoftware.jeb.core.units.code.debug.DebuggerSuspendPolicy`
- return type: `boolean`

Description: Set the suspend policy, that is what threads are/are not paused when a breakpoint\-like event is reported to the debugger.
parameter: eventType: 
parameter: suspendPolicy: 
return: 

## Method: terminate
- return type: `boolean`

Description: Kill the target \(if possible\).
return: 

## Method: unregisterDebuggee
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.code.ICodeUnit`
- return type: `boolean`

Description: 
parameter: unit: 
return: 

## Method: writeMemory
- parameter: `memoryAddress`, type: `long`
- parameter: `size`, type: `int`
- parameter: `src`, type: `byte[]`
- parameter: `srcOffset`, type: `int`
- return type: `int`

Description: Write to memory. Optional method, supported only if the debugger allows direct memory access. If the memory cannot be written at the time of the call, the method may attempt to modify the state of the debuggee to allow the write operation.
parameter: memoryAddress: 
parameter: size: 
parameter: src: 
parameter: srcOffset: 
return: number of bytes written, \-1 on error

