retdec
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::JSONConfig Class Reference

Config in the JSON format. More...

#include <json_config.h>

Inheritance diagram for retdec::llvmir2hll::JSONConfig:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::JSONConfig:
Collaboration graph
[legend]

Classes

struct  Impl
 Private implementation. More...
 

Public Member Functions

virtual ~JSONConfig () override
 
Debugging
virtual void dump () override
 Dumps the contents of the config to the standard error. More...
 
Variables
virtual bool isGlobalVarStoringWideString (const std::string &var) const override
 Stores the given global variable a wide string? More...
 
virtual std::string comesFromGlobalVar (const std::string &func, const std::string &var) const override
 Returns the name of a global variable from which the given local variable comes from. More...
 
virtual std::string getRegisterForGlobalVar (const std::string &var) const override
 Returns the name of the register corresponding to the given global variable. More...
 
virtual Address getAddressForGlobalVar (const std::string &var) const override
 Returns the address of the given global variable. More...
 
virtual std::string getDetectedCryptoPatternForGlobalVar (const std::string &var) const override
 Returns a description of the detected cryptographic pattern for the given global variable. More...
 
Functions
virtual std::string getRealNameForFunc (const std::string &func) const override
 Returns the real name of the given function. More...
 
virtual AddressRange getAddressRangeForFunc (const std::string &func) const override
 Returns the address range of the given function. More...
 
virtual LineRange getLineRangeForFunc (const std::string &func) const override
 Returns the line range of the given function. More...
 
virtual bool isDecompilerDefinedFunc (const std::string &func) const override
 Is the given function decompiler-defined? More...
 
virtual bool isUserDefinedFunc (const std::string &func) const override
 Is the given function user-defined? More...
 
virtual bool isStaticallyLinkedFunc (const std::string &func) const override
 Is the given function statically linked? More...
 
virtual bool isDynamicallyLinkedFunc (const std::string &func) const override
 Is the given function dynamically linked? More...
 
virtual bool isSyscallFunc (const std::string &func) const override
 Is the given function, in fact, a system call? More...
 
virtual bool isInstructionIdiomFunc (const std::string &func) const override
 Did the given function, in fact, come from an instruction idiom? More...
 
virtual bool isExportedFunc (const std::string &func) const override
 Is the given function exported? More...
 
virtual void markFuncAsStaticallyLinked (const std::string &func) override
 Marks the given function as statically linked. More...
 
virtual std::string getDeclarationStringForFunc (const std::string &func) const override
 Returns a C declaration string for the given function. More...
 
virtual std::string getCommentForFunc (const std::string &func) const override
 Returns a comment for the given functions. More...
 
virtual StringSet getDetectedCryptoPatternsForFunc (const std::string &func) const override
 Returns a set of names of detected cryptographic patterns that the given function uses. More...
 
virtual std::string getWrappedFunc (const std::string &func) const override
 Returns the name of a function that func wraps. More...
 
virtual std::string getDemangledNameOfFunc (const std::string &func) const override
 Returns the demangled named of the given function. More...
 
Classes
virtual StringSet getClassNames () const override
 Returns the set of found class names. More...
 
virtual std::string getClassForFunc (const std::string &func) const override
 Returns the name of a class to which the given function belongs. More...
 
virtual std::string getTypeOfFuncInClass (const std::string &func, const std::string &cl) const override
 Returns the type of the given function in the given class. More...
 
virtual StringVector getBaseClassNames (const std::string &cl) const override
 Returns the names of base classes of the given class. More...
 
virtual std::string getDemangledNameOfClass (const std::string &cl) const override
 Returns the demangled named of the given class. More...
 
Debug Info
virtual bool isDebugInfoAvailable () const override
 Is Debug info available? More...
 
virtual std::string getDebugModuleNameForFunc (const std::string &func) const override
 Returns the name of a module from which the given function originates. More...
 
virtual StringSet getDebugModuleNames () const override
 Returns a set of module names from which functions originate. More...
 
virtual std::string getDebugNameForGlobalVar (const std::string &var) const override
 Returns a name from debug information of the given global variable. More...
 
virtual std::string getDebugNameForLocalVar (const std::string &func, const std::string &var) const override
 Returns a name from debug information of the given local variable from the given function. More...
 
Meta Information
virtual std::size_t getNumberOfFuncsDetectedInFrontend () const override
 Returns the number of functions detected in the front-end. More...
 
virtual std::string getDetectedCompilerOrPacker () const override
 Returns the detected compiler or packer. More...
 
virtual std::string getDetectedLanguage () const override
 Returns the detected language. More...
 
virtual StringSet getSelectedButNotFoundFuncs () const override
 Returns a set of functions that were selected to be decompiled but were not found. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Config
virtual ~Config ()=default
 

Private Member Functions

 JSONConfig ()
 

Private Attributes

UPtr< Implimpl
 Private implementation. More...
 

Loading and Saving

virtual void saveTo (const std::string &path) override
 Saves the config to the given file. More...
 
static UPtr< JSONConfigfromFile (const std::string &path)
 Parses and returns a config from the given file. More...
 
static UPtr< JSONConfigfromString (const std::string &str)
 Parses and returns a config from the given JSON string. More...
 
static UPtr< JSONConfigempty ()
 Returns an empty config. More...
 

Detailed Description

Config in the JSON format.

Constructor & Destructor Documentation

◆ ~JSONConfig()

retdec::llvmir2hll::JSONConfig::~JSONConfig ( )
overridevirtualdefault

◆ JSONConfig()

retdec::llvmir2hll::JSONConfig::JSONConfig ( )
private

Member Function Documentation

◆ comesFromGlobalVar()

std::string retdec::llvmir2hll::JSONConfig::comesFromGlobalVar ( const std::string &  func,
const std::string &  var 
) const
overridevirtual

Returns the name of a global variable from which the given local variable comes from.

If the given variable does not come from a global variable, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ dump()

void retdec::llvmir2hll::JSONConfig::dump ( )
overridevirtual

Dumps the contents of the config to the standard error.

Implements retdec::llvmir2hll::Config.

◆ empty()

UPtr< JSONConfig > retdec::llvmir2hll::JSONConfig::empty ( )
static

Returns an empty config.

◆ fromFile()

UPtr< JSONConfig > retdec::llvmir2hll::JSONConfig::fromFile ( const std::string &  path)
static

Parses and returns a config from the given file.

Exceptions
JSONConfigFileNotFoundErrorwhen the file does not exist.
JSONConfigParsingErrorwhen there is a parsing error.

◆ fromString()

UPtr< JSONConfig > retdec::llvmir2hll::JSONConfig::fromString ( const std::string &  str)
static

Parses and returns a config from the given JSON string.

Exceptions
JSONConfigParsingErrorwhen there is a parsing error.

◆ getAddressForGlobalVar()

Address retdec::llvmir2hll::JSONConfig::getAddressForGlobalVar ( const std::string &  var) const
overridevirtual

Returns the address of the given global variable.

If the given variable is not a global variable or it does not have any address attached, the undefined address is returned.

Implements retdec::llvmir2hll::Config.

◆ getAddressRangeForFunc()

AddressRange retdec::llvmir2hll::JSONConfig::getAddressRangeForFunc ( const std::string &  func) const
overridevirtual

Returns the address range of the given function.

If the given function does not have an address range, NO_ADDRESS_RANGE is returned.

Implements retdec::llvmir2hll::Config.

◆ getBaseClassNames()

StringVector retdec::llvmir2hll::JSONConfig::getBaseClassNames ( const std::string &  cl) const
overridevirtual

Returns the names of base classes of the given class.

If there is no such class, the empty vector is returned.

Implements retdec::llvmir2hll::Config.

◆ getClassForFunc()

std::string retdec::llvmir2hll::JSONConfig::getClassForFunc ( const std::string &  func) const
overridevirtual

Returns the name of a class to which the given function belongs.

If func does not belong to any class, the empty string is returned. If func belongs to multiple classes, the name of the first class is returned.

Implements retdec::llvmir2hll::Config.

◆ getClassNames()

StringSet retdec::llvmir2hll::JSONConfig::getClassNames ( ) const
overridevirtual

Returns the set of found class names.

Implements retdec::llvmir2hll::Config.

◆ getCommentForFunc()

std::string retdec::llvmir2hll::JSONConfig::getCommentForFunc ( const std::string &  func) const
overridevirtual

Returns a comment for the given functions.

If the given function does not have a comment or it is empty, the empty string is returned.

Line breaks inside the comment are unified to LF.

Implements retdec::llvmir2hll::Config.

◆ getDebugModuleNameForFunc()

std::string retdec::llvmir2hll::JSONConfig::getDebugModuleNameForFunc ( const std::string &  func) const
overridevirtual

Returns the name of a module from which the given function originates.

When debug info is not available, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDebugModuleNames()

StringSet retdec::llvmir2hll::JSONConfig::getDebugModuleNames ( ) const
overridevirtual

Returns a set of module names from which functions originate.

When debug info is not available, the empty set is returned.

Implements retdec::llvmir2hll::Config.

◆ getDebugNameForGlobalVar()

std::string retdec::llvmir2hll::JSONConfig::getDebugNameForGlobalVar ( const std::string &  var) const
overridevirtual

Returns a name from debug information of the given global variable.

If the variable has no such name attached, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDebugNameForLocalVar()

std::string retdec::llvmir2hll::JSONConfig::getDebugNameForLocalVar ( const std::string &  func,
const std::string &  var 
) const
overridevirtual

Returns a name from debug information of the given local variable from the given function.

If the variable has no such name attached, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDeclarationStringForFunc()

std::string retdec::llvmir2hll::JSONConfig::getDeclarationStringForFunc ( const std::string &  func) const
overridevirtual

Returns a C declaration string for the given function.

If the function does not exist or does not have any C declaration string attached, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDemangledNameOfClass()

std::string retdec::llvmir2hll::JSONConfig::getDemangledNameOfClass ( const std::string &  cl) const
overridevirtual

Returns the demangled named of the given class.

If there is no such class or its name cannot be demangled, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDemangledNameOfFunc()

std::string retdec::llvmir2hll::JSONConfig::getDemangledNameOfFunc ( const std::string &  func) const
overridevirtual

Returns the demangled named of the given function.

If there is no such function or its name cannot be demangled, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDetectedCompilerOrPacker()

std::string retdec::llvmir2hll::JSONConfig::getDetectedCompilerOrPacker ( ) const
overridevirtual

Returns the detected compiler or packer.

Returns the empty string if there is no compiler or packer.

Implements retdec::llvmir2hll::Config.

◆ getDetectedCryptoPatternForGlobalVar()

std::string retdec::llvmir2hll::JSONConfig::getDetectedCryptoPatternForGlobalVar ( const std::string &  var) const
overridevirtual

Returns a description of the detected cryptographic pattern for the given global variable.

If the given variable is not a global variable or it does not have any cryptographic-pattern description attached, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getDetectedCryptoPatternsForFunc()

StringSet retdec::llvmir2hll::JSONConfig::getDetectedCryptoPatternsForFunc ( const std::string &  func) const
overridevirtual

Returns a set of names of detected cryptographic patterns that the given function uses.

If the given function does not exist or does not use any cryptographic patterns, the empty set is returned.

Implements retdec::llvmir2hll::Config.

◆ getDetectedLanguage()

std::string retdec::llvmir2hll::JSONConfig::getDetectedLanguage ( ) const
overridevirtual

Returns the detected language.

Returns the empty string if there is no language.

Implements retdec::llvmir2hll::Config.

◆ getLineRangeForFunc()

LineRange retdec::llvmir2hll::JSONConfig::getLineRangeForFunc ( const std::string &  func) const
overridevirtual

Returns the line range of the given function.

If the given function does not have a line range, NO_LINE_RANGE is returned.

Implements retdec::llvmir2hll::Config.

◆ getNumberOfFuncsDetectedInFrontend()

std::size_t retdec::llvmir2hll::JSONConfig::getNumberOfFuncsDetectedInFrontend ( ) const
overridevirtual

Returns the number of functions detected in the front-end.

Returns 0 if there are no detected functions.

Implements retdec::llvmir2hll::Config.

◆ getRealNameForFunc()

std::string retdec::llvmir2hll::JSONConfig::getRealNameForFunc ( const std::string &  func) const
overridevirtual

Returns the real name of the given function.

If the given function does not have a real name, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getRegisterForGlobalVar()

std::string retdec::llvmir2hll::JSONConfig::getRegisterForGlobalVar ( const std::string &  var) const
overridevirtual

Returns the name of the register corresponding to the given global variable.

If the given variable is not a global variable or it does not have any register name attached, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getSelectedButNotFoundFuncs()

StringSet retdec::llvmir2hll::JSONConfig::getSelectedButNotFoundFuncs ( ) const
overridevirtual

Returns a set of functions that were selected to be decompiled but were not found.

Implements retdec::llvmir2hll::Config.

◆ getTypeOfFuncInClass()

std::string retdec::llvmir2hll::JSONConfig::getTypeOfFuncInClass ( const std::string &  func,
const std::string &  cl 
) const
overridevirtual

Returns the type of the given function in the given class.

The returned value is a textual representation, e.g. "constructor" or "virtual member function".

If func does not belong to any class, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ getWrappedFunc()

std::string retdec::llvmir2hll::JSONConfig::getWrappedFunc ( const std::string &  func) const
overridevirtual

Returns the name of a function that func wraps.

A function A wraps another function B when the only thing A does is that it calls B (with an optional prologue/epilogue).

If func does not exist or it is not a wrapper, the empty string is returned.

Implements retdec::llvmir2hll::Config.

◆ isDebugInfoAvailable()

bool retdec::llvmir2hll::JSONConfig::isDebugInfoAvailable ( ) const
overridevirtual

Is Debug info available?

Implements retdec::llvmir2hll::Config.

◆ isDecompilerDefinedFunc()

bool retdec::llvmir2hll::JSONConfig::isDecompilerDefinedFunc ( const std::string &  func) const
overridevirtual

Is the given function decompiler-defined?

Implements retdec::llvmir2hll::Config.

◆ isDynamicallyLinkedFunc()

bool retdec::llvmir2hll::JSONConfig::isDynamicallyLinkedFunc ( const std::string &  func) const
overridevirtual

Is the given function dynamically linked?

Implements retdec::llvmir2hll::Config.

◆ isExportedFunc()

bool retdec::llvmir2hll::JSONConfig::isExportedFunc ( const std::string &  func) const
overridevirtual

Is the given function exported?

A function is exported if it is marked as such in the input binary file (e.g. a DLL exports its functions).

Implements retdec::llvmir2hll::Config.

◆ isGlobalVarStoringWideString()

bool retdec::llvmir2hll::JSONConfig::isGlobalVarStoringWideString ( const std::string &  var) const
overridevirtual

Stores the given global variable a wide string?

Implements retdec::llvmir2hll::Config.

◆ isInstructionIdiomFunc()

bool retdec::llvmir2hll::JSONConfig::isInstructionIdiomFunc ( const std::string &  func) const
overridevirtual

Did the given function, in fact, come from an instruction idiom?

Implements retdec::llvmir2hll::Config.

◆ isStaticallyLinkedFunc()

bool retdec::llvmir2hll::JSONConfig::isStaticallyLinkedFunc ( const std::string &  func) const
overridevirtual

Is the given function statically linked?

Implements retdec::llvmir2hll::Config.

◆ isSyscallFunc()

bool retdec::llvmir2hll::JSONConfig::isSyscallFunc ( const std::string &  func) const
overridevirtual

Is the given function, in fact, a system call?

Implements retdec::llvmir2hll::Config.

◆ isUserDefinedFunc()

bool retdec::llvmir2hll::JSONConfig::isUserDefinedFunc ( const std::string &  func) const
overridevirtual

Is the given function user-defined?

Implements retdec::llvmir2hll::Config.

◆ markFuncAsStaticallyLinked()

void retdec::llvmir2hll::JSONConfig::markFuncAsStaticallyLinked ( const std::string &  func)
overridevirtual

Marks the given function as statically linked.

If there is no such function, nothing is done.

Implements retdec::llvmir2hll::Config.

◆ saveTo()

void retdec::llvmir2hll::JSONConfig::saveTo ( const std::string &  path)
overridevirtual

Saves the config to the given file.

Implements retdec::llvmir2hll::Config.

Member Data Documentation

◆ impl

UPtr<Impl> retdec::llvmir2hll::JSONConfig::impl
private

Private implementation.


The documentation for this class was generated from the following files: