Class DecompilationContext
java.lang.Object
com.pnfsoftware.jeb.core.units.code.DecompilationContext
Decompilation context holding information about a decompilation and its results, as well as
decompilation options. Immutable object, Thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new context with no particular options (defaults will be used).DecompilationContext(int flags) Convenience constructor.DecompilationContext(int flags, Long maxTimePerMethod, Long maxTimeTotal) Convenience constructor.Construct a new context with the provided options. -
Method Summary
Modifier and TypeMethodDescriptionaddFlags(int flags) Convenience method.fork()Fork the context.Get the progress callback.intRetrieve the value of custom counter 1.intRetrieve the value of custom counter 2.Retrieve custom data.Get a decompilation error.Convenience method.intgetFlags()Convenience method.getMap1()Retrieve the custom map 1.getMap2()Retrieve the custom map 2.Convenience method.Convenience method.Get the current options.Get the result map.getResults(String sig) Get a decompilation result.booleanDetermine whether errors were recorded.booleanhasFlags(int f) Convenience method.intIncrement the value of custom counter 1.intIncrement the value of custom counter 2.booleanDetermine whether interruption was requested.voidAttach custom data to this context.booleanrecordAndCheckDeferredRequests(int cnt, int cap) Record occurrences or future occurrences of deferred requests, and check them against a provided cap.intRecord the occurrence or future occurrence of a deferred request.voidrecordError(String sig, String error) Record a decompilation error.voidrecordResult(String sig, DecompilationResult r) Record a decompilation result.removeFlags(int flags) Convenience method.voidRequest interruption of the current decompilation.static DecompilationContextsafe(DecompilationContext ctx) Return a non-null decompilation context.voidsetCallback(IProgressCallback callback) Set an optional callback object to receive progress information regarding a decompilation operation.setOptions(DecompilationOptions options) Set the current options.
-
Constructor Details
-
DecompilationContext
public DecompilationContext()Construct a new context with no particular options (defaults will be used). -
DecompilationContext
Construct a new context with the provided options.- Parameters:
opt- decompilation options
-
DecompilationContext
Convenience constructor.- Parameters:
flags- decompilation flagsmaxTimePerMethod- maximum time per method, in millisecondsmaxTimeTotal- maximum total time, in milliseconds
-
DecompilationContext
public DecompilationContext(int flags) Convenience constructor.- Parameters:
flags- decompilation flags
-
-
Method Details
-
safe
Return a non-null decompilation context.- Parameters:
ctx- context, possibly null- Returns:
- provided context, or a default context
-
fork
Fork the context. The fork context reuses this context's objects. Forked contexts may be used hen performing concurrent decompilations.- Returns:
- a new context
-
getOptions
Get the current options.- Returns:
- current options (never null)
-
setOptions
Set the current options.- Parameters:
options- new options- Returns:
- the previous options
-
getCallback
Get the progress callback.- Returns:
- progress callback, or null
-
setCallback
Set an optional callback object to receive progress information regarding a decompilation operation.- Parameters:
callback- progress callback
-
addFlags
Convenience method.- Parameters:
flags- option flags to be added- Returns:
- the previous options
-
removeFlags
Convenience method.- Parameters:
flags- option flags to be removed- Returns:
- the previous options
-
getFlags
public int getFlags()Convenience method.- Returns:
- decompilation flags
-
hasFlags
public boolean hasFlags(int f) Convenience method.- Parameters:
f- flags to test- Returns:
- true if all provided flags are set
-
getMaxTimePerMethod
Convenience method.- Returns:
- maximum time per method, in milliseconds, or null
-
getMaxTimeTotal
Convenience method.- Returns:
- maximum total time, in milliseconds, or null
-
requestInterruption
public void requestInterruption()Request interruption of the current decompilation. -
isInterruptionRequested
public boolean isInterruptionRequested()Determine whether interruption was requested.- Returns:
- true if interruption was requested
-
recordResult
Record a decompilation result.- Parameters:
sig- object signaturer- decompilation result, or null to remove
-
getResults
Get a decompilation result.- Parameters:
sig- object signature- Returns:
- decompilation result, or null
-
getResultMap
Get the result map.- Returns:
- read-only result map
-
recordError
Record a decompilation error.- Parameters:
sig- object signatureerror- error message, or null to remove
-
getError
Get a decompilation error.- Parameters:
sig- object signature- Returns:
- error message, or null
-
getErrorMap
Convenience method. Map of key=object signature (e.g., method jvm name) to value= error string (e.g., stacktrace)- Returns:
- read-only error map
-
hasErrors
public boolean hasErrors()Determine whether errors were recorded.- Returns:
- true if errors were recorded
-
putData
Attach custom data to this context.- Parameters:
key- data keyvalue- data value, or null to remove
-
getData
Retrieve custom data.- Parameters:
key- data key- Returns:
- data value, or null
-
recordDeferredRequest
public int recordDeferredRequest()Record the occurrence or future occurrence of a deferred request.- Returns:
- the updated recorded count of deferred requests
-
recordAndCheckDeferredRequests
public boolean recordAndCheckDeferredRequests(int cnt, int cap) Record occurrences or future occurrences of deferred requests, and check them against a provided cap.- Parameters:
cnt- count of deferred requests to recordcap- current cap (a negative number means no cap)- Returns:
- true if the updated recorded count of deferred requests is within the cap; false if it exceeds the cap
-
getMap1
Retrieve the custom map 1. A decompiler may use this concurrent map as they choose.- Returns:
- custom map 1
-
getMap2
Retrieve the custom map 2. A decompiler may use this concurrent map as they choose.- Returns:
- custom map 2
-
getCounter1
public int getCounter1()Retrieve the value of custom counter 1. The counter is initialized with 0.- Returns:
- the counter value
-
incrementCounter1
public int incrementCounter1()Increment the value of custom counter 1. A decompiler may use this counter as they choose.- Returns:
- the updated counter value
-
getCounter2
public int getCounter2()Retrieve the value of custom counter 2. The counter is initialized with 0.- Returns:
- the counter value
-
incrementCounter2
public int incrementCounter2()Increment the value of custom counter 2. A decompiler may use this counter as they choose.- Returns:
- the updated counter value
-