Class DecompilationContext

java.lang.Object
com.pnfsoftware.jeb.core.units.code.DecompilationContext

public class DecompilationContext extends Object
Decompilation context holding information about a decompilation and its results, as well as decompilation options. Immutable object, Thread-safe.
  • Constructor Details

    • DecompilationContext

      public DecompilationContext()
      Construct a new context with no particular options (defaults will be used).
    • DecompilationContext

      public DecompilationContext(DecompilationOptions opt)
      Construct a new context with the provided options.
      Parameters:
      opt - decompilation options
    • DecompilationContext

      public DecompilationContext(int flags, Long maxTimePerMethod, Long maxTimeTotal)
      Convenience constructor.
      Parameters:
      flags - decompilation flags
      maxTimePerMethod - maximum time per method, in milliseconds
      maxTimeTotal - maximum total time, in milliseconds
    • DecompilationContext

      public DecompilationContext(int flags)
      Convenience constructor.
      Parameters:
      flags - decompilation flags
  • Method Details

    • safe

      public static DecompilationContext safe(DecompilationContext ctx)
      Return a non-null decompilation context.
      Parameters:
      ctx - context, possibly null
      Returns:
      provided context, or a default context
    • fork

      public DecompilationContext 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

      public DecompilationOptions getOptions()
      Get the current options.
      Returns:
      current options (never null)
    • setOptions

      public DecompilationOptions setOptions(DecompilationOptions options)
      Set the current options.
      Parameters:
      options - new options
      Returns:
      the previous options
    • getCallback

      public IProgressCallback getCallback()
      Get the progress callback.
      Returns:
      progress callback, or null
    • setCallback

      public void setCallback(IProgressCallback callback)
      Set an optional callback object to receive progress information regarding a decompilation operation.
      Parameters:
      callback - progress callback
    • addFlags

      public DecompilationOptions addFlags(int flags)
      Convenience method.
      Parameters:
      flags - option flags to be added
      Returns:
      the previous options
    • removeFlags

      public DecompilationOptions removeFlags(int flags)
      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

      public Long getMaxTimePerMethod()
      Convenience method.
      Returns:
      maximum time per method, in milliseconds, or null
    • getMaxTimeTotal

      public Long 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

      public void recordResult(String sig, DecompilationResult r)
      Record a decompilation result.
      Parameters:
      sig - object signature
      r - decompilation result, or null to remove
    • getResults

      public DecompilationResult getResults(String sig)
      Get a decompilation result.
      Parameters:
      sig - object signature
      Returns:
      decompilation result, or null
    • getResultMap

      public Map<String,DecompilationResult> getResultMap()
      Get the result map.
      Returns:
      read-only result map
    • recordError

      public void recordError(String sig, String error)
      Record a decompilation error.
      Parameters:
      sig - object signature
      error - error message, or null to remove
    • getError

      public String getError(String sig)
      Get a decompilation error.
      Parameters:
      sig - object signature
      Returns:
      error message, or null
    • getErrorMap

      public Map<String,String> 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

      public void putData(String key, Object value)
      Attach custom data to this context.
      Parameters:
      key - data key
      value - data value, or null to remove
    • getData

      public Object getData(String key)
      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 record
      cap - 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

      public Map<String,Object> getMap1()
      Retrieve the custom map 1. A decompiler may use this concurrent map as they choose.
      Returns:
      custom map 1
    • getMap2

      public Map<String,Object> 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