| BPatch.h | | BPatch.h | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| | | | |
| #ifndef _BPatch_h_ | | #ifndef _BPatch_h_ | |
| #define _BPatch_h_ | | #define _BPatch_h_ | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_thread.h" | | #include "BPatch_thread.h" | |
| #include "BPatch_type.h" | | #include "BPatch_type.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_process.h" | | #include "BPatch_process.h" | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| #include "BPatch_callbacks.h" | | #include "BPatch_callbacks.h" | |
|
| | | #include <set> | |
| | | | |
| class BPatch_typeCollection; | | class BPatch_typeCollection; | |
| class BPatch_libInfo; | | class BPatch_libInfo; | |
| class BPatch_module; | | class BPatch_module; | |
| class PCProcess; | | class PCProcess; | |
| class PCThread; | | class PCThread; | |
| class PCEventHandler; | | class PCEventHandler; | |
| class func_instance; | | class func_instance; | |
| | | | |
| //Keep old versions defined, that way someone can test if we're more | | //Keep old versions defined, that way someone can test if we're more | |
| // at or more recent than version 5.1 with '#if defined(DYNINST_5_1)' | | // at or more recent than version 5.1 with '#if defined(DYNINST_5_1)' | |
| //If they want to get the current version, they should use DYNINST_MAJOR, | | //If they want to get the current version, they should use DYNINST_MAJOR, | |
| // DYNINST_MINOR, and DYNINST_SUBMINOR | | // DYNINST_MINOR, and DYNINST_SUBMINOR | |
| #define DYNINST_5_1 | | #define DYNINST_5_1 | |
| #define DYNINST_5_2 | | #define DYNINST_5_2 | |
| #define DYNINST_6_0 | | #define DYNINST_6_0 | |
| #define DYNINST_6_1 | | #define DYNINST_6_1 | |
| #define DYNINST_7_0 | | #define DYNINST_7_0 | |
| #define DYNINST_8_0 | | #define DYNINST_8_0 | |
|
| | | #define DYNINST_8_1 | |
| | | #define DYNINST_8_1_1 | |
| | | | |
| #define DYNINST_MAJOR 8 | | #define DYNINST_MAJOR 8 | |
|
| #define DYNINST_MINOR 0 | | #define DYNINST_MINOR 1 | |
| #define DYNINST_SUBMINOR 0 | | #define DYNINST_SUBMINOR 1 | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| typedef void *BPatch_Address; | | typedef void *BPatch_Address; | |
| #endif | | #endif | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(push) | | #pragma warning(push) | |
| #pragma warning(disable:4251) | | #pragma warning(disable:4251) | |
| #endif | | #endif | |
| | | | |
| | | | |
| skipping to change at line 116 | | skipping to change at line 118 | |
| char *tool; | | char *tool; | |
| char *host; | | char *host; | |
| } BPatch_remoteWtxInfo; | | } BPatch_remoteWtxInfo; | |
| | | | |
| typedef struct { | | typedef struct { | |
| BPatch_remote_t type; | | BPatch_remote_t type; | |
| void *info; | | void *info; | |
| } BPatch_remoteHost; | | } BPatch_remoteHost; | |
| // -------------------------------------------------------------------- | | // -------------------------------------------------------------------- | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch { | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch | | | |
| class BPATCH_DLL_EXPORT BPatch : public BPatch_eventLock { | | | |
| friend class BPatch_thread; | | friend class BPatch_thread; | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_point; | | friend class BPatch_point; | |
| friend class PCProcess; | | friend class PCProcess; | |
| friend class func_instance; | | friend class func_instance; | |
| | | | |
| BPatch_libInfo *info; | | BPatch_libInfo *info; | |
| | | | |
| bool typeCheckOn; | | bool typeCheckOn; | |
| int lastError; | | int lastError; | |
| bool debugParseOn; | | bool debugParseOn; | |
| bool baseTrampDeletionOn; | | bool baseTrampDeletionOn; | |
| | | | |
| /* If true, trampolines can recurse to their heart's content. | | /* If true, trampolines can recurse to their heart's content. | |
| Defaults to false */ | | Defaults to false */ | |
| bool trampRecursiveOn; | | bool trampRecursiveOn; | |
| | | | |
| bool forceRelocation_NP; | | bool forceRelocation_NP; | |
|
| /* If true, allows automatic relocation of functions if dyninst | | /* If true,allows automatic relocation of functions if dyninst | |
| deems it necessary. Defaults to true */ | | deems it necessary. Defaults to true */ | |
| bool autoRelocation_NP; | | bool autoRelocation_NP; | |
| | | | |
| /* If true, we save FPRs in situations we normally would | | /* If true, we save FPRs in situations we normally would | |
| Defaults to true */ | | Defaults to true */ | |
| bool saveFloatingPointsOn; | | bool saveFloatingPointsOn; | |
| bool forceSaveFloatingPointsOn; | | bool forceSaveFloatingPointsOn; | |
| | | | |
| /* If true, we will use liveness calculations to avoid saving | | /* If true, we will use liveness calculations to avoid saving | |
| registers on platforms that support it. | | registers on platforms that support it. | |
| | | | |
| skipping to change at line 196 | | skipping to change at line 194 | |
| BPatchForkCallback preForkCallback; | | BPatchForkCallback preForkCallback; | |
| BPatchForkCallback postForkCallback; | | BPatchForkCallback postForkCallback; | |
| BPatchExecCallback execCallback; | | BPatchExecCallback execCallback; | |
| BPatchExitCallback exitCallback; | | BPatchExitCallback exitCallback; | |
| BPatchOneTimeCodeCallback oneTimeCodeCallback; | | BPatchOneTimeCodeCallback oneTimeCodeCallback; | |
| BPatchDynLibraryCallback dynLibraryCallback; | | BPatchDynLibraryCallback dynLibraryCallback; | |
| BPatchAsyncThreadEventCallback threadCreateCallback; | | BPatchAsyncThreadEventCallback threadCreateCallback; | |
| BPatchAsyncThreadEventCallback threadDestroyCallback; | | BPatchAsyncThreadEventCallback threadDestroyCallback; | |
| BPatchDynamicCallSiteCallback dynamicCallSiteCallback; | | BPatchDynamicCallSiteCallback dynamicCallSiteCallback; | |
| InternalSignalHandlerCallback signalHandlerCallback; | | InternalSignalHandlerCallback signalHandlerCallback; | |
|
| BPatch_Set<long> *callbackSignals; | | std::set<long> callbackSignals; | |
| InternalCodeOverwriteCallback codeOverwriteCallback; | | InternalCodeOverwriteCallback codeOverwriteCallback; | |
| | | | |
| BPatch_Vector<BPatchUserEventCallback> userEventCallbacks; | | BPatch_Vector<BPatchUserEventCallback> userEventCallbacks; | |
| BPatch_Vector<BPatchStopThreadCallback> stopThreadCallbacks; | | BPatch_Vector<BPatchStopThreadCallback> stopThreadCallbacks; | |
| | | | |
| public: | | public: | |
| | | | |
|
| /* And auxiliary functions for the above */ | | | |
| /* These are NOT part of the API, do not use externally */ | | | |
| void signalNotificationFD(); // Called when an event happens | | | |
| void clearNotificationFD(); // Called during poll/waitForStatusChange | | | |
| void createNotificationFD(); // Creates the FD | | | |
| | | | |
| public: | | public: | |
| static BPatch *bpatch; | | static BPatch *bpatch; | |
| | | | |
| static BPatch *getBPatch(); | | static BPatch *getBPatch(); | |
| BPatch_builtInTypeCollection *builtInTypes; | | BPatch_builtInTypeCollection *builtInTypes; | |
| BPatch_typeCollection *stdTypes; | | BPatch_typeCollection *stdTypes; | |
| BPatch_typeCollection *APITypes; //API/User defined types | | BPatch_typeCollection *APITypes; //API/User defined types | |
| BPatch_type *type_Error; | | BPatch_type *type_Error; | |
| BPatch_type *type_Untyped; | | BPatch_type *type_Untyped; | |
| | | | |
| | | | |
| skipping to change at line 265 | | skipping to change at line 257 | |
| void clearError() { lastError = 0; } | | void clearError() { lastError = 0; } | |
| int getLastError() { return lastError; } | | int getLastError() { return lastError; } | |
| // End of functions that are for internal use only | | // End of functions that are for internal use only | |
| | | | |
| public: | | public: | |
| | | | |
| BPatch(); | | BPatch(); | |
| | | | |
| // BPatch::~BPatch | | // BPatch::~BPatch | |
| // destructor | | // destructor | |
|
| API_EXPORT_DTOR(_dtor, (), | | ~BPatch(); | |
| | | | |
| ~,BPatch,()); | | | |
| | | | |
| static const char *getEnglishErrorString(int number); | | static const char *getEnglishErrorString(int number); | |
| static void formatErrorString(char *dst, int size, | | static void formatErrorString(char *dst, int size, | |
| const char *fmt, const char * const *param
s); | | const char *fmt, const char * const *param
s); | |
| | | | |
| // BPatch::isTypeChecked: | | // BPatch::isTypeChecked: | |
| // returns whether type checking is on. | | // returns whether type checking is on. | |
|
| API_EXPORT(Int, (), | | bool isTypeChecked(); | |
| | | | |
| bool,isTypeChecked,()); | | | |
| | | | |
| // BPatch::parseDebugInfo: | | // BPatch::parseDebugInfo: | |
| // returns whether debugging information is set to be parsed | | // returns whether debugging information is set to be parsed | |
|
| API_EXPORT(Int, (), | | bool parseDebugInfo(); | |
| | | | |
| bool,parseDebugInfo,()); | | | |
| | | | |
| // BPatch::baseTrampDeletion: | | // BPatch::baseTrampDeletion: | |
| // returns whether base trampolines are set to be deleted | | // returns whether base trampolines are set to be deleted | |
|
| API_EXPORT(Int, (), | | bool baseTrampDeletion(); | |
| | | | |
| bool,baseTrampDeletion,()); | | | |
| | | | |
| // BPatch::setPrelinkCommand | | // BPatch::setPrelinkCommand | |
| // sets the fully qualified path name of the prelink command | | // sets the fully qualified path name of the prelink command | |
|
| API_EXPORT_V(Int, (command), | | void setPrelinkCommand(char *command); | |
| | | | |
| void,setPrelinkCommand,(char *command)); | | | |
| | | | |
| // BPatch::getPrelinkCommand | | // BPatch::getPrelinkCommand | |
| // gets the fully qualified path name of the prelink command | | // gets the fully qualified path name of the prelink command | |
|
| API_EXPORT(Int, (), | | char* getPrelinkCommand(); | |
| | | | |
| char*,getPrelinkCommand,()); | | | |
| | | | |
| // BPatch::isTrampRecursive: | | // BPatch::isTrampRecursive: | |
| // returns whether trampolines are set to handle recursive instrumentat
ion | | // returns whether trampolines are set to handle recursive instrumentat
ion | |
|
| API_EXPORT(Int, (), | | bool isTrampRecursive(); | |
| | | | |
| bool,isTrampRecursive,()); | | | |
| | | | |
| // BPatch::isMergeTramp: | | // BPatch::isMergeTramp: | |
| // returns whether base tramp and mini-tramp is merged | | // returns whether base tramp and mini-tramp is merged | |
|
| API_EXPORT(Int, (), | | bool isMergeTramp(); | |
| | | | |
| bool,isMergeTramp,()); | | | |
| | | | |
| // BPatch::saveFPROn: | | // BPatch::saveFPROn: | |
| // returns whether base tramp and mini-tramp is merged | | // returns whether base tramp and mini-tramp is merged | |
|
| API_EXPORT(Int, (), | | bool isSaveFPROn(); | |
| | | | |
| bool,isSaveFPROn,()); | | | |
| | | | |
| // BPatch::forceSaveFPROn: | | // BPatch::forceSaveFPROn: | |
| // returns whether base tramp and mini-tramp is merged | | // returns whether base tramp and mini-tramp is merged | |
|
| API_EXPORT(Int, (), | | bool isForceSaveFPROn(); | |
| | | | |
| bool,isForceSaveFPROn,()); | | | |
| | | | |
| // BPatch::hasForcedRelocation_NP: | | // BPatch::hasForcedRelocation_NP: | |
| // returns whether all instrumented functions will be relocated | | // returns whether all instrumented functions will be relocated | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,hasForcedRelocation_NP,()); | | bool hasForcedRelocation_NP(); | |
| | | | |
| // BPatch::autoRelocationsOn: | | // BPatch::autoRelocationsOn: | |
| // returns whether functions will be relocated when appropriate | | // returns whether functions will be relocated when appropriate | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,autoRelocationOn,()); | | bool autoRelocationOn(); | |
| | | | |
| // BPatch::delayedParsingOn: | | // BPatch::delayedParsingOn: | |
| // returns whether inst info is parsed a priori, or on demand | | // returns whether inst info is parsed a priori, or on demand | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,delayedParsingOn,()); | | bool delayedParsingOn(); | |
| | | | |
| // Liveness... | | // Liveness... | |
|
| API_EXPORT(Int, (), | | | |
| bool, livenessAnalysisOn, ()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | bool livenessAnalysisOn(); | |
| int, livenessAnalysisDepth, ()); | | | |
| | | int livenessAnalysisDepth(); | |
| | | | |
| // User-specified callback functions... | | // User-specified callback functions... | |
| | | | |
| // BPatch::registerErrorCallback: | | // BPatch::registerErrorCallback: | |
| // Register error handling/reporting callback | | // Register error handling/reporting callback | |
|
| API_EXPORT(Int, (function), | | | |
| | | | |
|
| BPatchErrorCallback, registerErrorCallback,(BPatchErrorCallback functio
n)); | | BPatchErrorCallback registerErrorCallback(BPatchErrorCallback function)
; | |
| | | | |
| // BPatch::registerDynLibraryCallback: | | // BPatch::registerDynLibraryCallback: | |
| // Register callback for new library events (eg. load) | | // Register callback for new library events (eg. load) | |
|
| API_EXPORT(Int, (func), | | | |
| | | | |
|
| BPatchDynLibraryCallback, registerDynLibraryCallback,(BPatchDynLibraryC
allback func)); | | BPatchDynLibraryCallback registerDynLibraryCallback(BPatchDynLibraryCal
lback func); | |
| | | | |
| // BPatch::registerPostForkCallback: | | // BPatch::registerPostForkCallback: | |
| // Register callback to handle mutatee fork events (before fork) | | // Register callback to handle mutatee fork events (before fork) | |
|
| API_EXPORT(Int, (func), | | | |
| | | | |
|
| BPatchForkCallback, registerPostForkCallback,(BPatchForkCallback func))
; | | BPatchForkCallback registerPostForkCallback(BPatchForkCallback func); | |
| | | | |
| // BPatch::registerPreForkCallback: | | // BPatch::registerPreForkCallback: | |
| // Register callback to handle mutatee fork events (before fork) | | // Register callback to handle mutatee fork events (before fork) | |
|
| API_EXPORT(Int, (func), | | | |
| | | | |
|
| BPatchForkCallback, registerPreForkCallback,(BPatchForkCallback func)); | | BPatchForkCallback registerPreForkCallback(BPatchForkCallback func); | |
| | | | |
| // BPatch::registerExecCallback: | | // BPatch::registerExecCallback: | |
| // Register callback to handle mutatee exec events | | // Register callback to handle mutatee exec events | |
|
| API_EXPORT(Int, (func), | | | |
| BPatchExecCallback, registerExecCallback,(BPatchExecCallback func)); | | BPatchExecCallback registerExecCallback(BPatchExecCallback func); | |
| | | | |
| // BPatch::registerExitCallback: | | // BPatch::registerExitCallback: | |
| // Register callback to handle mutatee exit events | | // Register callback to handle mutatee exit events | |
|
| API_EXPORT(Int, (func), | | | |
| | | | |
|
| BPatchExitCallback, registerExitCallback,(BPatchExitCallback func)); | | BPatchExitCallback registerExitCallback(BPatchExitCallback func); | |
| | | | |
| // BPatch::registerOneTimeCodeCallback: | | // BPatch::registerOneTimeCodeCallback: | |
| // Register callback to run at completion of oneTimeCode | | // Register callback to run at completion of oneTimeCode | |
|
| API_EXPORT(Int, (func), | | | |
| BPatchOneTimeCodeCallback, registerOneTimeCodeCallback,(BPatchOneTimeCo | | BPatchOneTimeCodeCallback registerOneTimeCodeCallback(BPatchOneTimeCode | |
| deCallback func)); | | Callback func); | |
| | | | |
| // BPatch::registerThreadEventCallback | | // BPatch::registerThreadEventCallback | |
| // Registers a callback to run when a thread is created | | // Registers a callback to run when a thread is created | |
|
| API_EXPORT(Int, (type,cb), | | | |
| bool,registerThreadEventCallback,(BPatch_asyncEventType type, | | bool registerThreadEventCallback(BPatch_asyncEventType type, | |
| BPatchAsyncThreadEventCallback cb)); | | BPatchAsyncThreadEventCallback cb); | |
| | | | |
| // BPatch::removeThreadEventCallback | | // BPatch::removeThreadEventCallback | |
| // Registers a callback to run when a thread is destroyed | | // Registers a callback to run when a thread is destroyed | |
|
| API_EXPORT(Int, (type,cb), | | | |
| bool,removeThreadEventCallback,(BPatch_asyncEventType type, | | bool removeThreadEventCallback(BPatch_asyncEventType type, | |
| BPatchAsyncThreadEventCallback cb)); | | BPatchAsyncThreadEventCallback cb); | |
| | | | |
| // BPatch::registerDynamicCallCallback | | // BPatch::registerDynamicCallCallback | |
| // Specifies a user-supplied function to be called when a dynamic call
is | | // Specifies a user-supplied function to be called when a dynamic call
is | |
| // executed. | | // executed. | |
| | | | |
|
| API_EXPORT(Int, (cb), | | bool registerDynamicCallCallback(BPatchDynamicCallSiteCallback cb); | |
| bool,registerDynamicCallCallback,(BPatchDynamicCallSiteCallback cb)); | | | |
| | | | |
|
| API_EXPORT(Int, (cb), | | bool removeDynamicCallCallback(BPatchDynamicCallSiteCallback cb); | |
| bool,removeDynamicCallCallback,(BPatchDynamicCallSiteCallback cb)); | | | |
| | | | |
| // BPatch::registerUserEventCallback | | // BPatch::registerUserEventCallback | |
| // | | // | |
| // Specifies a user defined function to call when a "user event" | | // Specifies a user defined function to call when a "user event" | |
| // occurs, user events are trigger by calls to the function | | // occurs, user events are trigger by calls to the function | |
| // DYNINSTuserMessage(void *, int) in the runtime library. | | // DYNINSTuserMessage(void *, int) in the runtime library. | |
| // | | // | |
| // BPatchUserEventCallback is: | | // BPatchUserEventCallback is: | |
| // void (*BPatchUserEventCallback)(void *msg, unsigned int msg_size); | | // void (*BPatchUserEventCallback)(void *msg, unsigned int msg_size); | |
| | | | |
|
| API_EXPORT(Int, (cb), | | bool registerUserEventCallback(BPatchUserEventCallback cb); | |
| bool,registerUserEventCallback,(BPatchUserEventCallback cb)); | | | |
| | | | |
|
| API_EXPORT(Int, (cb), | | bool removeUserEventCallback(BPatchUserEventCallback cb); | |
| bool,removeUserEventCallback,(BPatchUserEventCallback cb)); | | | |
| | | | |
| // BPatch::registerSignalHandlerCallback | | // BPatch::registerSignalHandlerCallback | |
| // | | // | |
| // If the mutator produces a signal matching an element of | | // If the mutator produces a signal matching an element of | |
| // signal_numbers, the callback is invoked, returning the point | | // signal_numbers, the callback is invoked, returning the point | |
| // that caused the exception, the signal number, and a Vector | | // that caused the exception, the signal number, and a Vector | |
| // representing the address of signal handler(s) in the mutatee | | // representing the address of signal handler(s) in the mutatee | |
| // for the exception. In Windows this is the handler stack, each | | // for the exception. In Windows this is the handler stack, each | |
| // function of which is invoked until one is found that agrees to | | // function of which is invoked until one is found that agrees to | |
| // handle the exception. In Unix there will be at most one | | // handle the exception. In Unix there will be at most one | |
| // handler for the signal number, the handler registered with | | // handler for the signal number, the handler registered with | |
| // syscalls signal() or sigaction(), or the default system | | // syscalls signal() or sigaction(), or the default system | |
| // handler, in which case we return an empty vector. | | // handler, in which case we return an empty vector. | |
|
| API_EXPORT(Int, (cb,signal_numbers), | | | |
| bool,registerSignalHandlerCallback, | | bool registerSignalHandlerCallback(BPatchSignalHandlerCallback cb, | |
| (BPatchSignalHandlerCallback cb, | | std::set<long> &signal_numbers); | |
| BPatch_Set<long> *signal_numbers)); | | bool registerSignalHandlerCallback(BPatchSignalHandlerCallback cb, | |
| | | BPatch_Set<long> *signal_numbers); | |
| API_EXPORT(Int, (cb), | | | |
| bool,removeSignalHandlerCallback,(BPatchSignalHandlerCallback cb)); | | bool removeSignalHandlerCallback(BPatchSignalHandlerCallback cb); | |
| | | | |
| API_EXPORT(Int, (cb), | | bool registerCodeDiscoveryCallback(BPatchCodeDiscoveryCallback cb); | |
| bool,registerCodeDiscoveryCallback,(BPatchCodeDiscoveryCallback cb)); | | | |
| API_EXPORT(Int, (cb), | | bool removeCodeDiscoveryCallback(BPatchCodeDiscoveryCallback cb); | |
| bool,removeCodeDiscoveryCallback,(BPatchCodeDiscoveryCallback cb)); | | | |
| | | | |
| // BPatch::registerCodeOverwriteCallbacks | | // BPatch::registerCodeOverwriteCallbacks | |
| // | | // | |
| // Registers a callback at the beginning and end of overwrite events | | // Registers a callback at the beginning and end of overwrite events | |
|
| API_EXPORT(Int, (cbBegin, cbEnd), | | | |
| bool,registerCodeOverwriteCallbacks, | | bool registerCodeOverwriteCallbacks | |
| (BPatchCodeOverwriteBeginCallback cbBegin, | | (BPatchCodeOverwriteBeginCallback cbBegin, | |
|
| BPatchCodeOverwriteEndCallback cbEnd)); | | BPatchCodeOverwriteEndCallback cbEnd); | |
| | | | |
| // BPatch::getProcesses: | | // BPatch::getProcesses: | |
| // Get a vector of all processes | | // Get a vector of all processes | |
|
| API_EXPORT(Int, (), | | | |
| BPatch_Vector<BPatch_process*> *,getProcesses,()); | | BPatch_Vector<BPatch_process*> * getProcesses(); | |
| | | | |
| // | | // | |
| // General BPatch parameter settings: | | // General BPatch parameter settings: | |
| // | | // | |
| | | | |
| // BPatch::setDebugParsing: | | // BPatch::setDebugParsing: | |
| // Turn on/off parsing of debug section(s) | | // Turn on/off parsing of debug section(s) | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setDebugParsing,(bool x)); | | void setDebugParsing(bool x); | |
| | | | |
| // BPatch::setBaseTrampDeletion: | | // BPatch::setBaseTrampDeletion: | |
| // Turn on/off deletion of base tramp | | // Turn on/off deletion of base tramp | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setBaseTrampDeletion,(bool x)); | | void setBaseTrampDeletion(bool x); | |
| | | | |
| // BPatch::setTypeChecking: | | // BPatch::setTypeChecking: | |
| // Turn on/off type checking | | // Turn on/off type checking | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setTypeChecking,(bool x)); | | void setTypeChecking(bool x); | |
| | | | |
|
| API_EXPORT_V(Int, (b), | | void setInstrStackFrames(bool b); | |
| void,setInstrStackFrames,(bool b)); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | bool getInstrStackFrames(); | |
| bool,getInstrStackFrames,()); | | | |
| | | | |
| // BPatch::setTypeChecking: | | // BPatch::setTypeChecking: | |
| // Turn on/off line info truncating | | // Turn on/off line info truncating | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,truncateLineInfoFilenames,(bool x)); | | void truncateLineInfoFilenames(bool x); | |
| | | | |
| // BPatch::setTrampRecursive: | | // BPatch::setTrampRecursive: | |
| // Turn on/off recursive trampolines | | // Turn on/off recursive trampolines | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setTrampRecursive,(bool x)); | | void setTrampRecursive(bool x); | |
| | | | |
| // BPatch::setMergeTramp: | | // BPatch::setMergeTramp: | |
| // Turn on/off merged base & mini-tramps | | // Turn on/off merged base & mini-tramps | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setMergeTramp,(bool x)); | | void setMergeTramp(bool x); | |
| | | | |
| // BPatch::setSaveFPR: | | // BPatch::setSaveFPR: | |
| // Turn on/off merged base & mini-tramps | | // Turn on/off merged base & mini-tramps | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setSaveFPR,(bool x)); | | void setSaveFPR(bool x); | |
| | | | |
| // BPatch::forceSaveFPR: | | // BPatch::forceSaveFPR: | |
| // Force Turn on/off merged base & mini-tramps - ignores isConservativ
e | | // Force Turn on/off merged base & mini-tramps - ignores isConservativ
e | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,forceSaveFPR,(bool x)); | | void forceSaveFPR(bool x); | |
| | | | |
| // BPatch::setForcedRelocation_NP: | | // BPatch::setForcedRelocation_NP: | |
| // Turn on/off forced relocation of instrumted functions | | // Turn on/off forced relocation of instrumted functions | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setForcedRelocation_NP,(bool x)); | | void setForcedRelocation_NP(bool x); | |
| | | | |
| // BPatch::setAutoRelocation_NP: | | // BPatch::setAutoRelocation_NP: | |
| // Turn on/off function relocations, performed when necessary | | // Turn on/off function relocations, performed when necessary | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setAutoRelocation_NP,(bool x)); | | void setAutoRelocation_NP(bool x); | |
| | | | |
| // BPatch::setDelayedParsing: | | // BPatch::setDelayedParsing: | |
| // Turn on/off delayed parsing | | // Turn on/off delayed parsing | |
|
| API_EXPORT_V(Int, (x), | | | |
| | | | |
|
| void,setDelayedParsing,(bool x)); | | void setDelayedParsing(bool x); | |
| | | | |
| // Liveness... | | // Liveness... | |
|
| API_EXPORT_V(Int, (x), | | | |
| void, setLivenessAnalysis, (bool x)); | | | |
| | | | |
|
| API_EXPORT_V(Int, (x), | | void setLivenessAnalysis(bool x); | |
| void, setLivenessAnalysisDepth, (int x)); | | | |
| | | void setLivenessAnalysisDepth(int x); | |
| | | | |
| // BPatch::processCreate: | | // BPatch::processCreate: | |
| // Create a new mutatee process | | // Create a new mutatee process | |
|
| API_EXPORT(Int, (path, argv, envp, stdin_fd, stdout_fd, stderr_fd, mode | | | |
| ), | | BPatch_process * processCreate(const char *path, | |
| BPatch_process *,processCreate,(const char *path, | | const char *argv[], | |
| const char *argv[], | | const char **envp = NULL, | |
| const char **envp = NULL, | | int stdin_fd=0, | |
| int stdin_fd=0, | | int stdout_fd=1, | |
| int stdout_fd=1, | | int stderr_fd=2, | |
| int stderr_fd=2, | | BPatch_hybridMode mode=BPatch_normalMode) | |
| BPatch_hybridMode mode=BPatch_normalMod | | ; | |
| e)); | | | |
| | | | |
| // BPatch::processAttach | | // BPatch::processAttach | |
| // Attach to mutatee process | | // Attach to mutatee process | |
|
| API_EXPORT(Int, (path, pid, mode), | | | |
| BPatch_process *,processAttach,(const char *path, int pid, | | BPatch_process *processAttach(const char *path, int pid, | |
| BPatch_hybridMode mode=BPatch_normalMod | | BPatch_hybridMode mode=BPatch_normalMod | |
| e)); | | e); | |
| | | | |
| // BPatch::openBinary | | // BPatch::openBinary | |
| // Open a binary for static instrumentation | | // Open a binary for static instrumentation | |
| // | | // | |
| // The second parameter really should be a boolean, but the value | | // The second parameter really should be a boolean, but the value | |
| // gets reset between the openBinary and openBinaryInt calls--is | | // gets reset between the openBinary and openBinaryInt calls--is | |
| // this a gcc bug??? | | // this a gcc bug??? | |
| // | | // | |
|
| API_EXPORT(Int, (path, openDependencies), | | | |
| BPatch_binaryEdit *, openBinary, (const char *path, bool ope | | BPatch_binaryEdit * openBinary(const char *path, bool openDe | |
| nDependencies = false)); | | pendencies = false); | |
| | | | |
| // BPatch::createEnum: | | // BPatch::createEnum: | |
| // Create Enum types. | | // Create Enum types. | |
|
| API_EXPORT(Int, (name, elementNames, elementIds), | | | |
| | | | |
|
| BPatch_type *,createEnum,(const char * name, BPatch_Vector<char *> &ele | | BPatch_type *createEnum(const char * name, BPatch_Vector<char *> &eleme | |
| mentNames, | | ntNames, | |
| BPatch_Vector<int> &elementIds)); | | BPatch_Vector<int> &elementIds); | |
| | | | |
| // BPatch::createEnum: | | // BPatch::createEnum: | |
| // API selects elementIds | | // API selects elementIds | |
|
| API_EXPORT(AutoId, (name, elementNames), | | | |
| | | | |
|
| BPatch_type *,createEnum,(const char * name, BPatch_Vector<char *> &ele
mentNames)); | | BPatch_type *createEnum(const char * name, BPatch_Vector<char *> &eleme
ntNames); | |
| | | | |
| // BPatch::createStruct: | | // BPatch::createStruct: | |
| // Create Struct types. | | // Create Struct types. | |
|
| API_EXPORT(Int, (name, fieldNames, fieldTypes), | | | |
| | | | |
|
| BPatch_type *,createStruct,(const char * name, BPatch_Vector<char *> &f | | BPatch_type *createStruct(const char * name, BPatch_Vector<char *> &fie | |
| ieldNames, | | ldNames, | |
| BPatch_Vector<BPatch_type *> &fieldTypes)); | | BPatch_Vector<BPatch_type *> &fieldTypes); | |
| | | | |
| // BPatch::createUnion: | | // BPatch::createUnion: | |
| // Create Union types. | | // Create Union types. | |
|
| API_EXPORT(Int, (name, fieldNames, fieldTypes), | | | |
| | | | |
|
| BPatch_type *,createUnion,(const char * name, BPatch_Vector<char *> &fi | | BPatch_type *createUnion(const char * name, BPatch_Vector<char *> &fiel | |
| eldNames, | | dNames, | |
| BPatch_Vector<BPatch_type *> &fieldTypes)); | | BPatch_Vector<BPatch_type *> &fieldTypes); | |
| | | | |
| // BPatch::createArray: | | // BPatch::createArray: | |
| // Creates BPatch_array type or symtyperanges ( scalars with upper and | | // Creates BPatch_array type or symtyperanges ( scalars with upper and | |
| //lower bound). | | //lower bound). | |
|
| API_EXPORT(Int, (name, ptr, low, hi), | | | |
| | | | |
|
| BPatch_type *,createArray,(const char * name, BPatch_type * ptr, | | BPatch_type *createArray(const char * name, BPatch_type * ptr, | |
| unsigned int low, unsigned int hi)); | | unsigned int low, unsigned int hi); | |
| | | | |
| // BPatch::createPointer: | | // BPatch::createPointer: | |
| // Creates BPatch_pointer types | | // Creates BPatch_pointer types | |
|
| API_EXPORT(Int, (name, ptr, size), | | | |
| | | | |
|
| BPatch_type *,createPointer,(const char * name, BPatch_type * ptr, | | BPatch_type *createPointer(const char * name, BPatch_type * ptr, | |
| int size = sizeof(void *))); | | int size = sizeof(void *)); | |
| | | | |
| // BPatch::createScalar: | | // BPatch::createScalar: | |
| // Creates BPatch_scalar types | | // Creates BPatch_scalar types | |
|
| API_EXPORT(Int, (name, size), | | | |
| | | | |
|
| BPatch_type *,createScalar,(const char * name, int size)); | | BPatch_type *createScalar(const char * name, int size); | |
| | | | |
| // BPatch::createTypedef: | | // BPatch::createTypedef: | |
| // Creates typedefs. | | // Creates typedefs. | |
|
| API_EXPORT(Int, (name, ptr), | | | |
| | | | |
|
| BPatch_type *,createTypedef,(const char * name, BPatch_type * ptr)); | | BPatch_type *createTypedef(const char * name, BPatch_type * ptr); | |
| | | | |
| // User programs are required to call pollForStatusChange or | | // User programs are required to call pollForStatusChange or | |
| // waitForStatusChange before user-level callback functions | | // waitForStatusChange before user-level callback functions | |
| // are executed (for example, fork, exit, or a library load). | | // are executed (for example, fork, exit, or a library load). | |
| | | | |
| // Non-blocking form; returns immediately if no callback is | | // Non-blocking form; returns immediately if no callback is | |
| // ready, or executes callback(s) then returns. | | // ready, or executes callback(s) then returns. | |
|
| API_EXPORT(Int, (), | | | |
| bool,pollForStatusChange,()); | | bool pollForStatusChange(); | |
| | | | |
| // Blocks until a callback is ready. | | // Blocks until a callback is ready. | |
|
| API_EXPORT(Int, (), | | | |
| bool,waitForStatusChange,()); | | bool waitForStatusChange(); | |
| | | | |
| // For user programs that block on other things as well, | | // For user programs that block on other things as well, | |
| // we provide a (simulated) file descriptor that can be added | | // we provide a (simulated) file descriptor that can be added | |
| // to a poll or select fdset. When a callback is prepared the BPatch | | // to a poll or select fdset. When a callback is prepared the BPatch | |
| // layer writes to this fd, thus making poll/select return. The user | | // layer writes to this fd, thus making poll/select return. The user | |
| // program should then call pollForStatusChange. The BPatch layer | | // program should then call pollForStatusChange. The BPatch layer | |
| // will handle clearing the file descriptor; all the program must do | | // will handle clearing the file descriptor; all the program must do | |
| // is call pollForStatusChange or waitForStatusChange. | | // is call pollForStatusChange or waitForStatusChange. | |
|
| API_EXPORT(Int, (), | | | |
| int, getNotificationFD, ()); | | int getNotificationFD(); | |
| | | | |
| // BPatch:: waitUntilStopped: | | // BPatch:: waitUntilStopped: | |
| // Block until specified process has stopped. | | // Block until specified process has stopped. | |
|
| API_EXPORT(Int, (appThread), | | | |
| | | | |
|
| bool,waitUntilStopped,(BPatch_thread *appThread)); | | bool waitUntilStopped(BPatch_thread *appThread); | |
| | | | |
| // BPatch::getBPatchStatistics: | | // BPatch::getBPatchStatistics: | |
| // Get Instrumentation statistics | | // Get Instrumentation statistics | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_stats &,getBPatchStatistics,()); | | BPatch_stats & getBPatchStatistics(); | |
| | | | |
|
| API_EXPORT_V(Int, (major, minor, subminor), | | void getBPatchVersion(int &major, int &minor, int &subminor); | |
| void ,getBPatchVersion,(int &major, int &minor, int &subminor)); | | | |
| | | | |
| // These three should probably be moved into their own BPatch_* class. | | // These three should probably be moved into their own BPatch_* class. | |
| // Perhaps BPatch_remoteDebug? | | // Perhaps BPatch_remoteDebug? | |
|
| API_EXPORT(Int, (), | | | |
| bool, isConnected, ()); | | | |
| | | | |
|
| API_EXPORT(Int, (remote), | | bool isConnected(); | |
| bool, remoteConnect, (BPatch_remoteHost &remote)); | | | |
| | | | |
|
| API_EXPORT(Int, (remote, pidlist), | | bool remoteConnect(BPatch_remoteHost &remote); | |
| bool,getPidList,(BPatch_remoteHost &remote, BPatch_Vector<unsigned int> | | | |
| &pidlist)); | | | |
| | | | |
|
| API_EXPORT(Int, (remote, pid, pidStr), | | bool getPidList(BPatch_remoteHost &remote, BPatch_Vector<unsigned int> | |
| bool,getPidInfo,(BPatch_remoteHost &remote, unsigned int pid, std::stri | | &pidlist); | |
| ng &pidStr)); | | | |
| | | | |
|
| API_EXPORT(Int, (remote), | | bool getPidInfo(BPatch_remoteHost &remote, unsigned int pid, std::strin | |
| bool, remoteDisconnect, (BPatch_remoteHost &remote)); | | g &pidStr); | |
| | | | |
| | | bool remoteDisconnect(BPatch_remoteHost &remote); | |
| | | | |
| // BPatch::addNonReturningFunc: | | // BPatch::addNonReturningFunc: | |
| // Globally specify that any function with a given name will not retur
n | | // Globally specify that any function with a given name will not retur
n | |
|
| API_EXPORT_V(Int, (name), | | | |
| void, addNonReturningFunc, (std::string name)); | | void addNonReturningFunc(std::string name); | |
| }; | | }; | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(pop) | | #pragma warning(pop) | |
| #endif | | #endif | |
| | | | |
| #endif /* _BPatch_h_ */ | | #endif /* _BPatch_h_ */ | |
| | | | |
End of changes. 107 change blocks. |
| 199 lines changed or deleted | | 127 lines changed or added | |
|
| BPatch_addressSpace.h | | BPatch_addressSpace.h | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_addressSpace_h_ | | #ifndef _BPatch_addressSpace_h_ | |
| #define _BPatch_addressSpace_h_ | | #define _BPatch_addressSpace_h_ | |
| | | | |
| #include "boost/shared_ptr.hpp" | | #include "boost/shared_ptr.hpp" | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| #include "BPatch_instruction.h" // for register type | | #include "BPatch_instruction.h" // for register type | |
| #include "BPatch_callbacks.h" | | #include "BPatch_callbacks.h" | |
| | | | |
| #include <vector> | | #include <vector> | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include <signal.h> | | #include <signal.h> | |
| | | | |
| // PatchAPI stuffs | | // PatchAPI stuffs | |
| //#include "Command.h" | | //#include "Command.h" | |
| | | | |
| class BPatch_addressSpace; | | class BPatch_addressSpace; | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
|
| namespace PatchAPI { | | namespace PatchAPI { | |
| class PatchMgr; | | class PatchMgr; | |
| class DynAddrSpace; | | class DynAddrSpace; | |
| class Patcher; | | class Patcher; | |
| class Instance; | | class Instance; | |
| class PatchFunction; | | class PatchFunction; | |
| class Point; | | class Point; | |
| typedef boost::shared_ptr<PatchMgr> PatchMgrPtr; | | typedef boost::shared_ptr<PatchMgr> PatchMgrPtr; | |
| typedef boost::shared_ptr<DynAddrSpace> DynAddrSpacePtr; | | typedef boost::shared_ptr<DynAddrSpace> DynAddrSpacePtr; | |
| typedef boost::shared_ptr<Instance> InstancePtr; | | typedef boost::shared_ptr<Instance> InstancePtr; | |
| PatchMgrPtr convert(const BPatch_addressSpace *); | | BPATCH_DLL_EXPORT PatchMgrPtr convert(const BPatch_addressSpace *); | |
| }; | | }; | |
| namespace SymtabAPI { | | namespace SymtabAPI { | |
| class Symbol; | | class Symbol; | |
| }; | | }; | |
| } | | } | |
| | | | |
| class BPatch_statement; | | class BPatch_statement; | |
| class BPatch_snippet; | | class BPatch_snippet; | |
| class BPatch_point; | | class BPatch_point; | |
| class BPatch_variableExpr; | | class BPatch_variableExpr; | |
| class BPatch_type; | | class BPatch_type; | |
| class AddressSpace; | | class AddressSpace; | |
| class miniTrampHandle; | | class miniTrampHandle; | |
| class miniTramp; | | class miniTramp; | |
| | | | |
| skipping to change at line 89 | | skipping to change at line 88 | |
| class BPatch_image; | | class BPatch_image; | |
| | | | |
| struct batchInsertionRecord; | | struct batchInsertionRecord; | |
| class instPoint; | | class instPoint; | |
| class int_variable; | | class int_variable; | |
| | | | |
| typedef enum{ | | typedef enum{ | |
| TRADITIONAL_PROCESS, STATIC_EDITOR | | TRADITIONAL_PROCESS, STATIC_EDITOR | |
| } processType; | | } processType; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatchSnippetHandle { | |
| #undef DYNINST_CLASS_NAME | | friend class BPatch_point; | |
| #endif | | friend class BPatch_image; | |
| #define DYNINST_CLASS_NAME BPatchSnippetHandle | | friend class BPatch_process; | |
| class BPATCH_DLL_EXPORT BPatchSnippetHandle : public BPatch_eventLock { | | friend class BPatch_binaryEdit; | |
| friend class BPatch_point; | | friend class BPatch_addressSpace; | |
| friend class BPatch_image; | | friend class BPatch_thread; | |
| friend class BPatch_process; | | | |
| friend class BPatch_binaryEdit; | | private: | |
| friend class BPatch_addressSpace; | | // Address Space snippet belogns to | |
| friend class BPatch_thread; | | BPatch_addressSpace *addSpace_; | |
| | | | |
| private: | | // low-level mappings for removal | |
| // Address Space snippet belogns to | | std::vector<Dyninst::PatchAPI::InstancePtr> instances_; | |
| BPatch_addressSpace *addSpace_; | | | |
| | | // a flag for catchup | |
| // low-level mappings for removal | | bool catchupNeeded; | |
| std::vector<Dyninst::PatchAPI::InstancePtr> instances_; | | // and a list of threads to apply catchup to | |
| | | BPatch_Vector<BPatch_thread *> catchup_threads; | |
| // a flag for catchup | | | |
| bool catchupNeeded; | | | |
| // and a list of threads to apply catchup to | | | |
| BPatch_Vector<BPatch_thread *> catchup_threads; | | | |
| | | | |
| BPatchSnippetHandle(BPatch_addressSpace * addSpace); | | | |
| | | | |
| void addInstance(Dyninst::PatchAPI::InstancePtr p) { instances_.push_ba | | | |
| ck(p); } | | | |
| | | | |
| public: | | | |
| | | | |
| API_EXPORT_DTOR(_dtor, (), | | | |
| ~,BPatchSnippetHandle,()); | | | |
| | | | |
| // Returns whether the installed miniTramps use traps. | | | |
| // Not 100% accurate due to internal Dyninst design; we can | | | |
| // have multiple instances of instrumentation due to function | | | |
| // relocation. | | | |
| API_EXPORT(Int, (), bool, usesTrap, ()); | | | |
| | | | |
| // mtHandles_ is not empty, , returns the function that the | | | |
| // instrumentation was added to | | | |
| API_EXPORT(Int, (), | | | |
| BPatch_function *, getFunc, ()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatchSnippetHandle(BPatch_addressSpace * addSpace); | |
| BPatch_addressSpace *, getAddressSpace, ()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | void addInstance(Dyninst::PatchAPI::InstancePtr p) { instances_.push_back | |
| BPatch_process *, getProcess, ()); | | (p); } | |
| | | | |
|
| API_EXPORT(Int, (), | | public: | |
| BPatch_Vector<BPatch_thread *> &, getCatchupThreads, ()); | | | |
| | | | |
|
| }; | | ~BPatchSnippetHandle(); | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | // Returns whether the installed miniTramps use traps. | |
| #undef DYNINST_CLASS_NAME | | // Not 100% accurate due to internal Dyninst design; we can | |
| #endif | | // have multiple instances of instrumentation due to function | |
| #define DYNINST_CLASS_NAME BPatch_addressSpace | | // relocation. | |
| | | bool usesTrap(); | |
| | | | |
| | | // mtHandles_ is not empty, , returns the function that the | |
| | | // instrumentation was added to | |
| | | BPatch_function * getFunc (); | |
| | | | |
| | | BPatch_addressSpace * getAddressSpace(); | |
| | | | |
| | | BPatch_process * getProcess(); | |
| | | | |
|
| class BPATCH_DLL_EXPORT BPatch_addressSpace : public BPatch_eventLock { | | BPatch_Vector<BPatch_thread *> & getCatchupThreads(); | |
| friend class BPatch; | | | |
| friend class BPatch_image; | | }; | |
| friend class BPatch_function; | | | |
| friend class BPatch_frame; | | class BPATCH_DLL_EXPORT BPatch_addressSpace { | |
| friend class BPatch_module; | | friend class BPatch; | |
| friend class BPatch_basicBlock; | | friend class BPatch_image; | |
| friend class BPatch_flowGraph; | | friend class BPatch_function; | |
| friend class BPatch_loopTreeNode; | | friend class BPatch_frame; | |
| friend class BPatch_point; | | friend class BPatch_module; | |
| friend class BPatch_funcCallExpr; | | friend class BPatch_basicBlock; | |
| friend class BPatch_eventMailbox; | | friend class BPatch_flowGraph; | |
| friend class BPatch_instruction; | | friend class BPatch_loopTreeNode; | |
| friend Dyninst::PatchAPI::PatchMgrPtr Dyninst::PatchAPI::convert(const | | friend class BPatch_point; | |
| BPatch_addressSpace *); | | friend class BPatch_funcCallExpr; | |
| | | friend class BPatch_eventMailbox; | |
| | | friend class BPatch_instruction; | |
| | | friend Dyninst::PatchAPI::PatchMgrPtr Dyninst::PatchAPI::convert(const BP | |
| | | atch_addressSpace *); | |
| | | | |
| public: | | public: | |
| | | | |
| BPatch_function *findOrCreateBPFunc(Dyninst::PatchAPI::PatchFunction *ifu
nc, | | BPatch_function *findOrCreateBPFunc(Dyninst::PatchAPI::PatchFunction *ifu
nc, | |
| BPatch_module *bpmod); | | BPatch_module *bpmod); | |
| | | | |
| BPatch_point *findOrCreateBPPoint(BPatch_function *bpfunc, | | BPatch_point *findOrCreateBPPoint(BPatch_function *bpfunc, | |
| Dyninst::PatchAPI::Point *ip, | | Dyninst::PatchAPI::Point *ip, | |
| BPatch_procedureLocation pointType); | | BPatch_procedureLocation pointType); | |
| | | | |
| | | | |
| skipping to change at line 222 | | skipping to change at line 207 | |
| // internal functions, do not use // | | // internal functions, do not use // | |
| BPatch_module *findModuleByAddr(Dyninst::Address addr);//doesn't cause pa
rsing | | BPatch_module *findModuleByAddr(Dyninst::Address addr);//doesn't cause pa
rsing | |
| bool findFuncsByRange(Dyninst::Address startAddr, | | bool findFuncsByRange(Dyninst::Address startAddr, | |
| Dyninst::Address endAddr, | | Dyninst::Address endAddr, | |
| std::set<BPatch_function*> &funcs); | | std::set<BPatch_function*> &funcs); | |
| // end internal functions........ // | | // end internal functions........ // | |
| | | | |
| // BPatch_addressSpace::insertSnippet | | // BPatch_addressSpace::insertSnippet | |
| // | | // | |
| // Insert new code into the mutatee | | // Insert new code into the mutatee | |
|
| API_EXPORT_VIRT(Int, (expr, point, order), | | virtual BPatchSnippetHandle * insertSnippet(const BPatch_snippet &expr, | |
| BPatchSnippetHandle *,insertSnippet,(const BPatch_snippet | | BPatch_point &point, | |
| &expr, | | BPatch_snippetOrder order = BP | |
| BPatch_point &point, | | atch_firstSnippet); | |
| BPatch_snippetOrder | | | |
| order = BPatch_firstSnippet)); | | | |
| | | | |
|
| //BPatch_addressSpace::insertSnippet | | //BPatch_addressSpace::insertSnippet | |
| | | | |
|
| //Insert new code into the mutatee, specifying "when" (before/after poi
nt) | | //Insert new code into the mutatee, specifying "when" (before/after point
) | |
| | | | |
|
| API_EXPORT_VIRT(When, (expr, point, when, order), | | virtual BPatchSnippetHandle* insertSnippet(const BPatch_snippet &expr, | |
| BPatchSnippetHandle *,insertSnippet,(const BPatch_snipp | | BPatch_point &point, | |
| et &expr, | | BPatch_callWhen when, | |
| BPatch_point &poin | | BPatch_snippetOrder order = BPa | |
| t, | | tch_firstSnippet); | |
| BPatch_callWhen wh | | | |
| en, | | | |
| BPatch_snippetOrde | | | |
| r order = BPatch_firstSnippet)); | | | |
| | | | |
|
| //BPatch_addressSpace::insertSnippet | | //BPatch_addressSpace::insertSnippet | |
| | | | |
|
| //Insert new code into the mutatee at multiple points | | //Insert new code into the mutatee at multiple points | |
| | | | |
|
| API_EXPORT_VIRT(AtPoints, (expr, points, order), | | virtual BPatchSnippetHandle * insertSnippet(const BPatch_snippet &expr, | |
| BPatchSnippetHandle *,insertSnippet,(const BPatch_snipp | | const BPatch_Vector<BPatch_poi | |
| et &expr, | | nt *> &points, | |
| const BPatch_Vecto | | BPatch_snippetOrder order = BP | |
| r<BPatch_point *> &points, | | atch_firstSnippet); | |
| BPatch_snippetOrde | | | |
| r order = BPatch_firstSnippet)); | | | |
| | | | |
|
| // BPatch_addressSpace::insertSnippet | | // BPatch_addressSpace::insertSnippet | |
| | | | |
|
| //Insert new code into the mutatee at multiple points, specifying "wh
en" | | //Insert new code into the mutatee at multiple points, specifying "when" | |
| | | | |
|
| API_EXPORT_VIRT(AtPointsWhen, (expr, points, when, order), | | virtual BPatchSnippetHandle * insertSnippet(const BPatch_snippet &expr, | |
| BPatchSnippetHandle *,insertSnippet,(const BPatch_snipp | | const BPatch_Vector<BPatch_poi | |
| et &expr, | | nt *> &points, | |
| const BPatch_Vecto | | BPatch_callWhen when, | |
| r<BPatch_point *> &points, | | BPatch_snippetOrder order = BP | |
| BPatch_callWhen wh | | atch_firstSnippet); | |
| en, | | | |
| BPatch_snippetOrde | | | |
| r order = BPatch_firstSnippet)); | | | |
| | | | |
| virtual void beginInsertionSet() = 0; | | virtual void beginInsertionSet() = 0; | |
| | | | |
| virtual bool finalizeInsertionSet(bool atomic, bool *modified = NULL) = 0
; | | virtual bool finalizeInsertionSet(bool atomic, bool *modified = NULL) = 0
; | |
| | | | |
| // BPatch_addressSpace::deleteSnippet | | // BPatch_addressSpace::deleteSnippet | |
| // | | // | |
| // Remove instrumentation from the mutatee process | | // Remove instrumentation from the mutatee process | |
| | | | |
|
| API_EXPORT(Int, (handle), | | bool deleteSnippet(BPatchSnippetHandle *handle); | |
| bool,deleteSnippet,(BPatchSnippetHandle *handle)); | | | |
| | | | |
| // BPatch_addressSpace::replaceCode | | // BPatch_addressSpace::replaceCode | |
| // | | // | |
| // Replace a point (must be an instruction...) with a given BPatch_snipp
et | | // Replace a point (must be an instruction...) with a given BPatch_snipp
et | |
| | | | |
|
| API_EXPORT(Int, (point, snippet), | | bool replaceCode(BPatch_point *point, BPatch_snippet *snippet); | |
| bool, replaceCode, (BPatch_point *point, BPatch_snippet *snippet)); | | | |
| | | // BPatch_addressSpace::replaceFunctionCall | |
| | | // | |
| | | // Replace function call at one point with another | |
| | | | |
| | | bool replaceFunctionCall(BPatch_point &point, BPatch_function &newFunc); | |
| | | | |
| | | // BPatch_addressSpace::removeFunctionCall | |
| | | // | |
| | | // Remove function call at one point | |
| | | | |
| | | bool removeFunctionCall(BPatch_point &point); | |
| | | | |
| | | // BPatch_addressSpace::replaceFunction | |
| | | // | |
| | | // Replace all calls to a function with calls to another | |
| | | | |
| | | bool replaceFunction(BPatch_function &oldFunc, BPatch_function &newFunc); | |
| | | | |
| | | // BPatch_addressSpace::revertReplaceFunction | |
| | | // | |
| | | // Undo the operation of a replace function | |
| | | bool revertReplaceFunction(BPatch_function &oldFunc); | |
| | | | |
| | | // BPatch_addressSpace::wrapFunction | |
| | | // | |
| | | // Replace oldFunc with newFunc as above; however, also rename oldFunc | |
| | | // to the provided name so it can still be reached. | |
| | | | |
| | | bool wrapFunction(BPatch_function *oldFunc, BPatch_function *newFunc, Dyn | |
| | | inst::SymtabAPI::Symbol *clone); | |
| | | | |
| | | // BPatch_addressSpace::revertWrapFunction | |
| | | // | |
| | | // Undo the operations of a wrapFunction, restoring the original | |
| | | // functionality | |
| | | | |
| | | bool revertWrapFunction(BPatch_function *wrappedFunc); | |
| | | | |
| | | // BPatch_addressSpace::getSourceLines | |
| | | // | |
| | | // Method that retrieves the line number and file name corresponding | |
| | | // to an address | |
| | | | |
| | | bool getSourceLines(unsigned long addr, BPatch_Vector< BPatch_statement > | |
| | | & lines ); | |
| | | | |
| | | // BPatch_addressSpace::getAddressRanges | |
| | | // | |
| | | // Method that retrieves address range(s) for a given filename and line n | |
| | | umber. | |
| | | | |
| | | bool getAddressRanges(const char * fileName, unsigned int lineNo, std::ve | |
| | | ctor< std::pair< unsigned long, unsigned long > > & ranges ); | |
| | | | |
| | | // DEPRECATED: | |
| | | // BPatch_addressSpace::findFunctionByAddr | |
| | | // | |
| | | // Returns the function containing an address | |
| | | | |
| | | BPatch_function * findFunctionByAddr(void *addr); | |
| | | | |
| | | // BPatch_addressSpace::findFunctionByEntry | |
| | | // | |
| | | // Returns the function starting at the given address | |
| | | | |
| | | BPatch_function * findFunctionByEntry(Dyninst::Address entry); | |
| | | | |
| | | // BPatch_addressSpace::findFunctionsByAddr | |
| | | // | |
| | | // Returns the functions containing an address | |
| | | // (multiple functions are returned when code is shared) | |
| | | | |
| | | bool findFunctionsByAddr(Dyninst::Address addr, | |
| | | std::vector<BPatch_function*> &funcs); | |
| | | | |
| | | // BPatch_addressSpace::getImage | |
| | | // | |
| | | // Obtain BPatch_image associated with this BPatch_addressSpace | |
| | | | |
| | | BPatch_image * getImage(); | |
| | | | |
| | | // BPatch_addressSpace::malloc | |
| | | // | |
| | | // Allocate memory for a new variable in the mutatee process | |
| | | | |
| | | BPatch_variableExpr * malloc(int n, std::string name = std::string("")); | |
| | | | |
|
| // BPatch_addressSpace::replaceFunctionCall | | // BPatch_addressSpace::malloc | |
| // | | // | |
| // Replace function call at one point with another | | // Allocate memory for a new variable in the mutatee process | |
| | | | |
| API_EXPORT(Int, (point, newFunc), | | BPatch_variableExpr * malloc(const BPatch_type &type, std::string name = | |
| bool,replaceFunctionCall,(BPatch_point &point, BPatch_function &newFunc | | std::string("")); | |
| )); | | | |
| | | BPatch_variableExpr * createVariable(Dyninst::Address at_addr, | |
| // BPatch_addressSpace::removeFunctionCall | | BPatch_type *type, | |
| // | | std::string var_name = std::string("" | |
| // Remove function call at one point | | ), | |
| | | BPatch_module *in_module = NULL); | |
| API_EXPORT(Int, (point), | | | |
| bool,removeFunctionCall,(BPatch_point &point)); | | // BPatch_addressSpace::free | |
| | | // | |
| // BPatch_addressSpace::replaceFunction | | // Free memory allocated by Dyninst in the mutatee process | |
| // | | | |
| // Replace all calls to a function with calls to another | | bool free(BPatch_variableExpr &ptr); | |
| | | | |
| API_EXPORT(Int, (oldFunc, newFunc), | | // BPatch_addressSpace::createVariable | |
| bool,replaceFunction,(BPatch_function &oldFunc, BPatch_function &newFun | | // | |
| c)); | | // Wrap an existing piece of allocated memory with a BPatch_variableExpr. | |
| | | // Used (for instance) by the shared memory library to wrap its externall | |
| // BPatch_addressSpace::revertReplaceFunction | | y | |
| // | | // allocated memory for use by BPatch. | |
| // Undo the operation of a replace function | | BPatch_variableExpr * createVariable(std::string name, | |
| API_EXPORT(Int, (oldFunc), | | Dyninst::Address addr, | |
| bool, revertReplaceFunction, (BPatch_function &oldFunc)); | | BPatch_type *type = NULL); | |
| | | bool getRegisters(std::vector<BPatch_register> ®s); | |
| // BPatch_addressSpace::wrapFunction | | | |
| // | | bool createRegister_NP(std::string regName, BPatch_register ®); | |
| // Replace oldFunc with newFunc as above; however, also rename oldFunc | | | |
| // to the provided name so it can still be reached. | | void allowTraps(bool allowtraps); | |
| | | | |
| API_EXPORT(Int, (oldFunc, newFunc, clone), | | // BPatch_addressSpace::loadLibrary | |
| bool,wrapFunction,(BPatch_function *oldFunc, BPatch_function | | // | |
| *newFunc, Dyninst::SymtabAPI::Symbol *clone)); | | // Load a shared library into the mutatee's address space | |
| | | // Returns true if successful | |
| // BPatch_addressSpace::revertWrapFunction | | // | |
| // | | // the reload argument is used by save the world to determine | |
| // Undo the operations of a wrapFunction, restoring the original | | // if this library should be reloaded by the mutated binary | |
| // functionality | | // when it starts up. this is up to the user because loading | |
| | | // an extra shared library could hide access to the 'correct' | |
| API_EXPORT(Int, (wrappedFunc), | | // function by redefining a function | |
| bool,revertWrapFunction,(BPatch_function *wrappedFunc)); | | | |
| | | virtual BPatch_object * loadLibrary(const char *libname, bool reload = fa | |
| // BPatch_addressSpace::getSourceLines | | lse) = 0; | |
| // | | | |
| // Method that retrieves the line number and file name corresponding | | // BPatch_addressSpace::isStaticExecutable | |
| // to an address | | // | |
| | | // Returns true if the underlying image represents a | |
| API_EXPORT(Int, (addr, lines), | | // statically-linked executable, false otherwise | |
| bool,getSourceLines,(unsigned long addr, BPatch_Vector< BPatch_statemen | | bool isStaticExecutable(); | |
| t > & lines )); | | | |
| | | | |
| // BPatch_addressSpace::getAddressRanges | | | |
| // | | | |
| // Method that retrieves address range(s) for a given filename and line | | | |
| number. | | | |
| | | | |
| API_EXPORT(Int, (fileName, lineNo, ranges), | | | |
| bool,getAddressRanges,(const char * fileName, unsigned int lineNo, std: | | | |
| :vector< std::pair< unsigned long, unsigned long > > & ranges )); | | | |
| | | | |
| // DEPRECATED: | | | |
| // BPatch_addressSpace::findFunctionByAddr | | | |
| // | | | |
| // Returns the function containing an address | | | |
| | | | |
| API_EXPORT(Int, (addr), | | | |
| BPatch_function *,findFunctionByAddr,(void *addr)); | | | |
| | | | |
| // BPatch_addressSpace::findFunctionByEntry | | | |
| // | | | |
| // Returns the function starting at the given address | | | |
| | | | |
| API_EXPORT(Int, (entry), | | | |
| BPatch_function *,findFunctionByEntry,(Dyninst::Address entry)); | | | |
| | | | |
| // BPatch_addressSpace::findFunctionsByAddr | | | |
| // | | | |
| // Returns the functions containing an address | | | |
| // (multiple functions are returned when code is shared) | | | |
| | | | |
| API_EXPORT(Int, (addr,funcs), | | | |
| bool, findFunctionsByAddr,(Dyninst::Address addr, | | | |
| std::vector<BPatch_function*> &funcs)); | | | |
| | | | |
| // BPatch_addressSpace::getImage | | | |
| // | | | |
| // Obtain BPatch_image associated with this BPatch_addressSpace | | | |
| | | | |
| API_EXPORT(Int, (), | | | |
| BPatch_image *,getImage,()); | | | |
| | | | |
| // BPatch_addressSpace::malloc | | | |
| // | | | |
| // Allocate memory for a new variable in the mutatee process | | | |
| | | | |
| API_EXPORT(Int, (n, name), | | | |
| BPatch_variableExpr *,malloc,(int n, std::string name = std: | | | |
| :string(""))); | | | |
| | | | |
| // BPatch_addressSpace::malloc | | | |
| // | | | |
| // Allocate memory for a new variable in the mutatee process | | | |
| | | | |
| API_EXPORT(ByType, (type, name), | | | |
| BPatch_variableExpr *,malloc,(const BPatch_type &type, std:: | | | |
| string name = std::string(""))); | | | |
| | | | |
| API_EXPORT(Int, (at_addr, type, var_name, in_module), | | | |
| BPatch_variableExpr *, createVariable,(Dyninst::Address at_addr, | | | |
| BPatch_type *type, | | | |
| std::string var_name = std::stri | | | |
| ng(""), | | | |
| BPatch_module *in_module = NULL) | | | |
| ); | | | |
| | | | |
| // BPatch_addressSpace::free | | | |
| // | | | |
| // Free memory allocated by Dyninst in the mutatee process | | | |
| | | | |
| API_EXPORT(Int, (ptr), | | | |
| bool,free,(BPatch_variableExpr &ptr)); | | | |
| | | | |
| // BPatch_addressSpace::createVariable | | | |
| // | | | |
| // Wrap an existing piece of allocated memory with a BPatch_variableExp | | | |
| r. | | | |
| // Used (for instance) by the shared memory library to wrap its externa | | | |
| lly | | | |
| // allocated memory for use by BPatch. | | | |
| | | | |
| API_EXPORT(Int, (name, addr, type), | | | |
| BPatch_variableExpr *, createVariable, | | | |
| (std::string name, Dyninst::Address addr, BPatch_type *type | | | |
| = NULL)); | | | |
| | | | |
| API_EXPORT(Int, (regs), | | | |
| bool, getRegisters, (std::vector<BPatch_register> ®s)); | | | |
| | | | |
| API_EXPORT(Int, (regName, reg), | | | |
| bool, createRegister_NP, (std::string regName, BPatch_register ®)); | | | |
| | | | |
| API_EXPORT_V(Int, (allowtraps), | | | |
| void, allowTraps, (bool allowtraps)); | | | |
| | | | |
| // BPatch_addressSpace::loadLibrary | | | |
| // | | | |
| // Load a shared library into the mutatee's address space | | | |
| // Returns true if successful | | | |
| // | | | |
| // the reload argument is used by save the world to determine | | | |
| // if this library should be reloaded by the mutated binary | | | |
| // when it starts up. this is up to the user because loading | | | |
| // an extra shared library could hide access to the 'correct' | | | |
| // function by redefining a function | | | |
| | | | |
| API_EXPORT_VIRT(Int, (libname, reload), | | | |
| BPatch_object *, loadLibrary,(const char *libname, bool reload = false) | | | |
| ); | | | |
| | | | |
| // BPatch_addressSpace::isStaticExecutable | | | |
| // | | | |
| // Returns true if the underlying image represents a | | | |
| // statically-linked executable, false otherwise | | | |
| API_EXPORT(Int, (), | | | |
| bool, isStaticExecutable,()); | | | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 22 change blocks. |
| 296 lines changed or deleted | | 239 lines changed or added | |
|
| BPatch_basicBlock.h | | BPatch_basicBlock.h | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_basicBlock_h_ | | #ifndef _BPatch_basicBlock_h_ | |
| #define _BPatch_basicBlock_h_ | | #define _BPatch_basicBlock_h_ | |
| | | | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_sourceBlock.h" | | #include "BPatch_sourceBlock.h" | |
| #include "BPatch_instruction.h" | | #include "BPatch_instruction.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "Instruction.h" | | #include "Instruction.h" | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| //#include "BPatch_edge.h" | | //#include "BPatch_edge.h" | |
| | | | |
| class image; | | class image; | |
| class func_instance; | | class func_instance; | |
| class instPoint; | | class instPoint; | |
| class block_instance; | | class block_instance; | |
| class BPatch_point; | | class BPatch_point; | |
| class BPatch_edge; | | class BPatch_edge; | |
| class BPatch_function; | | class BPatch_function; | |
| class BPatch_flowGraph; | | class BPatch_flowGraph; | |
| class BPatch_basicBlock; | | class BPatch_basicBlock; | |
| | | | |
| /* Currently all this bitarray stuff is just for power, | | /* Currently all this bitarray stuff is just for power, | |
| but could be extended as we do liveness stuff for other platforms */ | | but could be extended as we do liveness stuff for other platforms */ | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
|
| namespace ParseAPI { | | namespace ParseAPI { | |
| class Block; | | class Block; | |
| Block *convert(const BPatch_basicBlock *); | | BPATCH_DLL_EXPORT Block *convert(const BPatch_basicBlock *); | |
| }; | | }; | |
| namespace PatchAPI { | | namespace PatchAPI { | |
| class PatchBlock; | | class PatchBlock; | |
| PatchBlock *convert(const BPatch_basicBlock *); | | BPATCH_DLL_EXPORT PatchBlock *convert(const BPatch_basicBlock *); | |
| }; | | }; | |
| | | }; | |
| | | | |
| | | namespace std { | |
| | | template <> | |
| | | struct less<BPatch_basicBlock *> { | |
| | | BPATCH_DLL_EXPORT bool operator()(const BPatch_basicBlock * const &l, co | |
| | | nst BPatch_basicBlock * const &r) const; | |
| | | }; | |
| | | }; | |
| | | | |
| | | template <> | |
| | | struct comparison <BPatch_basicBlock *> { | |
| | | BPATCH_DLL_EXPORT bool operator()(const BPatch_basicBlock * const &x, | |
| | | const BPatch_basicBlock * const &y) const; | |
| }; | | }; | |
| | | | |
| /** class for machine code basic blocks. We assume the user can not | | /** class for machine code basic blocks. We assume the user can not | |
|
| * create basic blocks using its constructor. It is not safe. | | * create basic blocks using its constructor. It is not safe. | |
| * basic blocks are used for reading purposes not for inserting | | * basic blocks are used for reading purposes not for inserting | |
| * a new code to the machine executable other than instrumentation code | | * a new code to the machine executable other than instrumentation code | |
| * | | * | |
| * @see BPatch_flowGraph | | * @see BPatch_flowGraph | |
| * @see BPatch_sourceBlock | | * @see BPatch_sourceBlock | |
| * @see BPatch_basicBlockLoop | | * @see BPatch_basicBlockLoop | |
| */ | | */ | |
| class BPatch_flowGraph; | | class BPatch_flowGraph; | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | struct BPATCH_DLL_EXPORT insnPredicate : public std::unary_function<Dyninst | |
| #endif | | ::InstructionAPI::Instruction::Ptr, bool> | |
| #define DYNINST_CLASS_NAME BPatch_basicBlock | | | |
| struct insnPredicate : public std::unary_function<Dyninst::InstructionAPI:: | | | |
| Instruction::Ptr, bool> | | | |
| { | | { | |
|
| virtual result_type operator()(argument_type arg) = 0; | | virtual result_type operator()(argument_type arg) = 0; | |
| virtual ~insnPredicate() {} | | virtual ~insnPredicate() {} | |
| | | | |
| }; | | }; | |
| | | | |
|
| class BPATCH_DLL_EXPORT BPatch_basicBlock : public BPatch_eventLock { | | class BPATCH_DLL_EXPORT BPatch_basicBlock { | |
| friend class BPatch_flowGraph; | | friend class BPatch_flowGraph; | |
| friend class TarjanDominator; | | friend class TarjanDominator; | |
| friend class dominatorCFG; | | friend class dominatorCFG; | |
| friend class InstrucIter; | | friend class InstrucIter; | |
| friend class func_instance; | | friend class func_instance; | |
| friend class BPatch_instruction; | | friend class BPatch_instruction; | |
| friend std::ostream& operator<<(std::ostream&,BPatch_basicBlock&); | | friend std::ostream& operator<<(std::ostream&,BPatch_basicBlock&); | |
| friend Dyninst::ParseAPI::Block *Dyninst::ParseAPI::convert(const B | | friend Dyninst::ParseAPI::Block *Dyninst::ParseAPI::convert(const BPatch_ | |
| Patch_basicBlock *); | | basicBlock *); | |
| friend Dyninst::PatchAPI::PatchBlock *Dyninst::PatchAPI::convert(co | | friend Dyninst::PatchAPI::PatchBlock *Dyninst::PatchAPI::convert(const BP | |
| nst BPatch_basicBlock *); | | atch_basicBlock *); | |
| | | | |
| private: | | private: | |
|
| /** the internal basic block structure **/ | | /** the internal basic block structure **/ | |
| block_instance *iblock; | | block_instance *iblock; | |
| | | | |
|
| /** the flow graph that contains this basic block */ | | /** the flow graph that contains this basic block */ | |
| BPatch_flowGraph *flowGraph; | | BPatch_flowGraph *flowGraph; | |
| | | | |
| /** set of basic blocks that this basicblock dominates immediately*/ | | /** set of basic blocks that this basicblock dominates immediately*/ | |
|
| BPatch_Set<BPatch_basicBlock*>* immediateDominates; | | std::set<BPatch_basicBlock*>* immediateDominates; | |
| | | | |
|
| /** basic block which is the immediate dominator of the basic block */ | | /** basic block which is the immediate dominator of the basic block */ | |
| BPatch_basicBlock *immediateDominator; | | BPatch_basicBlock *immediateDominator; | |
| | | | |
| /** same as previous two fields, but for postdominator tree */ | | /** same as previous two fields, but for postdominator tree */ | |
|
| BPatch_Set<BPatch_basicBlock*> *immediatePostDominates; | | std::set<BPatch_basicBlock*> *immediatePostDominates; | |
| BPatch_basicBlock *immediatePostDominator; | | BPatch_basicBlock *immediatePostDominator; | |
| | | | |
|
| /** the source block(source lines) that basic block corresponds*/ | | /** the source block(source lines) that basic block corresponds*/ | |
| BPatch_Vector<BPatch_sourceBlock*> *sourceBlocks; | | BPatch_Vector<BPatch_sourceBlock*> *sourceBlocks; | |
| | | | |
|
| /** the instructions within this block */ | | /** the instructions within this block */ | |
| BPatch_Vector<BPatch_instruction*> *instructions; | | BPatch_Vector<BPatch_instruction*> *instructions; | |
| | | | |
| /** the incoming edges */ | | /** the incoming edges */ | |
|
| BPatch_Set<BPatch_edge*> incomingEdges; | | std::set<BPatch_edge*> incomingEdges; | |
| | | | |
| /** the outgoing edges */ | | /** the outgoing edges */ | |
|
| BPatch_Set<BPatch_edge*> outgoingEdges; | | std::set<BPatch_edge*> outgoingEdges; | |
| | | | |
|
| public: | | public: | |
| BPatch_flowGraph *fg() const { return flowGraph; } | | BPatch_flowGraph *fg() const { return flowGraph; } | |
| block_instance *block() const { return iblock; } | | block_instance *block() const { return iblock; } | |
| BPatch_function *func() const; | | BPatch_function *func() const; | |
| func_instance *ifunc() const; | | func_instance *ifunc() const; | |
| | | | |
| protected: | | protected: | |
| | | | |
|
| /** constructor of class */ | | /** constructor of class */ | |
| BPatch_basicBlock(block_instance *ib, BPatch_flowGraph *fg); | | BPatch_basicBlock(block_instance *ib, BPatch_flowGraph *fg); | |
| | | | |
|
| BPatch_Vector<BPatch_point*>* | | BPatch_Vector<BPatch_point*>* | |
| findPointByPredicate(insnPredicate& f); | | findPointByPredicate(insnPredicate& f); | |
| | | | |
| public: | | public: | |
| | | | |
|
| // Internal functions. Don't use these unless you know what you're | | // Internal functions. Don't use these unless you know what you're | |
| // doing. | | // doing. | |
| block_instance *lowlevel_block() { return iblock; } | | block_instance *lowlevel_block() { return iblock; } | |
| | | | |
|
| void setlowlevel_block(block_instance *b) { iblock = b; } | | void setlowlevel_block(block_instance *b) { iblock = b; } | |
| void getAllPoints(std::vector<BPatch_point*>& allPoints); | | void getAllPoints(std::vector<BPatch_point*>& allPoints); | |
| BPatch_point *convertPoint(instPoint *pt); | | BPatch_point *convertPoint(instPoint *pt); | |
| BPatch_function *getCallTarget(); | | BPatch_function *getCallTarget(); | |
| // end internal functions | | // end internal functions | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_flowGraph * getFlowGraph() const; | |
| BPatch_flowGraph *, getFlowGraph, () CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::getSources */ | | /** BPatch_basicBlock::getSources */ | |
| /** method that returns the predecessors of the basic block */ | | /** method that returns the predecessors of the basic block */ | |
| | | | |
|
| API_EXPORT_V(Int, (srcs), | | void getSources(BPatch_Vector<BPatch_basicBlock*> &srcs); | |
| void,getSources,(BPatch_Vector<BPatch_basicBlock*> &srcs)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getTargets */ | | /** BPatch_basicBlock::getTargets */ | |
| /** method that returns the successors of the basic block */ | | /** method that returns the successors of the basic block */ | |
| | | | |
|
| API_EXPORT_V(Int, (targets), | | void getTargets(BPatch_Vector<BPatch_basicBlock*> &targets); | |
| void,getTargets,(BPatch_Vector<BPatch_basicBlock*> &targets | | | |
| )); | | | |
| | | | |
|
| /** BPatch_basicBlock::dominates */ | | /** BPatch_basicBlock::dominates */ | |
| /** returns true if argument is dominated by this basic block */ | | /** returns true if argument is dominated by this basic block */ | |
| | | | |
|
| API_EXPORT(Int, (block), | | bool dominates(BPatch_basicBlock *block); | |
| bool,dominates,(BPatch_basicBlock *block)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getImmediateDominiator */ | | /** BPatch_basicBlock::getImmediateDominiator */ | |
| /** return the immediate dominator of a basic block */ | | /** return the immediate dominator of a basic block */ | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_basicBlock* getImmediateDominator(); | |
| BPatch_basicBlock*,getImmediateDominator,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::getImmediateDominates */ | | /** BPatch_basicBlock::getImmediateDominates */ | |
| /** method that returns the basic blocks immediately dominated by | | /** method that returns the basic blocks immediately dominated by */ | |
| */ | | /** the basic block */ | |
| /** the basic block */ | | | |
| | | | |
|
| API_EXPORT_V(Int, (blocks), | | void getImmediateDominates(BPatch_Vector<BPatch_basicBlock*> &blocks); | |
| void,getImmediateDominates,(BPatch_Vector<BPatch_basicBlock | | | |
| *> &blocks)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getAllDominates */ | | /** BPatch_basicBlock::getAllDominates */ | |
| /** method that returns all basic blocks dominated by the basic bloc | | /** method that returns all basic blocks dominated by the basic block */ | |
| k */ | | | |
| | | | |
|
| API_EXPORT_V(Int, (blocks), | | void getAllDominates(BPatch_Set<BPatch_basicBlock*> &blocks); | |
| void,getAllDominates,(BPatch_Set<BPatch_basicBlock*> &block | | void getAllDominates(std::set<BPatch_basicBlock*> &blocks); | |
| s)); | | | |
| | | | |
|
| /** the previous four methods, but for postdominators */ | | /** the previous four methods, but for postdominators */ | |
| | | | |
|
| /** BPatch_basicBlock::postdominates */ | | /** BPatch_basicBlock::postdominates */ | |
| | | | |
|
| API_EXPORT(Int, (block), | | bool postdominates(BPatch_basicBlock *block); | |
| bool,postdominates,(BPatch_basicBlock *block)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getImmediatePostDominator */ | | /** BPatch_basicBlock::getImmediatePostDominator */ | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_basicBlock* getImmediatePostDominator(); | |
| BPatch_basicBlock*,getImmediatePostDominator,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::getImmediatePostDominates */ | | /** BPatch_basicBlock::getImmediatePostDominates */ | |
| | | | |
|
| API_EXPORT_V(Int, (blocks), | | void getImmediatePostDominates(BPatch_Vector<BPatch_basicBlock*> &blocks) | |
| void,getImmediatePostDominates,(BPatch_Vector<BPatch_basicB | | ; | |
| lock*> &blocks)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getAllPostDominates */ | | /** BPatch_basicBlock::getAllPostDominates */ | |
| | | | |
|
| API_EXPORT_V(Int, (blocks), | | void getAllPostDominates(BPatch_Set<BPatch_basicBlock*> &blocks); | |
| void,getAllPostDominates,(BPatch_Set<BPatch_basicBlock*> &b | | void getAllPostDominates(std::set<BPatch_basicBlock*> &blocks); | |
| locks)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getSourceBlocks */ | | /** BPatch_basicBlock::getSourceBlocks */ | |
| /** returns the source block corresponding to the basic block */ | | /** returns the source block corresponding to the basic block */ | |
| | | | |
|
| API_EXPORT(Int, (blocks), | | bool getSourceBlocks(BPatch_Vector<BPatch_sourceBlock*> &blocks); | |
| bool,getSourceBlocks,(BPatch_Vector<BPatch_sourceBlock*> &blo | | | |
| cks)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getBlockNumber */ | | /** BPatch_basicBlock::getBlockNumber */ | |
| /** returns the block id */ | | /** returns the block id */ | |
| | | | |
|
| API_EXPORT(Int, (), | | int getBlockNumber(); | |
| int,getBlockNumber,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::setEmtryBlock */ | | /** BPatch_basicBlock::setEmtryBlock */ | |
| /** sets whether this block is an entry block (or not) */ | | /** sets whether this block is an entry block (or not) */ | |
| | | | |
|
| /** BPatch_basicBlock::isEntryBlock */ | | /** BPatch_basicBlock::isEntryBlock */ | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isEntryBlock() const; | |
| bool,isEntryBlock,() CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::isExitBlock */ | | /** BPatch_basicBlock::isExitBlock */ | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isExitBlock() const; | |
| bool,isExitBlock,() CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::size */ | | /** BPatch_basicBlock::size */ | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned size() const; | |
| unsigned,size,() CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::getStartAddress */ | | /** BPatch_basicBlock::getStartAddress */ | |
| //these always return absolute address | | //these always return absolute address | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned long getStartAddress() const; | |
| unsigned long,getStartAddress,() CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::getLastInsnAddress */ | | /** BPatch_basicBlock::getLastInsnAddress */ | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned long getLastInsnAddress() const; | |
| unsigned long,getLastInsnAddress,() CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::getEndAddress */ | | /** BPatch_basicBlock::getEndAddress */ | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned long getEndAddress() const; | |
| unsigned long, getEndAddress, () CONST_EXPORT); | | | |
| | | | |
|
| /** BPatch_basicBlock::~BPatch_basicBlock */ | | /** BPatch_basicBlock::~BPatch_basicBlock */ | |
| /** destructor of class */ | | /** destructor of class */ | |
| | | | |
|
| API_EXPORT_DTOR(_dtor, (), | | ~BPatch_basicBlock(); | |
| ~,BPatch_basicBlock,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::getAddressRange */ | | /** BPatch_basicBlock::getAddressRange */ | |
| /** return the start and end addresses of the basic block */ | | /** return the start and end addresses of the basic block */ | |
| | | | |
|
| API_EXPORT(Int, (_startAddress, _endAddress), | | bool getAddressRange(void*& _startAddress, void*& _endAddress); | |
| bool,getAddressRange,(void*& _startAddress, void*& _endAddres | | | |
| s)); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
|
| // dummy placeholder. I think this is only used by dpcl in a debug rou | | // dummy placeholder. I think this is only used by dpcl in a debug rout | |
| tine | | ine | |
| API_EXPORT(Int, (_startLine, _endLine), | | bool getLineNumbers(unsigned int &_startLine, unsigned int &_endLine); | |
| bool,getLineNumbers,(unsigned int &_startLine, unsigned int | | | |
| &_endLine)); | | | |
| #endif | | #endif | |
|
| /** BPatch_basicBlock::findEntryPoint */ | | /** BPatch_basicBlock::findEntryPoint */ | |
| /** return point at the start of the basic block */ | | /** return point at the start of the basic block */ | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_point* findEntryPoint(); | |
| BPatch_point*, findEntryPoint,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::findExitPoint */ | | /** BPatch_basicBlock::findExitPoint */ | |
| /** return point at the start of the basic block */ | | /** return point at the start of the basic block */ | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_point* findExitPoint(); | |
| BPatch_point*, findExitPoint,()); | | | |
| | | | |
|
| /** BPatch_basicBlock::findPoint */ | | /** BPatch_basicBlock::findPoint */ | |
| /** return a set of points within the basic block */ | | /** return a set of points within the basic block */ | |
| | | | |
|
| API_EXPORT(Int, (ops), | | BPatch_Vector<BPatch_point*> * findPoint(const BPatch_Set<BPatch_opCode>& | |
| BPatch_Vector<BPatch_point*> *,findPoint,(const BPatch_Set<BP | | ops); | |
| atch_opCode>& ops)); | | BPatch_Vector<BPatch_point*> * findPoint(const std::set<BPatch_opCode>& o | |
| | | ps); | |
| | | | |
|
| API_EXPORT(Int, (filter), | | BPatch_Vector<BPatch_point*> * findPoint(bool(*filter)(Dyninst::Instructi | |
| BPatch_Vector<BPatch_point*> *,findPoint,(bool(*filter)(Dynin | | onAPI::Instruction::Ptr)); | |
| st::InstructionAPI::Instruction::Ptr))); | | | |
| | | | |
|
| API_EXPORT(Int, (addr), | | BPatch_point * findPoint(Dyninst::Address addr); | |
| BPatch_point *, findPoint, (Dyninst::Address addr)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getInstructions */ | | /** BPatch_basicBlock::getInstructions */ | |
| /** return the instructions that belong to the block */ | | /** return the instructions that belong to the block */ | |
| | | | |
|
| API_EXPORT(Int, (insns), | | bool getInstructions(std::vector<Dyninst::InstructionAPI::Instruction::P | |
| bool, getInstructions, (std::vector<Dyninst::InstructionAPI::I | | tr>& insns); | |
| nstruction::Ptr>& insns)); | | bool getInstructions(std::vector<std::pair<Dyninst::InstructionAPI::Inst | |
| API_EXPORT(Addrs, (insnInstances), | | ruction::Ptr, Dyninst::Address> >& insnInstances); | |
| bool, getInstructions, (std::vector<std::pair<Dyninst::Instruc | | | |
| tionAPI::Instruction::Ptr, Dyninst::Address> >& insnInstances)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getIncomingEdges */ | | /** BPatch_basicBlock::getIncomingEdges */ | |
| /** returns the incoming edges */ | | /** returns the incoming edges */ | |
| | | | |
|
| API_EXPORT_V(Int, (inc), | | void getIncomingEdges(BPatch_Vector<BPatch_edge*> &inc); | |
| void,getIncomingEdges,(BPatch_Vector<BPatch_edge*> &inc)); | | | |
| | | | |
|
| /** BPatch_basicBlock::getOutgoingEdges */ | | /** BPatch_basicBlock::getOutgoingEdges */ | |
| /** returns the outgoming edges */ | | /** returns the outgoming edges */ | |
| | | | |
|
| API_EXPORT_V(Int, (out), | | void getOutgoingEdges(BPatch_Vector<BPatch_edge*> &out); | |
| void,getOutgoingEdges,(BPatch_Vector<BPatch_edge*> &out)); | | | |
| | | | |
|
| operator Dyninst::ParseAPI::Block *() const; | | operator Dyninst::ParseAPI::Block *() const; | |
| operator Dyninst::PatchAPI::PatchBlock *() const; | | operator Dyninst::PatchAPI::PatchBlock *() const; | |
| | | | |
|
| int blockNo() const; | | int blockNo() const; | |
| | | | |
| }; | | }; | |
| | | | |
|
| template <> | | | |
| struct comparison <BPatch_basicBlock *> { | | | |
| bool operator()(const BPatch_basicBlock * const &x, | | | |
| const BPatch_basicBlock * const &y) const { | | | |
| return (x->getStartAddress() < y->getStartAddress()); | | | |
| }; | | | |
| }; | | | |
| | | | |
| #endif /* _BPatch_basicBlock_h_ */ | | #endif /* _BPatch_basicBlock_h_ */ | |
| | | | |
End of changes. 81 change blocks. |
| 204 lines changed or deleted | | 170 lines changed or added | |
|
| BPatch_basicBlockLoop.h | | BPatch_basicBlockLoop.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| #ifndef _BPatch_basicBlockLoop_h | | #ifndef _BPatch_basicBlockLoop_h | |
| #define _BPatch_basicBlockLoop_h | | #define _BPatch_basicBlockLoop_h | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <string> | | #include <string> | |
| #include "Annotatable.h" | | #include "Annotatable.h" | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_basicBlock.h" | | #include "BPatch_basicBlock.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_flowGraph.h" | | #include "BPatch_flowGraph.h" | |
| | | | |
| /** class to represent the loops composed of machine code basic | | /** class to represent the loops composed of machine code basic | |
| * blocks in the executable (Natural loops) | | * blocks in the executable (Natural loops) | |
| * | | * | |
| * @see BPatch_basicBlock | | * @see BPatch_basicBlock | |
| * @see BPatch_flowGraph | | * @see BPatch_flowGraph | |
| */ | | */ | |
| | | | |
| class BPatch_variableExpr; | | class BPatch_variableExpr; | |
| class BPatch_loopTreeNode; | | class BPatch_loopTreeNode; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_basicBlockLoop | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_basicBlockLoop : | | class BPATCH_DLL_EXPORT BPatch_basicBlockLoop : | |
|
| public BPatch_eventLock, | | | |
| public Dyninst::AnnotatableSparse | | public Dyninst::AnnotatableSparse | |
| { | | { | |
| friend class BPatch_flowGraph; | | friend class BPatch_flowGraph; | |
| friend std::ostream& operator<<(std::ostream&,BPatch_basicBlockLoop&
); | | friend std::ostream& operator<<(std::ostream&,BPatch_basicBlockLoop&
); | |
| friend void dfsCreateLoopHierarchy(BPatch_loopTreeNode * parent, | | friend void dfsCreateLoopHierarchy(BPatch_loopTreeNode * parent, | |
| BPatch_Vector<BPatch_basicBlockL
oop *> &loops, | | BPatch_Vector<BPatch_basicBlockL
oop *> &loops, | |
| std::string level); | | std::string level); | |
| | | | |
| private: | | private: | |
| std::set<BPatch_edge*> backEdges; | | std::set<BPatch_edge*> backEdges; | |
| | | | |
| // the flow graph this loop is part of | | // the flow graph this loop is part of | |
| BPatch_flowGraph *flowGraph; | | BPatch_flowGraph *flowGraph; | |
| | | | |
| /** set of loops that are contained (nested) in this loop. */ | | /** set of loops that are contained (nested) in this loop. */ | |
|
| BPatch_Set<BPatch_basicBlockLoop*> containedLoops; | | std::set<BPatch_basicBlockLoop*> containedLoops; | |
| | | | |
| /** the basic blocks in the loop */ | | /** the basic blocks in the loop */ | |
|
| BPatch_Set<BPatch_basicBlock*> basicBlocks; | | std::set<BPatch_basicBlock*> basicBlocks; | |
| | | | |
| /** this func is only invoked by BPatch_flowGraph::createLoops */ | | /** this func is only invoked by BPatch_flowGraph::createLoops */ | |
| void addBackEdges(std::vector<BPatch_edge*> &edges); | | void addBackEdges(std::vector<BPatch_edge*> &edges); | |
| | | | |
| public: | | public: | |
| /** If loop which directly encloses this loop. NULL if no such loop
*/ | | /** If loop which directly encloses this loop. NULL if no such loop
*/ | |
| BPatch_basicBlockLoop* parent; | | BPatch_basicBlockLoop* parent; | |
| | | | |
| /** BPatch_basicBlockLoop::containsAddress */ | | /** BPatch_basicBlockLoop::containsAddress */ | |
| /** Return true if the given address is within the range of | | /** Return true if the given address is within the range of | |
| this loop's basicBlocks */ | | this loop's basicBlocks */ | |
|
| API_EXPORT(Int, (addr), | | | |
| | | | |
|
| bool,containsAddress,(unsigned long addr)); | | bool containsAddress(unsigned long addr); | |
| | | | |
| /** Return true if the given address is within the range of | | /** Return true if the given address is within the range of | |
| this loop's basicBlocks or its children */ | | this loop's basicBlocks or its children */ | |
|
| API_EXPORT(Int, (addr), | | | |
| | | | |
|
| bool,containsAddressInclusive,(unsigned long addr)); | | bool containsAddressInclusive(unsigned long addr); | |
| | | | |
| /** BPatch_basicBlockLoop::getBackEdge */ | | /** BPatch_basicBlockLoop::getBackEdge */ | |
| /** return a back edge that defines this loop */ | | /** return a back edge that defines this loop */ | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_edge *,getBackEdge,()); | | BPatch_edge * getBackEdge(); | |
| | | | |
| /** BPatch_basicBlockLoop::getBackEdges */ | | /** BPatch_basicBlockLoop::getBackEdges */ | |
| /** Sets edges to the set of back edges that define this loop, | | /** Sets edges to the set of back edges that define this loop, | |
| returns the number of back edges that define this loop */ | | returns the number of back edges that define this loop */ | |
|
| API_EXPORT(Int, (edges), | | int getBackEdges(BPatch_Vector<BPatch_edge*> &edges); | |
| int,getBackEdges,(BPatch_Vector<BPatch_edge*> &edges)); | | | |
| | | | |
| /** BPatch_basicBlockLoop::getContainedLoops */ | | /** BPatch_basicBlockLoop::getContainedLoops */ | |
| /** returns vector of contained loops */ | | /** returns vector of contained loops */ | |
|
| API_EXPORT(Int, (loops), | | | |
| | | | |
|
| bool,getContainedLoops,(BPatch_Vector<BPatch_basicBlockLoop*> &loop
s)); | | bool getContainedLoops(BPatch_Vector<BPatch_basicBlockLoop*> &loops
); | |
| | | | |
| /** BPatch_basicBlockLoop::getOuterLoops */ | | /** BPatch_basicBlockLoop::getOuterLoops */ | |
| /** returns vector of outer contained loops */ | | /** returns vector of outer contained loops */ | |
|
| API_EXPORT(Int, (loops), | | | |
| | | | |
|
| bool,getOuterLoops,(BPatch_Vector<BPatch_basicBlockLoop*> &loops) ); | | bool getOuterLoops(BPatch_Vector<BPatch_basicBlockLoop*> &loops); | |
| | | | |
| /** BPatch_basicBlockLoop::getLoopBasicBlocks */ | | /** BPatch_basicBlockLoop::getLoopBasicBlocks */ | |
| /** returns all basic blocks in the loop */ | | /** returns all basic blocks in the loop */ | |
|
| API_EXPORT(Int, (blocks), | | | |
| | | | |
|
| bool,getLoopBasicBlocks,(BPatch_Vector<BPatch_basicBlock*> &blocks)
); | | bool getLoopBasicBlocks(BPatch_Vector<BPatch_basicBlock*> &blocks); | |
| | | | |
| /** BPatch_basicBlockLoop::getLoopBasicBlocksExclusive */ | | /** BPatch_basicBlockLoop::getLoopBasicBlocksExclusive */ | |
| /** returns all basic blocks in this loop, exluding the blocks | | /** returns all basic blocks in this loop, exluding the blocks | |
| of its sub loops. */ | | of its sub loops. */ | |
|
| API_EXPORT(Int, (blocks), | | | |
| | | | |
|
| bool,getLoopBasicBlocksExclusive,(BPatch_Vector<BPatch_basicBlock*>
&blocks)); | | bool getLoopBasicBlocksExclusive(BPatch_Vector<BPatch_basicBlock*>
&blocks); | |
| | | | |
| /** does this loop or its subloops contain the given block? */ | | /** does this loop or its subloops contain the given block? */ | |
|
| API_EXPORT(Int, (b), | | | |
| | | | |
|
| bool,hasBlock,(BPatch_basicBlock *b)); | | bool hasBlock(BPatch_basicBlock *b); | |
| | | | |
| /** does this loop contain the given block? */ | | /** does this loop contain the given block? */ | |
|
| API_EXPORT(Int, (b), | | | |
| | | | |
|
| bool,hasBlockExclusive,(BPatch_basicBlock *b)); | | bool hasBlockExclusive(BPatch_basicBlock *b); | |
| | | | |
| /** BPatch_basicBlockLoop::hasAncestor */ | | /** BPatch_basicBlockLoop::hasAncestor */ | |
| /** returns true if this loop is a descendant of the given loop */ | | /** returns true if this loop is a descendant of the given loop */ | |
|
| API_EXPORT(Int, (loop), | | | |
| | | | |
|
| bool,hasAncestor,(BPatch_basicBlockLoop *loop)); | | bool hasAncestor(BPatch_basicBlockLoop *loop); | |
| | | | |
| /** returns the flow graph this loop is in */ | | /** returns the flow graph this loop is in */ | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_flowGraph *,getFlowGraph,()); | | BPatch_flowGraph * getFlowGraph(); | |
| | | | |
| /** BPatch_basicBlockLoop::getLoopHead */ | | /** BPatch_basicBlockLoop::getLoopHead */ | |
| /** returns the head basic block of the loop */ | | /** returns the head basic block of the loop */ | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_basicBlock *,getLoopHead,()); | | BPatch_basicBlock * getLoopHead(); | |
| | | | |
| /** BPatch_basicBlockLoop::getLoopIterators */ | | /** BPatch_basicBlockLoop::getLoopIterators */ | |
| /** method that returns the variables used as iterator */ | | /** method that returns the variables used as iterator */ | |
| /** not implemented yet */ | | /** not implemented yet */ | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_Set<BPatch_variableExpr*> *,getLoopIterators,()); | | std::set<BPatch_variableExpr*> * getLoopIterators(); | |
| | | | |
| /** BPatch_basicBlockLoop::~BPatch_basicBlockLoop */ | | /** BPatch_basicBlockLoop::~BPatch_basicBlockLoop */ | |
| /** destructor for the class */ | | /** destructor for the class */ | |
| | | | |
|
| public: ~BPatch_basicBlockLoop() { } | | ~BPatch_basicBlockLoop() { } | |
| | | | |
| | | std::string format() const; | |
| | | | |
| private: | | private: | |
| // internal use only | | // internal use only | |
| /** constructor of class */ | | /** constructor of class */ | |
| BPatch_basicBlockLoop(BPatch_flowGraph *); | | BPatch_basicBlockLoop(BPatch_flowGraph *); | |
| | | | |
| /** constructor of the class */ | | /** constructor of the class */ | |
| BPatch_basicBlockLoop(BPatch_edge *, BPatch_flowGraph *); | | BPatch_basicBlockLoop(BPatch_edge *, BPatch_flowGraph *); | |
| | | | |
| /** get either contained or outer loops, determined by outerMostOnly
*/ | | /** get either contained or outer loops, determined by outerMostOnly
*/ | |
| | | | |
End of changes. 33 change blocks. |
| 38 lines changed or deleted | | 19 lines changed or added | |
|
| BPatch_flowGraph.h | | BPatch_flowGraph.h | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| #define _BPatch_flowGraph_h_ | | #define _BPatch_flowGraph_h_ | |
| | | | |
| #include <string> | | #include <string> | |
| #include <set> | | #include <set> | |
| #include "Annotatable.h" | | #include "Annotatable.h" | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_basicBlock.h" | | #include "BPatch_basicBlock.h" | |
| #include "BPatch_basicBlockLoop.h" | | #include "BPatch_basicBlockLoop.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_loopTreeNode.h" | | #include "BPatch_loopTreeNode.h" | |
| #include "BPatch_edge.h" | | #include "BPatch_edge.h" | |
| | | | |
| class func_instance; | | class func_instance; | |
| class AddressSpace; | | class AddressSpace; | |
| class BPatch_edge; | | class BPatch_edge; | |
| class edge_instance; | | class edge_instance; | |
| | | | |
| typedef BPatch_basicBlockLoop BPatch_loop; | | typedef BPatch_basicBlockLoop BPatch_loop; | |
| | | | |
| /** class which represents the control flow graph of a function | | /** class which represents the control flow graph of a function | |
| * in a executable code. | | * in a executable code. | |
| * | | * | |
| * @see BPatch_basicBlock | | * @see BPatch_basicBlock | |
| * @see BPatch_basicBlockLoop | | * @see BPatch_basicBlockLoop | |
| */ | | */ | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_flowGraph | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_flowGraph : | | class BPATCH_DLL_EXPORT BPatch_flowGraph : | |
|
| public BPatch_eventLock, | | | |
| public Dyninst::AnnotatableSparse | | public Dyninst::AnnotatableSparse | |
| { | | { | |
| friend class BPatch_basicBlock; | | friend class BPatch_basicBlock; | |
| friend class BPatch_edge; | | friend class BPatch_edge; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| friend class dominatorCFG; | | friend class dominatorCFG; | |
| friend class func_instance; // This is illegal here... keeps us from havi
ng to | | friend class func_instance; // This is illegal here... keeps us from havi
ng to | |
| // have a public constructor... PDSEP | | // have a public constructor... PDSEP | |
| friend std::ostream& operator<<(std::ostream&,BPatch_flowGraph&); | | friend std::ostream& operator<<(std::ostream&,BPatch_flowGraph&); | |
| friend void dfsCreateLoopHierarchy(BPatch_loopTreeNode * parent, | | friend void dfsCreateLoopHierarchy(BPatch_loopTreeNode * parent, | |
| | | | |
| skipping to change at line 94 | | skipping to change at line 88 | |
| std::map<const block_instance *, BPatch_basicBlock *> blockMap_; | | std::map<const block_instance *, BPatch_basicBlock *> blockMap_; | |
| std::map<const edge_instance *, BPatch_edge *> edgeMap_; | | std::map<const edge_instance *, BPatch_edge *> edgeMap_; | |
| | | | |
| public: | | public: | |
| | | | |
| //BPatch_process *getBProcess() const { return bproc; } | | //BPatch_process *getBProcess() const { return bproc; } | |
| BPatch_addressSpace *getAddSpace() const { return addSpace; } | | BPatch_addressSpace *getAddSpace() const { return addSpace; } | |
| AddressSpace *getllAddSpace() const; | | AddressSpace *getllAddSpace() const; | |
| BPatch_function *getFunction() const { return func_; } | | BPatch_function *getFunction() const { return func_; } | |
| BPatch_module *getModule() const { return mod; } | | BPatch_module *getModule() const { return mod; } | |
|
| BPatch_basicBlock *findBlockByAddr(Dyninst::Address addr); | | | |
| BPatch_basicBlock *findBlock(block_instance *b); | | BPatch_basicBlock *findBlock(block_instance *b); | |
| BPatch_edge *findEdge(edge_instance *e); | | BPatch_edge *findEdge(edge_instance *e); | |
| void invalidate(); // invoked when additional parsing takes place | | void invalidate(); // invoked when additional parsing takes place | |
| // End of deprecated function | | // End of deprecated function | |
| | | | |
| // Functions for use by Dyninst users | | // Functions for use by Dyninst users | |
| | | | |
|
| API_EXPORT_DTOR(_dtor, (), | | ~BPatch_flowGraph(); | |
| ~,BPatch_flowGraph,()); | | | |
| | | | |
| /** returns the set of all basic blocks in the CFG */ | | /** returns the set of all basic blocks in the CFG */ | |
|
| API_EXPORT(Int, (blocks), | | bool getAllBasicBlocks(BPatch_Set<BPatch_basicBlock*> &blocks); | |
| bool,getAllBasicBlocks,(BPatch_Set<BPatch_basicBlock*> &blocks)); | | bool getAllBasicBlocks(std::set<BPatch_basicBlock *> &blocks); | |
| | | | |
| API_EXPORT(STL, (blocks), | | | |
| bool, getAllBasicBlocks,(std::set<BPatch_basicBlock *> &blocks)); | | | |
| | | | |
| /** returns the vector of entry basic blocks to CFG */ | | /** returns the vector of entry basic blocks to CFG */ | |
|
| API_EXPORT(Int, (blocks), | | bool getEntryBasicBlock(BPatch_Vector<BPatch_basicBlock*> &blocks); | |
| bool,getEntryBasicBlock,(BPatch_Vector<BPatch_basicBlock*> &blocks)); | | | |
| | | | |
| /** returns the vector of exit basic blocks to CFG */ | | /** returns the vector of exit basic blocks to CFG */ | |
|
| API_EXPORT(Int, (blocks), | | bool getExitBasicBlock(BPatch_Vector<BPatch_basicBlock*> &blocks); | |
| bool,getExitBasicBlock,(BPatch_Vector<BPatch_basicBlock*> &blocks)); | | | |
| | | /** Finds the block containing a specific instruction. Warning: | |
| | | this method is slow! **/ | |
| | | BPatch_basicBlock *findBlockByAddr(Dyninst::Address addr); | |
| | | | |
| /** returns the vector of loops in CFG */ | | /** returns the vector of loops in CFG */ | |
|
| API_EXPORT(Int, (loops), | | bool getLoops(BPatch_Vector<BPatch_basicBlockLoop*> &loops); | |
| bool,getLoops,(BPatch_Vector<BPatch_basicBlockLoop*> &loops)); | | | |
| | | | |
| /** returns a vector of outer loops in the CFG */ | | /** returns a vector of outer loops in the CFG */ | |
|
| API_EXPORT(Int, (loops), | | bool getOuterLoops(BPatch_Vector<BPatch_basicBlockLoop*> &loops); | |
| bool,getOuterLoops,(BPatch_Vector<BPatch_basicBlockLoop*> &loops)); | | | |
| | | | |
| /** creates the source line blocks of all blocks in CFG. | | /** creates the source line blocks of all blocks in CFG. | |
| * without calling this method line info is not available | | * without calling this method line info is not available | |
| */ | | */ | |
|
| API_EXPORT(Int, (), | | bool createSourceBlocks(); | |
| bool,createSourceBlocks,()); | | | |
| | | | |
| /** fills the dominator and immediate-dom information of basic blocks. | | /** fills the dominator and immediate-dom information of basic blocks. | |
| * without calling this method dominator info is not available | | * without calling this method dominator info is not available | |
| */ | | */ | |
|
| API_EXPORT_V(Int, (), | | void fillDominatorInfo(); | |
| void,fillDominatorInfo,()); | | | |
| | | | |
| /** same as above, but for postdominator/immediate-postdom info | | /** same as above, but for postdominator/immediate-postdom info | |
| */ | | */ | |
|
| API_EXPORT_V(Int, (), | | void fillPostDominatorInfo(); | |
| void,fillPostDominatorInfo,()); | | | |
| | | | |
| /** return root of loop hierarchy */ | | /** return root of loop hierarchy */ | |
|
| API_EXPORT(Int, (), | | BPatch_loopTreeNode * getLoopTree(); | |
| BPatch_loopTreeNode *,getLoopTree,()); | | | |
| | | | |
| /** returns true if the cfg contains dynamic callsites */ | | /** returns true if the cfg contains dynamic callsites */ | |
|
| API_EXPORT(Int, (), | | bool containsDynamicCallsites(); | |
| bool,containsDynamicCallsites,()); | | | |
| | | | |
| // for debugging, print loops with line numbers to stderr | | // for debugging, print loops with line numbers to stderr | |
|
| API_EXPORT_V(Int, (), | | void printLoops(); | |
| void,printLoops,()); | | | |
| | | | |
|
| API_EXPORT(Int, (name), | | BPatch_basicBlockLoop * findLoop(const char *name); | |
| BPatch_basicBlockLoop *,findLoop,(const char *name)); | | | |
| | | | |
| // Deprecated - this should not be an API method | | // Deprecated - this should not be an API method | |
|
| //API_EXPORT_V(Int, (), | | //void, initLivenessInfo(); | |
| //void, initLivenessInfo,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isValid(); | |
| bool,isValid,()); | | | |
| | | | |
| /* | | /* | |
|
| API_EXPORT(Int, (edge), | | BPatch_point * createInstPointAtEdge(BPatch_edge *edge); | |
| BPatch_point *,createInstPointAtEdge,(BPatch_edge *edge)); | | | |
| */ | | */ | |
| // Deprecated... use BPatch_edge->point() instead | | // Deprecated... use BPatch_edge->point() instead | |
| | | | |
| /** find instrumentation points specified by loc, add to points*/ | | /** find instrumentation points specified by loc, add to points*/ | |
|
| API_EXPORT(Int, (loc, loop), | | BPatch_Vector<BPatch_point*> * | |
| BPatch_Vector<BPatch_point*> *, | | findLoopInstPoints(const BPatch_procedureLocation loc, | |
| findLoopInstPoints,(CONST_EXPORT BPatch_procedureLocation loc, | | BPatch_basicBlockLoop *loop); | |
| BPatch_basicBlockLoop *loop)); | | | |
| | | | |
| private: | | private: | |
| | | | |
| BPatch_function *func_; | | BPatch_function *func_; | |
| BPatch_addressSpace *addSpace; | | BPatch_addressSpace *addSpace; | |
| // BPatch_process *bproc; | | // BPatch_process *bproc; | |
| BPatch_module *mod; | | BPatch_module *mod; | |
| | | | |
| /** set of loops contained in control flow graph */ | | /** set of loops contained in control flow graph */ | |
|
| BPatch_Set<BPatch_basicBlockLoop*> *loops; | | std::set<BPatch_basicBlockLoop*> *loops; | |
| | | | |
| /** set of all basic blocks that control flow graph has */ | | /** set of all basic blocks that control flow graph has */ | |
|
| BPatch_Set<BPatch_basicBlock*> allBlocks; | | std::set<BPatch_basicBlock*> allBlocks; | |
| | | | |
| /** root of the tree of loops */ | | /** root of the tree of loops */ | |
| BPatch_loopTreeNode *loopRoot; | | BPatch_loopTreeNode *loopRoot; | |
| | | | |
| /** set of back edges */ | | /** set of back edges */ | |
|
| BPatch_Set<BPatch_edge*> backEdges; | | std::set<BPatch_edge*> backEdges; | |
| | | | |
| /** flag that keeps whether dominator info is initialized*/ | | /** flag that keeps whether dominator info is initialized*/ | |
| bool isDominatorInfoReady; | | bool isDominatorInfoReady; | |
| | | | |
| /** flag that keeps whether postdominator info is initialized*/ | | /** flag that keeps whether postdominator info is initialized*/ | |
| bool isPostDominatorInfoReady; | | bool isPostDominatorInfoReady; | |
| | | | |
| /** flag that keeps whether source block info is initialized*/ | | /** flag that keeps whether source block info is initialized*/ | |
| bool isSourceBlockInfoReady; | | bool isSourceBlockInfoReady; | |
| | | | |
| | | | |
| skipping to change at line 219 | | skipping to change at line 198 | |
| /** create the tree of loops/callees for this flow graph */ | | /** create the tree of loops/callees for this flow graph */ | |
| void createLoopHierarchy(); | | void createLoopHierarchy(); | |
| | | | |
| void dfsVisitWithTargets(BPatch_basicBlock*,int*); | | void dfsVisitWithTargets(BPatch_basicBlock*,int*); | |
| | | | |
| void dfsVisitWithSources(BPatch_basicBlock*,int*); | | void dfsVisitWithSources(BPatch_basicBlock*,int*); | |
| | | | |
| void findAndDeleteUnreachable(); | | void findAndDeleteUnreachable(); | |
| | | | |
| static void findBBForBackEdge(BPatch_edge*, | | static void findBBForBackEdge(BPatch_edge*, | |
|
| BPatch_Set<BPatch_basicBlock*>&); | | std::set<BPatch_basicBlock*>&); | |
| | | | |
| void getLoopsByNestingLevel(BPatch_Vector<BPatch_basicBlockLoop*>&, | | void getLoopsByNestingLevel(BPatch_Vector<BPatch_basicBlockLoop*>&, | |
| bool outerMostOnly); | | bool outerMostOnly); | |
| | | | |
| bool dfsInsertCalleeIntoLoopHierarchy(BPatch_loopTreeNode *node, | | bool dfsInsertCalleeIntoLoopHierarchy(BPatch_loopTreeNode *node, | |
| func_instance *func, | | func_instance *func, | |
| unsigned long addr); | | unsigned long addr); | |
| | | | |
| void insertCalleeIntoLoopHierarchy(func_instance * func, unsigned long ad
dr); | | void insertCalleeIntoLoopHierarchy(func_instance * func, unsigned long ad
dr); | |
| | | | |
| | | | |
End of changes. 25 change blocks. |
| 50 lines changed or deleted | | 29 lines changed or added | |
|
| BPatch_function.h | | BPatch_function.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| #ifndef _BPatch_function_h_ | | #ifndef _BPatch_function_h_ | |
| #define _BPatch_function_h_ | | #define _BPatch_function_h_ | |
| | | | |
| #include "Annotatable.h" | | #include "Annotatable.h" | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| #include "BPatch_type.h" | | #include "BPatch_type.h" | |
| #include "BPatch_module.h" | | #include "BPatch_module.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_memoryAccess_NP.h" | | #include "BPatch_memoryAccess_NP.h" | |
| //#include "BPatch_dependenceGraphNode.h" | | //#include "BPatch_dependenceGraphNode.h" | |
| // class BPatch_dependenceGraphNode; | | // class BPatch_dependenceGraphNode; | |
| | | | |
| class func_instance; | | class func_instance; | |
| class InstrucIter; | | class InstrucIter; | |
| | | | |
| class BPatch_localVarCollection; | | class BPatch_localVarCollection; | |
| class BPatch_function; | | class BPatch_function; | |
| class BPatch_point; | | class BPatch_point; | |
| class BPatch_flowGraph; | | class BPatch_flowGraph; | |
| | | | |
| class BPatchTranslatorBase; | | class BPatchTranslatorBase; | |
| class ParameterType; | | class ParameterType; | |
| class ReturnParameterType; | | class ReturnParameterType; | |
| class BPatch_function; | | class BPatch_function; | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
| namespace ParseAPI { | | namespace ParseAPI { | |
| class Function; | | class Function; | |
|
| PARSER_EXPORT Function *convert(const BPatch_function *); | | BPATCH_DLL_EXPORT Function *convert(const BPatch_function *); | |
| }; | | }; | |
| namespace PatchAPI { | | namespace PatchAPI { | |
| class PatchFunction; | | class PatchFunction; | |
|
| PARSER_EXPORT PatchFunction *convert(const BPatch_function *); | | BPATCH_DLL_EXPORT PatchFunction *convert(const BPatch_function *); | |
| }; | | }; | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_function | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_function : | | class BPATCH_DLL_EXPORT BPatch_function : | |
| public BPatch_sourceObj, | | public BPatch_sourceObj, | |
|
| public BPatch_eventLock, | | | |
| public Dyninst::AnnotatableSparse | | public Dyninst::AnnotatableSparse | |
| { | | { | |
| friend class BPatch_flowGraph; | | friend class BPatch_flowGraph; | |
| friend class InstrucIter; | | friend class InstrucIter; | |
| friend class BPatch_basicBlock; | | friend class BPatch_basicBlock; | |
| friend class BPatch_asyncEventHandler; | | friend class BPatch_asyncEventHandler; | |
| friend class BPatch_image; | | friend class BPatch_image; | |
| friend class BPatch_thread; | | friend class BPatch_thread; | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_binaryEdit; | | friend class BPatch_binaryEdit; | |
| | | | |
| skipping to change at line 182 | | skipping to change at line 175 | |
| // BPatch_storageClass _sc = BPatch_storageFrameOffset); | | // BPatch_storageClass _sc = BPatch_storageFrameOffset); | |
| void fixupUnknown(BPatch_module *); | | void fixupUnknown(BPatch_module *); | |
| | | | |
| // This isn't so much for internal use only, but it *should* | | // This isn't so much for internal use only, but it *should* | |
| // remain undocumented for now. | | // remain undocumented for now. | |
| bool containsSharedBlocks(); | | bool containsSharedBlocks(); | |
| | | | |
| // End of functions for internal use only | | // End of functions for internal use only | |
| | | | |
| // For users of the library: | | // For users of the library: | |
|
| API_EXPORT(Str, (), std::string, getName, ()); | | | |
| API_EXPORT(Str, (), std::string, getDemangledName, ()); | | | |
| API_EXPORT(Str, (), std::string, getMangledName, ()); | | | |
| API_EXPORT(Str, (), std::string, getTypedName, ()); | | | |
| API_EXPORT(Str, (names), bool, getNames, (std::vector<std::string> & | | | |
| names)); | | | |
| API_EXPORT(Str, (names), bool, getDemangledNames, (std::vector<std:: | | | |
| string> &names)); | | | |
| API_EXPORT(Str, (names), bool, getMangledNames, (std::vector<std::st | | | |
| ring> &names)); | | | |
| API_EXPORT(Str, (names), bool, getTypedNames, (std::vector<std::stri | | | |
| ng> &names)); | | | |
| | | | |
| // BPatch_function::getName | | // BPatch_function::getName | |
| // Returns <demangled> name of function | | // Returns <demangled> name of function | |
|
| API_EXPORT(Buffer, (s, len), | | | |
| | | | |
|
| char *,getName,(char *s, int len)); | | char * getName(char *s, int len); | |
| | | | |
| // String interface to mangled name | | // String interface to mangled name | |
|
| | | std::string getName(); | |
| | | std::string getMangledName(); | |
| | | std::string getDemangledName(); | |
| | | std::string getTypedName(); | |
| | | bool getNames(std::vector<std::string> &names); | |
| | | bool getDemangledNames(std::vector<std::string> &names); | |
| | | bool getMangledNames(std::vector<std::string> &names); | |
| | | bool getTypedNames(std::vector<std::string> &names); | |
| | | | |
| // BPatch_function::getMangledName | | // BPatch_function::getMangledName | |
| // Returns mangled name of function, same as getName for non-c++ mutat
ees | | // Returns mangled name of function, same as getName for non-c++ mutat
ees | |
|
| API_EXPORT(Int, (s, len), | | | |
| | | | |
|
| char *,getMangledName,(char *s, int len)); | | char * getMangledName(char *s, int len); | |
| | | | |
| // BPatch_function::getTypedName | | // BPatch_function::getTypedName | |
| // Returns demanged name of function (with type string), may be empty | | // Returns demanged name of function (with type string), may be empty | |
|
| API_EXPORT(Int, (s, len), | | | |
| | | | |
|
| char *,getTypedName,(char *s, int len)); | | char * getTypedName(char *s, int len); | |
| | | | |
| // BPatch_function::getNames | | // BPatch_function::getNames | |
| // Adds all names of the function (inc. weak symbols) to the | | // Adds all names of the function (inc. weak symbols) to the | |
| // provided vector. Names are represented as const char *s, | | // provided vector. Names are represented as const char *s, | |
| // and do not require cleanup by the user. | | // and do not require cleanup by the user. | |
| | | | |
|
| API_EXPORT(Int, (names), | | bool getNames(BPatch_Vector<const char *> &names); | |
| bool, getNames, (BPatch_Vector<const char *> &names)); | | | |
| | | | |
| // BPatch_function::getMangledNames | | // BPatch_function::getMangledNames | |
| // Adds all mangled names of the function (inc. weak symbols) to | | // Adds all mangled names of the function (inc. weak symbols) to | |
| // the provided vector. Names are represented as const char *s, | | // the provided vector. Names are represented as const char *s, | |
| // and do not require cleanup by the user. | | // and do not require cleanup by the user. | |
| | | | |
|
| API_EXPORT(Int, (names), | | bool getMangledNames(BPatch_Vector<const char *> &names); | |
| bool, getMangledNames, (BPatch_Vector<const char *> &names)); | | | |
| | | | |
| // BPatch_function::getBaseAddr | | // BPatch_function::getBaseAddr | |
| // Returns base address of function | | // Returns base address of function | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| void *,getBaseAddr,(void)); | | void * getBaseAddr(void); | |
| | | | |
| // BPatch_function::getReturnType | | // BPatch_function::getReturnType | |
| // Returns the <BPatch_type> return type of this function | | // Returns the <BPatch_type> return type of this function | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_type * getReturnType(); | |
| | | | |
| BPatch_type *,getReturnType,()); | | | |
| | | | |
| // BPatch_function::getModule | | // BPatch_function::getModule | |
| // Returns the BPatch_module to which this function belongs | | // Returns the BPatch_module to which this function belongs | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_module * getModule(); | |
| | | | |
| BPatch_module *,getModule,()); | | | |
| | | | |
| // BPatch_function::getParams | | // BPatch_function::getParams | |
| // Returns a vector of BPatch_localVar, representing this function's p
arameters | | // Returns a vector of BPatch_localVar, representing this function's p
arameters | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_Vector<BPatch_localVar *> * getParams(); | |
| | | | |
| BPatch_Vector<BPatch_localVar *> *,getParams,()); | | | |
| | | | |
| // BPatch_function::getVars | | // BPatch_function::getVars | |
| // Returns a vector of local variables in this functions | | // Returns a vector of local variables in this functions | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_Vector<BPatch_localVar *> * getVars(); | |
| | | | |
| BPatch_Vector<BPatch_localVar *> *,getVars,()); | | | |
| | | | |
| // BPatch_function::findPoint | | // BPatch_function::findPoint | |
| // Returns a vector of inst points, corresponding to the given BPatch_
procedureLocation | | // Returns a vector of inst points, corresponding to the given BPatch_
procedureLocation | |
| | | | |
|
| API_EXPORT(Int, (loc), | | BPatch_Vector<BPatch_point *> * findPoint(const BPatch_procedureLocatio | |
| | | n loc); | |
| BPatch_Vector<BPatch_point *> *,findPoint,(CONST_EXPORT BPatch_procedur | | | |
| eLocation loc)); | | | |
| | | | |
| // BPatch_function::findPoint | | // BPatch_function::findPoint | |
| // Returns a vector of inst points, corresponding to the given set of
op codes | | // Returns a vector of inst points, corresponding to the given set of
op codes | |
| | | | |
|
| API_EXPORT(ByOp, (ops), | | BPatch_Vector<BPatch_point *> * findPoint(const BPatch_Set<BPatch_opCod | |
| | | e>& ops); | |
| BPatch_Vector<BPatch_point *> *,findPoint,(const BPatch_Set<BPatch_opCo | | BPatch_Vector<BPatch_point *> * findPoint(const std::set<BPatch_opCode> | |
| de>& ops)); | | & ops); | |
| | | | |
| // BPatch_function::findPoint | | // BPatch_function::findPoint | |
| // | | // | |
| // Returns a BPatch_point that corresponds with the provided address.
Returns NULL | | // Returns a BPatch_point that corresponds with the provided address.
Returns NULL | |
| // if the address does not correspond with an instruction. | | // if the address does not correspond with an instruction. | |
|
| API_EXPORT(Int, (addr), | | BPatch_point * findPoint(Dyninst::Address addr); | |
| BPatch_point *, findPoint, (Dyninst::Address addr)); | | | |
| | | | |
| // BPatch_function::findLocalVar | | // BPatch_function::findLocalVar | |
| // Returns a BPatch_localVar, if a match for <name> is found | | // Returns a BPatch_localVar, if a match for <name> is found | |
| | | | |
|
| API_EXPORT(Int, (name), | | BPatch_localVar * findLocalVar(const char * name); | |
| | | | |
| BPatch_localVar *,findLocalVar,(const char * name)); | | | |
| | | | |
| // BPatch_function::findLocalParam | | // BPatch_function::findLocalParam | |
| // Returns a BPatch_localVar, if a match for <name> is found | | // Returns a BPatch_localVar, if a match for <name> is found | |
| | | | |
|
| API_EXPORT(Int, (name), | | BPatch_localVar * findLocalParam(const char * name); | |
| | | | |
| BPatch_localVar *,findLocalParam,(const char * name)); | | | |
| | | | |
| // BPatch_function::findVariable | | // BPatch_function::findVariable | |
| // Returns a set of variables matching <name> at the scope of this fun
ction | | // Returns a set of variables matching <name> at the scope of this fun
ction | |
| // -- or global scope, if nothing found in this scope | | // -- or global scope, if nothing found in this scope | |
| | | | |
|
| API_EXPORT(Int, (name), | | BPatch_Vector<BPatch_variableExpr *> * findVariable(const char *name); | |
| BPatch_Vector<BPatch_variableExpr *> *,findVariable,(const char *name)) | | | |
| ; | | | |
| | | | |
|
| API_EXPORT(Int, (name, vars), | | bool findVariable(const char *name, BPatch_Vector<BPatch_variableExpr* | |
| bool, findVariable,(const char *name, BPatch_Vector<BPatch_variableExpr | | > &vars); | |
| *> &vars)); | | | |
| | | | |
| // BPatch_function::getVariables | | // BPatch_function::getVariables | |
| // This returns false, and should probably not exist. See getVars. | | // This returns false, and should probably not exist. See getVars. | |
| // is this defined, what variables should be returned?? | | // is this defined, what variables should be returned?? | |
| // FIXME (delete me) | | // FIXME (delete me) | |
| | | | |
|
| API_EXPORT(Int, (vect), | | bool getVariables(BPatch_Vector<BPatch_variableExpr *> &vect); | |
| | | | |
| bool,getVariables,(BPatch_Vector<BPatch_variableExpr *> &vect)); | | | |
| | | | |
| // BPatch_function::getModuleName | | // BPatch_function::getModuleName | |
| // Returns name of module this function belongs to | | // Returns name of module this function belongs to | |
| | | | |
|
| API_EXPORT(Int, (name, maxLen), | | char * getModuleName(char *name, int maxLen); | |
| | | | |
| char *,getModuleName,(char *name, int maxLen)); | | | |
| | | | |
| // BPatch_function::isInstrumentable | | // BPatch_function::isInstrumentable | |
| // | | // | |
| // Returns true if the function is instrumentable. | | // Returns true if the function is instrumentable. | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isInstrumentable(); | |
| | | | |
| bool,isInstrumentable,()); | | | |
| | | | |
| // BPatch_function::isSharedLib | | // BPatch_function::isSharedLib | |
| // Returns true if this function lives in a shared library | | // Returns true if this function lives in a shared library | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isSharedLib(); | |
| | | | |
| bool,isSharedLib,()); | | | |
| | | | |
| // BPatch_function::getCFG | | // BPatch_function::getCFG | |
| // | | // | |
| // method to create the control flow graph for the function | | // method to create the control flow graph for the function | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_flowGraph* getCFG(); | |
| | | | |
| BPatch_flowGraph*,getCFG,()); | | | |
| | | | |
|
| API_EXPORT(Int, (name, isPrimary, isMangled), | | const char * addName(const char *name, bool isPrimary = true, bool isM | |
| const char *, addName, (const char *name, bool isPrimary = true, bool i | | angled = false); | |
| sMangled = false)); | | | |
| | | | |
| // Return native pointer to the function. | | // Return native pointer to the function. | |
| // Allocates and returns a special type of BPatch_variableExpr. | | // Allocates and returns a special type of BPatch_variableExpr. | |
|
| API_EXPORT( Int, (), BPatch_variableExpr *, getFunctionRef, () ); | | | |
| | | | |
| // Get all functions that share a block (or any code, but it will | | // Get all functions that share a block (or any code, but it will | |
| // always be a block) with this function. | | // always be a block) with this function. | |
|
| API_EXPORT( Int, (funcs), bool, findOverlapping, (BPatch_Vector<BPatch_
function *> &funcs)); | | | |
| | | | |
| // Get the underlying ParseAPI Function | | // Get the underlying ParseAPI Function | |
| operator Dyninst::ParseAPI::Function *() const; | | operator Dyninst::ParseAPI::Function *() const; | |
| | | | |
| // Get the underlying PatchAPI Function | | // Get the underlying PatchAPI Function | |
| operator Dyninst::PatchAPI::PatchFunction *() const; | | operator Dyninst::PatchAPI::PatchFunction *() const; | |
| | | | |
|
| API_EXPORT(Int, (start, end), | | bool getAddressRange(void * &start, void * &end); | |
| bool,getAddressRange,(void * &start, void * &end)); | | | |
| | | | |
|
| API_EXPORT(Int, (start, end), | | bool getAddressRange(Dyninst::Address &start, Dyninst::Addre | |
| bool,getAddressRange,(Dyninst::Address &start, Dyninst::Addr | | ss &end); | |
| ess &end)); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned int getFootprint(); | |
| unsigned int,getFootprint,()); | | BPatch_variableExpr *getFunctionRef(); | |
| | | bool findOverlapping(BPatch_Vector<BPatch_function *> &funcs); | |
| | | | |
| }; | | }; | |
| | | | |
| #endif /* _BPatch_function_h_ */ | | #endif /* _BPatch_function_h_ */ | |
| | | | |
End of changes. 39 change blocks. |
| 94 lines changed or deleted | | 45 lines changed or added | |
|
| BPatch_image.h | | BPatch_image.h | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_image_h_ | | #ifndef _BPatch_image_h_ | |
| #define _BPatch_image_h_ | | #define _BPatch_image_h_ | |
| | | | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_sourceObj.h" | | #include "BPatch_sourceObj.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_module.h" | | #include "BPatch_module.h" | |
| #include "BPatch_type.h" | | #include "BPatch_type.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_process.h" | | #include "BPatch_process.h" | |
| #include "BPatch_binaryEdit.h" | | #include "BPatch_binaryEdit.h" | |
| #include "BPatch_parRegion.h" | | #include "BPatch_parRegion.h" | |
| #include "dyntypes.h" | | #include "dyntypes.h" | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <map> | | #include <map> | |
| | | | |
| typedef bool (*BPatchFunctionNameSieve)(const char *test,void *data); | | typedef bool (*BPatchFunctionNameSieve)(const char *test,void *data); | |
| class image; | | class image; | |
| class int_variable; | | class int_variable; | |
| class BPatch_point; | | class BPatch_point; | |
| class BPatch_object; | | class BPatch_object; | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| | | | |
| typedef enum BPatch_LpModel { | | typedef enum BPatch_LpModel { | |
|
| LP32, /* 32 bit image */ | | LP32, /* 32 bit image */ | |
| LP64, /* 64 bit image */ | | LP64, /* 64 bit image */ | |
| UNKNOWN_LP /* cannot be determined */ | | UNKNOWN_LP /* cannot be determined */ | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
| class BPatch_statement; | | class BPatch_statement; | |
| class BPatch_image; | | class BPatch_image; | |
|
| | | class BPatch_object_getMod; | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
|
| namespace PatchAPI { | | namespace PatchAPI { | |
| class PatchMgr; | | class PatchMgr; | |
| typedef boost::shared_ptr<PatchMgr> PatchMgrPtr; | | typedef boost::shared_ptr<PatchMgr> PatchMgrPtr; | |
| PatchMgrPtr convert(const BPatch_image *); | | BPATCH_DLL_EXPORT PatchMgrPtr convert(const BPatch_image *); | |
| } | | } | |
| } | | } | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_image: public BPatch_sourceObj { | |
| #undef DYNINST_CLASS_NAME | | friend class BPatch; // registerLoaded... callbacks | |
| #endif | | friend class BPatch_module; // access to findOrCreate... | |
| #define DYNINST_CLASS_NAME BPatch_image | | friend class BPatch_object; // Also access to findOrCreate | |
| | | friend class BPatch_object_getMod; | |
| class BPATCH_DLL_EXPORT BPatch_image: public BPatch_sourceObj, public BPatc | | friend class BPatch_process; | |
| h_eventLock { | | friend class BPatch_addressSpace; | |
| friend class BPatch; // registerLoaded... callbacks | | friend class BPatch_binaryEdit; | |
| friend class BPatch_module; // access to findOrCreate... | | friend Dyninst::PatchAPI::PatchMgrPtr Dyninst::PatchAPI::convert(const BP | |
| friend class BPatch_process; | | atch_image *); | |
| friend class BPatch_addressSpace; | | | |
| friend class BPatch_binaryEdit; | | | |
| friend Dyninst::PatchAPI::PatchMgrPtr Dyninst::PatchAPI::convert(const | | | |
| BPatch_image *); | | | |
| friend class BPatch_object; | | | |
| | | | |
|
| BPatch_variableExpr *findOrCreateVariable(int_variable *); | | BPatch_variableExpr *findOrCreateVariable(int_variable *); | |
| public: | | public: | |
| | | | |
|
| // The following functions are for internal use by the library only: | | // The following functions are for internal use by the library only: | |
| // As such, these functions are not locked. | | // As such, these functions are not locked. | |
| //BPatch_image(BPatch_process *_proc); | | //BPatch_image(BPatch_process *_proc); | |
| BPatch_image(BPatch_addressSpace *addSpace); | | BPatch_image(BPatch_addressSpace *addSpace); | |
| BPatch_image(); | | BPatch_image(); | |
| BPatch_module *findModule(mapped_module *base); | | BPatch_module *findModule(mapped_module *base); | |
| BPatch_object *findObject(mapped_object *base); | | BPatch_object *findObject(mapped_object *base); | |
| virtual ~BPatch_image(); | | virtual ~BPatch_image(); | |
| void getNewCodeRegions | | void getNewCodeRegions | |
| (std::vector<BPatch_function*>&newFuncs, | | (std::vector<BPatch_function*>&newFuncs, | |
| std::vector<BPatch_function*>&modFuncs); | | std::vector<BPatch_function*>&modFuncs); | |
| void clearNewCodeRegions(); | | void clearNewCodeRegions(); | |
| // End functions for internal use only | | // End functions for internal use only | |
| | | | |
| // BPatch_image::getThr | | // BPatch_image::getThr | |
| // | | // | |
| // return the BPatch_thread associated with this image | | // return the BPatch_thread associated with this image | |
| API_EXPORT(Int, (), | | BPatch_thread * getThr(); | |
| BPatch_thread *,getThr,()); | | | |
| | | // BPatch_image::getAddressSpace() | |
| // BPatch_image::getAddressSpace() | | // | |
| // | | // return the BPatch_addressSpace associated with this image | |
| // return the BPatch_addressSpace associated with this image | | BPatch_addressSpace * getAddressSpace(); | |
| API_EXPORT(Int, (), | | | |
| BPatch_addressSpace *,getAddressSpace,()); | | // BPatch_image::getProcess | |
| | | // | |
| // BPatch_image::getProcess | | // return the BPatch_process associated with this image | |
| // | | BPatch_process * getProcess(); | |
| // return the BPatch_process associated with this image | | | |
| API_EXPORT(Int, (), | | // BPatch_image::getSourceObj | |
| BPatch_process *,getProcess,()); | | // | |
| | | // fill a vector with children source objects (modules) | |
| // BPatch_image::getSourceObj | | | |
| // | | bool getSourceObj(BPatch_Vector<BPatch_sourceObj *> &sources); | |
| // fill a vector with children source objects (modules) | | | |
| API_EXPORT(Int, (sources), | | // BPatch_image::getObjParent | |
| | | // | |
| bool,getSourceObj,(BPatch_Vector<BPatch_sourceObj *> &sources)); | | // Return the parent of this image (always NULL since this is the top le | |
| | | vel) | |
| // BPatch_image::getObjParent | | | |
| // | | BPatch_sourceObj * getObjParent(); | |
| // Return the parent of this image (always NULL since this is the top | | | |
| level) | | // BPatch_image::getVariables | |
| API_EXPORT(Int, (), | | // | |
| | | // Returns the global variables defined in this image | |
| BPatch_sourceObj *,getObjParent,()); | | | |
| | | bool getVariables(BPatch_Vector<BPatch_variableExpr *> &vars); | |
| // BPatch_image::getVariables | | | |
| // | | // BPatch_image::getProcedures | |
| // Returns the global variables defined in this image | | // | |
| API_EXPORT(Int, (vars), | | // Returns a list of all procedures in the image upon success, | |
| | | // NULL upon failure | |
| bool,getVariables,(BPatch_Vector<BPatch_variableExpr *> &vars)); | | BPatch_Vector<BPatch_function *> * getProcedures(bool incUninstrumentable | |
| | | = false); | |
| // BPatch_image::getProcedures | | | |
| // | | bool getProcedures(BPatch_Vector<BPatch_function*> &procs, bool incUninst | |
| // Returns a list of all procedures in the image upon success, | | rumentable = false); | |
| // NULL upon failure | | | |
| API_EXPORT(Int, (incUninstrumentable), | | // BPatch_image::getParRegions | |
| BPatch_Vector<BPatch_function *> *,getProcedures,(bool incUninstrumenta | | // | |
| ble = false)); | | // Returns a list of all procedures in the image upon success, | |
| | | // NULL upon failure | |
| API_EXPORT(Int, (procs, incUninstrumentable), | | | |
| bool,getProcedures,(BPatch_Vector<BPatch_function*> &procs, bool incUni | | BPatch_Vector<BPatch_parRegion *> * | |
| nstrumentable = false)); | | getParRegions(bool incUninstrumentable = false); | |
| | | | |
| // BPatch_image::getParRegions | | // BPatch_image::getModules | |
| // | | // | |
| // Returns a list of all procedures in the image upon success, | | // Returns a vector of all modules in this image | |
| // NULL upon failure | | BPatch_Vector<BPatch_module *> * getModules(); | |
| API_EXPORT(Int, (incUninstrumentable), | | | |
| | | // BPatch_image::getObjects | |
| BPatch_Vector<BPatch_parRegion *> *, | | // | |
| getParRegions,(bool incUninstrumentable = false)); | | // Returns a vector of all objects in this image | |
| | | void getObjects(std::vector<BPatch_object *> &objs); | |
| // BPatch_image::getModules | | | |
| // | | bool getModules(BPatch_Vector<BPatch_module*> &mods); | |
| // Returns a vector of all modules in this image | | | |
| API_EXPORT(Int, (), | | // BPatch_image::findModule | |
| BPatch_Vector<BPatch_module *> *,getModules,()); | | // | |
| | | // Returns a module matching <name> if present in image, NULL if not fou | |
| // BPatch_image::getObjects | | nd | |
| // | | // if <substring_match> is set, the first module that has <name> as a su | |
| // Returns a vector of all objects in this image | | bstring | |
| API_EXPORT_V(Int, (objs), | | // of its name is returned (eg, to find "libpthread.so.1", search for "l | |
| void, getObjects, (std::vector<BPatch_object *> &objs)); | | ibpthread" | |
| | | // with substring_match set to true) | |
| API_EXPORT(Int, (mods), | | | |
| bool,getModules,(BPatch_Vector<BPatch_module*> &mods)); | | BPatch_module * findModule(const char *name, bool substring_match = false | |
| | | ); | |
| // BPatch_image::findModule | | | |
| // | | // BPatch_image::getGlobalVariables | |
| // Returns a module matching <name> if present in image, NULL if not f | | // | |
| ound | | // Returns the global variables defined in this image | |
| // if <substring_match> is set, the first module that has <name> as a | | | |
| substring | | BPatch_Vector<BPatch_variableExpr *> * getGlobalVariables(); | |
| // of its name is returned (eg, to find "libpthread.so.1", search for | | | |
| "libpthread" | | // BPatch_image::findFunction | |
| // with substring_match set to true) | | // | |
| API_EXPORT(Int, (name, substring_match), | | // Returns a vector of functions matching <name>, if <name> is a regular | |
| | | // expression, a (slower) regex search will be performed. | |
| BPatch_module *,findModule,(const char *name, bool substring_match = fa | | // Returns NULL on failure. | |
| lse)); | | | |
| | | BPatch_Vector<BPatch_function*> * findFunction(const char *name, | |
| // BPatch_image::getGlobalVariables | | BPatch_Vector<BPatch_functi | |
| // | | on*> &funcs, | |
| // Returns the global variables defined in this image | | bool showError=true, | |
| API_EXPORT(Int, (), | | bool regex_case_sensitive=t | |
| | | rue, | |
| BPatch_Vector<BPatch_variableExpr *> *,getGlobalVariables,()); | | bool incUninstrumentable = | |
| | | false); | |
| // BPatch_image::findFunction | | | |
| // | | // BPatch_image::findFunction | |
| // Returns a vector of functions matching <name>, if <name> is a regul | | // | |
| ar | | // Returns a vector of functions matching criterion specified by user de | |
| // expression, a (slower) regex search will be performed. | | fined | |
| // Returns NULL on failure. | | // callback function bpsieve. | |
| API_EXPORT(Int, (name, funcs, showError, regex_case_sensitive, incUnins | | | |
| trumentable), | | BPatch_Vector<BPatch_function *> * | |
| | | findFunction(BPatch_Vector<BPatch_function *> &funcs, | |
| BPatch_Vector<BPatch_function*> *,findFunction,(const char *name, | | BPatchFunctionNameSieve bpsieve, | |
| BPatch_Vector<BPatch_fu | | void *user_data=NULL, | |
| nction*> &funcs, | | int showError=0, | |
| bool showError=true, | | bool incUninstrumentable = false); | |
| bool regex_case_sensiti | | | |
| ve=true, | | // BPatch_image::findFunction(Address) | |
| bool incUninstrumentabl | | // | |
| e = false)); | | // Returns a function at a specified address | |
| | | BPatch_function * findFunction(unsigned long addr); | |
| // BPatch_image::findFunction | | | |
| // | | bool findFunction(Dyninst::Address addr, | |
| // Returns a vector of functions matching criterion specified by user | | BPatch_Vector<BPatch_function *> &funcs); | |
| defined | | | |
| // callback function bpsieve. | | // BPatch_image::findVariable | |
| API_EXPORT(WithSieve, (funcs, bpsieve, user_data, showError, incUninstr | | // | |
| umentable), | | // Returns global variable matching <name> in the image. NULL if not fo | |
| | | und. | |
| BPatch_Vector<BPatch_function *> *, | | | |
| findFunction,(BPatch_Vector<BPatch_function *> &funcs, | | BPatch_variableExpr * findVariable(const char *name, bool showError=true) | |
| BPatchFunctionNameSieve bpsieve, | | ; | |
| void *user_data=NULL, | | | |
| int showError=0, | | // BPatch_image::findVariable | |
| bool incUninstrumentable = false)); | | // | |
| | | // Returns local variable matching name <nm> in function scope of | |
| // BPatch_image::findFunction(Address) | | // provided BPatch_point. | |
| // | | | |
| // Returns a function at a specified address | | BPatch_variableExpr * findVariable(BPatch_point &scp, const char *nm, boo | |
| API_EXPORT(Int, (addr), | | l showError=true); | |
| BPatch_function *, findFunction,(unsigned long addr)); | | | |
| | | // BPatch_image::findType | |
| API_EXPORT(Int, (addr, funcs), | | // | |
| bool, findFunction,(Dyninst::Address addr, | | // Returns a BPatch_type corresponding to <name>, if exists, NULL if not | |
| BPatch_Vector<BPatch_function *> &funcs) | | found | |
| ); | | | |
| | | BPatch_type * findType(const char *name); | |
| // BPatch_image::findVariable | | | |
| // | | // BPatch_image::findPoints | |
| // Returns global variable matching <name> in the image. NULL if not | | // | |
| found. | | // Returns a vector of BPatch_points that correspond with the provided a | |
| API_EXPORT(Int, (name, showError), | | ddress, one | |
| | | // per function that includes an instruction at that address. Will have | |
| BPatch_variableExpr *,findVariable,(const char *name, bool showError=tr | | one element | |
| ue)); | | // if there is not overlapping code. | |
| | | bool findPoints(Dyninst::Address addr, std::vector<BPatch_point *> &poin | |
| // BPatch_image::findVariable | | ts); | |
| // | | | |
| // Returns local variable matching name <nm> in function scope of | | // BPatch_image::getAddressRanges | |
| // provided BPatch_point. | | // | |
| API_EXPORT(InScope, (scp, nm, showError), | | // method to retrieve addresses corresponding to a line in a file | |
| | | | |
| BPatch_variableExpr *,findVariable,(BPatch_point &scp, const | | bool getAddressRanges( const char * fileName, unsigned int lineNo, | |
| char *nm, bool showError=true)); | | std::vector<std::pair<unsigned long, unsigned long> | |
| | | > & ranges ); | |
| // BPatch_image::findType | | | |
| // | | bool getSourceLines( unsigned long addr, BPatch_Vector<BPatch_statement> | |
| // Returns a BPatch_type corresponding to <name>, if exists, NULL if n | | & lines ); | |
| ot found | | | |
| API_EXPORT(Int, (name), | | // BPatch_image::getProgramName | |
| | | // | |
| BPatch_type *,findType,(const char *name)); | | // fills provided buffer <name> with the program's name, up to <len> cha | |
| | | rs | |
| // BPatch_image::findPoints | | | |
| // | | char * getProgramName(char *name, unsigned int len); | |
| // Returns a vector of BPatch_points that correspond with the provided | | | |
| address, one | | // BPatch_image::getProgramFileName | |
| // per function that includes an instruction at that address. Will hav | | // | |
| e one element | | // fills provided buffer <name> with the program's file name, | |
| // if there is not overlapping code. | | // which may include path information. | |
| API_EXPORT(Int, (addr, points), | | | |
| bool, findPoints, (Dyninst::Address addr, std::vector<BPatch_point *> & | | char * getProgramFileName(char *name, unsigned int len); | |
| points)); | | | |
| | | /* BPatch_image::parseNewFunctions | |
| // BPatch_image::getAddressRanges | | * | |
| // | | * This function uses function entry addresses to find and parse | |
| // method to retrieve addresses corresponding to a line in a file | | * new functions using our control-flow traversal parsing. | |
| API_EXPORT(Int, (fileName, lineNo, ranges), | | * | |
| | | * funcEntryAddrs: this is a vector of function start addresses | |
| bool,getAddressRanges,( const char * fileName, unsigned int lineNo, | | * that seed the control-flow-traversal parsing. If they lie in | |
| std::vector<std::pair<unsigned long, unsigned l | | * an existing module they are parsed in that module, otherwise a | |
| ong> > & ranges )); | | * new module is created. In both cases the modules are added to | |
| | | * affectedModules | |
| API_EXPORT(Int, (addr, lines), | | * | |
| bool,getSourceLines,( unsigned long addr, BPatch_Vector<BPatch_statemen | | * affectedModules: BPatch_modules will be added to this vector if no | |
| t> & lines )); | | * existing modules bounded the specified function entry points. | |
| | | * Unfortunately, new modules will also sometimes have to be created | |
| // BPatch_image::getProgramName | | * for dynamically created code in memory that does not map to the | |
| // | | * file version of the binary. | |
| // fills provided buffer <name> with the program's name, up to <len> c | | * | |
| hars | | * Return value: This value is true if a new module was created or if | |
| API_EXPORT(Int, (name, len), | | * new code was parsed in an existing module | |
| | | */ | |
| char *,getProgramName,(char *name, unsigned int len)); | | bool parseNewFunctions(BPatch_Vector<BPatch_module*> &affectedModules, | |
| | | const BPatch_Vector<Dyninst::Address> &funcEntryAdd | |
| // BPatch_image::getProgramFileName | | rs); | |
| // | | | |
| // fills provided buffer <name> with the program's file name, | | // | |
| // which may include path information. | | // Reads a string from the target process | |
| API_EXPORT(Int, (name, len), | | bool readString(Dyninst::Address addr, std::string &str, | |
| | | unsigned size_limit = 0); | |
| char *,getProgramFileName,(char *name, unsigned int len)); | | | |
| | | | |
| /* BPatch_image::parseNewFunctions | | | |
| * | | | |
| * This function uses function entry addresses to find and parse | | | |
| * new functions using our control-flow traversal parsing. | | | |
| * | | | |
| * funcEntryAddrs: this is a vector of function start addresses | | | |
| * that seed the control-flow-traversal parsing. If they lie in | | | |
| * an existing module they are parsed in that module, otherwise a | | | |
| * new module is created. In both cases the modules are added to | | | |
| * affectedModules | | | |
| * | | | |
| * affectedModules: BPatch_modules will be added to this vector if no | | | |
| * existing modules bounded the specified function entry points. | | | |
| * Unfortunately, new modules will also sometimes have to be created | | | |
| * for dynamically created code in memory that does not map to the | | | |
| * file version of the binary. | | | |
| * | | | |
| * Return value: This value is true if a new module was created or if | | | |
| * new code was parsed in an existing module | | | |
| */ | | | |
| API_EXPORT(Int, (affectedModules, funcEntryAddrs), | | | |
| bool ,parseNewFunctions, | | | |
| (BPatch_Vector<BPatch_module*> &affectedModules, | | | |
| const BPatch_Vector<Dyninst::Address> &funcEntryAddrs)); | | | |
| | | | |
| // | | | |
| // Reads a string from the target process | | | |
| API_EXPORT(Int, (addr, str, size_limit), | | | |
| bool, readString,(Dyninst::Address addr, std::string &str, | | | |
| unsigned size_limit = 0)); | | | |
| | | | |
| API_EXPORT(Int, (expr, str, size_limit), | | | |
| bool, readString,(BPatch_variableExpr *expr, std::string &st | | | |
| r, | | | |
| unsigned size_limit = 0)); | | | |
| | | | |
|
| #ifdef IBM_BPATCH_COMPAT | | bool readString(BPatch_variableExpr *expr, std::string &str, | |
| API_EXPORT(Ptr, (name, funcs, showError, regex_case_sensitive, incUnins | | unsigned size_limit = 0); | |
| trumentable), | | | |
| | | | |
|
| BPatch_Vector<BPatch_function*> *, | | #ifdef IBM_BPATCH_COMPAT | |
| findFunction,(const char *name, | | | |
| BPatch_Vector<BPatch_function*> *funcs, | | | |
| bool showError=true, | | | |
| bool regex_case_sensitive=true, | | | |
| bool incUninstrumentable = false)); | | | |
| | | | |
|
| API_EXPORT(Int, (name, len), | | BPatch_Vector<BPatch_function*> * | |
| | | findFunction(const char *name, | |
| | | BPatch_Vector<BPatch_function*> *funcs, | |
| | | bool showError=true, | |
| | | bool regex_case_sensitive=true, | |
| | | bool incUninstrumentable = false); | |
| | | | |
|
| char *,programName,(char *name, unsigned int len)); | | char * programName(char *name, unsigned int len); | |
| | | | |
|
| API_EXPORT(Int, (), | | int lpType(); | |
| int,lpType,()); | | | |
| #endif | | #endif | |
| | | | |
|
| private: | | private: | |
| BPatch_addressSpace *addSpace; | | BPatch_addressSpace *addSpace; | |
| BPatch_module *defaultModule; | | BPatch_module *defaultModule; | |
| | | | |
| BPatch_module *findOrCreateModule(mapped_module *base); | | BPatch_module *findOrCreateModule(mapped_module *base); | |
| BPatch_object *findOrCreateObject(mapped_object *base); | | BPatch_object *findOrCreateObject(mapped_object *base); | |
| void removeModule(BPatch_module *mod); | | void removeModule(BPatch_module *mod); | |
| void removeAllModules(); | | void removeAllModules(); | |
| | | | |
| #if defined(_MSC_VER) | | #if defined(_MSC_VER) | |
| #pragma warning(push) | | #pragma warning(push) | |
| #pragma warning(disable:4251) | | #pragma warning(disable:4251) | |
| #endif | | #endif | |
|
| typedef std::map<mapped_module *, BPatch_module *> ModMap; | | typedef std::map<mapped_module *, BPatch_module *> ModMap; | |
| typedef std::map<mapped_object *, BPatch_object *> ObjMap; | | typedef std::map<mapped_object *, BPatch_object *> ObjMap; | |
| | | | |
|
| ModMap modmap; | | ModMap modmap; | |
| ObjMap objmap; | | ObjMap objmap; | |
| | | | |
|
| // Annoying backwards-compatible return type | | // Annoying backwards-compatible return type | |
| std::vector<BPatch_module *> modlist; | | std::vector<BPatch_module *> modlist; | |
| | | | |
|
| BPatch_Vector<BPatch_module *> removed_list; | | BPatch_Vector<BPatch_module *> removed_list; | |
| BPatch_Vector<BPatch_point *> unresolvedCF; | | BPatch_Vector<BPatch_point *> unresolvedCF; | |
| #if defined(_MSC_VER) | | #if defined(_MSC_VER) | |
| #pragma warning(pop) | | #pragma warning(pop) | |
| #endif | | #endif | |
| | | | |
|
| // These private "find" functions convert from internal func_instance | | // These private "find" functions convert from internal func_instance | |
| // representation to the exported BPatch_Function type | | // representation to the exported BPatch_Function type | |
| void findFunctionInImage(const char *name, image *img, | | void findFunctionInImage(const char *name, image *img, | |
| BPatch_Vector<BPatch_function*> *funcs, | | BPatch_Vector<BPatch_function*> *funcs, | |
| | | bool incUninstrumentable = false); | |
| | | void sieveFunctionsInImage(image *img, | |
| | | BPatch_Vector<BPatch_function *> *funcs, | |
| | | BPatchFunctionNameSieve bpsieve, | |
| | | void *user_data, | |
| bool incUninstrumentable = false); | | bool incUninstrumentable = false); | |
|
| void sieveFunctionsInImage(image *img, | | | |
| BPatch_Vector<BPatch_function *> *funcs, | | | |
| BPatchFunctionNameSieve bpsieve, | | | |
| void *user_data, | | | |
| bool incUninstrumentable = false); | | | |
| | | | |
|
| static bool setFuncModulesCallback(BPatch_function *bpf, void *data); | | static bool setFuncModulesCallback(BPatch_function *bpf, void *data); | |
| }; | | }; | |
| | | | |
| #endif /* _BPatch_image_h_ */ | | #endif /* _BPatch_image_h_ */ | |
| | | | |
End of changes. 20 change blocks. |
| 320 lines changed or deleted | | 276 lines changed or added | |
|
| BPatch_module.h | | BPatch_module.h | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_module_h_ | | #ifndef _BPatch_module_h_ | |
| #define _BPatch_module_h_ | | #define _BPatch_module_h_ | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_sourceObj.h" | | #include "BPatch_sourceObj.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| #include "dyntypes.h" | | #include "dyntypes.h" | |
| #include <vector> | | #include <vector> | |
| #include <map> | | #include <map> | |
| #if defined(IBM_BPATCH_COMPAT) | | #if defined(IBM_BPATCH_COMPAT) | |
| #include <string> | | #include <string> | |
| #endif | | #endif | |
| | | | |
| class mapped_module; | | class mapped_module; | |
| | | | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 65 | |
| class instPoint; | | class instPoint; | |
| class AddressSpace; | | class AddressSpace; | |
| class BPatch_snippet; | | class BPatch_snippet; | |
| class BPatchSnippetHandle; | | class BPatchSnippetHandle; | |
| class BPatch_module; | | class BPatch_module; | |
| class BPatch_object; | | class BPatch_object; | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
| namespace SymtabAPI { | | namespace SymtabAPI { | |
| class Module; | | class Module; | |
|
| SYMTAB_EXPORT Module *convert(const BPatch_module *); | | BPATCH_DLL_EXPORT Module *convert(const BPatch_module *); | |
| } | | } | |
| namespace PatchAPI { | | namespace PatchAPI { | |
| class PatchFunction; | | class PatchFunction; | |
| class Point; | | class Point; | |
| } | | } | |
| } | | } | |
| | | | |
| extern BPatch_builtInTypeCollection * builtInTypes; | | extern BPatch_builtInTypeCollection * builtInTypes; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_module: public BPatch_sourceObj{ | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_module | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_module: public BPatch_sourceObj, public BPat | | | |
| ch_eventLock{ | | | |
| | | | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| friend class BPatch_flowGraph; | | friend class BPatch_flowGraph; | |
| friend class BPatch_image; | | friend class BPatch_image; | |
| friend class InstrucIter; | | friend class InstrucIter; | |
| friend class BPatch_thread; | | friend class BPatch_thread; | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_binaryEdit; | | friend class BPatch_binaryEdit; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| friend class BPatch_statement; | | friend class BPatch_statement; | |
| | | | |
| skipping to change at line 132 | | skipping to change at line 126 | |
| void handleUnload(); | | void handleUnload(); | |
| bool isExploratoryModeOn();// true if exploratory or defensive mode is
on | | bool isExploratoryModeOn();// true if exploratory or defensive mode is
on | |
| bool setAnalyzedCodeWriteable(bool writeable);//sets write perm's analy
zed code pages | | bool setAnalyzedCodeWriteable(bool writeable);//sets write perm's analy
zed code pages | |
| bool isSystemLib(); | | bool isSystemLib(); | |
| bool remove(BPatch_function*); | | bool remove(BPatch_function*); | |
| bool remove(instPoint*); | | bool remove(instPoint*); | |
| // End functions for internal use only | | // End functions for internal use only | |
| | | | |
| // BPatch_module::getName | | // BPatch_module::getName | |
| // Returns file name associated with module | | // Returns file name associated with module | |
|
| API_EXPORT(Int, (buffer, length), | | | |
| | | | |
|
| char *,getName,(char *buffer, int length)); | | char * getName(char *buffer, int length); | |
| | | | |
| // BPatch_module::getFullName | | // BPatch_module::getFullName | |
| // Returns full path name of module, when available | | // Returns full path name of module, when available | |
|
| API_EXPORT(Int, (buffer, length), | | | |
| | | | |
|
| char *,getFullName,(char *buffer, int length)); | | char * getFullName(char *buffer, int length); | |
| | | | |
| // BPatch_module::libraryName | | // BPatch_module::libraryName | |
| // Returns name if library, if this module is a shared object | | // Returns name if library, if this module is a shared object | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| const char *,libraryName,()); | | const char * libraryName(); | |
| | | | |
| // BPatch_module::getObject | | // BPatch_module::getObject | |
| // Returns BPatch_object containing this file | | // Returns BPatch_object containing this file | |
|
| API_EXPORT(Int, (), | | BPatch_object * getObject(); | |
| BPatch_object *, getObject, ()); | | | |
| | | | |
| // BPatch_module::getAddressWidth | | // BPatch_module::getAddressWidth | |
| // Returns the width (in bytes) of an address in this module | | // Returns the width (in bytes) of an address in this module | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| size_t,getAddressWidth,()); | | size_t getAddressWidth(); | |
| | | | |
| // BPatch_module::getVariables | | // BPatch_module::getVariables | |
| // Fills a vector with the global variables that are specified in this
module | | // Fills a vector with the global variables that are specified in this
module | |
|
| API_EXPORT(Int, (vars), | | | |
| | | | |
|
| bool,getVariables,(BPatch_Vector<BPatch_variableExpr *> &vars)); | | bool getVariables(BPatch_Vector<BPatch_variableExpr *> &vars); | |
| | | | |
| // BPatch_module::findVariable | | // BPatch_module::findVariable | |
| // Find and return a global variable (NULL if not found) | | // Find and return a global variable (NULL if not found) | |
|
| API_EXPORT(Int, (name), | | | |
| | | | |
|
| BPatch_variableExpr*,findVariable,(const char* name)); | | BPatch_variableExpr* findVariable(const char* name); | |
| | | | |
| // BPatch_module::getProcedures | | // BPatch_module::getProcedures | |
| // Returns a vector of all functions in this module | | // Returns a vector of all functions in this module | |
|
| API_EXPORT(Int, (incUninstrumentable), | | BPatch_Vector<BPatch_function *> * getProcedures(bool incUninstrumentab | |
| BPatch_Vector<BPatch_function *> *,getProcedures,(bool incUninstrumenta | | le = false); | |
| ble = false)); | | | |
| | | | |
|
| API_EXPORT(Int, (procs, incUninstrumentable), | | bool getProcedures(BPatch_Vector<BPatch_function*> &procs, | |
| bool, getProcedures,(BPatch_Vector<BPatch_function*> &procs, | | bool incUninstrumentable = false); | |
| bool incUninstrumentable = false)); | | | |
| | | | |
| // BPatch_module::findFunction | | // BPatch_module::findFunction | |
|
| // Returns a vector of BPatch_function *, matching specified <name> | | // Returns a vector of BPatch_function * matching specified <name> | |
| API_EXPORT(Int, (name, funcs, notify_on_failure,regex_case_sensitive,in | | | |
| cUninstrumentable,dont_use_regex), | | | |
| | | | |
|
| BPatch_Vector<BPatch_function *> *,findFunction,(const char *name, | | BPatch_Vector<BPatch_function *> * findFunction(const char *name, | |
| BPatch_Vector<BPatch_function *> &funcs, | | BPatch_Vector<BPatch_function *> &funcs, | |
| bool notify_on_failure =true, | | bool notify_on_failure =true, | |
| bool regex_case_sensitive =true, | | bool regex_case_sensitive =true, | |
| bool incUninstrumentable =false, | | bool incUninstrumentable =false, | |
|
| bool dont_use_regex = false)); | | bool dont_use_regex = false); | |
| | | | |
| // BPatch_addressSpace::findFunctionByEntry | | // BPatch_addressSpace::findFunctionByEntry | |
| // Returns the function starting at the given address | | // Returns the function starting at the given address | |
|
| API_EXPORT(Int, (entry), | | BPatch_function * findFunctionByEntry(Dyninst::Address entry); | |
| BPatch_function *,findFunctionByEntry,(Dyninst::Address entry)); | | | |
| | | | |
| // FIXME: This method is (undocumented) | | // FIXME: This method is (undocumented) | |
|
| API_EXPORT(Int, (addr, funcs, notify_on_failure, incUninstrumentable), | | | |
| | | | |
|
| BPatch_Vector<BPatch_function *> *, | | BPatch_Vector<BPatch_function *> * | |
| findFunctionByAddress,(void *addr, | | findFunctionByAddress(void *addr, | |
| BPatch_Vector<BPatch_function *> &funcs, | | BPatch_Vector<BPatch_function *> &funcs, | |
| bool notify_on_failure = true, | | bool notify_on_failure = true, | |
|
| bool incUninstrumentable = false)); | | bool incUninstrumentable = false); | |
| | | | |
| // get the module types member (instead of directly accessing) | | // get the module types member (instead of directly accessing) | |
|
| API_EXPORT(Int, (), BPatch_typeCollection *, getModuleTypes, ()); | | BPatch_typeCollection *getModuleTypes(); | |
| | | | |
| // BPatch_module::findFunctionByMangled | | // BPatch_module::findFunctionByMangled | |
| // Returns a function, if it exits, that matches the provided mangled n
ame | | // Returns a function, if it exits, that matches the provided mangled n
ame | |
|
| API_EXPORT(Int, (mangled_name, incUninstrumentable), | | | |
| | | | |
|
| BPatch_function *,findFunctionByMangled,(const char * mangled_name, | | BPatch_function * findFunctionByMangled(const char * mangled_name, | |
| bool incUninstrumentable=false | | bool incUninstrumentable=false | |
| )); | | ); | |
| | | | |
| // BPatch_module::findPoints | | // BPatch_module::findPoints | |
| // | | // | |
| // Returns a vector of BPatch_points that correspond with the provided
address, one | | // Returns a vector of BPatch_points that correspond with the provided
address, one | |
| // per function that includes an instruction at that address. Will hav
e one element | | // per function that includes an instruction at that address. Will hav
e one element | |
| // if there is not overlapping code. | | // if there is not overlapping code. | |
|
| API_EXPORT(Int, (addr, points), | | bool findPoints(Dyninst::Address addr, std::vector<BPatch_point *> &po | |
| bool, findPoints, (Dyninst::Address addr, std::vector<BPatch_point *> & | | ints); | |
| points)); | | | |
| | | | |
| // BPatch_module::dumpMangled | | // BPatch_module::dumpMangled | |
| // Prints all <mangled> function names in this module | | // Prints all <mangled> function names in this module | |
|
| API_EXPORT(Int, (prefix), | | | |
| | | | |
|
| bool,dumpMangled,(char *prefix)); | | bool dumpMangled(char *prefix); | |
| | | | |
| // BPatch_module::isSharedLib | | // BPatch_module::isSharedLib | |
| // Returns true if this module represents a shared library | | // Returns true if this module represents a shared library | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,isSharedLib,()); | | bool isSharedLib(); | |
| | | | |
| // BPatch_module::isNativeCompiler | | // BPatch_module::isNativeCompiler | |
| // Returns true if this module was compiled with a native compiler for | | // Returns true if this module was compiled with a native compiler for | |
| // the particular platform | | // the particular platform | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,isNativeCompiler,()); | | bool isNativeCompiler(); | |
| | | | |
| // BPatch_module::getAddressRanges | | // BPatch_module::getAddressRanges | |
| // | | // | |
| // function to get addresses for a line of the module | | // function to get addresses for a line of the module | |
| // if fileName is NULL, uses the name of the module | | // if fileName is NULL, uses the name of the module | |
|
| API_EXPORT(Int, (fileName, lineNo, ranges), | | | |
| | | | |
|
| bool,getAddressRanges,( const char * fileName, unsigned int lineNo, std
::vector< std::pair< unsigned long, unsigned long > > & ranges )); | | bool getAddressRanges( const char * fileName, unsigned int lineNo, std:
:vector< std::pair< unsigned long, unsigned long > > & ranges ); | |
| | | | |
| // BPatch_module::getSourceLines | | // BPatch_module::getSourceLines | |
| // | | // | |
| // function to get source file names and lines | | // function to get source file names and lines | |
| // for an address in the module | | // for an address in the module | |
|
| API_EXPORT(Int, (addr, lines), | | | |
| | | | |
|
| bool,getSourceLines,( unsigned long addr, BPatch_Vector<BPatch_statemen
t> &lines)); | | bool getSourceLines( unsigned long addr, BPatch_Vector<BPatch_statement
> &lines); | |
| | | | |
| // BPatch_mode::getStatements | | // BPatch_mode::getStatements | |
| // | | // | |
| // Fill supplied vector with all BPatch_statements from this module | | // Fill supplied vector with all BPatch_statements from this module | |
|
| API_EXPORT(Int, (statements), | | | |
| | | | |
|
| bool,getStatements,(BPatch_Vector<BPatch_statement> &statements)); | | bool getStatements(BPatch_Vector<BPatch_statement> &statements); | |
| | | | |
| // BPatch_module::wgetBaseAddr | | // BPatch_module::wgetBaseAddr | |
| // Returns a base address of the module; defined as the start | | // Returns a base address of the module; defined as the start | |
| // of the first function. | | // of the first function. | |
|
| API_EXPORT(Int, (), | | void * getBaseAddr(void); | |
| void *,getBaseAddr,(void)); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | Dyninst::Address getLoadAddr(void); | |
| Dyninst::Address, getLoadAddr, (void)); | | | |
| | | | |
| // BPatch_module::getSize | | // BPatch_module::getSize | |
| // Returns the size of the module; defined as the end of the last | | // Returns the size of the module; defined as the end of the last | |
| // function minus the start of the first function. | | // function minus the start of the first function. | |
|
| API_EXPORT(Int, (), | | unsigned long getSize(void); | |
| unsigned long, getSize, (void)); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isValid(); | |
| bool, isValid, ()); | | | |
| | | | |
| // BPastch_module::getHybridMode | | // BPastch_module::getHybridMode | |
| // returns the hybrid Analysis mode: normal, exploratory, defensive | | // returns the hybrid Analysis mode: normal, exploratory, defensive | |
|
| API_EXPORT(Int, (), BPatch_hybridMode, getHybridMode,()); | | BPatch_hybridMode getHybridMode(); | |
| | | | |
|
| API_EXPORT(Int, (callback), | | BPatchSnippetHandle* insertInitCallback(BPatch_snippet& callback); | |
| BPatchSnippetHandle*, insertInitCallback, (BPatch_snippet& c | | | |
| allback)); | | | |
| | | | |
|
| API_EXPORT(Int, (callback), | | BPatchSnippetHandle* insertFiniCallback(BPatch_snippet& callback); | |
| BPatchSnippetHandle*, insertFiniCallback, (BPatch_snippet& c | | | |
| allback)); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
|
| API_EXPORT(Int, (start, end), | | bool getLineNumbers(unsigned int &start, unsigned int &end); | |
| bool,getLineNumbers,(unsigned int &start, unsigned int &end)); | | | |
| | | | |
|
| API_EXPORT(Int, (start, end), | | bool getAddressRange(void * &start, void * &end); | |
| bool,getAddressRange,(void * &start, void * &end)); | | | |
| | | | |
|
| API_EXPORT(Int, (buffer, length), | | char * getUniqueString(char *buffer, int length); | |
| char *,getUniqueString,(char *buffer, int length)); | | | |
| | | | |
| char *sharedLibraryName(char *buffer, int length) { getFullName(buffer,
length); return buffer;} | | char *sharedLibraryName(char *buffer, int length) { getFullName(buffer,
length); return buffer;} | |
| char *getSharedLibName(char *buffer, int length) { getFullName(buffer,
length); return buffer;} | | char *getSharedLibName(char *buffer, int length) { getFullName(buffer,
length); return buffer;} | |
| | | | |
|
| API_EXPORT(Int, (), | | int getSharedLibType(); | |
| int,getSharedLibType,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | int getBindingType(); | |
| int,getBindingType,()); | | | |
| | | | |
| struct Statement { | | struct Statement { | |
| unsigned long begin; // Beginning address for this statement | | unsigned long begin; // Beginning address for this statement | |
| unsigned long end; // Ending address for this statement | | unsigned long end; // Ending address for this statement | |
| std::string path; // Path name of this statement's source file | | std::string path; // Path name of this statement's source file | |
| int line; // Line number of the statement | | int line; // Line number of the statement | |
| int column; // Column number of the statement | | int column; // Column number of the statement | |
| } Statement; | | } Statement; | |
| | | | |
|
| API_EXPORT(Int, (), | | std::vector<struct BPatch_module::Statement> getStatements(); | |
| std::vector<struct BPatch_module::Statement>, getStatements, ()); | | | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| // Parse wrapper | | // Parse wrapper | |
| bool parseTypesIfNecessary(); | | bool parseTypesIfNecessary(); | |
| BPatch_typeCollection *moduleTypes; | | BPatch_typeCollection *moduleTypes; | |
| | | | |
| // In particular, we understand the type information | | // In particular, we understand the type information | |
| // in both DWARF and STABS format. | | // in both DWARF and STABS format. | |
| void parseStabTypes(); | | void parseStabTypes(); | |
| | | | |
End of changes. 54 change blocks. |
| 87 lines changed or deleted | | 45 lines changed or added | |
|
| BPatch_point.h | | BPatch_point.h | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_point_h_ | | #ifndef _BPatch_point_h_ | |
| #define _BPatch_point_h_ | | #define _BPatch_point_h_ | |
| | | | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_Set.h" | | #include "BPatch_Set.h" | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| | | | |
| class InstrucIter; | | class InstrucIter; | |
| class instPoint; | | class instPoint; | |
| class miniTramp; | | class miniTramp; | |
| class BPatch_thread; | | class BPatch_thread; | |
| class BPatch_image; | | class BPatch_image; | |
| class BPatch_function; | | class BPatch_function; | |
| class BPatch_memoryAccess; | | class BPatch_memoryAccess; | |
| | | | |
| skipping to change at line 93 | | skipping to change at line 92 | |
| #define BPatch_locBasicBlockLoopEntry BPatch_locLoopEntry | | #define BPatch_locBasicBlockLoopEntry BPatch_locLoopEntry | |
| #define BPatch_locBasicBlockLoopExit BPatch_locLoopExit | | #define BPatch_locBasicBlockLoopExit BPatch_locLoopExit | |
| #endif | | #endif | |
| | | | |
| /* VG(09/17/01) Added memory access pointer */ | | /* VG(09/17/01) Added memory access pointer */ | |
| | | | |
| /* VG(11/06/01) Moved constructor to implementation file because it | | /* VG(11/06/01) Moved constructor to implementation file because it | |
| needs to link instPoint back pointer (and we don't want to include | | needs to link instPoint back pointer (and we don't want to include | |
| that here) */ | | that here) */ | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_point { | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_point | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_point : public BPatch_eventLock { | | | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_binaryEdit; | | friend class BPatch_binaryEdit; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| friend class BPatch_image; | | friend class BPatch_image; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| friend class BPatch_basicBlock; | | friend class BPatch_basicBlock; | |
| friend class BPatch_basicBlockLoop; | | friend class BPatch_basicBlockLoop; | |
| friend class BPatch_flowGraph; // Access to setLoop | | friend class BPatch_flowGraph; // Access to setLoop | |
| friend class BPatch_asyncEventHandler; | | friend class BPatch_asyncEventHandler; | |
| friend class BPatch_edge; | | friend class BPatch_edge; | |
| | | | |
| skipping to change at line 130 | | skipping to change at line 124 | |
| // (e.g., an instruction) and how the internals represent a point | | // (e.g., an instruction) and how the internals represent a point | |
| // (e.g., pre-instruction). We handle this here with a secondary | | // (e.g., pre-instruction). We handle this here with a secondary | |
| // instPoint that is defined to be the "after" equivalent. | | // instPoint that is defined to be the "after" equivalent. | |
| instPoint *point; | | instPoint *point; | |
| instPoint *secondaryPoint; | | instPoint *secondaryPoint; | |
| | | | |
| BPatch_procedureLocation pointType; | | BPatch_procedureLocation pointType; | |
| BPatch_memoryAccess *memacc; | | BPatch_memoryAccess *memacc; | |
| // Instruction constructor... | | // Instruction constructor... | |
| BPatch_point(BPatch_addressSpace *_addSpace, BPatch_function *_func, | | BPatch_point(BPatch_addressSpace *_addSpace, BPatch_function *_func, | |
|
| instPoint *_point, instPoint *_secondary, | | instPoint *_point, instPoint *_secondary, | |
| BPatch_procedureLocation _pointType, | | BPatch_procedureLocation _pointType, | |
| AddressSpace *as); | | AddressSpace *as); | |
| | | | |
| // Edge constructor... | | // Edge constructor... | |
| BPatch_point(BPatch_addressSpace *_addSpace, BPatch_function *_func, | | BPatch_point(BPatch_addressSpace *_addSpace, BPatch_function *_func, | |
| BPatch_edge *_edge, instPoint *_point, AddressSpace *as); | | BPatch_edge *_edge, instPoint *_point, AddressSpace *as); | |
| | | | |
| void setLoop(BPatch_basicBlockLoop *l); | | void setLoop(BPatch_basicBlockLoop *l); | |
| | | | |
| // We often create a point with the arbitrary point type, | | // We often create a point with the arbitrary point type, | |
| | | | |
| skipping to change at line 190 | | skipping to change at line 184 | |
| // Hack to get edge information. DO NOT USE. | | // Hack to get edge information. DO NOT USE. | |
| BPatch_edge *edge() const { return edge_; } | | BPatch_edge *edge() const { return edge_; } | |
| bool isReturnInstruction(); | | bool isReturnInstruction(); | |
| static BPatch_procedureLocation convertInstPointType_t(int intType); | | static BPatch_procedureLocation convertInstPointType_t(int intType); | |
| instPoint *llpoint() { return point; } | | instPoint *llpoint() { return point; } | |
| Dyninst::Address getCallFallThroughAddr(); | | Dyninst::Address getCallFallThroughAddr(); | |
| bool patchPostCallArea(); | | bool patchPostCallArea(); | |
| // End internal functions | | // End internal functions | |
| | | | |
| //Added for DynC... | | //Added for DynC... | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_addressSpace *, getAddressSpace, ()); | | BPatch_addressSpace * getAddressSpace(); | |
| | | | |
| // Get the loop ID | | // Get the loop ID | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| BPatch_basicBlockLoop *, getLoop, ()); | | BPatch_basicBlockLoop * getLoop(); | |
| | | | |
| // BPatch_point::getPointType | | // BPatch_point::getPointType | |
| // | | // | |
|
| API_EXPORT(Int, (), | | BPatch_procedureLocation getPointType(); | |
| BPatch_procedureLocation,getPointType,()); | | | |
| | | | |
| // BPatch_point::getFunction | | // BPatch_point::getFunction | |
| // Returns function to which this point belongs | | // Returns function to which this point belongs | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_function * getFunction(); | |
| | | | |
| BPatch_function *,getFunction,()); | | | |
| | | | |
| // BPatch_point::getCalledFunction | | // BPatch_point::getCalledFunction | |
| // Returns a BPatch_function representing the function being called at
this point. | | // Returns a BPatch_function representing the function being called at
this point. | |
| // If this point is not a call site, returns NULL. | | // If this point is not a call site, returns NULL. | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_function * getCalledFunction(); | |
| | | | |
| BPatch_function *,getCalledFunction,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | std::string getCalledFunctionName(); | |
| std::string,getCalledFunctionName,()); | | | |
| | | | |
| // BPatch_point::getBlock | | // BPatch_point::getBlock | |
| // Returns block to which this point belongs if such a block exists | | // Returns block to which this point belongs if such a block exists | |
| // For example, function entry points do not have blocks associated wi
th them. | | // For example, function entry points do not have blocks associated wi
th them. | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_basicBlock * getBlock(); | |
| | | | |
| BPatch_basicBlock *,getBlock,()); | | | |
| | | | |
| // BPatch_point::getAddress | | // BPatch_point::getAddress | |
| // Returns the address of this point in the mutatee | | // Returns the address of this point in the mutatee | |
| | | | |
|
| API_EXPORT(Int, (), | | void * getAddress(); | |
| | | | |
| void *,getAddress,()); | | | |
| | | | |
| // BPatch_point::getMemoryAccess | | // BPatch_point::getMemoryAccess | |
| // | | // | |
| | | | |
|
| API_EXPORT(Int, (), | | const BPatch_memoryAccess * getMemoryAccess(); | |
| | | | |
|
| const BPatch_memoryAccess *,getMemoryAccess,()); | | Dyninst::InstructionAPI::Instruction::Ptr getInsnAtPoint(); | |
| | | | |
| API_EXPORT(Int, (), | | | |
| Dyninst::InstructionAPI::Instruction::Ptr, getInsnAtPoint, () | | | |
| ); | | | |
| | | | |
| // BPatch_point::getCurrentSnippets | | // BPatch_point::getCurrentSnippets | |
| // | | // | |
| // to get all current snippets at this point | | // to get all current snippets at this point | |
| | | | |
|
| API_EXPORT(Int, (), | | const BPatch_Vector<BPatchSnippetHandle *> getCurrentSnippets(); | |
| | | | |
| const BPatch_Vector<BPatchSnippetHandle *>,getCurrentSnippets,()); | | | |
| | | | |
| // BPatch_point::getCurrentSnippets | | // BPatch_point::getCurrentSnippets | |
| // | | // | |
| // to get all current snippets as defined by when at this point | | // to get all current snippets as defined by when at this point | |
| | | | |
|
| API_EXPORT(ByWhen, (when), | | const BPatch_Vector<BPatchSnippetHandle *> getCurrentSnippets(BPatch_ca | |
| | | llWhen when); | |
| const BPatch_Vector<BPatchSnippetHandle *>,getCurrentSnippets,(BPatch_c | | | |
| allWhen when)); | | | |
| | | | |
| // BPatch_point::getLiveRegisters | | // BPatch_point::getLiveRegisters | |
| // | | // | |
| // Get Live registers at this point | | // Get Live registers at this point | |
| | | | |
|
| API_EXPORT(Int, (liveRegs), | | bool getLiveRegisters(std::vector<BPatch_register> &liveRegs); | |
| | | | |
| bool, getLiveRegisters, (std::vector<BPatch_register> &liveRegs)); | | | |
| | | | |
| // BPatch_point::isDynamic | | // BPatch_point::isDynamic | |
| // | | // | |
| // isDynamic() returns true if this is a dynamic call site | | // isDynamic() returns true if this is a dynamic call site | |
| // (eg a call site where a func call is made via func ptr) | | // (eg a call site where a func call is made via func ptr) | |
| | | | |
|
| API_EXPORT(Int, (), | | bool isDynamic(); | |
| | | | |
| bool,isDynamic,()); | | | |
| | | | |
| // BPatch_point::monitorCalls | | // BPatch_point::monitorCalls | |
| // | | // | |
| // monitorCalls(BPatch_function *cbFuncInUserLibrary) | | // monitorCalls(BPatch_function *cbFuncInUserLibrary) | |
| // Applies only to dynamic call sites (returns false if this BPatch_po
int | | // Applies only to dynamic call sites (returns false if this BPatch_po
int | |
| // is not a dynamic call site). Inserts a call to the user-written fu
nction | | // is not a dynamic call site). Inserts a call to the user-written fu
nction | |
| // cbFuncInUserLibrary(), which must exist in a user defined library, | | // cbFuncInUserLibrary(), which must exist in a user defined library, | |
| // at this call site. cbFuncInUserLibrary must adhere to the prototyp
e: | | // at this call site. cbFuncInUserLibrary must adhere to the prototyp
e: | |
| // void cbFuncInUserLibrary(void *callee_address, void *callSite_addre
ss). | | // void cbFuncInUserLibrary(void *callee_address, void *callSite_addre
ss). | |
| // | | // | |
| // Returns handle on success, NULL on failure | | // Returns handle on success, NULL on failure | |
| | | | |
|
| API_EXPORT(Int, (f), | | void * monitorCalls(BPatch_function *f = NULL); | |
| | | | |
| void *,monitorCalls,(BPatch_function *f = NULL)); | | | |
| | | | |
| // BPatch_point::stopMonitoring | | // BPatch_point::stopMonitoring | |
|
| // If this point, as a dynamic call site, was being monitored, turns o
ff monitoring | | // If this point as a dynamic call site, was being monitored, turns o
ff monitoring | |
| // <handle> is the handle returned my monitorCalls() | | // <handle> is the handle returned my monitorCalls() | |
| | | | |
|
| API_EXPORT(Int, (), | | bool stopMonitoring(); | |
| | | | |
| bool,stopMonitoring,()); | | | |
| | | | |
| // BPatch_point::getDisplacedInstructions | | // BPatch_point::getDisplacedInstructions | |
| // Returns the instructions to be relocated when instrumentation is in
serted | | // Returns the instructions to be relocated when instrumentation is in
serted | |
| // at this point. Returns the number of bytes taken up by these instr
uctions. | | // at this point. Returns the number of bytes taken up by these instr
uctions. | |
| | | | |
|
| API_EXPORT(Int, (maxSize, insns), | | int getDisplacedInstructions(int maxSize, void *insns); | |
| | | | |
| int,getDisplacedInstructions,(int maxSize, void *insns)); | | | |
| | | | |
| // BPatch_point::usesTrap_NP | | // BPatch_point::usesTrap_NP | |
| // Returns true if this point is or would be instrumented with a trap,
rather | | // Returns true if this point is or would be instrumented with a trap,
rather | |
| // than a jump to the base tramp, false otherwise. On platforms that
do not | | // than a jump to the base tramp, false otherwise. On platforms that
do not | |
| // use traps (everything other than x86), it always returns false; | | // use traps (everything other than x86), it always returns false; | |
| | | | |
|
| API_EXPORT(Int, (), | | bool usesTrap_NP(); | |
| | | | |
| bool,usesTrap_NP,()); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| void *getPointAddress() { return getAddress(); } | | void *getPointAddress() { return getAddress(); } | |
| int getPointLine() { return -1; } | | int getPointLine() { return -1; } | |
| BPatch_function *getContainingFunction() { return const_cast<BPatch_fun
ction*>(getFunction()); }; | | BPatch_function *getContainingFunction() { return const_cast<BPatch_fun
ction*>(getFunction()); }; | |
| #endif | | #endif | |
| | | | |
| }; | | }; | |
| | | | |
| #endif /* _BPatch_point_h_ */ | | #endif /* _BPatch_point_h_ */ | |
| | | | |
End of changes. 24 change blocks. |
| 60 lines changed or deleted | | 22 lines changed or added | |
|
| BPatch_process.h | | BPatch_process.h | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_process_h_ | | #ifndef _BPatch_process_h_ | |
| #define _BPatch_process_h_ | | #define _BPatch_process_h_ | |
| | | | |
| #include "BPatch_snippet.h" | | #include "BPatch_snippet.h" | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
|
| //#include "BPatch_image.h" | | // #include "BPatch_image.h" | |
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_addressSpace.h" | | #include "BPatch_addressSpace.h" | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| | | | |
| #include "BPatch_callbacks.h" | | #include "BPatch_callbacks.h" | |
|
| | | #include "PCProcess.h" | |
| | | | |
| #include <vector> | | #include <vector> | |
| | | | |
|
| #include <stdio.h> | | #include <cstdio> | |
| #include <signal.h> | | #include <csignal> | |
| | | | |
| class PCProcess; | | class PCProcess; | |
| class AddressSpace; | | class AddressSpace; | |
| class PCThread; | | class PCThread; | |
| class miniTrampHandle; | | class miniTrampHandle; | |
| class miniTramp; | | class miniTramp; | |
| class BPatch; | | class BPatch; | |
| class BPatch_thread; | | class BPatch_thread; | |
| class BPatch_process; | | class BPatch_process; | |
| class BPatch_point; | | class BPatch_point; | |
| | | | |
| skipping to change at line 98 | | skipping to change at line 98 | |
| BPatch_thread *thread; | | BPatch_thread *thread; | |
| } BPatch_catchupInfo; | | } BPatch_catchupInfo; | |
| | | | |
| /* | | /* | |
| * class OneTimeCodeInfo | | * class OneTimeCodeInfo | |
| * | | * | |
| * This is used by the oneTimeCode (inferiorRPC) mechanism to keep per-RPC | | * This is used by the oneTimeCode (inferiorRPC) mechanism to keep per-RPC | |
| * information. | | * information. | |
| */ | | */ | |
| class OneTimeCodeInfo { | | class OneTimeCodeInfo { | |
|
| bool synchronous; | | bool synchronous; | |
| bool completed; | | bool completed; | |
| void *userData; | | void *userData; | |
| BPatchOneTimeCodeCallback cb; | | BPatchOneTimeCodeCallback cb; | |
| void *returnValue; | | void *returnValue; | |
| unsigned thrID; | | unsigned thrID; | |
| public: | | public: | |
| OneTimeCodeInfo(bool _synchronous, void *_userData, BPatchOneTimeCodeCal | | OneTimeCodeInfo(bool _synchronous, void *_userData, BPatchOneTimeCodeCallb | |
| lback _cb, unsigned _thrID) : | | ack _cb, unsigned _thrID) : | |
| synchronous(_synchronous), completed(false), userData(_userData), cb( | | synchronous(_synchronous), completed(false), userData(_userData), cb(_cb) | |
| _cb), | | , | |
| thrID(_thrID) { }; | | thrID(_thrID) { }; | |
| | | | |
| bool isSynchronous() { return synchronous; } | | bool isSynchronous() { return synchronous; } | |
| | | | |
| bool isCompleted() const { return completed; } | | bool isCompleted() const { return completed; } | |
| void setCompleted(bool _completed) { completed = _completed; } | | void setCompleted(bool _completed) { completed = _completed; } | |
| | | | |
|
| void *getUserData() { return userData; } | | void *getUserData() { return userData; } | |
| | | | |
|
| void setReturnValue(void *_returnValue) { returnValue = _returnValue; } | | void setReturnValue(void *_returnValue) { returnValue = _returnValue; } | |
| void *getReturnValue() { return returnValue; } | | void *getReturnValue() { return returnValue; } | |
| | | | |
|
| unsigned getThreadID() { return thrID; } | | unsigned getThreadID() { return thrID; } | |
| | | | |
|
| BPatchOneTimeCodeCallback getCallback() { return cb;} | | BPatchOneTimeCodeCallback getCallback() { return cb;} | |
| | | | |
| }; | | }; | |
| | | | |
| /* | | /* | |
| * Represents a process | | * Represents a process | |
| */ | | */ | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_process | | | |
| class BPATCH_DLL_EXPORT BPatch_process : public BPatch_addressSpace { | | class BPATCH_DLL_EXPORT BPatch_process : public BPatch_addressSpace { | |
|
| friend class BPatch; | | friend class BPatch; | |
| friend class BPatch_image; | | friend class BPatch_image; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| friend class BPatch_frame; | | friend class BPatch_frame; | |
| friend class BPatch_thread; | | friend class BPatch_thread; | |
| friend class BPatch_asyncEventHandler; | | friend class BPatch_asyncEventHandler; | |
| friend class BPatch_module; | | friend class BPatch_module; | |
| friend class BPatch_basicBlock; | | friend class BPatch_basicBlock; | |
| friend class BPatch_flowGraph; | | friend class BPatch_flowGraph; | |
| friend class BPatch_loopTreeNode; | | friend class BPatch_loopTreeNode; | |
| friend class BPatch_point; | | friend class BPatch_point; | |
| friend class BPatch_funcCallExpr; | | friend class BPatch_funcCallExpr; | |
| friend class BPatch_eventMailbox; | | friend class BPatch_eventMailbox; | |
| friend class BPatch_instruction; | | friend class BPatch_instruction; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| friend class AstNode; // AST needs to translate instPoint to | | friend class AstNode; // AST needs to translate instPoint to | |
| friend class AstOperatorNode; | | friend class AstOperatorNode; | |
| friend class AstMemoryNode; | | friend class AstMemoryNode; | |
| friend class PCEventHandler; // to deliver events for callbacks | | friend class PCEventHandler; // to deliver events for callbacks | |
| | | | |
| protected: | | protected: | |
| void getAS(std::vector<AddressSpace *> &as); | | void getAS(std::vector<AddressSpace *> &as); | |
| | | | |
| public: | | public: | |
| void PDSEP_updateObservedCostAddr(unsigned long a); | | void PDSEP_updateObservedCostAddr(unsigned long a); | |
| private: | | private: | |
| | | | |
| //References to lower level objects | | //References to lower level objects | |
| PCProcess *llproc; | | PCProcess *llproc; | |
| | | | |
| BPatch_Vector<BPatch_thread *> threads; | | BPatch_Vector<BPatch_thread *> threads; | |
| | | | |
| int lastSignal; | | int lastSignal; | |
| int exitCode; | | int exitCode; | |
| int exitSignal; | | int exitSignal; | |
| bool exitedNormally; | | bool exitedNormally; | |
| bool exitedViaSignal; | | bool exitedViaSignal; | |
| bool mutationsActive; | | bool mutationsActive; | |
| bool createdViaAttach; | | bool createdViaAttach; | |
| bool detached; | | bool detached; | |
| | | | |
| // BPatch-level; once the callbacks are sent by the llproc, we're termi | | // BPatch-level; once the callbacks are sent by the llproc, we're termina | |
| nated | | ted | |
| // Used because callbacks go (and can clean up user code) before the lo | | // Used because callbacks go (and can clean up user code) before the low- | |
| w-level process | | level process | |
| // sets flags. | | // sets flags. | |
| bool terminated; | | bool terminated; | |
| bool reportedExit; | | bool reportedExit; | |
| | | | |
| void setExitedNormally(); | | void setExitedNormally(); | |
| void setExitedViaSignal(int signalnumber); | | void setExitedViaSignal(int signalnumber); | |
| | | | |
| void setExitCode(int exitcode) { exitCode = exitcode; } | | void setExitCode(int exitcode) { exitCode = exitcode; } | |
| void setExitSignal(int exitsignal) { exitSignal = exitsignal; } | | void setExitSignal(int exitsignal) { exitSignal = exitsignal; } | |
| | | | |
| bool statusIsTerminated(); | | bool statusIsTerminated(); | |
| | | | |
| void setLastSignal(int signal) { lastSignal = signal; } | | void setLastSignal(int signal) { lastSignal = signal; } | |
| | | | |
| bool getType(); | | bool getType(); | |
| bool getTerminated() {return terminated;} | | bool getTerminated() {return terminated;} | |
| bool getMutationsActive() {return mutationsActive;} | | bool getMutationsActive() {return mutationsActive;} | |
| | | | |
| HybridAnalysis *hybridAnalysis_; | | HybridAnalysis *hybridAnalysis_; | |
| | | | |
| static int oneTimeCodeCallbackDispatch(PCProcess *theProc, | | static int oneTimeCodeCallbackDispatch(PCProcess *theProc, | |
| unsigned /* rpcid */, | | unsigned /* rpcid */, | |
| void *userData, | | void *userData, | |
| void *returnValue); | | void *returnValue); | |
| | | | |
| void *oneTimeCodeInternal(const BPatch_snippet &expr, | | void *oneTimeCodeInternal(const BPatch_snippet &expr, | |
| BPatch_thread *thread, // == NULL if proc-wid | | BPatch_thread *thread, // == NULL if proc-wide | |
| e | | void *userData, | |
| void *userData, | | BPatchOneTimeCodeCallback cb = NULL, | |
| BPatchOneTimeCodeCallback cb = NULL, | | bool synchronous = true, bool *err = NULL, | |
| bool synchronous = true, bool *err = NULL, | | bool userRPC = true); | |
| bool userRPC = true); | | | |
| | | protected: | |
| protected: | | // for creating a process | |
| // for creating a process | | BPatch_process(const char *path, const char *argv[], | |
| BPatch_process(const char *path, const char *argv[], | | BPatch_hybridMode mode, const char **envp = NULL, | |
| BPatch_hybridMode mode, const char **envp = NULL, | | int stdin_fd = 0, int stdout_fd = 1, int stderr_fd = 2); | |
| int stdin_fd = 0, int stdout_fd = 1, int stderr_fd = 2); | | // for attaching | |
| // for attaching | | BPatch_process(const char *path, int pid, BPatch_hybridMode mode); | |
| BPatch_process(const char *path, int pid, BPatch_hybridMode mode); | | | |
| | | // for forking | |
| // for forking | | BPatch_process(PCProcess *proc); | |
| BPatch_process(PCProcess *proc); | | | |
| | | void triggerThreadCreate(PCThread *thread); | |
| void triggerThreadCreate(PCThread *thread); | | void triggerInitialThreadEvents(); | |
| void triggerInitialThreadEvents(); | | void deleteBPThread(BPatch_thread *thrd); | |
| void deleteBPThread(BPatch_thread *thrd); | | | |
| | | public: | |
| public: | | | |
| | | // Begin internal functions, DO NOT USE | |
| // Begin internal functions, DO NOT USE | | // | |
| // | | // this function should go away as soon as Paradyn links against Dyninst | |
| // this function should go away as soon as Paradyn links against Dynins | | PCProcess *lowlevel_process() const { return llproc; } | |
| t | | // These internal funcs trigger callbacks registered to matching events | |
| PCProcess *lowlevel_process() const { return llproc; } | | bool triggerStopThread(instPoint *intPoint, func_instance *intFunc, | |
| // These internal funcs trigger callbacks registered to matching events | | int cb_ID, void *retVal); | |
| bool triggerStopThread(instPoint *intPoint, func_instance *intFunc, | | bool triggerSignalHandlerCB(instPoint *point, func_instance *func, long s | |
| int cb_ID, void *retVal); | | ignum, | |
| bool triggerSignalHandlerCB(instPoint *point, func_instance *func, long | | BPatch_Vector<Dyninst::Address> *handlers); | |
| signum, | | bool triggerCodeOverwriteCB(instPoint * faultPoint, | |
| BPatch_Vector<Dyninst::Address> *handlers); | | Dyninst::Address faultTarget); | |
| bool triggerCodeOverwriteCB(instPoint * faultPoint, | | bool setMemoryAccessRights(Dyninst::Address start, size_t size, | |
| Dyninst::Address faultTarget); | | Dyninst::ProcControlAPI::Process::mem_perm righ | |
| bool setMemoryAccessRights(Dyninst::Address start, Dyninst::Address siz | | ts); | |
| e, | | unsigned char *makeShadowPage(Dyninst::Address pageAddress); | |
| int rights); | | void overwriteAnalysisUpdate | |
| unsigned char *makeShadowPage(Dyninst::Address pageAddress); | | ( std::map<Dyninst::Address,unsigned char*>& owPages, //input | |
| void overwriteAnalysisUpdate | | std::vector<std::pair<Dyninst::Address,int> >& deadBlocks, //output | |
| ( std::map<Dyninst::Address,unsigned char*>& owPages, //input | | std::vector<BPatch_function*>& owFuncs, //output | |
| std::vector<std::pair<Dyninst::Address,int> >& deadBlocks, //outp | | std::set<BPatch_function *> &monitorFuncs, //output | |
| ut | | bool &changedPages, bool &changedCode ); //output | |
| std::vector<BPatch_function*>& owFuncs, //output | | HybridAnalysis *getHybridAnalysis() { return hybridAnalysis_; } | |
| std::set<BPatch_function *> &monitorFuncs, //output | | bool protectAnalyzedCode(); | |
| bool &changedPages, bool &changedCode ); //output | | // DO NOT USE | |
| HybridAnalysis *getHybridAnalysis() { return hybridAnalysis_; } | | // This is an internal debugging function | |
| bool protectAnalyzedCode(); | | void debugSuicide(); | |
| // DO NOT USE | | // | |
| // This is an internal debugging function | | // End internal functions | |
| API_EXPORT_V(Int, (), | | | |
| void, debugSuicide,()); | | // BPatch_process::~BPatch_process | |
| // | | // | |
| // End internal functions | | // Destructor | |
| | | ~BPatch_process(); | |
| // BPatch_process::~BPatch_process | | | |
| // | | // BPatch_process::getPid | |
| // Destructor | | // | |
| API_EXPORT_DTOR(_dtor, (), | | // Get id of mutatee process | |
| ~,BPatch_process,()); | | | |
| | | int getPid(); | |
| // BPatch_process::getPid | | | |
| // | | // BPatch_process::getAddressWidth | |
| // Get id of mutatee process | | // | |
| | | // Get the address width (4 or 8) of the process | |
| API_EXPORT(Int, (), | | | |
| int,getPid,()); | | int getAddressWidth(); | |
| | | | |
| // BPatch_process::getAddressWidth | | // BPatch_process::stopExecution | |
| // | | // | |
| // Get the address width (4 or 8) of the process | | // Stop the mutatee process | |
| | | | |
| API_EXPORT(Int, (), | | bool stopExecution(); | |
| int,getAddressWidth,()); | | | |
| | | // BPatch_process::continueExecution | |
| // BPatch_process::stopExecution | | // | |
| // | | // Resume execution of mutatee process | |
| // Stop the mutatee process | | | |
| | | bool continueExecution(); | |
| API_EXPORT(Int, (), | | | |
| bool,stopExecution,()); | | // BPatch_process::terminateExecution | |
| | | // | |
| // BPatch_process::continueExecution | | // Terminate mutatee process | |
| // | | | |
| // Resume execution of mutatee process | | bool terminateExecution(); | |
| | | | |
| API_EXPORT(Int, (), | | // BPatch_process::isStopped | |
| bool,continueExecution,()); | | // | |
| | | // Returns true if mutatee process is currently stopped | |
| // BPatch_process::terminateExecution | | | |
| // | | bool isStopped(); | |
| // Terminate mutatee process | | | |
| | | // BPatch_process::stopSignal | |
| API_EXPORT(Int, (), | | // | |
| bool,terminateExecution,()); | | // Returns signal number of signal that stopped mutatee process | |
| | | | |
| // BPatch_process::isStopped | | int stopSignal(); | |
| // | | | |
| // Returns true if mutatee process is currently stopped | | // BPatch_process::isTerminated | |
| | | // | |
| API_EXPORT(Int, (), | | // Returns true if mutatee process is terminated | |
| bool,isStopped,()); | | | |
| | | bool isTerminated(); | |
| // BPatch_process::stopSignal | | | |
| // | | // BPatch_process::terminationStatus | |
| // Returns signal number of signal that stopped mutatee process | | // | |
| | | // Returns information on how mutatee process was terminated | |
| API_EXPORT(Int, (), | | | |
| int,stopSignal,()); | | BPatch_exitType terminationStatus(); | |
| | | | |
| // BPatch_process::isTerminated | | // BPatch_process::getExitCode | |
| // | | // | |
| // Returns true if mutatee process is terminated | | // Returns integer exit code of (exited) mutatee process | |
| | | | |
| API_EXPORT(Int, (), | | int getExitCode(); | |
| bool,isTerminated,()); | | | |
| | | // BPatch_process::getExitSignal | |
| // BPatch_process::terminationStatus | | // | |
| // | | // Returns integer signal number of signal that caused mutatee to exit | |
| // Returns information on how mutatee process was terminated | | | |
| | | int getExitSignal(); | |
| API_EXPORT(Int, (), | | | |
| BPatch_exitType,terminationStatus,()); | | // BPatch_process::detach | |
| | | // | |
| // BPatch_process::getExitCode | | // Detach from the mutatee process, optionally leaving it running | |
| // | | | |
| // Returns integer exit code of (exited) mutatee process | | bool wasRunningWhenAttached(); | |
| | | | |
| API_EXPORT(Int, (), | | // BPatch_process::detach | |
| int,getExitCode,()); | | // | |
| | | // Detach from the mutatee process, optionally leaving it running | |
| // BPatch_process::getExitSignal | | | |
| // | | bool detach(bool cont); | |
| // Returns integer signal number of signal that caused mutatee to exit | | | |
| | | // BPatch_process::isDetached | |
| API_EXPORT(Int, (), | | // | |
| int,getExitSignal,()); | | // Returns true if DyninstAPI is detached from this mutatee | |
| | | | |
| // BPatch_process::detach | | bool isDetached(); | |
| // | | | |
| // Detach from the mutatee process, optionally leaving it running | | // BPatch_process::getThreads | |
| | | // | |
| API_EXPORT(Int, (), | | // Fills a vector with the BPatch_thread objects that belong to | |
| bool,wasRunningWhenAttached,()); | | // this process | |
| | | void getThreads(BPatch_Vector<BPatch_thread *> &thrds); | |
| // BPatch_process::detach | | | |
| // | | // BPatch_prOcess::isMultithreaded | |
| // Detach from the mutatee process, optionally leaving it running | | // | |
| | | // Returns true if this process has more than one thread | |
| API_EXPORT(Int, (cont), | | bool isMultithreaded(); | |
| bool,detach,(bool cont)); | | | |
| | | // BPatch_prOcess::isMultithreadCapable | |
| // BPatch_process::isDetached | | // | |
| // | | // Returns true if this process is linked against a thread library | |
| // Returns true if DyninstAPI is detached from this mutatee | | // (and thus might be multithreaded) | |
| | | bool isMultithreadCapable(); | |
| API_EXPORT(Int, (), | | | |
| bool,isDetached,()); | | // BPatch_process::getThread | |
| | | // | |
| // BPatch_process::getThreads | | // Returns one of this process's threads, given a tid | |
| // | | BPatch_thread * getThread(dynthread_t tid); | |
| // Fills a vector with the BPatch_thread objects that belong to | | | |
| // this process | | // BPatch_process::getThread | |
| API_EXPORT_V(Int, (thrds), | | // | |
| void, getThreads, (BPatch_Vector<BPatch_thread *> &thrds)); | | // Returns one of this process's threads, given an index | |
| | | BPatch_thread * getThreadByIndex(unsigned index); | |
| // BPatch_prOcess::isMultithreaded | | | |
| // | | // BPatch_process::dumpCore | |
| // Returns true if this process has more than one thread | | // | |
| API_EXPORT(Int, (), | | // Produce a core dump file <file> for the mutatee process | |
| bool, isMultithreaded, ()); | | | |
| | | bool dumpCore(const char *file, bool terminate); | |
| // BPatch_prOcess::isMultithreadCapable | | | |
| // | | // BPatch_process::dumpImage | |
| // Returns true if this process is linked against a thread library | | // | |
| // (and thus might be multithreaded) | | // Write contents of memory to <file> | |
| API_EXPORT(Int, (), | | | |
| bool, isMultithreadCapable, ()); | | bool dumpImage(const char *file); | |
| | | | |
| // BPatch_process::getThread | | // BPatch_process::getInheritedVariable | |
| // | | // | |
| // Returns one of this process's threads, given a tid | | // | |
| API_EXPORT(Int, (tid), | | | |
| BPatch_thread *, getThread, (dynthread_t tid)); | | BPatch_variableExpr * getInheritedVariable(BPatch_variableExpr &pVar); | |
| | | | |
| // BPatch_process::getThread | | // BPatch_process::getInheritedSnippet | |
| // | | // | |
| // Returns one of this process's threads, given an index | | // | |
| API_EXPORT(Int, (index), | | | |
| BPatch_thread *, getThreadByIndex, (unsigned index)); | | BPatchSnippetHandle * getInheritedSnippet(BPatchSnippetHandle &parentSnip | |
| | | pet); | |
| // BPatch_process::dumpCore | | | |
| // | | // BPatch_binaryEdit::beginInsertionSet() | |
| // Produce a core dump file <file> for the mutatee process | | // | |
| | | // Start the batch insertion of multiple points; all calls to insertSnip | |
| API_EXPORT(Int, (file, terminate), | | pet* | |
| bool,dumpCore,(const char *file, bool terminate)); | | // after this call will not actually instrument until finalizeInsertionS | |
| | | et is | |
| // BPatch_process::dumpImage | | // called | |
| // | | | |
| // Write contents of memory to <file> | | void beginInsertionSet(); | |
| | | | |
| API_EXPORT(Int, (file), | | //BPatch_process::finalizeInsertionSet() | |
| bool,dumpImage,(const char *file)); | | | |
| | | // Finalizes all instrumentation logically added since a call to beginIns | |
| // BPatch_process::getInheritedVariable | | ertionSet. | |
| // | | // Returns true if all instrumentation was successfully inserted; otherw | |
| // | | ise, none | |
| | | // was. Individual instrumentation can be manipulated via the BPatchSnip | |
| API_EXPORT(Int, (pVar), | | petHandles | |
| BPatch_variableExpr *,getInheritedVariable,(BPatch_variableExpr &pVar)) | | // returned from individual calls to insertSnippet. | |
| ; | | // | |
| | | // atomic: if true, all instrumentation will be removed if any fails to | |
| // BPatch_process::getInheritedSnippet | | go in. | |
| // | | // modified: if provided, and set to true by finalizeInsertionSet, addit | |
| // | | ional | |
| | | // steps were taken to make the installation work, such as mod | |
| API_EXPORT(Int, (parentSnippet), | | ifying | |
| BPatchSnippetHandle *,getInheritedSnippet,(BPatchSnippetHandle &parentS | | // process state. Note that such steps will be taken whether | |
| nippet)); | | or not | |
| | | // a variable is provided. | |
| // BPatch_binaryEdit::beginInsertionSet() | | | |
| // | | bool finalizeInsertionSet(bool atomic, bool *modified = NULL); | |
| // Start the batch insertion of multiple points; all calls to insertSn | | | |
| ippet* | | bool finalizeInsertionSetWithCatchup(bool atomic, bool *modified, | |
| // after this call will not actually instrument until finalizeInsertio | | BPatch_Vector<BPatch_catchupInfo> &c | |
| nSet is | | atchup_handles); | |
| // called | | | |
| | | // BPatch_process::oneTimeCode | |
| API_EXPORT_V(Int, (), | | // | |
| void, beginInsertionSet, ()); | | // Have the specified code be executed by the mutatee once. Wait until | |
| | | done. | |
| //BPatch_process::finalizeInsertionSet() | | | |
| | | void* oneTimeCode(const BPatch_snippet &expr, bool *err = NULL); | |
| // Finalizes all instrumentation logically added since a call to beg | | | |
| inInsertionSet. | | // BPatch_process::oneTimeCodeAsync | |
| // Returns true if all instrumentation was successfully inserted; othe | | // | |
| rwise, none | | // Have the specified code be executed by the mutatee once. Dont wait u | |
| // was. Individual instrumentation can be manipulated via the BPatchSn | | ntil done. | |
| ippetHandles | | | |
| // returned from individual calls to insertSnippet. | | bool oneTimeCodeAsync(const BPatch_snippet &expr, void *userData = NULL, | |
| // | | BPatchOneTimeCodeCallback cb = NULL); | |
| // atomic: if true, all instrumentation will be removed if any fails t | | | |
| o go in. | | // BPatch_process::hideDebugger() | |
| // modified: if provided, and set to true by finalizeInsertionSet, add | | // | |
| itional | | // This is a Windows only function that removes debugging artifacts that | |
| // steps were taken to make the installation work, such as m | | // are added to user-space datastructures and the heap of the debugged | |
| odifying | | // process, by CreateProcess and DebugActiveProcess. Removing the artifa | |
| // process state. Note that such steps will be taken whethe | | cts | |
| r or not | | // doesn't have any effect on the process, as the kernel still knows that | |
| // a variable is provided. | | // the process is being debugged. Three of the artifacts are flags that | |
| | | can | |
| API_EXPORT(Int, (atomic, modified), | | // be reached through the Process Environment Block of the debuggee (PEB) | |
| bool, finalizeInsertionSet, (bool atomic, bool *modified = N | | : | |
| ULL)); | | // 1. BeingDebugged, one byte at offset 2 in the PEB. | |
| | | // 2. NtGlobalFlags, at offset 0x68 in the PEB | |
| API_EXPORT(Int, (atomic, modified, catchup_handles), | | // 3. There are two consecutive words of heap flags which are at offset | |
| bool, finalizeInsertionSetWithCatchup, (bool atomic, bool *m | | 0x0c | |
| odified, | | // from the beginning of the heap. The heap base address is at offs | |
| BPatch_Vector<BPatch_catchupInf | | et | |
| o> &catchup_handles)); | | // 0x18 from the beginning of the PEB. | |
| | | // The other thing this method does is clear the 0xabababababababab value | |
| // BPatch_process::oneTimeCode | | that | |
| // | | // it CreateProcess adds to the end of the heap section when creating a d | |
| // Have the specified code be executed by the mutatee once. Wait unti | | ebugged | |
| l done. | | // process, in response to the heap flag: HEAP_TAIL_CHECKING_ENABLED, whi | |
| | | ch it | |
| API_EXPORT(Int, (expr, err), | | // sets to true for debugged processes. We are clearing that flag, but b | |
| void *,oneTimeCode,(const BPatch_snippet &expr, bool *err = NULL)); | | y the | |
| | | // time we do, the value is already written to disk. | |
| // BPatch_process::oneTimeCodeAsync | | // | |
| // | | // Various system calls can still be used by the debuggee to recognize th | |
| // Have the specified code be executed by the mutatee once. Dont wait | | at | |
| until done. | | // it is being debugged, so this is not a complete solution. | |
| | | bool hideDebugger(); | |
| API_EXPORT(Int, (expr, userData, cb), | | | |
| bool,oneTimeCodeAsync,(const BPatch_snippet &expr, void *userData = NUL | | | |
| L, | | | |
| BPatchOneTimeCodeCallback cb = NULL)); | | | |
| | | | |
| // BPatch_process::hideDebugger() | | | |
| // | | | |
| // This is a Windows only function that removes debugging artifacts tha | | | |
| t | | | |
| // are added to user-space datastructures and the heap of the debugged | | | |
| // process, by CreateProcess and DebugActiveProcess. Removing the arti | | | |
| facts | | | |
| // doesn't have any effect on the process, as the kernel still knows th | | | |
| at | | | |
| // the process is being debugged. Three of the artifacts are flags tha | | | |
| t can | | | |
| // be reached through the Process Environment Block of the debuggee (PE | | | |
| B): | | | |
| // 1. BeingDebugged, one byte at offset 2 in the PEB. | | | |
| // 2. NtGlobalFlags, at offset 0x68 in the PEB | | | |
| // 3. There are two consecutive words of heap flags which are at offs | | | |
| et 0x0c | | | |
| // from the beginning of the heap. The heap base address is at of | | | |
| fset | | | |
| // 0x18 from the beginning of the PEB. | | | |
| // The other thing this method does is clear the 0xabababababababab val | | | |
| ue that | | | |
| // it CreateProcess adds to the end of the heap section when creating a | | | |
| debugged | | | |
| // process, in response to the heap flag: HEAP_TAIL_CHECKING_ENABLED, w | | | |
| hich it | | | |
| // sets to true for debugged processes. We are clearing that flag, but | | | |
| by the | | | |
| // time we do, the value is already written to disk. | | | |
| // | | | |
| // Various system calls can still be used by the debuggee to recognize | | | |
| that | | | |
| // it is being debugged, so this is not a complete solution. | | | |
| API_EXPORT(Int, (), | | | |
| bool,hideDebugger,()); | | | |
| #if 0 | | #if 0 | |
|
| API_EXPORT_V(Int, (), | | void printDefensiveStats(); | |
| void, printDefensiveStats, ()); | | | |
| #endif | | #endif | |
|
| // BPatch_process::enableDumpPatchedImage | | // BPatch_process::enableDumpPatchedImage | |
| // | | // | |
| // | | // | |
| API_EXPORT_V(Int, (), | | void enableDumpPatchedImage(); | |
| void,enableDumpPatchedImage,()); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
|
| API_EXPORT(Int, (name, loadaddr), | | bool addSharedObject(const char *name, const unsigned long loadaddr); | |
| bool,addSharedObject,(const char *name, const unsigned long loadaddr)); | | | |
| #endif | | #endif | |
| | | | |
|
| // BPatch_process::loadLibrary | | // BPatch_process::loadLibrary | |
| // | | // | |
| // Load a shared library into the mutatee's address space | | // Load a shared library into the mutatee's address space | |
| // Returns true if successful | | // Returns true if successful | |
| | | | |
|
| API_EXPORT_VIRT(Int, (libname, reload), | | virtual BPatch_object * loadLibrary(const char *libname, bool reload = fa | |
| BPatch_object *, loadLibrary,(const char *libname, bool reload = false) | | lse); | |
| ); | | | |
| | | | |
| }; | | }; | |
| | | | |
| #endif /* BPatch_process_h_ */ | | #endif /* BPatch_process_h_ */ | |
| | | | |
End of changes. 15 change blocks. |
| 434 lines changed or deleted | | 386 lines changed or added | |
|
| BPatch_snippet.h | | BPatch_snippet.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| #ifndef _BPatch_snippet_h_ | | #ifndef _BPatch_snippet_h_ | |
| #define _BPatch_snippet_h_ | | #define _BPatch_snippet_h_ | |
| | | | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
| #include "BPatch_sourceObj.h" | | #include "BPatch_sourceObj.h" | |
| #include "BPatch_type.h" | | #include "BPatch_type.h" | |
| #include "BPatch_module.h" | | #include "BPatch_module.h" | |
| //#include "BPatch_addressSpace.h" | | //#include "BPatch_addressSpace.h" | |
| //#include "BPatch_function.h" | | //#include "BPatch_function.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include "BPatch_callbacks.h" | | #include "BPatch_callbacks.h" | |
| #include "BPatch_instruction.h" // for register type | | #include "BPatch_instruction.h" // for register type | |
| #include "BPatch_enums.h" | | #include "BPatch_enums.h" | |
| #include "boost/shared_ptr.hpp" | | #include "boost/shared_ptr.hpp" | |
| | | | |
| class AstNode; | | class AstNode; | |
| // Don't include the boost shared_ptr library | | // Don't include the boost shared_ptr library | |
| class BPatch_snippet; | | class BPatch_snippet; | |
| | | | |
| typedef boost::shared_ptr<AstNode> AstNodePtr; | | typedef boost::shared_ptr<AstNode> AstNodePtr; | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 114 | |
| BPatch_negate, | | BPatch_negate, | |
| BPatch_address, | | BPatch_address, | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| BPatch_deref, | | BPatch_deref, | |
| BPatch_bit_compl // not supported yet | | BPatch_bit_compl // not supported yet | |
| #else | | #else | |
| BPatch_deref | | BPatch_deref | |
| #endif | | #endif | |
| } BPatch_unOp; | | } BPatch_unOp; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_snippet { | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_snippet | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_snippet : public BPatch_eventLock { | | | |
| | | | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_binaryEdit; | | friend class BPatch_binaryEdit; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| friend class BPatch_thread; | | friend class BPatch_thread; | |
| friend class BPatch_arithExpr; | | friend class BPatch_arithExpr; | |
| friend class BPatch_boolExpr; | | friend class BPatch_boolExpr; | |
| friend class BPatch_funcCallExpr; | | friend class BPatch_funcCallExpr; | |
| friend class BPatch_variableExpr; | | friend class BPatch_variableExpr; | |
| friend class BPatch_ifExpr; | | friend class BPatch_ifExpr; | |
| | | | |
| skipping to change at line 152 | | skipping to change at line 146 | |
| friend Dyninst::PatchAPI::SnippetPtr convert(const BPatch_snippet *snip
); | | friend Dyninst::PatchAPI::SnippetPtr convert(const BPatch_snippet *snip
); | |
| | | | |
| public: | | public: | |
| | | | |
| int PDSEP_astMinCost(); // This will go away too | | int PDSEP_astMinCost(); // This will go away too | |
| | | | |
| // BPatch_snippet::BPatch_snippet | | // BPatch_snippet::BPatch_snippet | |
| // Default constructor | | // Default constructor | |
| | | | |
| BPatch_snippet(); | | BPatch_snippet(); | |
|
| BPatch_snippet(AstNodePtr ast) {BPatch_snippet(); ast_wrapper = ast;} | | BPatch_snippet(const AstNodePtr& ast); | |
| | | | |
| // BPatch_snippet::BPatch_snippet | | // BPatch_snippet::BPatch_snippet | |
| // Copy constructor | | // Copy constructor | |
| | | | |
|
| public: BPatch_snippet(const BPatch_snippet &src) : BPatch_eventLock(s | | public: BPatch_snippet(const BPatch_snippet &src); | |
| rc) | | | |
| { LOCK_FUNCTION_V(BPatch_snippetInt,(src)); } | | | |
| | | | |
| public: | | public: | |
| //DynC internal use only | | //DynC internal use only | |
| // BPatch_snippet::getType | | // BPatch_snippet::getType | |
| // Returns the type of the underlying AST | | // Returns the type of the underlying AST | |
|
| API_EXPORT(Int, (), | | BPatch_type * getType(); | |
| BPatch_type *,getType,()); | | | |
| | | | |
|
| private: | | public: | |
| | | | |
|
| void BPatch_snippetInt(const BPatch_snippet &src); | | | |
| void BPatch_snippetInt(const AstNodePtr &node); | | | |
| // BPatch_snippet:operator= | | // BPatch_snippet:operator= | |
| // Assign one BPatch_snippet to another | | // Assign one BPatch_snippet to another | |
|
| API_EXPORT_OPER(_equals, (src), | | | |
| | | | |
|
| BPatch_snippet &,operator=,(const BPatch_snippet &src)); | | BPatch_snippet & operator=(const BPatch_snippet &src); | |
| | | | |
| // BPatch_snippet::~BPatch_snippet | | // BPatch_snippet::~BPatch_snippet | |
| // Destructor, decrements reference count to snippet, deleting when no
ne are left | | // Destructor, decrements reference count to snippet, deleting when no
ne are left | |
|
| API_EXPORT_DTOR(_dtor, (), | | | |
| | | | |
|
| ~,BPatch_snippet,()); | | virtual ~BPatch_snippet(); | |
| | | | |
| // BPatch_snippet::getCost | | // BPatch_snippet::getCost | |
| // Returns an estimated cost of executing the snippet, in seconds. | | // Returns an estimated cost of executing the snippet, in seconds. | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| float,getCost,()); | | float getCost(); | |
| | | | |
| // BPatch_snippet::getCostAtPoint | | // BPatch_snippet::getCostAtPoint | |
| // Returns an estimated cost of executing the snippet at a specified p
oint, in seconds. | | // Returns an estimated cost of executing the snippet at a specified p
oint, in seconds. | |
|
| API_EXPORT(Int, (pt), | | | |
| | | | |
|
| float,getCostAtPoint,(BPatch_point *pt)); | | float getCostAtPoint(BPatch_point *pt); | |
| | | | |
| // BPatch_snippet::is_trivial | | // BPatch_snippet::is_trivial | |
| // allows users to check to see if | | // allows users to check to see if | |
| // a snippet operation failed (leaving ast NULL) | | // a snippet operation failed (leaving ast NULL) | |
|
| API_EXPORT(Int, (), | | | |
| | | | |
|
| bool,is_trivial,()); | | bool is_trivial(); | |
| | | | |
| // protected: | | // protected: | |
| //AstNodePtr *ast_wrapper; | | //AstNodePtr *ast_wrapper; | |
| | | | |
| AstNodePtr ast_wrapper; | | AstNodePtr ast_wrapper; | |
| | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_arithExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_arithExpr: public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_arithExpr: public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_arithExpr::BPatch_arithExpr (Binary Arithmetic Operation) | | // BPatch_arithExpr::BPatch_arithExpr (Binary Arithmetic Operation) | |
| // | | // | |
|
| API_EXPORT_CTOR(Bin, (op, lOperand, rOperand), | | BPatch_arithExpr(BPatch_binOp op, | |
| BPatch_arithExpr,(BPatch_binOp op, | | | |
| const BPatch_snippet &lOperand, | | const BPatch_snippet &lOperand, | |
|
| const BPatch_snippet &rOperand)); | | const BPatch_snippet &rOperand); | |
| | | | |
| // BPatch_arithExpr::BPatch_arithExpr (Unary Arithmetic Operation) | | // BPatch_arithExpr::BPatch_arithExpr (Unary Arithmetic Operation) | |
| // | | // | |
|
| API_EXPORT_CTOR(Un, (op, lOperand), | | BPatch_arithExpr(BPatch_unOp op, const BPatch_snippet &lOperand); | |
| BPatch_arithExpr,(BPatch_unOp op, const BPatch_snippet &lOperand)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_boolExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_boolExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_boolExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_boolExpr::BPatch_boolExpr | | // BPatch_boolExpr::BPatch_boolExpr | |
| // Creates a representation of boolean operation | | // Creates a representation of boolean operation | |
|
| API_EXPORT_CTOR(Int, (op, lOperand, rOperand), | | BPatch_boolExpr(BPatch_relOp op, const BPatch_snippet &lOperand, | |
| BPatch_boolExpr,(BPatch_relOp op, const BPatch_snippet &lOperand, | | const BPatch_snippet &rOperand); | |
| const BPatch_snippet &rOperand)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_constExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_constExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_constExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_constExpr::BPatch_constExpr | | // BPatch_constExpr::BPatch_constExpr | |
| // Creates a representation of a (signed int) value | | // Creates a representation of a (signed int) value | |
|
| API_EXPORT_CTOR(SignedInt, (value), | | BPatch_constExpr(signed int value); | |
| BPatch_constExpr,(signed int value)); | | | |
| | | | |
| // Creates a representation of an (unsigned int) value | | // Creates a representation of an (unsigned int) value | |
|
| API_EXPORT_CTOR(UnsignedInt, (value), | | BPatch_constExpr(unsigned int value); | |
| BPatch_constExpr,(unsigned int value)); | | | |
| | | | |
| // Creates a representation of a (signed long) value | | // Creates a representation of a (signed long) value | |
|
| API_EXPORT_CTOR(SignedLong, (value), | | BPatch_constExpr(signed long value); | |
| BPatch_constExpr,(signed long value)); | | | |
| | | | |
| // Creates a representation of an (unsigned long) value | | // Creates a representation of an (unsigned long) value | |
|
| API_EXPORT_CTOR(UnsignedLong, (value), | | BPatch_constExpr(unsigned long value); | |
| BPatch_constExpr,(unsigned long value)); | | | |
| | | | |
| // BPatch_constExpr::BPatch_constExpr | | // BPatch_constExpr::BPatch_constExpr | |
| // Creates a representation of a (char *) value | | // Creates a representation of a (char *) value | |
|
| API_EXPORT_CTOR(CharStar, (value), | | BPatch_constExpr(const char *value); | |
| BPatch_constExpr,(const char *value)); | | | |
| | | | |
| // BPatch_constExpr::BPatch_constExpr | | // BPatch_constExpr::BPatch_constExpr | |
| // Creates a representation of a (void *) value | | // Creates a representation of a (void *) value | |
|
| API_EXPORT_CTOR(VoidStar, (value), | | BPatch_constExpr(const void *value); | |
| BPatch_constExpr,(const void *value)); | | | |
| | | | |
| // BPatch_constExpr::BPatch_constExpr | | // BPatch_constExpr::BPatch_constExpr | |
| // Creates a representation of a (long long) value | | // Creates a representation of a (long long) value | |
|
| API_EXPORT_CTOR(LongLong, (value), | | BPatch_constExpr(long long value); | |
| BPatch_constExpr,(long long value)); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| // BPatch_constExpr::BPatch_constExpr | | // BPatch_constExpr::BPatch_constExpr | |
| // Creates a representation of a (float) value | | // Creates a representation of a (float) value | |
|
| API_EXPORT_CTOR(Float, (value), | | BPatch_constExpr(float value); | |
| BPatch_constExpr,(float value)); | | | |
| #endif | | #endif | |
| | | | |
| // Should _always_ have a default constructor. This | | // Should _always_ have a default constructor. This | |
| // one produces a 0 | | // one produces a 0 | |
| BPatch_constExpr() : BPatch_snippet() {}; | | BPatch_constExpr() : BPatch_snippet() {}; | |
| | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_whileExpr : public BPatch_snippet { | |
| #undef DYNINST_CLASS_NAME | | public: | |
| #endif | | // BPatch_whileExpr::BPatch_whileExpr (while loop) | |
| #define DYNINST_CLASS_NAME BPatch_regExpr | | BPatch_whileExpr(const BPatch_snippet &condition, | |
| | | const BPatch_snippet &body); | |
| | | }; | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_regExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_regExpr : public BPatch_snippet { | |
|
| | | public: | |
| // DEPRECATED!!! | | // DEPRECATED!!! | |
| | | | |
| // BPatch_regExpr::BPatch_regExpr | | // BPatch_regExpr::BPatch_regExpr | |
| // Creates a representation of the contents of a particular register | | // Creates a representation of the contents of a particular register | |
| // specified by <value> | | // specified by <value> | |
|
| API_EXPORT_CTOR(Int, (value), | | BPatch_regExpr(unsigned int value); | |
| BPatch_regExpr,(unsigned int value)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_funcCallExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_funcCallExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_funcCallExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_funcCallExpr::BPatch_funcCallExpr | | // BPatch_funcCallExpr::BPatch_funcCallExpr | |
| // Creates a representation of a function call | | // Creates a representation of a function call | |
|
| API_EXPORT_CTOR(Int, (func, args), | | BPatch_funcCallExpr(const BPatch_function& func, | |
| BPatch_funcCallExpr,(const BPatch_function& func, | | const BPatch_Vector<BPatch_snippet *> &args); | |
| const BPatch_Vector<BPatch_snippet *> &args)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_ifExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_ifExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_ifExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_ifExpr::BPatch_ifExpr | | // BPatch_ifExpr::BPatch_ifExpr | |
| // Creates a conditional expression "if <conditional> tClause;" | | // Creates a conditional expression "if <conditional> tClause;" | |
|
| API_EXPORT_CTOR(Int, (conditional, tClause), | | BPatch_ifExpr(const BPatch_boolExpr &conditional, | |
| BPatch_ifExpr,(const BPatch_boolExpr &conditional, | | const BPatch_snippet &tClause); | |
| const BPatch_snippet &tClause)); | | | |
| | | | |
| // BPatch_ifExpr::BPatch_ifExpr | | // BPatch_ifExpr::BPatch_ifExpr | |
| // Creates a conditional expression | | // Creates a conditional expression | |
| // "if <conditional> tClause; else fClause;" | | // "if <conditional> tClause; else fClause;" | |
|
| API_EXPORT_CTOR(WithElse, (conditional, tClause, fClause), | | BPatch_ifExpr(const BPatch_boolExpr &conditional, | |
| BPatch_ifExpr,(const BPatch_boolExpr &conditional, | | | |
| const BPatch_snippet &tClause, | | const BPatch_snippet &tClause, | |
|
| const BPatch_snippet &fClause)); | | const BPatch_snippet &fClause); | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_nullExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_nullExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_nullExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_nullExpr::BPatch_nullExpr | | // BPatch_nullExpr::BPatch_nullExpr | |
| // Creates a null snippet that can be used as a placeholder. | | // Creates a null snippet that can be used as a placeholder. | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_nullExpr(); | |
| BPatch_nullExpr,()); | | | |
| | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_paramExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_paramExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_paramExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_paramExpr::BPatch_paramExpr | | // BPatch_paramExpr::BPatch_paramExpr | |
| // Represents a parameter of a function (used in creating funcCallExpr
) | | // Represents a parameter of a function (used in creating funcCallExpr
) | |
| // n is the index of the parameter that should be retrieved | | // n is the index of the parameter that should be retrieved | |
| // loc indicates whether the parameter lookup will be added at the ca
ll, | | // loc indicates whether the parameter lookup will be added at the ca
ll, | |
| // at the function's entry point, or whether Dyninst should guess | | // at the function's entry point, or whether Dyninst should guess | |
| // based on the instPoint type, which is error-prone and deprecat
ed | | // based on the instPoint type, which is error-prone and deprecat
ed | |
|
| API_EXPORT_CTOR(Int, (n,loc), | | BPatch_paramExpr(int n, BPatch_ploc loc=BPatch_ploc_guess); | |
| BPatch_paramExpr,(int n, BPatch_ploc loc=BPatch_ploc_guess)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_retExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_retExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_retExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_retExpr::BPatch_retExpr | | // BPatch_retExpr::BPatch_retExpr | |
| // Represents the return value from the function in which the | | // Represents the return value from the function in which the | |
| // snippet is inserted | | // snippet is inserted | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_retExpr(); | |
| BPatch_retExpr,()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_retAddrExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_retAddrExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_retAddrExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_retAddrExpr::BPatch_retAddrExpr | | // BPatch_retAddrExpr::BPatch_retAddrExpr | |
| // Represents the return address from the function in which the | | // Represents the return address from the function in which the | |
| // snippet is inserted | | // snippet is inserted | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_retAddrExpr(); | |
| BPatch_retAddrExpr,()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_registerExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_registerExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_registerExpr : public BPatch_snippet { | |
|
| | | public: | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| // BPatch_registerExpr::BPatch_registerExpr | | // BPatch_registerExpr::BPatch_registerExpr | |
| // Represents the return value from the function in which the | | // Represents the return value from the function in which the | |
| // snippet is inserted | | // snippet is inserted | |
| | | | |
|
| API_EXPORT_CTOR(Int, (reg), | | BPatch_registerExpr(BPatch_register reg); | |
| BPatch_registerExpr, (BPatch_register reg)); | | BPatch_registerExpr(Dyninst::MachRegister reg); | |
| API_EXPORT_CTOR(Int, (reg), | | | |
| BPatch_registerExpr, (Dyninst::MachRegister reg)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_sequence | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_sequence : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_sequence : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_sequence::BPatch_sequence | | // BPatch_sequence::BPatch_sequence | |
| // Represents a sequence of statements | | // Represents a sequence of statements | |
|
| API_EXPORT_CTOR(Int, (items), | | BPatch_sequence(const BPatch_Vector<BPatch_snippet *> &items); | |
| BPatch_sequence,(const BPatch_Vector<BPatch_snippet *> &items)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_variableExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_variableExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_variableExpr : public BPatch_snippet | |
| { | | { | |
| friend class BPatch_process; | | friend class BPatch_process; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| friend class BPatch_binaryEdit; | | friend class BPatch_binaryEdit; | |
| friend class BPatch_image; | | friend class BPatch_image; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| | | | |
| const char *name; | | const char *name; | |
| BPatch_addressSpace *appAddSpace; | | BPatch_addressSpace *appAddSpace; | |
| AddressSpace *lladdrSpace; | | AddressSpace *lladdrSpace; | |
| void *address; | | void *address; | |
| int size; | | int size; | |
| BPatch_point *scope; | | BPatch_point *scope; | |
| bool isLocal; | | bool isLocal; | |
| BPatch_type *type; | | BPatch_type *type; | |
| int_variable *intvar; | | int_variable *intvar; | |
| | | | |
| AddressSpace *getAS(); | | AddressSpace *getAS(); | |
|
| private: | | | |
| // Used to get expressions for the components of a structure | | // Used to get expressions for the components of a structure | |
| // Used to get function pointers | | // Used to get function pointers | |
| BPatch_variableExpr(char *in_name, | | BPatch_variableExpr(char *in_name, | |
| BPatch_addressSpace *in_addSpace, | | BPatch_addressSpace *in_addSpace, | |
| AddressSpace *as, | | AddressSpace *as, | |
| AstNodePtr ast_wrapper_, | | AstNodePtr ast_wrapper_, | |
| BPatch_type *type, void* in_address); | | BPatch_type *type, void* in_address); | |
| // Used to get forked copies of variable expressions | | // Used to get forked copies of variable expressions | |
| // Used by malloc & malloc_by_type | | // Used by malloc & malloc_by_type | |
| BPatch_variableExpr(BPatch_addressSpace *in_addSpace, | | BPatch_variableExpr(BPatch_addressSpace *in_addSpace, | |
| | | | |
| skipping to change at line 488 | | skipping to change at line 394 | |
| BPatch_localVar *lv, BPatch_type *type, | | BPatch_localVar *lv, BPatch_type *type, | |
| BPatch_point *scp); | | BPatch_point *scp); | |
| | | | |
| // BPatch_variableExpr(const char *name, BPatch_addressSpace *in_add
Space, | | // BPatch_variableExpr(const char *name, BPatch_addressSpace *in_add
Space, | |
| // AddressSpace *ll_addSpace, void *in_address, | | // AddressSpace *ll_addSpace, void *in_address, | |
| // BPatch_type *type); | | // BPatch_type *type); | |
| // Used by findOrCreateVariable | | // Used by findOrCreateVariable | |
| BPatch_variableExpr(BPatch_addressSpace *in_addSpace, | | BPatch_variableExpr(BPatch_addressSpace *in_addSpace, | |
| AddressSpace *ll_addSpace, int_variable *iv, | | AddressSpace *ll_addSpace, int_variable *iv, | |
| BPatch_type *type); | | BPatch_type *type); | |
|
| | | public: | |
| static BPatch_variableExpr* makeVariableExpr(BPatch_addressSpace* in_ad
dSpace, | | static BPatch_variableExpr* makeVariableExpr(BPatch_addressSpace* in_ad
dSpace, | |
| int_variable* v, | | int_variable* v, | |
| BPatch_type* type); | | BPatch_type* type); | |
| static BPatch_variableExpr* makeVariableExpr(BPatch_addressSpace* in_ad
dSpace, | | static BPatch_variableExpr* makeVariableExpr(BPatch_addressSpace* in_ad
dSpace, | |
| AddressSpace* in_llAddSpace
, | | AddressSpace* in_llAddSpace
, | |
| std::string name, | | std::string name, | |
| void* offset, | | void* offset, | |
| BPatch_type* type); | | BPatch_type* type); | |
| | | | |
| public: | | public: | |
| | | | |
| // Public functions for use by users of the library: | | // Public functions for use by users of the library: | |
| | | | |
| // BPatch_variableExpr::getSize | | // BPatch_variableExpr::getSize | |
| // Returns the size (in bytes) of this variable | | // Returns the size (in bytes) of this variable | |
|
| API_EXPORT(Int, (), | | unsigned int getSize() const; | |
| unsigned int,getSize,() CONST_EXPORT); | | | |
| | | | |
| // BPatch_variableExpr::getType | | // BPatch_variableExpr::getType | |
| // Returns the type of this variable | | // Returns the type of this variable | |
|
| API_EXPORT(Int, (), | | const BPatch_type * getType(); | |
| const BPatch_type *,getType,()); | | | |
| | | | |
| // BPatch_variableExpr::setType | | // BPatch_variableExpr::setType | |
| // Sets the type of this variable | | // Sets the type of this variable | |
| // XXX -- should this really be public? | | // XXX -- should this really be public? | |
|
| API_EXPORT(Int, (t), | | bool setType(BPatch_type *t); | |
| bool,setType,(BPatch_type *t)); | | | |
| | | | |
| // BPatch_variableExpr::setSize | | // BPatch_variableExpr::setSize | |
| // Sets the size of this variable | | // Sets the size of this variable | |
| // XXX -- should this really be public? | | // XXX -- should this really be public? | |
|
| API_EXPORT(Int, (sz), | | bool setSize(int sz); | |
| bool,setSize,(int sz)); | | | |
| | | | |
| // BPatch_variableExpr::readValue | | // BPatch_variableExpr::readValue | |
| // Read the value of a variable in a thread's address space. | | // Read the value of a variable in a thread's address space. | |
| // <dst> is assumed to be the same size as the variable. | | // <dst> is assumed to be the same size as the variable. | |
|
| API_EXPORT(Int, (dst), | | bool readValue(void *dst); | |
| bool,readValue,(void *dst)); | | | |
| | | | |
| // BPatch_variableExpr::readValue | | // BPatch_variableExpr::readValue | |
| // Read the value of a variable in a thread's address space. | | // Read the value of a variable in a thread's address space. | |
| // Will read <len> bytes into <dst> | | // Will read <len> bytes into <dst> | |
|
| API_EXPORT(WithLength, (dst, len), | | bool readValue(void *dst, int len); | |
| bool,readValue,(void *dst, int len)); | | | |
| | | | |
| // BPatch_variableExpr::writeValue | | // BPatch_variableExpr::writeValue | |
| // Write a value into a variable in a thread's address space. | | // Write a value into a variable in a thread's address space. | |
| // variable is assumed to be the same size as the <dst>. | | // variable is assumed to be the same size as the <dst>. | |
| // returns false if the type info isn't available (i.e. we don't know
the size) | | // returns false if the type info isn't available (i.e. we don't know
the size) | |
|
| API_EXPORT(Int, (src, saveWorld), | | bool writeValue(const void *src, bool saveWorld=false); | |
| bool,writeValue,(const void *src, bool saveWorld=false)); | | | |
| | | | |
| // BPatch_variableExpr::writeValue | | // BPatch_variableExpr::writeValue | |
| // Write a value into a variable in a thread's address space. | | // Write a value into a variable in a thread's address space. | |
| // Will write <len> bytes from <src> into variable | | // Will write <len> bytes from <src> into variable | |
|
| API_EXPORT(WithLength, (src, len, saveWorld), | | bool writeValue(const void *src, int len,bool saveWorld=false); | |
| bool,writeValue,(const void *src, int len,bool saveWorld=false)); | | | |
| | | | |
| // BPatch_variableExpr::getName | | // BPatch_variableExpr::getName | |
| // Returns the symbol table name for this variable | | // Returns the symbol table name for this variable | |
|
| API_EXPORT(Int, (), | | const char * getName(); | |
| const char *,getName,()); | | | |
| | | | |
| // BPatch_variableExpr::getBaseAddr | | // BPatch_variableExpr::getBaseAddr | |
| // Returns base address of this variable in the target's address space | | // Returns base address of this variable in the target's address space | |
|
| API_EXPORT(Int, (), | | void * getBaseAddr(); | |
| void *,getBaseAddr,()); | | | |
| | | | |
| // BPatch_variableExpr::getComponents | | // BPatch_variableExpr::getComponents | |
| // return variable expressions for all of the fields in a struct/union | | // return variable expressions for all of the fields in a struct/union | |
|
| API_EXPORT(Int, (), | | BPatch_Vector<BPatch_variableExpr *> * getComponents(); | |
| BPatch_Vector<BPatch_variableExpr *> *,getComponents,()); | | | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
|
| API_EXPORT(WithLength, (buffer, max), | | char * getName(char *buffer, int max); | |
| char *,getName,(char *buffer, int max)); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | void * getAddress(); | |
| void *,getAddress,()); | | | |
| | | | |
| #endif | | #endif | |
| | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_breakPointExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_breakPointExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_breakPointExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_breakPointExpr::BPatch_breakPointExpr | | // BPatch_breakPointExpr::BPatch_breakPointExpr | |
| // Creates a representation of a break point in the target process | | // Creates a representation of a break point in the target process | |
| | | | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_breakPointExpr(); | |
| BPatch_breakPointExpr,()); | | | |
| }; | | }; | |
| | | | |
| // VG(11/05/01): This nullary snippet will return the effective | | // VG(11/05/01): This nullary snippet will return the effective | |
| // address of a memory access when inserted at an instrumentation | | // address of a memory access when inserted at an instrumentation | |
| // point that is a memory access. In other words, the instruction at | | // point that is a memory access. In other words, the instruction at | |
| // the point where it is inserted is the one to get effective address | | // the point where it is inserted is the one to get effective address | |
| // for. Furthermore, there must be memory access information about | | // for. Furthermore, there must be memory access information about | |
| // the inst. point; this basically means that the point must have been | | // the inst. point; this basically means that the point must have been | |
| // created using a method that attaches that info to the point - | | // created using a method that attaches that info to the point - | |
|
| // e.g. using findPoint(const BPatch_Set<BPatch_opCode>& ops) from | | // e.g. using findPoint(const std::set<BPatch_opCode>& ops) from | |
| // BPatch_function. | | // BPatch_function. | |
| | | | |
| // VG(7/31/02): Since x86 can have 2 addresses per instruction, there is | | // VG(7/31/02): Since x86 can have 2 addresses per instruction, there is | |
| // now parameter for the constructor indicating which of these you want. | | // now parameter for the constructor indicating which of these you want. | |
| // It defaults to the 1st access (#0). | | // It defaults to the 1st access (#0). | |
| | | | |
| // VG(8/14/02): added conditional parameter | | // VG(8/14/02): added conditional parameter | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_effectiveAddressExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_effectiveAddressExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_effectiveAddressExpr : public BPatch_snippet | |
| { | | { | |
|
| | | public: | |
| // BPatch_effectiveAddressExpr:: BPatch_effectiveAddressExpr | | // BPatch_effectiveAddressExpr:: BPatch_effectiveAddressExpr | |
| // Construct a snippet representing an effective address. | | // Construct a snippet representing an effective address. | |
| | | | |
|
| API_EXPORT_CTOR(Int, (_which), | | BPatch_effectiveAddressExpr(int _which = 0); | |
| BPatch_effectiveAddressExpr,(int _which = 0)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_bytesAccessedExpr | | | |
| | | | |
| // Number of bytes moved | | // Number of bytes moved | |
| class BPATCH_DLL_EXPORT BPatch_bytesAccessedExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_bytesAccessedExpr : public BPatch_snippet | |
| { | | { | |
|
| | | public: | |
| // BPatch_bytesAccessedExpr::BPatch_bytesAccessedExpr | | // BPatch_bytesAccessedExpr::BPatch_bytesAccessedExpr | |
| // Construct a snippet representing the number of bytes accessed. | | // Construct a snippet representing the number of bytes accessed. | |
| | | | |
|
| API_EXPORT_CTOR(Int, (_which), | | BPatch_bytesAccessedExpr(int _which = 0); | |
| BPatch_bytesAccessedExpr,(int _which = 0)); | | | |
| }; | | }; | |
| | | | |
| // VG(8/11/2): It is possible to have a more general expression, say | | // VG(8/11/2): It is possible to have a more general expression, say | |
| // machineConditionExpr, then have this reimplemented as ifExpr(machineCond
itionExpr, ...), | | // machineConditionExpr, then have this reimplemented as ifExpr(machineCond
itionExpr, ...), | |
| // and have an optimization (fast path) for that case using the specialized | | // and have an optimization (fast path) for that case using the specialized | |
| // AST that supports this class. Memory instrumentation has no need for a s
tandalone | | // AST that supports this class. Memory instrumentation has no need for a s
tandalone | |
| // machineConditionExpr, so that remains TBD... | | // machineConditionExpr, so that remains TBD... | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_ifMachineConditionExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_ifMachineConditionExpr : public BPatch_snipp
et { | | class BPATCH_DLL_EXPORT BPatch_ifMachineConditionExpr : public BPatch_snipp
et { | |
|
| | | public: | |
| // BPatch_ifMachineConditionExpr::BPatch_ifMachineConditionExpr | | // BPatch_ifMachineConditionExpr::BPatch_ifMachineConditionExpr | |
| // | | // | |
| | | | |
|
| API_EXPORT_CTOR(Int, (tClause), | | BPatch_ifMachineConditionExpr(const BPatch_snippet &tClause); | |
| BPatch_ifMachineConditionExpr,(const BPatch_snippet &tClause)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_threadIndexExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_threadIndexExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_threadIndexExpr : public BPatch_snippet { | |
|
| | | public: | |
| // | | // | |
| // BPatch_threadIndexExpr::BPatch_threadIndexExpr | | // BPatch_threadIndexExpr::BPatch_threadIndexExpr | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_threadIndexExpr(); | |
| BPatch_threadIndexExpr,()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_tidExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_tidExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_tidExpr : public BPatch_snippet { | |
|
| | | public: | |
| // | | // | |
| // BPatch_tidExpr::BPatch_tidExpr | | // BPatch_tidExpr::BPatch_tidExpr | |
|
| API_EXPORT_CTOR(Int, (proc), | | BPatch_tidExpr(BPatch_process *proc); | |
| BPatch_tidExpr,(BPatch_process *proc)); | | | |
| }; | | }; | |
| | | | |
| class BPatch_instruction; | | class BPatch_instruction; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_insnExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_insnExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_insnExpr : public BPatch_snippet { | |
|
| | | public: | |
| // | | // | |
| // BPatch_insnExpr::BPatch_insnExpr | | // BPatch_insnExpr::BPatch_insnExpr | |
|
| API_EXPORT_CTOR(Int, (insn), | | BPatch_insnExpr(BPatch_instruction *insn); | |
| BPatch_insnExpr,(BPatch_instruction *insn)); | | | |
| | | | |
| // Replace the effective address of a load with the provided snippet | | // Replace the effective address of a load with the provided snippet | |
|
| API_EXPORT(Int, (l), | | bool overrideLoadAddress(BPatch_snippet &l); | |
| bool, overrideLoadAddress, (BPatch_snippet &l)); | | | |
| | | | |
| // Replace the effective address of a store with the provided snippet | | // Replace the effective address of a store with the provided snippet | |
|
| API_EXPORT(Int, (s), | | bool overrideStoreAddress(BPatch_snippet &s); | |
| bool, overrideStoreAddress, (BPatch_snippet &s)); | | | |
| | | | |
| }; | | }; | |
| | | | |
| typedef enum { | | typedef enum { | |
| BPatch_noInterp, | | BPatch_noInterp, | |
| BPatch_interpAsTarget, | | BPatch_interpAsTarget, | |
| BPatch_interpAsReturnAddr, | | BPatch_interpAsReturnAddr, | |
| } BPatch_stInterpret; | | } BPatch_stInterpret; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_shadowExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_shadowExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_shadowExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_stopThreadExpr | | // BPatch_stopThreadExpr | |
| // This snippet type stops the thread that executes it. It | | // This snippet type stops the thread that executes it. It | |
| // evaluates a calculation snippet and triggers a callback to the | | // evaluates a calculation snippet and triggers a callback to the | |
| // user program with the result of the calculation and a pointer to | | // user program with the result of the calculation and a pointer to | |
| // the BPatch_point at which the snippet was inserted | | // the BPatch_point at which the snippet was inserted | |
|
| API_EXPORT_CTOR(Int, (entry, cb, calculation, useCache, interp), | | BPatch_shadowExpr(bool entry, | |
| BPatch_shadowExpr, | | const BPatchStopThreadCallback &cb, | |
| (bool entry, | | const BPatch_snippet &calculation, | |
| const BPatchStopThreadCallback &cb, | | bool useCache = false, | |
| const BPatch_snippet &calculation, | | BPatch_stInterpret interp = BPatch_noInterp); | |
| bool useCache = false, | | | |
| BPatch_stInterpret interp = BPatch_noInterp)); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_stopThreadExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_stopThreadExpr : public BPatch_snippet { | | class BPATCH_DLL_EXPORT BPatch_stopThreadExpr : public BPatch_snippet { | |
|
| | | public: | |
| // BPatch_stopThreadExpr | | // BPatch_stopThreadExpr | |
| // This snippet type stops the thread that executes it. It | | // This snippet type stops the thread that executes it. It | |
| // evaluates a calculation snippet and triggers a callback to the | | // evaluates a calculation snippet and triggers a callback to the | |
| // user program with the result of the calculation and a pointer to | | // user program with the result of the calculation and a pointer to | |
| // the BPatch_point at which the snippet was inserted | | // the BPatch_point at which the snippet was inserted | |
|
| API_EXPORT_CTOR(Int, (cb, calculation, useCache, interp), | | BPatch_stopThreadExpr(const BPatchStopThreadCallback &cb, | |
| BPatch_stopThreadExpr, | | const BPatch_snippet &calculation, | |
| (const BPatchStopThreadCallback &cb, | | bool useCache = false, | |
| const BPatch_snippet &calculation, | | BPatch_stInterpret interp = BPatch_noInterp); | |
| bool useCache = false, | | | |
| BPatch_stInterpret interp = BPatch_noInterp)); | | | |
| | | | |
| // for internal use in conjunction with memory emulation and defensive | | // for internal use in conjunction with memory emulation and defensive | |
| // mode analysis | | // mode analysis | |
| BPatch_stopThreadExpr( | | BPatch_stopThreadExpr( | |
| const BPatchStopThreadCallback &cb, | | const BPatchStopThreadCallback &cb, | |
| const BPatch_snippet &calculation, | | const BPatch_snippet &calculation, | |
| const mapped_object &obj, | | const mapped_object &obj, | |
| bool useCache = false, | | bool useCache = false, | |
| BPatch_stInterpret interp = BPatch_noInterp); | | BPatch_stInterpret interp = BPatch_noInterp); | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_originalAddressExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_originalAddressExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_originalAddressExpr : public BPatch_snippet | |
| { | | { | |
|
| | | public: | |
| // BPatch_originalAddressExpr | | // BPatch_originalAddressExpr | |
| // Construct a snippet representing the original address of an | | // Construct a snippet representing the original address of an | |
| // instruction | | // instruction | |
| | | | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_originalAddressExpr(); | |
| BPatch_originalAddressExpr, ()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_actualAddressExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_actualAddressExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_actualAddressExpr : public BPatch_snippet | |
| { | | { | |
|
| | | public: | |
| // BPatch_actualAddressExpr | | // BPatch_actualAddressExpr | |
| // Construct a snippet representing the actual (relocated) address | | // Construct a snippet representing the actual (relocated) address | |
| // where the snippet was executed. | | // where the snippet was executed. | |
| | | | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_actualAddressExpr(); | |
| BPatch_actualAddressExpr, ()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_dynamicTargetExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_dynamicTargetExpr : public BPatch_snippet | | class BPATCH_DLL_EXPORT BPatch_dynamicTargetExpr : public BPatch_snippet | |
| { | | { | |
|
| | | public: | |
| // BPatch_dynamicTargetExpr | | // BPatch_dynamicTargetExpr | |
| // Construct a snippet to calculate the target of a | | // Construct a snippet to calculate the target of a | |
| // dynamic control transfer instruction | | // dynamic control transfer instruction | |
| | | | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_dynamicTargetExpr(); | |
| BPatch_dynamicTargetExpr, ()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_scrambleRegistersExpr | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_scrambleRegistersExpr : public BPatch_snippe
t | | class BPATCH_DLL_EXPORT BPatch_scrambleRegistersExpr : public BPatch_snippe
t | |
| { | | { | |
| | | | |
| // BPatch_scrambleRegistersExpr | | // BPatch_scrambleRegistersExpr | |
| // Set all GPR to flag value. | | // Set all GPR to flag value. | |
| | | | |
|
| API_EXPORT_CTOR(Int, (), | | BPatch_scrambleRegistersExpr(); | |
| BPatch_scrambleRegistersExpr, ()); | | | |
| }; | | }; | |
| | | | |
| #endif /* _BPatch_snippet_h_ */ | | #endif /* _BPatch_snippet_h_ */ | |
| | | | |
End of changes. 121 change blocks. |
| 291 lines changed or deleted | | 104 lines changed or added | |
|
| BPatch_type.h | | BPatch_type.h | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #ifndef _BPatch_type_h_ | | #ifndef _BPatch_type_h_ | |
| #define _BPatch_type_h_ | | #define _BPatch_type_h_ | |
| | | | |
| #include "BPatch_dll.h" | | #include "BPatch_dll.h" | |
| #include "BPatch_Vector.h" | | #include "BPatch_Vector.h" | |
|
| #include "BPatch_eventLock.h" | | | |
| #include <string.h> | | #include <string.h> | |
| | | | |
| #include "Type.h" | | #include "Type.h" | |
| #include "Variable.h" | | #include "Variable.h" | |
| | | | |
| class BPatch_type; | | class BPatch_type; | |
| namespace Dyninst { | | namespace Dyninst { | |
| namespace SymtabAPI { | | namespace SymtabAPI { | |
| class Type; | | class Type; | |
|
| Type *convert(const BPatch_type *); | | BPATCH_DLL_EXPORT Type *convert(const BPatch_type *); | |
| } | | } | |
| } | | } | |
| | | | |
| typedef enum {BPatchSymLocalVar, BPatchSymGlobalVar, BPatchSymRegisterVar, | | typedef enum {BPatchSymLocalVar, BPatchSymGlobalVar, BPatchSymRegisterVar, | |
| BPatchSymStaticLocalVar, BPatchSymStaticGlobal, | | BPatchSymStaticLocalVar, BPatchSymStaticGlobal, | |
| BPatchSymLocalFunc, BPatchSymGlobalFunc, BPatchSymFuncParam, | | BPatchSymLocalFunc, BPatchSymGlobalFunc, BPatchSymFuncParam, | |
| BPatchSymTypeName, BPatchSymAggType, BPatchSymTypeTag}symDescr
_t; | | BPatchSymTypeName, BPatchSymAggType, BPatchSymTypeTag}symDescr
_t; | |
| | | | |
| /* | | /* | |
| * Symbol Descriptors: | | * Symbol Descriptors: | |
| | | | |
| skipping to change at line 163 | | skipping to change at line 162 | |
| * BPatch_storageRegOffset - Address of variable = $reg + address. | | * BPatch_storageRegOffset - Address of variable = $reg + address. | |
| * BPatch_storageFrameOffset - Address of variable = $fp + address. | | * BPatch_storageFrameOffset - Address of variable = $fp + address. | |
| */ | | */ | |
| | | | |
| class BPatch_type; | | class BPatch_type; | |
| class BPatch_function; | | class BPatch_function; | |
| class BPatch_module; | | class BPatch_module; | |
| | | | |
| /* | | /* | |
| * A BPatch_field is equivalent to a field in a enum, struct, or union. | | * A BPatch_field is equivalent to a field in a enum, struct, or union. | |
|
| * A field can be an atomic type, i.e, int, char, or more complex like a | | * A field can be an atomic type, i.e, int char, or more complex like a | |
| * union or struct. | | * union or struct. | |
| */ | | */ | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_field { | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_field | | | |
| | | | |
| class BPATCH_DLL_EXPORT BPatch_field : public BPatch_eventLock{ | | | |
| friend class BPatch_variableExpr; | | friend class BPatch_variableExpr; | |
| friend class BPatch_cblock; | | friend class BPatch_cblock; | |
| | | | |
| BPatch_dataClass typeDes; | | BPatch_dataClass typeDes; | |
| /* For Enums */ | | /* For Enums */ | |
| int value; | | int value; | |
| | | | |
| /* For structs and unions */ | | /* For structs and unions */ | |
| int size; | | int size; | |
| | | | |
| //Symtab field | | //Symtab field | |
| Dyninst::SymtabAPI::Field *fld; | | Dyninst::SymtabAPI::Field *fld; | |
| | | | |
| protected: | | protected: | |
| void copy(BPatch_field &); | | void copy(BPatch_field &); | |
| void fixupUnknown(BPatch_module *); | | void fixupUnknown(BPatch_module *); | |
| | | | |
| public: | | public: | |
|
| /* | | | |
| // Enum constructor | | | |
| API_EXPORT_CTOR(Enum, (fName, _typeDes, eValue), | | | |
| BPatch_field,(const char * fName, BPatch_dataClass _typeDes, int eValue) | | | |
| ); | | | |
| // C++ version for Enum constructor | | | |
| API_EXPORT_CTOR(EnumCpp, (fName, _typeDes, eValue, _vis), | | | |
| BPatch_field, (const char * fName, BPatch_dataClass _typeDes, int eValue | | | |
| , | | | |
| BPatch_visibility _vis)); | | | |
| // Struct or Union construct | | | |
| API_EXPORT_CTOR(SU, (fName, _typeDes, suType, suOffset, suSize), | | | |
| BPatch_field,(const char * fName, BPatch_dataClass _typeDes, | | | |
| BPatch_type *suType, int suOffset, int suSize)); | | | |
| // C++ version for Struct or Union construct | | | |
| API_EXPORT_CTOR(SUCpp, (fName, _typeDes, suType, suOffset, suSize, _vis), | | | |
| BPatch_field,(const char * fName, BPatch_dataClass _typeDes, | | | |
| BPatch_type *suType, int suOffset, int suSize, | | | |
| BPatch_visibility _vis)); | | | |
| */ | | | |
| | | | |
| // Copy constructor | | // Copy constructor | |
| BPatch_field(BPatch_field &f); | | BPatch_field(BPatch_field &f); | |
|
| BPatch_field(Dyninst::SymtabAPI::Field *fld_ = NULL, BPatch_dataClass typ | | BPatch_field(Dyninst::SymtabAPI::Field *fld_ = NULL, | |
| eDescriptor = BPatch_dataUnknownType, int value_ = 0, int size_ = 0); | | BPatch_dataClass typeDescriptor = BPatch_dataUnknownType, | |
| | | int value_ = 0, | |
| API_EXPORT_DTOR(_dtor,(), | | int size_ = 0); | |
| ~,BPatch_field,()); | | | |
| | | | |
|
| API_EXPORT_OPER(_equals, (src), | | ~BPatch_field(); | |
| BPatch_field &,operator=,(BPatch_field &src)); | | | |
| | | | |
|
| #ifdef NOTDEF | | BPatch_field & operator=(BPatch_field &src); | |
| API_EXPORT_OPER(_equals_equals, (src), | | | |
| bool ,operator==,(const BPatch_field &src)); | | | |
| #endif | | | |
| | | | |
|
| API_EXPORT(Int, (), | | const char * getName(); | |
| const char *,getName,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_type * getType(); | |
| BPatch_type *,getType,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | int getValue(); | |
| int,getValue,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_visibility getVisibility(); | |
| BPatch_visibility,getVisibility,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_dataClass getTypeDesc(); | |
| BPatch_dataClass,getTypeDesc,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | int getSize(); | |
| int,getSize,()); | | | |
| | | | |
|
| API_EXPORT(Int, (), | | int getOffset(); | |
| int,getOffset,()); | | | |
| }; | | }; | |
| | | | |
| // | | // | |
| // Define an instance of a Common block. Each subroutine can have its own | | // Define an instance of a Common block. Each subroutine can have its own | |
| // version of the common block. | | // version of the common block. | |
| // | | // | |
| #ifdef DYNINST_CLASS_NAME | | #ifdef DYNINST_CLASS_NAME | |
| #undef DYNINST_CLASS_NAME | | #undef DYNINST_CLASS_NAME | |
| #endif | | #endif | |
| #define DYNINST_CLASS_NAME BPatch_cblock | | #define DYNINST_CLASS_NAME BPatch_cblock | |
|
| class BPATCH_DLL_EXPORT BPatch_cblock : public BPatch_eventLock{ | | class BPATCH_DLL_EXPORT BPatch_cblock { | |
| private: | | private: | |
| // the list of fields | | // the list of fields | |
| BPatch_Vector<BPatch_field *> fieldList; | | BPatch_Vector<BPatch_field *> fieldList; | |
| | | | |
| // which functions use this list | | // which functions use this list | |
| BPatch_Vector<BPatch_function *> functions; | | BPatch_Vector<BPatch_function *> functions; | |
| | | | |
| Dyninst::SymtabAPI::CBlock *cBlk; | | Dyninst::SymtabAPI::CBlock *cBlk; | |
| | | | |
| void fixupUnknowns(BPatch_module *); | | void fixupUnknowns(BPatch_module *); | |
| public: | | public: | |
| BPatch_cblock(Dyninst::SymtabAPI::CBlock *cBlk_); | | BPatch_cblock(Dyninst::SymtabAPI::CBlock *cBlk_); | |
| BPatch_cblock() {} | | BPatch_cblock() {} | |
| | | | |
|
| API_EXPORT(Int, (), | | BPatch_Vector<BPatch_field *> * getComponents(); | |
| BPatch_Vector<BPatch_field *> *,getComponents,()); | | BPatch_Vector<BPatch_function *> * getFunctions(); | |
| API_EXPORT(Int, (), | | | |
| BPatch_Vector<BPatch_function *> *,getFunctions,()); | | | |
| }; | | }; | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_type{ | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_type | | | |
| class BPATCH_DLL_EXPORT BPatch_type : public BPatch_eventLock{ | | | |
| friend class BPatch; | | friend class BPatch; | |
| friend class BPatch_module; | | friend class BPatch_module; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| friend class BPatch_typeCollection; | | friend class BPatch_typeCollection; | |
| friend class BPatch_localVar; | | friend class BPatch_localVar; | |
| friend class BPatch_field; | | friend class BPatch_field; | |
| friend class BPatch_addressSpace; | | friend class BPatch_addressSpace; | |
| | | | |
| protected: | | protected: | |
| int ID; /* unique ID of type */ | | int ID; /* unique ID of type */ | |
|
| static std::map<Dyninst::SymtabAPI::Type*, BPatch_type *> type_map; | | static std::map<Dyninst::SymtabAPI::Type*, BPatch_type *> type_map; | |
| BPatch_dataClass type_; | | BPatch_dataClass type_; | |
| | | | |
| //Symtab type | | //Symtab type | |
| Dyninst::SymtabAPI::Type *typ; | | Dyninst::SymtabAPI::Type *typ; | |
| | | | |
| /* For common blocks */ | | /* For common blocks */ | |
| | | | |
| static int USER_BPATCH_TYPE_ID; | | static int USER_BPATCH_TYPE_ID; | |
| | | | |
| // INTERNAL DATA MEMBERS | | // INTERNAL DATA MEMBERS | |
| | | | |
| skipping to change at line 326 | | skipping to change at line 285 | |
| static BPatch_type *createPlaceholder(int _ID, const char *_name = NULL) | | static BPatch_type *createPlaceholder(int _ID, const char *_name = NULL) | |
| { return new BPatch_type(_name, _ID, BPatch_dataUnknownType); } | | { return new BPatch_type(_name, _ID, BPatch_dataUnknownType); } | |
| | | | |
| public: | | public: | |
| BPatch_type(const char *name = NULL, int _ID = 0, BPatch_dataClass = BPat
ch_dataNullType); | | BPatch_type(const char *name = NULL, int _ID = 0, BPatch_dataClass = BPat
ch_dataNullType); | |
| BPatch_type(Dyninst::SymtabAPI::Type *typ_); | | BPatch_type(Dyninst::SymtabAPI::Type *typ_); | |
| virtual bool operator==(const BPatch_type &) const; | | virtual bool operator==(const BPatch_type &) const; | |
| | | | |
| int getID() const { return ID;} | | int getID() const { return ID;} | |
| | | | |
|
| API_EXPORT(Int, (), | | unsigned int getSize(); | |
| unsigned int,getSize,()); | | | |
| | | | |
| Dyninst::SymtabAPI::Type *getSymtabType() const; | | Dyninst::SymtabAPI::Type *getSymtabType() const; | |
| | | | |
| //Define all of these in .C | | //Define all of these in .C | |
| const char *getName() const; | | const char *getName() const; | |
| | | | |
| #ifdef IBM_BPATCH_COMPAT | | #ifdef IBM_BPATCH_COMPAT | |
| char *getName(char *buffer, int max) const; | | char *getName(char *buffer, int max) const; | |
| BPatch_dataClass type() const { return type_; } | | BPatch_dataClass type() const { return type_; } | |
| #endif | | #endif | |
| BPatch_dataClass getDataClass() const { return type_; } | | BPatch_dataClass getDataClass() const { return type_; } | |
| | | | |
| unsigned long getLow() const; | | unsigned long getLow() const; | |
| unsigned long getHigh() const; | | unsigned long getHigh() const; | |
| BPatch_Vector<BPatch_field *> * getComponents() const; | | BPatch_Vector<BPatch_field *> * getComponents() const; | |
|
| API_EXPORT(Int, (otype), | | bool isCompatible(BPatch_type * otype); | |
| bool, isCompatible, (BPatch_type * otype)); | | | |
| BPatch_type *getConstituentType() const; | | BPatch_type *getConstituentType() const; | |
| BPatch_Vector<BPatch_cblock *> *getCblocks() const; | | BPatch_Vector<BPatch_cblock *> *getCblocks() const; | |
| | | | |
| // INTERNAL METHODS | | // INTERNAL METHODS | |
| | | | |
| void incrRefCount() { ++refCount; } | | void incrRefCount() { ++refCount; } | |
| void decrRefCount() { assert(refCount > 0); if (!--refCount) delete this;
} | | void decrRefCount() { assert(refCount > 0); if (!--refCount) delete this;
} | |
| void fixupUnknowns(BPatch_module *) { } | | void fixupUnknowns(BPatch_module *) { } | |
| }; | | }; | |
| | | | |
| // | | // | |
| // This class stores information about local variables. | | // This class stores information about local variables. | |
| // It is desgined store information about a variable in a function. | | // It is desgined store information about a variable in a function. | |
| // Scope needs to be addressed in this class. | | // Scope needs to be addressed in this class. | |
| | | | |
|
| #ifdef DYNINST_CLASS_NAME | | class BPATCH_DLL_EXPORT BPatch_localVar{ | |
| #undef DYNINST_CLASS_NAME | | | |
| #endif | | | |
| #define DYNINST_CLASS_NAME BPatch_localVar | | | |
| class BPATCH_DLL_EXPORT BPatch_localVar : public BPatch_eventLock{ | | | |
| friend class BPatch; | | friend class BPatch; | |
| friend class BPatch_function; | | friend class BPatch_function; | |
| | | | |
| BPatch_type *type; | | BPatch_type *type; | |
| BPatch_storageClass storageClass; | | BPatch_storageClass storageClass; | |
| // scope_t scope; | | // scope_t scope; | |
| | | | |
| Dyninst::SymtabAPI::localVar *lVar; | | Dyninst::SymtabAPI::localVar *lVar; | |
| | | | |
| public: | | public: | |
| | | | |
End of changes. 22 change blocks. |
| 74 lines changed or deleted | | 24 lines changed or added | |
|
| PCProcess.h | | PCProcess.h | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
| #if !defined(PROCESSPC_H_) | | #if !defined(PROCESSPC_H_) | |
| #define PROCESSPC_H_ | | #define PROCESSPC_H_ | |
| | | | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| #include <map> | | #include <map> | |
| #include <set> | | #include <set> | |
|
| | | #include <iterator> | |
| | | | |
| #include "dyntypes.h" | | #include "dyntypes.h" | |
| #include "dyn_regs.h" | | #include "dyn_regs.h" | |
| #include "EventType.h" | | #include "EventType.h" | |
| #include "util.h" | | #include "util.h" | |
| #include "PCErrors.h" | | #include "PCErrors.h" | |
| #include "boost/checked_delete.hpp" | | #include "boost/checked_delete.hpp" | |
| #include "boost/shared_ptr.hpp" | | #include "boost/shared_ptr.hpp" | |
| #include "boost/weak_ptr.hpp" | | #include "boost/weak_ptr.hpp" | |
| #include "boost/enable_shared_from_this.hpp" | | #include "boost/enable_shared_from_this.hpp" | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 65 | |
| class int_thread; | | class int_thread; | |
| class int_threadPool; | | class int_threadPool; | |
| class int_registerPool; | | class int_registerPool; | |
| class rpc_wrapper; | | class rpc_wrapper; | |
| class int_iRPC; | | class int_iRPC; | |
| class int_notify; | | class int_notify; | |
| class HandlerPool; | | class HandlerPool; | |
| class MTLock; | | class MTLock; | |
| | | | |
| #define PC_VERSION_8_0_0 | | #define PC_VERSION_8_0_0 | |
|
| | | #define PC_VERSION_8_1_0 | |
| | | | |
| #define pc_const_cast boost::const_pointer_cast | | #define pc_const_cast boost::const_pointer_cast | |
| | | | |
| namespace Dyninst { | | namespace Dyninst { | |
| | | | |
| class SymbolReaderFactory; | | class SymbolReaderFactory; | |
| | | | |
| namespace ProcControlAPI { | | namespace ProcControlAPI { | |
| | | | |
| class Process; | | class Process; | |
| | | | |
| skipping to change at line 86 | | skipping to change at line 88 | |
| class EventDecoder; | | class EventDecoder; | |
| class EventGenerator; | | class EventGenerator; | |
| class EventHandler; | | class EventHandler; | |
| class Event; | | class Event; | |
| class RegisterPool; | | class RegisterPool; | |
| class Breakpoint; | | class Breakpoint; | |
| class ProcessSet; | | class ProcessSet; | |
| class ThreadSet; | | class ThreadSet; | |
| class LibraryTracking; | | class LibraryTracking; | |
| class ThreadTracking; | | class ThreadTracking; | |
|
| | | class LWPTracking; | |
| class CallStackUnwinding; | | class CallStackUnwinding; | |
| class FollowFork; | | class FollowFork; | |
|
| | | class SignalMask; | |
| | | | |
| class ExecFileInfo; | | class ExecFileInfo; | |
| | | | |
| class PC_EXPORT Breakpoint | | class PC_EXPORT Breakpoint | |
| { | | { | |
| friend class ::int_breakpoint; | | friend class ::int_breakpoint; | |
| friend void boost::checked_delete<Breakpoint>(Breakpoint *); | | friend void boost::checked_delete<Breakpoint>(Breakpoint *); | |
| friend void boost::checked_delete<const Breakpoint>(const Breakpoint *); | | friend void boost::checked_delete<const Breakpoint>(const Breakpoint *); | |
| private: | | private: | |
| int_breakpoint *llbreakpoint_; | | int_breakpoint *llbreakpoint_; | |
| | | | |
| skipping to change at line 112 | | skipping to change at line 116 | |
| static const int BP_W = 2; | | static const int BP_W = 2; | |
| static const int BP_R = 4; | | static const int BP_R = 4; | |
| | | | |
| int_breakpoint *llbp() const; | | int_breakpoint *llbp() const; | |
| typedef boost::shared_ptr<Breakpoint> ptr; | | typedef boost::shared_ptr<Breakpoint> ptr; | |
| typedef boost::shared_ptr<const Breakpoint> const_ptr; | | typedef boost::shared_ptr<const Breakpoint> const_ptr; | |
| typedef boost::weak_ptr<Breakpoint> weak_ptr; | | typedef boost::weak_ptr<Breakpoint> weak_ptr; | |
| | | | |
| static Breakpoint::ptr newBreakpoint(); | | static Breakpoint::ptr newBreakpoint(); | |
| static Breakpoint::ptr newTransferBreakpoint(Dyninst::Address to); | | static Breakpoint::ptr newTransferBreakpoint(Dyninst::Address to); | |
|
| | | static Breakpoint::ptr newTransferOffsetBreakpoint(signed long shift); | |
| static Breakpoint::ptr newHardwareBreakpoint(unsigned int mode, unsigned
int size); | | static Breakpoint::ptr newHardwareBreakpoint(unsigned int mode, unsigned
int size); | |
| | | | |
| void *getData() const; | | void *getData() const; | |
| void setData(void *p) const; | | void setData(void *p) const; | |
| | | | |
| bool isCtrlTransfer() const; | | bool isCtrlTransfer() const; | |
| Dyninst::Address getToAddress() const; | | Dyninst::Address getToAddress() const; | |
| | | | |
| void setSuppressCallbacks(bool); | | void setSuppressCallbacks(bool); | |
| bool suppressCallbacks() const; | | bool suppressCallbacks() const; | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 162 | |
| | | | |
| class PC_EXPORT LibraryPool | | class PC_EXPORT LibraryPool | |
| { | | { | |
| friend class ::int_process; | | friend class ::int_process; | |
| friend class Dyninst::ProcControlAPI::Process; | | friend class Dyninst::ProcControlAPI::Process; | |
| private: | | private: | |
| int_process *proc; | | int_process *proc; | |
| LibraryPool(); | | LibraryPool(); | |
| ~LibraryPool(); | | ~LibraryPool(); | |
| public: | | public: | |
|
| class PC_EXPORT iterator { | | class PC_EXPORT iterator { | |
| friend class Dyninst::ProcControlAPI::LibraryPool; | | friend class Dyninst::ProcControlAPI::LibraryPool; | |
| private: | | private: | |
| std::set<int_library *>::iterator int_iter; | | std::set<int_library *>::iterator int_iter; | |
| public: | | public: | |
| iterator(); | | iterator(); | |
| ~iterator(); | | ~iterator(); | |
| Library::ptr operator*() const; | | Library::ptr operator*() const; | |
| bool operator==(const iterator &i) const; | | bool operator==(const iterator &i) const; | |
| bool operator!=(const iterator &i) const; | | bool operator!=(const iterator &i) const; | |
| LibraryPool::iterator operator++(); | | LibraryPool::iterator operator++(); | |
| LibraryPool::iterator operator++(int); | | LibraryPool::iterator operator++(int); | |
|
| | | | |
| | | typedef Library::ptr value_type; | |
| | | typedef int difference_type; | |
| | | typedef Library::ptr *pointer; | |
| | | typedef Library::ptr &reference; | |
| | | typedef std::forward_iterator_tag iterator_category; | |
| }; | | }; | |
| | | | |
|
| class PC_EXPORT const_iterator { | | class PC_EXPORT const_iterator { | |
| friend class Dyninst::ProcControlAPI::LibraryPool; | | friend class Dyninst::ProcControlAPI::LibraryPool; | |
| private: | | private: | |
| std::set<int_library *>::iterator int_iter; | | std::set<int_library *>::iterator int_iter; | |
| public: | | public: | |
| const_iterator(); | | const_iterator(); | |
| ~const_iterator(); | | ~const_iterator(); | |
| Library::const_ptr operator*() const; | | Library::const_ptr operator*() const; | |
| bool operator==(const const_iterator &i); | | bool operator==(const const_iterator &i); | |
| bool operator!=(const const_iterator &i); | | bool operator!=(const const_iterator &i); | |
| LibraryPool::const_iterator operator++(); | | LibraryPool::const_iterator operator++(); | |
| LibraryPool::const_iterator operator++(int); | | LibraryPool::const_iterator operator++(int); | |
|
| | | | |
| | | typedef Library::const_ptr value_type; | |
| | | typedef int difference_type; | |
| | | typedef Library::const_ptr *pointer; | |
| | | typedef Library::const_ptr &reference; | |
| | | typedef std::forward_iterator_tag iterator_category; | |
| }; | | }; | |
| | | | |
| iterator begin(); | | iterator begin(); | |
| iterator end(); | | iterator end(); | |
| const_iterator begin() const; | | const_iterator begin() const; | |
| const_iterator end() const; | | const_iterator end() const; | |
| | | | |
| size_t size() const; | | size_t size() const; | |
| | | | |
| Library::ptr getExecutable(); | | Library::ptr getExecutable(); | |
| Library::const_ptr getExecutable() const; | | Library::const_ptr getExecutable() const; | |
| | | | |
| Library::ptr getLibraryByName(std::string s); | | Library::ptr getLibraryByName(std::string s); | |
| Library::const_ptr getLibraryByName(std::string s) const; | | Library::const_ptr getLibraryByName(std::string s) const; | |
|
| | | | |
| | | iterator find(Library::ptr lib); | |
| | | const_iterator find(Library::ptr lib) const; | |
| | | | |
| }; | | }; | |
| | | | |
| class PC_EXPORT IRPC | | class PC_EXPORT IRPC | |
| { | | { | |
| friend class ::int_iRPC; | | friend class ::int_iRPC; | |
| friend void boost::checked_delete<IRPC>(IRPC *); | | friend void boost::checked_delete<IRPC>(IRPC *); | |
| friend void boost::checked_delete<const IRPC>(const IRPC *); | | friend void boost::checked_delete<const IRPC>(const IRPC *); | |
| private: | | private: | |
| rpc_wrapper *wrapper; | | rpc_wrapper *wrapper; | |
| IRPC(rpc_wrapper *wrapper_); | | IRPC(rpc_wrapper *wrapper_); | |
| | | | |
| skipping to change at line 355 | | skipping to change at line 376 | |
| int getExitCode() const; | | int getExitCode() const; | |
| int getCrashSignal() const; | | int getCrashSignal() const; | |
| | | | |
| bool hasStoppedThread() const; | | bool hasStoppedThread() const; | |
| bool hasRunningThread() const; | | bool hasRunningThread() const; | |
| bool allThreadsStopped() const; | | bool allThreadsStopped() const; | |
| bool allThreadsRunning() const; | | bool allThreadsRunning() const; | |
| bool allThreadsRunningWhenAttached() const; | | bool allThreadsRunningWhenAttached() const; | |
| | | | |
| /** | | /** | |
|
| | | * What capabilities do we have on this process | |
| | | **/ | |
| | | static const unsigned int pc_read = (1<<0); | |
| | | static const unsigned int pc_write = (1<<1); | |
| | | static const unsigned int pc_irpc = (1<<2); | |
| | | static const unsigned int pc_control = (1<<3); | |
| | | unsigned int getCapabilities() const; | |
| | | | |
| | | /** | |
| * Queries for machine info | | * Queries for machine info | |
| **/ | | **/ | |
| Dyninst::Architecture getArchitecture() const; | | Dyninst::Architecture getArchitecture() const; | |
| Dyninst::OSType getOS() const; | | Dyninst::OSType getOS() const; | |
| | | | |
| /** | | /** | |
| * Query what kind of events this process supports | | * Query what kind of events this process supports | |
| **/ | | **/ | |
| bool supportsLWPEvents() const; | | bool supportsLWPEvents() const; | |
| bool supportsUserThreadEvents() const; | | bool supportsUserThreadEvents() const; | |
| bool supportsFork() const; | | bool supportsFork() const; | |
| bool supportsExec() const; | | bool supportsExec() const; | |
| | | | |
| /** | | /** | |
| * Control process | | * Control process | |
| **/ | | **/ | |
| bool continueProc(); | | bool continueProc(); | |
| bool stopProc(); | | bool stopProc(); | |
|
| bool detach(); | | bool detach(bool leaveStopped = false); | |
| bool terminate(); | | bool terminate(); | |
| bool temporaryDetach(); | | bool temporaryDetach(); | |
| bool reAttach(); | | bool reAttach(); | |
| | | | |
| /** | | /** | |
| * Memory management | | * Memory management | |
| **/ | | **/ | |
|
| | | class PC_EXPORT mem_perm { | |
| | | bool read; | |
| | | bool write; | |
| | | bool execute; | |
| | | | |
| | | int permVal() const; | |
| | | | |
| | | public: | |
| | | mem_perm() : read(false), write(false), execute(false) {} | |
| | | mem_perm(const mem_perm& p) : read(p.read), write(p.write), | |
| | | execute(p.execute) {} | |
| | | mem_perm(bool r, bool w, bool x) : read(r), write(w), execute(x) {} | |
| | | | |
| | | bool getR() const { return read; } | |
| | | bool getW() const { return write; } | |
| | | bool getX() const { return execute; } | |
| | | | |
| | | bool isNone() const { return !read && !write && !execute; } | |
| | | bool isR() const { return read && !write && !execute; } | |
| | | bool isX() const { return !read && !write && execute; } | |
| | | bool isRW() const { return read && write && !execute; } | |
| | | bool isRX() const { return read && !write && execute; } | |
| | | bool isRWX() const { return read && write && execute; } | |
| | | | |
| | | mem_perm& setR() { read = true; return *this; } | |
| | | mem_perm& setW() { write = true; return *this; } | |
| | | mem_perm& setX() { execute = true; return *this; } | |
| | | | |
| | | mem_perm& clrR() { read = false; return *this; } | |
| | | mem_perm& clrW() { write = false; return *this; } | |
| | | mem_perm& clrX() { execute = false; return *this; } | |
| | | | |
| | | bool operator< (const mem_perm& p) const; | |
| | | bool operator==(const mem_perm& p) const; | |
| | | bool operator!=(const mem_perm& p) const; | |
| | | | |
| | | std::string getPermName() const; | |
| | | }; | |
| | | | |
| | | unsigned getMemoryPageSize() const; | |
| | | | |
| Dyninst::Address mallocMemory(size_t size); | | Dyninst::Address mallocMemory(size_t size); | |
| Dyninst::Address mallocMemory(size_t size, Dyninst::Address addr); | | Dyninst::Address mallocMemory(size_t size, Dyninst::Address addr); | |
| bool freeMemory(Dyninst::Address addr); | | bool freeMemory(Dyninst::Address addr); | |
| bool writeMemory(Dyninst::Address addr, const void *buffer, size_t size)
const; | | bool writeMemory(Dyninst::Address addr, const void *buffer, size_t size)
const; | |
| bool readMemory(void *buffer, Dyninst::Address addr, size_t size) const; | | bool readMemory(void *buffer, Dyninst::Address addr, size_t size) const; | |
| | | | |
| bool writeMemoryAsync(Dyninst::Address addr, const void *buffer, size_t
size, void *opaque_val = NULL) const; | | bool writeMemoryAsync(Dyninst::Address addr, const void *buffer, size_t
size, void *opaque_val = NULL) const; | |
| bool readMemoryAsync(void *buffer, Dyninst::Address addr, size_t size, v
oid *opaque_val = NULL) const; | | bool readMemoryAsync(void *buffer, Dyninst::Address addr, size_t size, v
oid *opaque_val = NULL) const; | |
| | | | |
| /** | | /** | |
| * Currently Windows-only, needed for the test infrastructure but possib
ly useful elsewhere | | * Currently Windows-only, needed for the test infrastructure but possib
ly useful elsewhere | |
|
| */ | | **/ | |
| Dyninst::Address findFreeMemory(size_t size); | | Dyninst::Address findFreeMemory(size_t size); | |
| | | | |
|
| | | bool getMemoryAccessRights(Dyninst::Address addr, size_t size, | |
| | | mem_perm& rights); | |
| | | bool setMemoryAccessRights(Dyninst::Address addr, size_t size, | |
| | | mem_perm rights, mem_perm& oldRights); | |
| | | | |
| | | // MemoryRegion.first = startAddr, MemoryRegion.second = endAddr | |
| | | typedef std::pair<Dyninst::Address, Dyninst::Address> MemoryRegion; | |
| | | bool findAllocatedRegionAround(Dyninst::Address addr, MemoryRegion& memR | |
| | | egion); | |
| | | | |
| /** | | /** | |
| * Libraries | | * Libraries | |
| **/ | | **/ | |
| const LibraryPool &libraries() const; | | const LibraryPool &libraries() const; | |
| LibraryPool &libraries(); | | LibraryPool &libraries(); | |
| | | | |
|
| | | // Cause a library to be loaded into the process (via black magic) | |
| | | bool addLibrary(std::string libname); | |
| | | | |
| /** | | /** | |
| * Breakpoints | | * Breakpoints | |
| **/ | | **/ | |
| bool addBreakpoint(Dyninst::Address addr, Breakpoint::ptr bp) const; | | bool addBreakpoint(Dyninst::Address addr, Breakpoint::ptr bp) const; | |
| bool rmBreakpoint(Dyninst::Address addr, Breakpoint::ptr bp) const; | | bool rmBreakpoint(Dyninst::Address addr, Breakpoint::ptr bp) const; | |
| unsigned numHardwareBreakpointsAvail(unsigned mode); | | unsigned numHardwareBreakpointsAvail(unsigned mode); | |
| | | | |
| /** | | /** | |
| * Post IRPC. Use continueProc/continueThread to run it, | | * Post IRPC. Use continueProc/continueThread to run it, | |
| * and handleEvents to wait for a blocking IRPC to complete | | * and handleEvents to wait for a blocking IRPC to complete | |
| **/ | | **/ | |
| bool postIRPC(IRPC::ptr irpc) const; | | bool postIRPC(IRPC::ptr irpc) const; | |
| bool getPostedIRPCs(std::vector<IRPC::ptr> &rpcs) const; | | bool getPostedIRPCs(std::vector<IRPC::ptr> &rpcs) const; | |
| | | | |
| /** | | /** | |
|
| * Post and run an IRPC; user must wait for completion. Standard | | * Post, run, and wait for an IRPC to complete | |
| **/ | | **/ | |
| bool runIRPCSync(IRPC::ptr irpc); | | bool runIRPCSync(IRPC::ptr irpc); | |
| | | | |
| /** | | /** | |
|
| * Post, run, and wait for an IRPC to complete | | * Post and run an IRPC; user must wait for completion. | |
| **/ | | **/ | |
| bool runIRPCAsync(IRPC::ptr irpc); | | bool runIRPCAsync(IRPC::ptr irpc); | |
| | | | |
| /** | | /** | |
| * Symbol access | | * Symbol access | |
| **/ | | **/ | |
| void setSymbolReader(SymbolReaderFactory *reader) const; | | void setSymbolReader(SymbolReaderFactory *reader) const; | |
| SymbolReaderFactory *getSymbolReader() const; | | SymbolReaderFactory *getSymbolReader() const; | |
| static SymbolReaderFactory *getDefaultSymbolReader(); | | static SymbolReaderFactory *getDefaultSymbolReader(); | |
| static void setDefaultSymbolReader(SymbolReaderFactory *reader); | | static void setDefaultSymbolReader(SymbolReaderFactory *reader); | |
| | | | |
| /** | | /** | |
| * Perform specific operations. Interface objects will only be returned | | * Perform specific operations. Interface objects will only be returned | |
| * on appropriately supported platforms, others will return NULL. | | * on appropriately supported platforms, others will return NULL. | |
| **/ | | **/ | |
| LibraryTracking *getLibraryTracking(); | | LibraryTracking *getLibraryTracking(); | |
| ThreadTracking *getThreadTracking(); | | ThreadTracking *getThreadTracking(); | |
|
| | | LWPTracking *getLWPTracking(); | |
| FollowFork *getFollowFork(); | | FollowFork *getFollowFork(); | |
|
| | | SignalMask *getSignalMask(); | |
| const LibraryTracking *getLibraryTracking() const; | | const LibraryTracking *getLibraryTracking() const; | |
| const ThreadTracking *getThreadTracking() const; | | const ThreadTracking *getThreadTracking() const; | |
|
| | | const LWPTracking *getLWPTracking() const; | |
| const FollowFork *getFollowFork() const; | | const FollowFork *getFollowFork() const; | |
|
| | | const SignalMask *getSignalMask() const; | |
| | | | |
| /** | | /** | |
| * Errors that occured on this process | | * Errors that occured on this process | |
| **/ | | **/ | |
| ProcControlAPI::err_t getLastError() const; | | ProcControlAPI::err_t getLastError() const; | |
| const char *getLastErrorMsg() const; | | const char *getLastErrorMsg() const; | |
| | | | |
| /** | | /** | |
| * Executable info | | * Executable info | |
| **/ | | **/ | |
| | | | |
| skipping to change at line 501 | | skipping to change at line 588 | |
| bool stopThread(); | | bool stopThread(); | |
| bool continueThread(); | | bool continueThread(); | |
| | | | |
| void setSingleStepMode(bool s) const; | | void setSingleStepMode(bool s) const; | |
| bool getSingleStepMode() const; | | bool getSingleStepMode() const; | |
| | | | |
| bool getRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal &va
l) const; | | bool getRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal &va
l) const; | |
| bool getAllRegisters(RegisterPool &pool) const; | | bool getAllRegisters(RegisterPool &pool) const; | |
| bool setRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal val
) const; | | bool setRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal val
) const; | |
| bool setAllRegisters(RegisterPool &pool) const; | | bool setAllRegisters(RegisterPool &pool) const; | |
|
| | | bool getAllRegistersAsync(RegisterPool &pool, void *opaque_val = NULL) c | |
| | | onst; | |
| | | bool setAllRegistersAsync(RegisterPool &pool, void *opaque_val = NULL) c | |
| | | onst; | |
| | | | |
| /** | | /** | |
| * User level thread info. Only available after a UserThreadCreate even
t | | * User level thread info. Only available after a UserThreadCreate even
t | |
| **/ | | **/ | |
| bool haveUserThreadInfo() const; | | bool haveUserThreadInfo() const; | |
| Dyninst::THR_ID getTID() const; | | Dyninst::THR_ID getTID() const; | |
| Dyninst::Address getStartFunction() const; | | Dyninst::Address getStartFunction() const; | |
| Dyninst::Address getStackBase() const; | | Dyninst::Address getStackBase() const; | |
| unsigned long getStackSize() const; | | unsigned long getStackSize() const; | |
| Dyninst::Address getTLS() const; | | Dyninst::Address getTLS() const; | |
|
| | | Dyninst::Address getThreadInfoBlockAddr() const; | |
| | | | |
| /** | | /** | |
| * IRPC | | * IRPC | |
| **/ | | **/ | |
| bool postIRPC(IRPC::ptr irpc) const; | | bool postIRPC(IRPC::ptr irpc) const; | |
| bool runIRPCSync(IRPC::ptr irpc); | | bool runIRPCSync(IRPC::ptr irpc); | |
| bool runIRPCAsync(IRPC::ptr irpc); | | bool runIRPCAsync(IRPC::ptr irpc); | |
| | | | |
| bool getPostedIRPCs(std::vector<IRPC::ptr> &rpcs) const; | | bool getPostedIRPCs(std::vector<IRPC::ptr> &rpcs) const; | |
| IRPC::const_ptr getRunningIRPC() const; | | IRPC::const_ptr getRunningIRPC() const; | |
| | | | |
| skipping to change at line 674 | | skipping to change at line 764 | |
| typedef void (*notify_cb_t)(); | | typedef void (*notify_cb_t)(); | |
| | | | |
| int getFD(); | | int getFD(); | |
| void registerCB(notify_cb_t cb); | | void registerCB(notify_cb_t cb); | |
| void removeCB(notify_cb_t cb); | | void removeCB(notify_cb_t cb); | |
| }; | | }; | |
| PC_EXPORT EventNotify *evNotify(); | | PC_EXPORT EventNotify *evNotify(); | |
| | | | |
| class PC_EXPORT ExecFileInfo | | class PC_EXPORT ExecFileInfo | |
| { | | { | |
|
| public: | | public: | |
| void* fileHandle; | | void* fileHandle; | |
| void* processHandle; | | void* processHandle; | |
| Address fileBase; | | Address fileBase; | |
| }; | | }; | |
| | | | |
| } | | } | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 25 change blocks. |
| 8 lines changed or deleted | | 101 lines changed or added | |
|