From 3c2ac4496814a70b0675c778d98b1a98d5aa8b4e Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Fri, 3 Nov 2023 12:13:27 -0500 Subject: [PATCH] Merge Address definition and variable decls --- common/h/dyntypes.h | 17 ++++- common/src/Graph.C | 2 +- common/src/Types.h | 14 ++-- common/src/addrRange.h | 24 +++--- common/src/arch-aarch64.C | 14 ++-- common/src/arch-aarch64.h | 20 ++--- common/src/arch-power.C | 16 ++-- common/src/arch-power.h | 16 ++-- common/src/arch-x86.h | 29 ++++---- common/src/freebsdKludges.h | 2 +- common/src/linuxHeaders.h | 9 ++- common/src/linuxKludges.C | 42 +++++------ common/src/linuxKludges.h | 1 + common/src/parseauxv.C | 12 +-- common/src/parseauxv.h | 24 +++--- common/src/sha1.C | 2 +- dataflowAPI/rose/semantics/SymEvalSemantics.h | 1 + dynC_API/src/snippetGen.C | 1 + dyninstAPI/h/BPatch.h | 2 +- dyninstAPI/h/BPatch_addressSpace.h | 1 + dyninstAPI/h/BPatch_basicBlock.h | 1 + dyninstAPI/h/BPatch_callbacks.h | 2 + dyninstAPI/h/BPatch_flowGraph.h | 1 + dyninstAPI/h/BPatch_function.h | 1 + dyninstAPI/h/BPatch_memoryAccess_NP.h | 1 + dyninstAPI/h/BPatch_point.h | 2 + dyninstAPI/h/BPatch_process.h | 2 +- dyninstAPI/src/BPatch_libInfo.h | 10 +-- dyninstAPI/src/BPatch_memoryAccess.C | 12 +-- dyninstAPI/src/BPatch_memoryAccessAdapter.C | 2 +- dyninstAPI/src/BPatch_memoryAccessAdapter.h | 4 +- dyninstAPI/src/Parsing.h | 69 ++++++++--------- dyninstAPI/src/Relocation/DynPointMaker.h | 4 +- dyninstAPI/src/StackMod/StackLocation.h | 2 +- dyninstAPI/src/addressSpace.h | 2 +- dyninstAPI/src/ast.C | 6 +- dyninstAPI/src/ast.h | 58 +++++++-------- dyninstAPI/src/baseTramp.C | 4 +- dyninstAPI/src/baseTramp.h | 6 +- dyninstAPI/src/codeRange.C | 14 ++-- dyninstAPI/src/codeRange.h | 24 +++--- dyninstAPI/src/codegen-x86.C | 74 +++++++++---------- dyninstAPI/src/codegen-x86.h | 30 ++++---- dyninstAPI/src/codegen.C | 28 +++---- dyninstAPI/src/codegen.h | 32 ++++---- dyninstAPI/src/infHeap.h | 18 ++--- dyninstAPI/src/inst-x86.h | 4 +- dyninstAPI/src/inst.C | 4 +- dyninstAPI/src/inst.h | 26 +++---- dyninstAPI/src/parRegion.C | 14 ++-- dyninstAPI/src/parRegion.h | 35 ++++----- dyninstAPI/src/patch.h | 13 ++-- dyninstAPI/src/pcEventHandler.h | 36 ++++----- dyninstAPI/src/pcEventMuxer.h | 16 ++-- dyninstAPI/src/pcrel.h | 32 ++++---- dyninstAPI/src/trapMappings.h | 17 +++-- patchAPI/h/AddrSpace.h | 13 ++-- patchAPI/h/Point.h | 27 +++---- patchAPI/src/AddrSpace.C | 13 ++-- patchAPI/src/Point.C | 2 +- stackwalk/src/analysis_stepper.C | 2 +- symtabAPI/src/emitElf.h | 2 +- symtabAPI/src/indexed_symbols.hpp | 5 +- 63 files changed, 472 insertions(+), 447 deletions(-) diff --git a/common/h/dyntypes.h b/common/h/dyntypes.h index 42a04a6bc0..121dc8b7fe 100644 --- a/common/h/dyntypes.h +++ b/common/h/dyntypes.h @@ -48,6 +48,8 @@ #endif #endif +#ifdef __cplusplus + #include #include #include @@ -74,13 +76,15 @@ using dyn_hash_set = std::unordered_set; namespace Dyninst { #if defined(_WIN64) - typedef uintptr_t Address; - typedef uintptr_t Offset; + typedef uintptr_t Address; + typedef uintptr_t Offset; #else - typedef unsigned long Address; - typedef unsigned long Offset; + typedef unsigned long Address; + typedef unsigned long Offset; #endif + static constexpr Address ADDR_NULL{0}; + #if defined(_MSC_VER) typedef int PID; typedef HANDLE PROC_HANDLE; @@ -119,4 +123,9 @@ namespace Dyninst } OSType; } +#else +# define ADDR_NULL (0) +typedef unsigned long Address; +#endif + #endif diff --git a/common/src/Graph.C b/common/src/Graph.C index 979d12b20f..2c7bcb603c 100644 --- a/common/src/Graph.C +++ b/common/src/Graph.C @@ -40,7 +40,7 @@ using namespace Dyninst; -const Dyninst::Address Graph::INITIAL_ADDR = (Address) -1; +const Dyninst::Address Graph::INITIAL_ADDR = (Dyninst::Address) -1; diff --git a/common/src/Types.h b/common/src/Types.h index 220c92a5cd..4579c8ff6f 100644 --- a/common/src/Types.h +++ b/common/src/Types.h @@ -36,6 +36,8 @@ #if !defined(_Types_h_) #define _Types_h_ +#include "dyntypes.h" + #if defined __cplusplus # include #else @@ -43,15 +45,6 @@ #endif -#if defined(__cplusplus) -#include "common/h/dyntypes.h" -using namespace Dyninst; -static const Address ADDR_NULL = (Address)(0); -#else -#define ADDR_NULL (0) -typedef unsigned long Address; -#endif - typedef long long int RegValue; /* register content 64-bit */ /* This needs to be an int since it is sometimes used to pass offsets to the code generator (i.e. if-statement) - jkh 5/24/99 */ @@ -70,6 +63,9 @@ static const Register REG_NULL = (Register)(-1); #define MAPENTRIES_PATH_SIZE 512 #define MAPENTRIES_PATH_SIZE_STR "512" typedef struct maps_entries { +#if defined __cplusplus + using Address = Dyninst::Address; +#endif Address start; Address end; unsigned prems; diff --git a/common/src/addrRange.h b/common/src/addrRange.h index 0212547383..210302672f 100644 --- a/common/src/addrRange.h +++ b/common/src/addrRange.h @@ -54,7 +54,7 @@ typedef enum { TREE_RED, TREE_BLACK } color_t; class addrRange { public: - virtual Address get_address() const = 0; + virtual Dyninst::Address get_address() const = 0; virtual unsigned long get_size() const = 0; virtual std::string get_name() const { return std::string("UNNAMED"); @@ -71,7 +71,7 @@ class addrRangeTree { /** tree implementation structure. Used to implement the RB tree */ typedef struct entry { - Address key; + Dyninst::Address key; T *value; color_t color; /* color of the node */ struct entry* left; /* left child */ @@ -98,7 +98,7 @@ class addrRangeTree { * @param d data element * @param e nill entry */ - entry(Address key_, T *value_, entry* e) + entry(Dyninst::Address key_, T *value_, entry* e) : key(key_), value(value_), color(TREE_RED), left(e), right(e), parent(NULL) { @@ -241,7 +241,7 @@ class addrRangeTree { // insertion to a binary search tree. It returns the new element pointer // that is inserted. If element is already there it returns NULL - entry* treeInsert(Address key, T *value) + entry* treeInsert(Dyninst::Address key, T *value) { entry* y = NULL; entry* x = setData; @@ -292,7 +292,7 @@ class addrRangeTree { // method that returns the entry pointer for the element that is searched //for. If the entry is not found then it retuns NULL - entry* find_internal(Address element) const + entry* find_internal(Dyninst::Address element) const { entry* x = setData; while(x != nil){ @@ -355,7 +355,7 @@ class addrRangeTree { } // Similar to precessor, but returns an entry - bool precessor_internal(Address key, entry * &value) const + bool precessor_internal(Dyninst::Address key, entry * &value) const { entry *x = setData; entry *last = nil; @@ -389,7 +389,7 @@ class addrRangeTree { // Similar to successor, but returns an entry - bool successor_internal(Address key, entry * &value) const + bool successor_internal(Dyninst::Address key, entry * &value) const { entry *x = setData; entry *last = nil; @@ -504,7 +504,7 @@ class addrRangeTree { /** removes the element in the tree * @param 1 element that will be removed */ - void remove(Address key) + void remove(Dyninst::Address key) { entry* z = find_internal(key); if(!z) @@ -536,7 +536,7 @@ class addrRangeTree { /** returns true if the argument is member of the addrRangeTree * @param e the element that will be searched for */ - virtual bool find(Address key, T *& value) const + virtual bool find(Dyninst::Address key, T *& value) const { value = NULL; if (!precessor(key, value)) @@ -559,7 +559,7 @@ class addrRangeTree { /** Fills in the vector with all address ranges that overlap * with the address range defined by (start, end] */ - virtual bool find(Address start, Address end, + virtual bool find(Dyninst::Address start, Dyninst::Address end, std::vector &ranges) const { entry *cur = nil; @@ -585,7 +585,7 @@ class addrRangeTree { /** Returns the largest value less than or equal to the * key given */ - virtual bool precessor(Address key, T *& value) const + virtual bool precessor(Dyninst::Address key, T *& value) const { entry *val; bool result = precessor_internal(key, val); @@ -599,7 +599,7 @@ class addrRangeTree { /** Returns the smallest value greater than or equal to the * key given */ - virtual bool successor(Address key, T *& value) const + virtual bool successor(Dyninst::Address key, T *& value) const { entry *val; bool result = successor_internal(key, val); diff --git a/common/src/arch-aarch64.C b/common/src/arch-aarch64.C index f6b4dbcefc..4a559f2ded 100644 --- a/common/src/arch-aarch64.C +++ b/common/src/arch-aarch64.C @@ -77,7 +77,7 @@ unsigned instruction::getTargetReg() const { return -1; } -Address instruction::getTarget(Address addr) const { +Dyninst::Address instruction::getTarget(Dyninst::Address addr) const { if (isUncondBranch() || isCondBranch()) { return getBranchOffset() + addr; } @@ -86,7 +86,7 @@ Address instruction::getTarget(Address addr) const { } // TODO: argument _needs_ to be an int, or ABS() doesn't work. -void instruction::setBranchOffset(Address /*newOffset*/) { +void instruction::setBranchOffset(Dyninst::Address /*newOffset*/) { assert(0); } @@ -98,11 +98,11 @@ bool instruction::isCall() const return false; } -void instruction::setInstruction(codeBuf_t * /*ptr*/, Address) { +void instruction::setInstruction(codeBuf_t * /*ptr*/, Dyninst::Address) { assert(0); } -void instruction::setInstruction(unsigned char *ptr, Address) { +void instruction::setInstruction(unsigned char *ptr, Dyninst::Address) { // We don't need the addr on this platform insn_ = Dyninst::read_memory_as(ptr); } @@ -129,13 +129,13 @@ bool instruction::isCondBranch() const { return false; } -unsigned instruction::jumpSize(Address /*from*/, Address /*to*/, unsigned /*addr_width*/) { +unsigned instruction::jumpSize(Dyninst::Address /*from*/, Dyninst::Address /*to*/, unsigned /*addr_width*/) { assert(0); return -1; } // -1 is infinite, don't ya know. -unsigned instruction::jumpSize(Address /*disp*/, unsigned /*addr_width*/) { +unsigned instruction::jumpSize(Dyninst::Address /*disp*/, unsigned /*addr_width*/) { assert(0); return instruction::size(); } @@ -197,7 +197,7 @@ unsigned instruction::getBranchTargetReg() const{ return -1; } -Address instruction::getBranchOffset() const { +Dyninst::Address instruction::getBranchOffset() const { if (isUncondBranch()) { if( CHECK_INST(UNCOND_BR.IMM) ){ return signExtend(GET_OFFSET32(UNCOND_BR.IMM), 26+2 ); diff --git a/common/src/arch-aarch64.h b/common/src/arch-aarch64.h index 0d9446e130..fd1546166f 100644 --- a/common/src/arch-aarch64.h +++ b/common/src/arch-aarch64.h @@ -35,7 +35,7 @@ // Code generation -#include "common/src/Types.h" +#include "dyntypes.h" #include "registers/aarch64_regs.h" #include #include @@ -205,7 +205,7 @@ class COMMON_EXPORT instruction { instruction *copy() const; void clear() { insn_.raw = 0; } - void setInstruction(codeBuf_t *ptr, Address = 0); + void setInstruction(codeBuf_t *ptr, Dyninst::Address = 0); void setBits(unsigned int pos, unsigned int len, unsigned int value) { unsigned int mask; @@ -219,7 +219,7 @@ class COMMON_EXPORT instruction { insn_.raw = insn_.raw | value; } unsigned int asInt() const { return insn_.raw; } - void setInstruction(unsigned char *ptr, Address = 0); + void setInstruction(unsigned char *ptr, Dyninst::Address = 0); // To solve host/target endian mismatches @@ -229,14 +229,14 @@ class COMMON_EXPORT instruction { // We need instruction::size() all _over_ the place. static unsigned size() { return sizeof(instructUnion); } - Address getBranchOffset() const; - Address getBranchTargetAddress() const; - void setBranchOffset(Address newOffset); + Dyninst::Address getBranchOffset() const; + Dyninst::Address getBranchTargetAddress() const; + void setBranchOffset(Dyninst::Address newOffset); // And tell us how much space we'll need... // Returns -1 if we can't do a branch due to architecture limitations - static unsigned jumpSize(Address from, Address to, unsigned addr_width); - static unsigned jumpSize(Address disp, unsigned addr_width); + static unsigned jumpSize(Dyninst::Address from, Dyninst::Address to, unsigned addr_width); + static unsigned jumpSize(Dyninst::Address disp, unsigned addr_width); static unsigned maxJumpSize(unsigned addr_width); static unsigned maxInterFunctionJumpSize(unsigned addr_width); @@ -261,7 +261,7 @@ class COMMON_EXPORT instruction { return ((insn_.raw & mask) == match); } - Address getTarget(Address insnAddr) const; + Dyninst::Address getTarget(Dyninst::Address insnAddr) const; unsigned spaceToRelocate() const; bool getUsedRegs(std::vector ®s); @@ -273,7 +273,7 @@ class COMMON_EXPORT instruction { bool isCall() const; - static bool isAligned(Address addr) { + static bool isAligned(Dyninst::Address addr) { return !(addr & 0x3); } diff --git a/common/src/arch-power.C b/common/src/arch-power.C index dae500d88c..e014537659 100644 --- a/common/src/arch-power.C +++ b/common/src/arch-power.C @@ -73,7 +73,7 @@ instruction *instruction::copy() const { return new instruction(*this); } -Address instruction::getTarget(Address addr) const { +Dyninst::Address instruction::getTarget(Dyninst::Address addr) const { if (isUncondBranch() || isCondBranch()) { return getBranchOffset() + addr; } @@ -86,7 +86,7 @@ Address instruction::getTarget(Address addr) const { } // TODO: argument _needs_ to be an int, or ABS() doesn't work. -void instruction::setBranchOffset(Address newOffset) { +void instruction::setBranchOffset(Dyninst::Address newOffset) { if (isUncondBranch()) { assert(ABS((int) newOffset) < MAX_BRANCH); IFORM_LI_SET(*this, newOffset >> 2); @@ -111,13 +111,13 @@ bool instruction::isCall() const return(isInsnType(OPmask | AALKmask, CALLmatch)); } -void instruction::setInstruction(codeBuf_t *ptr, Address) { +void instruction::setInstruction(codeBuf_t *ptr, Dyninst::Address) { // We don't need the addr on this platform instructUnion *insnPtr = (instructUnion *)ptr; insn_.raw = (*insnPtr).raw; } -void instruction::setInstruction(unsigned char *ptr, Address) { +void instruction::setInstruction(unsigned char *ptr, Dyninst::Address) { // We don't need the addr on this platform insn_ = Dyninst::read_memory_as(ptr); } @@ -130,13 +130,13 @@ bool instruction::isCondBranch() const { return isInsnType(Bmask, BCmatch); } -unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) { - Address disp = ABS((long)(to - from)); +unsigned instruction::jumpSize(Dyninst::Address from, Dyninst::Address to, unsigned addr_width) { + Dyninst::Address disp = ABS((long)(to - from)); return jumpSize(disp, addr_width); } // -1 is infinite, don't ya know. -unsigned instruction::jumpSize(Address disp, unsigned addr_width) { +unsigned instruction::jumpSize(Dyninst::Address disp, unsigned addr_width) { if (ABS(disp) >= MAX_BRANCH) { return maxInterFunctionJumpSize(addr_width); } @@ -244,7 +244,7 @@ bool instruction::isThunk() const { return true; } -Address instruction::getBranchOffset() const { +Dyninst::Address instruction::getBranchOffset() const { if (isUncondBranch()) { return (IFORM_LI(*this) << 2); } diff --git a/common/src/arch-power.h b/common/src/arch-power.h index 6a911c18a1..9de066aae2 100644 --- a/common/src/arch-power.h +++ b/common/src/arch-power.h @@ -813,7 +813,7 @@ class COMMON_EXPORT instruction { instruction *copy() const; void clear() { insn_.raw = 0; } - void setInstruction(codeBuf_t *ptr, Address = 0); + void setInstruction(codeBuf_t *ptr, Dyninst::Address = 0); void setBits(unsigned int pos, unsigned int len, unsigned int value) { unsigned int mask; @@ -827,7 +827,7 @@ class COMMON_EXPORT instruction { insn_.raw = insn_.raw | value; } unsigned int asInt() const { return insn_.raw; } - void setInstruction(unsigned char *ptr, Address = 0); + void setInstruction(unsigned char *ptr, Dyninst::Address = 0); // To solve host/target endian mismatches @@ -837,13 +837,13 @@ class COMMON_EXPORT instruction { // We need instruction::size() all _over_ the place. static unsigned size() { return sizeof(instructUnion); } - Address getBranchOffset() const; - void setBranchOffset(Address newOffset); + Dyninst::Address getBranchOffset() const; + void setBranchOffset(Dyninst::Address newOffset); // And tell us how much space we'll need... // Returns -1 if we can't do a branch due to architecture limitations - static unsigned jumpSize(Address from, Address to, unsigned addr_width); - static unsigned jumpSize(Address disp, unsigned addr_width); + static unsigned jumpSize(Dyninst::Address from, Dyninst::Address to, unsigned addr_width); + static unsigned jumpSize(Dyninst::Address disp, unsigned addr_width); static unsigned maxJumpSize(unsigned addr_width); static unsigned maxInterFunctionJumpSize(unsigned addr_width); @@ -868,7 +868,7 @@ class COMMON_EXPORT instruction { return ((insn_.raw & mask) == match); } - Address getTarget(Address insnAddr) const; + Dyninst::Address getTarget(Dyninst::Address insnAddr) const; unsigned spaceToRelocate() const; bool getUsedRegs(std::vector ®s); @@ -890,7 +890,7 @@ class COMMON_EXPORT instruction { bool isCall() const; - static bool isAligned(Address addr) { + static bool isAligned(Dyninst::Address addr) { return !(addr & 0x3); } diff --git a/common/src/arch-x86.h b/common/src/arch-x86.h index 5677b791a6..518971e4d1 100644 --- a/common/src/arch-x86.h +++ b/common/src/arch-x86.h @@ -34,7 +34,8 @@ #ifndef _ARCH_X86_H #define _ARCH_X86_H -#include "common/src/Types.h" +#include "dyntypes.h" +#include "Types.h" #include #include #include @@ -985,8 +986,8 @@ COMMON_EXPORT unsigned get_instruction(const unsigned char *instr, unsigned &instType, const unsigned char **op_ptr, bool mode_64); /* get the target of a jump or call */ -COMMON_EXPORT Address get_target(const unsigned char *instr, unsigned type, unsigned size, - Address addr); +COMMON_EXPORT Dyninst::Address get_target(const unsigned char *instr, unsigned type, unsigned size, + Dyninst::Address addr); // Size of a jump rel32 instruction #define JUMP_REL32_SZ (6) @@ -1053,15 +1054,15 @@ class instruction { setInstruction((const unsigned char *) ptr, 0, mode_64); } - unsigned setInstruction(const unsigned char *p, Address, bool mode_64) { + unsigned setInstruction(const unsigned char *p, Dyninst::Address, bool mode_64) { ptr_ = p; size_ = get_instruction(ptr_, type_, &op_ptr_, mode_64); return size_; } // if the instruction is a jump or call, return the target, else return zero - Address getTarget(Address addr) const { - return (Address)get_target(ptr_, type_, size_, addr); + Dyninst::Address getTarget(Dyninst::Address addr) const { + return (Dyninst::Address)get_target(ptr_, type_, size_, addr); } // return the size of the instruction in bytes @@ -1086,7 +1087,7 @@ class instruction { static unsigned maxInterFunctionJumpSize(unsigned addr_width) { return maxJumpSize(addr_width); } // And tell us how much space we'll need... - COMMON_EXPORT static unsigned jumpSize(Address from, Address to, unsigned addr_width); + COMMON_EXPORT static unsigned jumpSize(Dyninst::Address from, Dyninst::Address to, unsigned addr_width); COMMON_EXPORT static unsigned jumpSize(long disp, unsigned addr_width); COMMON_EXPORT static unsigned maxJumpSize(unsigned addr_width); @@ -1127,7 +1128,7 @@ class instruction { bool isSysCallInsn() const { return op_ptr_[0] == SYSCALL[0] && op_ptr_[1] == SYSCALL[1]; } - static bool isAligned(const Address ) { return true; } + static bool isAligned(const Dyninst::Address ) { return true; } void print() { @@ -1162,10 +1163,10 @@ inline bool is_disp16(long disp) { inline bool is_disp32(long disp) { return (disp <= INT32_MAX && disp >= INT32_MIN); } -inline bool is_disp32(Address a1, Address a2) { +inline bool is_disp32(Dyninst::Address a1, Dyninst::Address a2) { return is_disp32(a2 - (a1 + JUMP_REL32_SZ)); } -inline bool is_addr32(Address addr) { +inline bool is_addr32(Dyninst::Address addr) { return (addr < UINT32_MAX); } @@ -1178,14 +1179,14 @@ COMMON_EXPORT const unsigned char* skip_headers(const unsigned char*, /* Address bounds of new dynamic heap segments. On x86 we don't try to allocate new segments near base tramps, so heap segments can be allocated anywhere (the tramp address "x" is ignored). */ -inline Address region_lo(const Address /*x*/) { return 0x00000000; } -inline Address region_hi(const Address /*x*/) { return 0xf0000000; } +inline Dyninst::Address region_lo(const Dyninst::Address /*x*/) { return 0x00000000; } +inline Dyninst::Address region_hi(const Dyninst::Address /*x*/) { return 0xf0000000; } #if defined(arch_x86_64) // range functions for AMD64 -inline Address region_lo_64(const Address x) { return x & 0xffffffff80000000; } -inline Address region_hi_64(const Address x) { return x | 0x000000007fffffff; } +inline Dyninst::Address region_lo_64(const Dyninst::Address x) { return x & 0xffffffff80000000; } +inline Dyninst::Address region_hi_64(const Dyninst::Address x) { return x | 0x000000007fffffff; } #endif diff --git a/common/src/freebsdKludges.h b/common/src/freebsdKludges.h index e2c342e75c..40a3cccc84 100644 --- a/common/src/freebsdKludges.h +++ b/common/src/freebsdKludges.h @@ -34,7 +34,7 @@ #include #include #include - +#include "dyntypes.h" #include #include diff --git a/common/src/linuxHeaders.h b/common/src/linuxHeaders.h index cf4b86182f..d160f38c66 100644 --- a/common/src/linuxHeaders.h +++ b/common/src/linuxHeaders.h @@ -62,6 +62,7 @@ #include #include "compiler_annotations.h" +#include "dyntypes.h" #define PDSOCKET_ERROR (-1) typedef int PDSOCKET; @@ -233,16 +234,16 @@ inline ssize_t P_recv(int s, void *buf, int len, int flags) { /* Ugly */ #if 0 -inline long int P_ptrace(int req, pid_t pid, Address addr, Address data, int word_len = -1) { - if (word_len != -1 && word_len != sizeof(Address)) { +inline long int P_ptrace(int req, pid_t pid, Dyninst::Address addr, Dyninst::Address data, int word_len = -1) { + if (word_len != -1 && word_len != sizeof(Dyninst::Address)) { return (ptrace((enum __ptrace_request)req, pid, (uint32_t)addr, (uint32_t)data)); } else { return (ptrace((enum __ptrace_request)req, pid, addr, data)); } } -// long int P_ptrace(int req, pid_t pid, Address addr, Address data, int word_len); +// long int P_ptrace(int req, pid_t pid, Dyninst::Address addr, Dyninst::Address data, int word_len); #else -inline long int P_ptrace(int req, pid_t pid, Address addr, Address data, int = -1) { +inline long int P_ptrace(int req, pid_t pid, Dyninst::Address addr, Dyninst::Address data, int = -1) { return (ptrace((enum __ptrace_request)req, pid, addr, data));} #endif diff --git a/common/src/linuxKludges.C b/common/src/linuxKludges.C index aa7db217d5..2302804308 100644 --- a/common/src/linuxKludges.C +++ b/common/src/linuxKludges.C @@ -112,13 +112,13 @@ std::string P_cplus_demangle( const std::string &symbol, bool includeTypes ) } /* end P_cplus_demangle() */ -bool PtraceBulkRead(Address inTraced, unsigned size, void *inSelf, int pid) +bool PtraceBulkRead(Dyninst::Address inTraced, unsigned size, void *inSelf, int pid) { static bool have_process_vm_readv = true; const unsigned char *ap = (const unsigned char*) inTraced; unsigned char *dp = (unsigned char *) inSelf; - Address w = 0x0; /* ptrace I/O buffer */ + Dyninst::Address w = 0x0; /* ptrace I/O buffer */ int len = sizeof(void *); unsigned cnt; @@ -158,7 +158,7 @@ bool PtraceBulkRead(Address inTraced, unsigned size, void *inSelf, int pid) /* Read the segment containing the unaligned portion, and copy what was requested to DP. */ errno = 0; - w = P_ptrace(PTRACE_PEEKDATA, pid, (Address) (ap-cnt), w, len); + w = P_ptrace(PTRACE_PEEKDATA, pid, (Dyninst::Address) (ap-cnt), w, len); if (errno) { return false; } @@ -176,7 +176,7 @@ bool PtraceBulkRead(Address inTraced, unsigned size, void *inSelf, int pid) /* Copy aligned portion */ while (size >= (u_int)len) { errno = 0; - w = P_ptrace(PTRACE_PEEKTEXT, pid, (Address) ap, 0, len); + w = P_ptrace(PTRACE_PEEKTEXT, pid, (Dyninst::Address) ap, 0, len); if (errno) { return false; } @@ -193,7 +193,7 @@ bool PtraceBulkRead(Address inTraced, unsigned size, void *inSelf, int pid) /* Read the segment containing the unaligned portion, and copy what was requested to DP. */ errno = 0; - w = P_ptrace(PTRACE_PEEKTEXT, pid, (Address) ap, 0, len); + w = P_ptrace(PTRACE_PEEKTEXT, pid, (Dyninst::Address) ap, 0, len); if (errno) { return false; } @@ -211,8 +211,8 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, unsigned char *ap = (unsigned char*) inTraced; const unsigned char *dp = (const unsigned char*) inSelf; - Address w = 0x0; /* ptrace I/O buffer */ - int len = sizeof(Address); /* address alignment of ptrace I/O requests */ + Dyninst::Address w = 0x0; /* ptrace I/O buffer */ + int len = sizeof(Dyninst::Address); /* address alignment of ptrace I/O requests */ unsigned cnt; if (0 == nbytes) { @@ -243,14 +243,14 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, } } - if ((cnt = ((Address)ap) % len)) { + if ((cnt = ((Dyninst::Address)ap) % len)) { /* Start of request is not aligned. */ unsigned char *p = (unsigned char*) &w; /* Read the segment containing the unaligned portion, edit in the data from DP, and write the segment back. */ errno = 0; - w = P_ptrace(PTRACE_PEEKTEXT, pid, (Address) (ap-cnt), 0); + w = P_ptrace(PTRACE_PEEKTEXT, pid, (Dyninst::Address) (ap-cnt), 0); if (errno) { return false; @@ -259,7 +259,7 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, for (unsigned i = 0; i < len-cnt && i < nbytes; i++) p[cnt+i] = dp[i]; - if (0 > P_ptrace(PTRACE_POKETEXT, pid, (Address) (ap-cnt), w)) { + if (0 > P_ptrace(PTRACE_POKETEXT, pid, (Dyninst::Address) (ap-cnt), w)) { return false; } @@ -274,9 +274,9 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, /* Copy aligned portion */ while (nbytes >= (u_int)len) { - assert(0 == ((Address)ap) % len); + assert(0 == ((Dyninst::Address)ap) % len); memcpy(&w, dp, len); - int retval = P_ptrace(PTRACE_POKETEXT, pid, (Address) ap, w); + int retval = P_ptrace(PTRACE_POKETEXT, pid, (Dyninst::Address) ap, w); if (retval < 0) { return false; } @@ -294,7 +294,7 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, /* Read the segment containing the unaligned portion, edit in the data from DP, and write it back. */ errno = 0; - w = P_ptrace(PTRACE_PEEKTEXT, pid, (Address) ap, 0); + w = P_ptrace(PTRACE_PEEKTEXT, pid, (Dyninst::Address) ap, 0); if (errno) { return false; @@ -304,7 +304,7 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, for (unsigned i = 0; i < nbytes; i++) p[i] = dp[i]; - if (0 > P_ptrace(PTRACE_POKETEXT, pid, (Address) ap, w)) { + if (0 > P_ptrace(PTRACE_POKETEXT, pid, (Dyninst::Address) ap, w)) { return false; } } @@ -325,7 +325,7 @@ bool PtraceBulkWrite(Dyninst::Address inTraced, unsigned nbytes, #define AT_SYSINFO_EHDR 33 #endif -static bool couldBeVsyscallPage(map_entries *entry, bool strict, Address) { +static bool couldBeVsyscallPage(map_entries *entry, bool strict, Dyninst::Address) { if (strict) { if (entry->prems != PREMS_PRIVATE) return false; @@ -352,7 +352,7 @@ bool AuxvParser::readAuxvInfo() uint32_t *buffer32 = NULL; uint64_t *buffer64 = NULL; unsigned pos = 0; - Address dso_start = 0x0, text_start = 0x0; + Dyninst::Address dso_start = 0x0, text_start = 0x0; struct { unsigned long type; @@ -428,7 +428,7 @@ bool AuxvParser::readAuxvInfo() * can be larger than a single page. Thus we look through /proc/pid/maps * for known, default, or guessed start address(es). **/ - std::vector
guessed_addrs; + std::vector guessed_addrs; /* The first thing to check is the auxvinfo, if we have any. */ if( dso_start != 0x0 ) @@ -458,7 +458,7 @@ bool AuxvParser::readAuxvInfo() map_entries *secondary_match = NULL; map_entries *maps = getVMMaps(pid, num_maps); for (unsigned i=0; istart || addr >= entry->end) @@ -618,9 +618,9 @@ static unsigned long get_word_at(process *p, unsigned long addr, bool &err) { * Check the machine's stack pointer, page align it, and start walking * back looking for an unaccessible page. **/ -static Address getStackTop(AddrSpaceReader *proc, bool &err) { - Address stack_pointer; - Address pagesize = getpagesize(); +static Dyninst::Address getStackTop(AddrSpaceReader *proc, bool &err) { + Dyninst::Address stack_pointer; + Dyninst::Address pagesize = getpagesize(); bool result; long word; err = false; diff --git a/common/src/linuxKludges.h b/common/src/linuxKludges.h index e8d340c4bc..0f6924b05d 100644 --- a/common/src/linuxKludges.h +++ b/common/src/linuxKludges.h @@ -33,6 +33,7 @@ #define _linux_kludges_h #include +#include "dyntypes.h" COMMON_EXPORT bool PtraceBulkRead(Dyninst::Address inTraced, unsigned size, void *inSelf, int pid); diff --git a/common/src/parseauxv.C b/common/src/parseauxv.C index f3b9b726b8..41fdacc4f7 100644 --- a/common/src/parseauxv.C +++ b/common/src/parseauxv.C @@ -97,7 +97,7 @@ AuxvParser::AuxvParser(int pid_, unsigned addr_size_) : create_err = !readAuxvInfo(); } -Address AuxvParser::getInterpreterBase() +Dyninst::Address AuxvParser::getInterpreterBase() { return interpreter_base; } @@ -107,27 +107,27 @@ bool AuxvParser::parsedVsyscall() return found_vsyscall; } -Address AuxvParser::getVsyscallBase() +Dyninst::Address AuxvParser::getVsyscallBase() { return vsyscall_base; } -Address AuxvParser::getVsyscallText() +Dyninst::Address AuxvParser::getVsyscallText() { return vsyscall_text; } -Address AuxvParser::getVsyscallEnd() +Dyninst::Address AuxvParser::getVsyscallEnd() { return vsyscall_end; } -Address AuxvParser::getProgramBase() +Dyninst::Address AuxvParser::getProgramBase() { return phdr; } -Address AuxvParser::getPageSize() +Dyninst::Address AuxvParser::getPageSize() { return page_size; } diff --git a/common/src/parseauxv.h b/common/src/parseauxv.h index 3f774f4054..fa710ff181 100644 --- a/common/src/parseauxv.h +++ b/common/src/parseauxv.h @@ -40,12 +40,12 @@ class COMMON_EXPORT AuxvParser int pid; unsigned ref_count; bool create_err; - Address interpreter_base; - Address vsyscall_base; - Address vsyscall_text; - Address vsyscall_end; + Dyninst::Address interpreter_base; + Dyninst::Address vsyscall_base; + Dyninst::Address vsyscall_text; + Dyninst::Address vsyscall_end; bool found_vsyscall; - Address phdr; + Dyninst::Address phdr; unsigned page_size; unsigned addr_size; @@ -53,7 +53,7 @@ class COMMON_EXPORT AuxvParser bool readAuxvInfo(); void *readAuxvFromProc(); void *readAuxvFromStack(); - Address getStackTop(bool &err); + Dyninst::Address getStackTop(bool &err); AuxvParser(int pid, unsigned asize); static std::map pid_to_parser; @@ -64,13 +64,13 @@ class COMMON_EXPORT AuxvParser void deleteAuxvParser(); ~AuxvParser(); - Address getInterpreterBase(); + Dyninst::Address getInterpreterBase(); bool parsedVsyscall(); - Address getVsyscallBase(); - Address getVsyscallText(); - Address getVsyscallEnd(); - Address getProgramBase(); - Address getPageSize(); + Dyninst::Address getVsyscallBase(); + Dyninst::Address getVsyscallText(); + Dyninst::Address getVsyscallEnd(); + Dyninst::Address getProgramBase(); + Dyninst::Address getPageSize(); }; diff --git a/common/src/sha1.C b/common/src/sha1.C index 81725ee213..08dd9f6bb4 100644 --- a/common/src/sha1.C +++ b/common/src/sha1.C @@ -103,7 +103,7 @@ A million repetitions of "a" #include #include -#include "common/src/Types.h" +#include "dyntypes.h" #include "common/src/sha1.h" /* #include */ /* prototype for exit() - JHB */ /* Using return() instead of exit() - SWR */ diff --git a/dataflowAPI/rose/semantics/SymEvalSemantics.h b/dataflowAPI/rose/semantics/SymEvalSemantics.h index cc5dbdfd5d..55f8f1a303 100644 --- a/dataflowAPI/rose/semantics/SymEvalSemantics.h +++ b/dataflowAPI/rose/semantics/SymEvalSemantics.h @@ -14,6 +14,7 @@ #include "external/rose/amdgpuInstructionEnum.h" #include "BaseSemantics2.h" #include "../../h/SymEval.h" +#include "dyntypes.h" namespace rose { namespace BinaryAnalysis { diff --git a/dynC_API/src/snippetGen.C b/dynC_API/src/snippetGen.C index 9dac35b8c6..f38f04e15b 100644 --- a/dynC_API/src/snippetGen.C +++ b/dynC_API/src/snippetGen.C @@ -28,6 +28,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "snippetGen.h" +#include "dyntypes.h" extern "C" { void getErrorBase(char *errbase, int length); diff --git a/dyninstAPI/h/BPatch.h b/dyninstAPI/h/BPatch.h index d9250d6f24..ab3628fee5 100644 --- a/dyninstAPI/h/BPatch.h +++ b/dyninstAPI/h/BPatch.h @@ -42,7 +42,7 @@ #include "BPatch_callbacks.h" #include #include - +#include "dyntypes.h" #include "dyninstversion.h" #include "compiler_diagnostics.h" diff --git a/dyninstAPI/h/BPatch_addressSpace.h b/dyninstAPI/h/BPatch_addressSpace.h index 581cbba3b7..c5cf5470d5 100644 --- a/dyninstAPI/h/BPatch_addressSpace.h +++ b/dyninstAPI/h/BPatch_addressSpace.h @@ -45,6 +45,7 @@ #include #include #include +#include "dyntypes.h" // PatchAPI stuffs //#include "Command.h" diff --git a/dyninstAPI/h/BPatch_basicBlock.h b/dyninstAPI/h/BPatch_basicBlock.h index 724d5fb539..7394a7c010 100644 --- a/dyninstAPI/h/BPatch_basicBlock.h +++ b/dyninstAPI/h/BPatch_basicBlock.h @@ -42,6 +42,7 @@ #include "BPatch_instruction.h" #include "Instruction.h" #include "BPatch_enums.h" +#include "dyntypes.h" //#include "BPatch_edge.h" class image; diff --git a/dyninstAPI/h/BPatch_callbacks.h b/dyninstAPI/h/BPatch_callbacks.h index fec837eb94..16bb5c20d3 100644 --- a/dyninstAPI/h/BPatch_callbacks.h +++ b/dyninstAPI/h/BPatch_callbacks.h @@ -33,6 +33,8 @@ #include #include "BPatch_Vector.h" +#include "dyntypes.h" + class BPatch_process; class BPatch_thread; class BPatch_module; diff --git a/dyninstAPI/h/BPatch_flowGraph.h b/dyninstAPI/h/BPatch_flowGraph.h index ceafb5a0c0..0ad5d8d21d 100644 --- a/dyninstAPI/h/BPatch_flowGraph.h +++ b/dyninstAPI/h/BPatch_flowGraph.h @@ -42,6 +42,7 @@ #include "BPatch_basicBlockLoop.h" #include "BPatch_loopTreeNode.h" #include "BPatch_edge.h" +#include "dyntypes.h" class func_instance; class AddressSpace; diff --git a/dyninstAPI/h/BPatch_function.h b/dyninstAPI/h/BPatch_function.h index 9baca1f4cf..68f9eb52eb 100644 --- a/dyninstAPI/h/BPatch_function.h +++ b/dyninstAPI/h/BPatch_function.h @@ -44,6 +44,7 @@ #include "BPatch_module.h" #include "BPatch_memoryAccess_NP.h" #include "StackMod.h" +#include "dyntypes.h" class func_instance; diff --git a/dyninstAPI/h/BPatch_memoryAccess_NP.h b/dyninstAPI/h/BPatch_memoryAccess_NP.h index 04a6bb3db6..55b48af40f 100644 --- a/dyninstAPI/h/BPatch_memoryAccess_NP.h +++ b/dyninstAPI/h/BPatch_memoryAccess_NP.h @@ -36,6 +36,7 @@ #include "BPatch_Vector.h" #include #include "BPatch_instruction.h" +#include "dyntypes.h" class BPatch_point; class internal_instruction; diff --git a/dyninstAPI/h/BPatch_point.h b/dyninstAPI/h/BPatch_point.h index 527fbbe16f..05d1bf6153 100644 --- a/dyninstAPI/h/BPatch_point.h +++ b/dyninstAPI/h/BPatch_point.h @@ -37,6 +37,8 @@ #include "BPatch_Vector.h" #include "BPatch_Set.h" #include "BPatch_enums.h" +#include "dyntypes.h" + class instPoint; class BPatch_thread; class BPatch_image; diff --git a/dyninstAPI/h/BPatch_process.h b/dyninstAPI/h/BPatch_process.h index 556a12a701..8f3bb11308 100644 --- a/dyninstAPI/h/BPatch_process.h +++ b/dyninstAPI/h/BPatch_process.h @@ -37,7 +37,7 @@ // #include "BPatch_image.h" #include "BPatch_addressSpace.h" #include "BPatch_enums.h" - +#include "dyntypes.h" #include "BPatch_callbacks.h" #include "PCProcess.h" diff --git a/dyninstAPI/src/BPatch_libInfo.h b/dyninstAPI/src/BPatch_libInfo.h index 76bdd710d2..1c44af28e2 100644 --- a/dyninstAPI/src/BPatch_libInfo.h +++ b/dyninstAPI/src/BPatch_libInfo.h @@ -35,7 +35,7 @@ #include "dyninstAPI/h/BPatch_process.h" #include "dyninstAPI/h/BPatch_point.h" #include -#include "common/src/Types.h" +#include "dyntypes.h" #include "common/h/util.h" #include "util.h" @@ -47,14 +47,14 @@ class BPatch_libInfo { {} bool registerMonitoredPoint(BPatch_point *point); - BPatch_point *getMonitoredPoint(Address addr); + BPatch_point *getMonitoredPoint(Dyninst::Address addr); - int getStopThreadCallbackID(Address cb); + int getStopThreadCallbackID(Dyninst::Address cb); protected: int stopThreadIDCounter_; - std::unordered_map stopThreadCallbacks_; - std::unordered_map monitoredPoints_; + std::unordered_map stopThreadCallbacks_; + std::unordered_map monitoredPoints_; }; #endif /* _BPatch_libInfo_h_ */ diff --git a/dyninstAPI/src/BPatch_memoryAccess.C b/dyninstAPI/src/BPatch_memoryAccess.C index 6d51be31b3..2d58bdac2f 100644 --- a/dyninstAPI/src/BPatch_memoryAccess.C +++ b/dyninstAPI/src/BPatch_memoryAccess.C @@ -138,7 +138,7 @@ BPatch_memoryAccess* BPatch_memoryAccess::init_tables() } // initializes only the first access; #bytes is a constant -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, unsigned int _bytes, long _imm, int _ra, int _rb, unsigned int _scale, int _cond, bool _nt) : @@ -151,7 +151,7 @@ BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _ad } // initializes only the first access; #bytes is an expression w/scale -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, long _imm_s, int _ra_s, int _rb_s, unsigned int _scale_s, long _imm_c, int _ra_c, int _rb_c, unsigned int _scale_c, int _cond, bool _nt, int _preFcn) : @@ -164,7 +164,7 @@ BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _ad } // initializes only the first access; #bytes is an expression -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, bool _isPrefetch, long _imm_s, int _ra_s, int _rb_s, long _imm_c, int _ra_c, int _rb_c, unsigned short _preFcn) : @@ -178,7 +178,7 @@ BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _ad } // initializes only the first access; #bytes is an expression & not a prefetch -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, long _imm_s, int _ra_s, int _rb_s, long _imm_c, int _ra_c, int _rb_c) : BPatch_instruction(insn, _addr) @@ -224,7 +224,7 @@ void BPatch_memoryAccess::set2nd(bool _isLoad, bool _isStore, } // initializes both accesses; #bytes is a constant -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, unsigned int _bytes, long _imm, int _ra, int _rb, unsigned int _scale, bool _isLoad2, bool _isStore2, unsigned int _bytes2, @@ -238,7 +238,7 @@ BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _ad } // initializes both accesses; #bytes is an expression & not a prefetch -BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Address _addr, +BPatch_memoryAccess::BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore, long _imm_s, int _ra_s, int _rb_s, unsigned int _scale_s, long _imm_c, int _ra_c, int _rb_c, unsigned int _scale_c, bool _isLoad2, bool _isStore2, long _imm2_s, diff --git a/dyninstAPI/src/BPatch_memoryAccessAdapter.C b/dyninstAPI/src/BPatch_memoryAccessAdapter.C index 6450487473..807991eb3a 100644 --- a/dyninstAPI/src/BPatch_memoryAccessAdapter.C +++ b/dyninstAPI/src/BPatch_memoryAccessAdapter.C @@ -44,7 +44,7 @@ using namespace InstructionAPI; BPatch_memoryAccess* BPatch_memoryAccessAdapter::convert(Instruction insn, - Address current, bool is64) + Dyninst::Address current, bool is64) { #if defined(arch_x86) || defined(arch_x86_64) static unsigned int log2[] = { 0, 0, 1, 1, 2, 2, 2, 2, 3 }; diff --git a/dyninstAPI/src/BPatch_memoryAccessAdapter.h b/dyninstAPI/src/BPatch_memoryAccessAdapter.h index 87f8fd188a..f1a8d39392 100644 --- a/dyninstAPI/src/BPatch_memoryAccessAdapter.h +++ b/dyninstAPI/src/BPatch_memoryAccessAdapter.h @@ -32,7 +32,7 @@ #include "Visitor.h" #include "Instruction.h" -#include "common/src/Types.h" +#include "dyntypes.h" class BPatch_memoryAccess; @@ -48,7 +48,7 @@ class BPatch_memoryAccessAdapter : public Dyninst::InstructionAPI::Visitor } BPatch_memoryAccess* convert(Dyninst::InstructionAPI::Instruction insn, - Address current, bool is64); + Dyninst::Address current, bool is64); virtual void visit(Dyninst::InstructionAPI::BinaryFunction* b); virtual void visit(Dyninst::InstructionAPI::Dereference* d); virtual void visit(Dyninst::InstructionAPI::RegisterAST* r); diff --git a/dyninstAPI/src/Parsing.h b/dyninstAPI/src/Parsing.h index 2e0b551e36..8aec96e661 100644 --- a/dyninstAPI/src/Parsing.h +++ b/dyninstAPI/src/Parsing.h @@ -38,11 +38,12 @@ #include "parseAPI/h/InstructionSource.h" #include "parseAPI/h/CFG.h" #include "parseAPI/h/ParseCallback.h" +#include "dyntypes.h" // some useful types -using ParseAPI::EdgeTypeEnum; -using ParseAPI::FuncReturnStatus; -using ParseAPI::FuncSource; +using Dyninst::ParseAPI::EdgeTypeEnum; +using Dyninst::ParseAPI::FuncReturnStatus; +using Dyninst::ParseAPI::FuncSource; using std::vector; /*** The image_* object factory ***/ @@ -59,20 +60,20 @@ class DynCFGFactory : public Dyninst::ParseAPI::CFGFactory { DynCFGFactory(image * im); ~DynCFGFactory() {} - ParseAPI::Function * mkfunc(Address addr, FuncSource src, std::string name, - ParseAPI::CodeObject * obj, ParseAPI::CodeRegion * reg, - InstructionSource * isrc); - ParseAPI::Block * mkblock(ParseAPI::Function * f, ParseAPI::CodeRegion * r, - Address addr); - ParseAPI::Edge * mkedge(ParseAPI::Block * src, ParseAPI::Block * trg, + Dyninst::ParseAPI::Function * mkfunc(Dyninst::Address addr, FuncSource src, std::string name, + Dyninst::ParseAPI::CodeObject * obj, Dyninst::ParseAPI::CodeRegion * reg, + Dyninst::InstructionSource * isrc); + Dyninst::ParseAPI::Block * mkblock(Dyninst::ParseAPI::Function * f, Dyninst::ParseAPI::CodeRegion * r, + Dyninst::Address addr); + Dyninst::ParseAPI::Edge * mkedge(Dyninst::ParseAPI::Block * src, Dyninst::ParseAPI::Block * trg, EdgeTypeEnum type); - ParseAPI::Block * mksink(ParseAPI::CodeObject *obj, ParseAPI::CodeRegion*r); + Dyninst::ParseAPI::Block * mksink(Dyninst::ParseAPI::CodeObject *obj, Dyninst::ParseAPI::CodeRegion*r); // leaving default atm - //void free_func(ParseAPI::Function * f); - //void free_block(ParseAPI::Block * b); - //void free_edge(ParseAPI::Edge * e); + //void free_func(Dyninst::ParseAPI::Function * f); + //void free_block(Dyninst::ParseAPI::Block * b); + //void free_edge(Dyninst::ParseAPI::Edge * e); //void free_all(); void dump_stats(); @@ -86,14 +87,14 @@ class DynCFGFactory : public Dyninst::ParseAPI::CFGFactory { int _sink_block_allocs; //int _sink_edge_allocs; FIXME can't determine - void _record_func_alloc(ParseAPI::FuncSource fs) + void _record_func_alloc(Dyninst::ParseAPI::FuncSource fs) { - assert(fs < ParseAPI::_funcsource_end_); + assert(fs < Dyninst::ParseAPI::_funcsource_end_); ++_func_allocs[fs]; } - void _record_edge_alloc(ParseAPI::EdgeTypeEnum et,bool /* sink */) + void _record_edge_alloc(Dyninst::ParseAPI::EdgeTypeEnum et,bool /* sink */) { - assert(et < ParseAPI::_edgetype_end_); + assert(et < Dyninst::ParseAPI::_edgetype_end_); ++_edge_allocs[et]; //if(sink) @@ -108,34 +109,34 @@ class DynCFGFactory : public Dyninst::ParseAPI::CFGFactory { }; class image; -class DynParseCallback : public ParseAPI::ParseCallback { +class DynParseCallback : public Dyninst::ParseAPI::ParseCallback { public: - DynParseCallback(image * img) : ParseAPI::ParseCallback(), _img(img) { } + DynParseCallback(image * img) : Dyninst::ParseAPI::ParseCallback(), _img(img) { } ~DynParseCallback() { } protected: // defensive and exploratory mode callbacks - virtual void abruptEnd_cf(Address,ParseAPI::Block *,default_details*); - virtual void newfunction_retstatus(ParseAPI::Function*); - virtual void patch_nop_jump(Address); - virtual bool hasWeirdInsns(const ParseAPI::Function*) const; - virtual void foundWeirdInsns(ParseAPI::Function*); + virtual void abruptEnd_cf(Dyninst::Address,Dyninst::ParseAPI::Block *,default_details*); + virtual void newfunction_retstatus(Dyninst::ParseAPI::Function*); + virtual void patch_nop_jump(Dyninst::Address); + virtual bool hasWeirdInsns(const Dyninst::ParseAPI::Function*) const; + virtual void foundWeirdInsns(Dyninst::ParseAPI::Function*); // other callbacks - virtual void interproc_cf(ParseAPI::Function*,ParseAPI::Block*,Address,interproc_details*); - virtual void overlapping_blocks(ParseAPI::Block*,ParseAPI::Block*); - virtual bool updateCodeBytes(Address target); // updates if needed - virtual void split_block_cb(ParseAPI::Block *, ParseAPI::Block *); // needed for defensive mode + virtual void interproc_cf(Dyninst::ParseAPI::Function*,Dyninst::ParseAPI::Block*,Dyninst::Address,interproc_details*); + virtual void overlapping_blocks(Dyninst::ParseAPI::Block*,Dyninst::ParseAPI::Block*); + virtual bool updateCodeBytes(Dyninst::Address target); // updates if needed + virtual void split_block_cb(Dyninst::ParseAPI::Block *, Dyninst::ParseAPI::Block *); // needed for defensive mode - virtual void destroy_cb(ParseAPI::Block *); - virtual void destroy_cb(ParseAPI::Edge *); - virtual void destroy_cb(ParseAPI::Function *); + virtual void destroy_cb(Dyninst::ParseAPI::Block *); + virtual void destroy_cb(Dyninst::ParseAPI::Edge *); + virtual void destroy_cb(Dyninst::ParseAPI::Function *); - virtual void remove_edge_cb(ParseAPI::Block *, ParseAPI::Edge *, edge_type_t); - virtual void remove_block_cb(ParseAPI::Function *, ParseAPI::Block *); + virtual void remove_edge_cb(Dyninst::ParseAPI::Block *, Dyninst::ParseAPI::Edge *, edge_type_t); + virtual void remove_block_cb(Dyninst::ParseAPI::Function *, Dyninst::ParseAPI::Block *); #if defined(arch_power) || defined(arch_aarch64) - void instruction_cb(ParseAPI::Function*, ParseAPI::Block *, Address, insn_details*); + void instruction_cb(Dyninst::ParseAPI::Function*, Dyninst::ParseAPI::Block *, Dyninst::Address, insn_details*); #endif private: image * _img; diff --git a/dyninstAPI/src/Relocation/DynPointMaker.h b/dyninstAPI/src/Relocation/DynPointMaker.h index 32eeaacb6c..46c49247a5 100644 --- a/dyninstAPI/src/Relocation/DynPointMaker.h +++ b/dyninstAPI/src/Relocation/DynPointMaker.h @@ -52,8 +52,8 @@ class DynPointMaker : public Dyninst::PatchAPI::PointMaker { virtual Point *mkFuncPoint(Point::Type t, PatchMgrPtr m, PatchFunction *); virtual Point *mkFuncSitePoint(Point::Type t, PatchMgrPtr m, PatchFunction *, PatchBlock *); virtual Point *mkBlockPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, PatchFunction *context); - virtual Point *mkInsnPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, Address, - InstructionAPI::Instruction, PatchFunction *context); + virtual Point *mkInsnPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, Dyninst::Address, + Dyninst::InstructionAPI::Instruction, PatchFunction *context); virtual Point *mkEdgePoint(Point::Type t, PatchMgrPtr m, PatchEdge *, PatchFunction *f); }; diff --git a/dyninstAPI/src/StackMod/StackLocation.h b/dyninstAPI/src/StackMod/StackLocation.h index 00ba9a43b6..6600b5cb13 100644 --- a/dyninstAPI/src/StackMod/StackLocation.h +++ b/dyninstAPI/src/StackMod/StackLocation.h @@ -37,7 +37,7 @@ #include "registers/MachRegister.h" #include "common/src/IntervalTree.h" #include "stackanalysis.h" - +#include "dyntypes.h" #include "StackAccess.h" using namespace Dyninst; diff --git a/dyninstAPI/src/addressSpace.h b/dyninstAPI/src/addressSpace.h index 3c6947cc3e..4d0161a058 100644 --- a/dyninstAPI/src/addressSpace.h +++ b/dyninstAPI/src/addressSpace.h @@ -45,7 +45,7 @@ #include #include #include - +#include "dyntypes.h" #include "common/src/IntervalTree.h" #include "parseAPI/h/CodeObject.h" diff --git a/dyninstAPI/src/ast.C b/dyninstAPI/src/ast.C index 7183d8402e..3227397bbb 100644 --- a/dyninstAPI/src/ast.C +++ b/dyninstAPI/src/ast.C @@ -209,7 +209,7 @@ AstNodePtr AstNode::sequenceNode(std::vector &sequence) { } AstNodePtr AstNode::variableNode(vector &ast_wrappers, - vector >*ranges) { + vector >*ranges) { return AstNodePtr(new AstVariableNode(ast_wrappers, ranges)); } @@ -466,7 +466,7 @@ AstSequenceNode::AstSequenceNode(std::vector &sequence) : } } -AstVariableNode::AstVariableNode(vector&ast_wrappers, vector > *ranges) : +AstVariableNode::AstVariableNode(vector&ast_wrappers, vector > *ranges) : ast_wrappers_(ast_wrappers), ranges_(ranges), index(0) { vector::iterator i; @@ -3207,7 +3207,7 @@ void AstVariableNode::setVariableAST(codeGen &gen){ index = 0; return; } - Address addr = gen.point()->addr_compat(); //Offset of inst point from function base address + Address addr = gen.point()->addr_compat(); //Dyninst::Offset of inst point from function base address bool found = false; for(unsigned i=0; i< ranges_->size();i++){ if((*ranges_)[i].first<=addr && addr<=(*ranges_)[i].second) { diff --git a/dyninstAPI/src/ast.h b/dyninstAPI/src/ast.h index dad15e64f6..9b24c14203 100644 --- a/dyninstAPI/src/ast.h +++ b/dyninstAPI/src/ast.h @@ -225,7 +225,7 @@ class AstNode : public Dyninst::PatchAPI::Snippet { static AstNodePtr sequenceNode(std::vector &sequence); - static AstNodePtr variableNode(std::vector&ast_wrappers_, std::vector > *ranges = NULL); + static AstNodePtr variableNode(std::vector&ast_wrappers_, std::vector > *ranges = NULL); static AstNodePtr operatorNode(opCode ot, AstNodePtr l = AstNodePtr(), @@ -235,7 +235,7 @@ class AstNode : public Dyninst::PatchAPI::Snippet { static AstNodePtr funcCallNode(const std::string &func, std::vector &args, AddressSpace *addrSpace = NULL); static AstNodePtr funcCallNode(func_instance *func, std::vector &args); static AstNodePtr funcCallNode(func_instance *func); // Special case for function call replacement. - static AstNodePtr funcCallNode(Address addr, std::vector &args); // For when you absolutely need + static AstNodePtr funcCallNode(Dyninst::Address addr, std::vector &args); // For when you absolutely need // to jump somewhere. // Acquire the thread index value - a 0...n labelling of threads. @@ -267,7 +267,7 @@ class AstNode : public Dyninst::PatchAPI::Snippet { virtual bool generateCode(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); // Can't use default references.... @@ -278,7 +278,7 @@ class AstNode : public Dyninst::PatchAPI::Snippet { virtual bool generateCode(codeGen &gen, bool noCost, Register &retReg) { - Address unused = ADDR_NULL; + Dyninst::Address unused = Dyninst::ADDR_NULL; return generateCode(gen, noCost, unused, retReg); } @@ -286,7 +286,7 @@ class AstNode : public Dyninst::PatchAPI::Snippet { // so we'll toss in two different return types. virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); // Perform whatever pre-processing steps are necessary. @@ -438,7 +438,7 @@ class AstNullNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; @@ -458,7 +458,7 @@ class AstStackInsertNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); int size; @@ -489,7 +489,7 @@ class AstStackRemoveNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); int size; @@ -510,7 +510,7 @@ class AstStackGenericNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; @@ -524,10 +524,10 @@ class AstLabelNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); std::string label_; - Address generatedAddr_; + Dyninst::Address generatedAddr_; }; class AstOperatorNode : public AstNode { @@ -561,7 +561,7 @@ class AstOperatorNode : public AstNode { virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); bool generateOptimizedAssignment(codeGen &gen, int size, bool noCost); @@ -638,7 +638,7 @@ class AstOperandNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); int_variable* lookUpVar(AddressSpace* as); @@ -656,7 +656,7 @@ class AstCallNode : public AstNode { AstCallNode(func_instance *func, std::vector&args); AstCallNode(const std::string &str, std::vector&args); - AstCallNode(Address addr, std::vector &args); + AstCallNode(Dyninst::Address addr, std::vector &args); AstCallNode(func_instance *func); ~AstCallNode() {} @@ -685,13 +685,13 @@ class AstCallNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); AstCallNode(): func_addr_(0), func_(NULL), callReplace_(false), constFunc_(false) {} // Sometimes we just don't have enough information... const std::string func_name_; - Address func_addr_; + Dyninst::Address func_addr_; func_instance *func_; std::vector args_; @@ -731,7 +731,7 @@ class AstSequenceNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); AstSequenceNode() {} @@ -740,7 +740,7 @@ class AstSequenceNode : public AstNode { class AstVariableNode : public AstNode { public: - AstVariableNode(std::vector&ast_wrappers, std::vector >*ranges); + AstVariableNode(std::vector&ast_wrappers, std::vector >*ranges); ~AstVariableNode() {} @@ -769,12 +769,12 @@ class AstVariableNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); AstVariableNode(): ranges_(NULL), index(0) {} std::vectorast_wrappers_; - std::vector > *ranges_; + std::vector > *ranges_; unsigned index; }; @@ -789,7 +789,7 @@ class AstMiniTrampNode : public AstNode { } - Address generateTramp(codeGen &gen, + Dyninst::Address generateTramp(codeGen &gen, int &trampCost, bool noCost); @@ -831,7 +831,7 @@ class AstMemoryNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); AstMemoryNode() {} @@ -855,7 +855,7 @@ class AstOriginalAddrNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; @@ -874,7 +874,7 @@ class AstActualAddrNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; @@ -893,7 +893,7 @@ class AstDynamicTargetNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; class AstScrambleRegistersNode : public AstNode { @@ -909,7 +909,7 @@ class AstScrambleRegistersNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); }; @@ -928,17 +928,17 @@ class AstSnippetNode : public AstNode { private: virtual bool generateCode_phase2(codeGen &gen, bool noCost, - Address &retAddr, + Dyninst::Address &retAddr, Register &retReg); Dyninst::PatchAPI::SnippetPtr snip_; }; -void emitLoadPreviousStackFrameRegister(Address register_num, +void emitLoadPreviousStackFrameRegister(Dyninst::Address register_num, Register dest, codeGen &gen, int size, bool noCost); -void emitStorePreviousStackFrameRegister(Address register_num, +void emitStorePreviousStackFrameRegister(Dyninst::Address register_num, Register src, codeGen &gen, int size, diff --git a/dyninstAPI/src/baseTramp.C b/dyninstAPI/src/baseTramp.C index 1fac9f195f..a87e9c2000 100644 --- a/dyninstAPI/src/baseTramp.C +++ b/dyninstAPI/src/baseTramp.C @@ -188,7 +188,7 @@ bool baseTramp::shouldRegenBaseTramp(registerSpace *rs) } bool baseTramp::generateCode(codeGen &gen, - Address baseInMutatee) { + Dyninst::Address baseInMutatee) { inst_printf("baseTramp %p ::generateCode(%p, 0x%lx, %u)\n", (void*)this, gen.start_ptr(), baseInMutatee, gen.used()); initializeFlags(); @@ -261,7 +261,7 @@ bool baseTramp::generateCode(codeGen &gen, #include "BPatch_collections.h" bool baseTramp::generateCodeInlined(codeGen &gen, - Address) { + Dyninst::Address) { // We're generating something like so: // // diff --git a/dyninstAPI/src/baseTramp.h b/dyninstAPI/src/baseTramp.h index 47faa48000..aabeec4686 100644 --- a/dyninstAPI/src/baseTramp.h +++ b/dyninstAPI/src/baseTramp.h @@ -35,7 +35,7 @@ #ifndef BASE_TRAMP_H #define BASE_TRAMP_H -#include "common/src/Types.h" +#include "dyntypes.h" #include "inst.h" // callWhen #include "dyninstAPI/src/codeRange.h" //#include "arch.h" @@ -63,10 +63,10 @@ class baseTramp { void initializeFlags(); bool generateCode(codeGen &gen, - Address baseInMutatee); + Dyninst::Address baseInMutatee); bool generateCodeInlined(codeGen &gen, - Address baseInMutatee); + Dyninst::Address baseInMutatee); bool checkForFuncCalls(); diff --git a/dyninstAPI/src/codeRange.C b/dyninstAPI/src/codeRange.C index e211289cd6..6173fbc274 100644 --- a/dyninstAPI/src/codeRange.C +++ b/dyninstAPI/src/codeRange.C @@ -179,7 +179,7 @@ void codeRangeTree::deleteFixup(entry* x){ // fails if the key value is already in the tree (happens for shared code) -codeRangeTree::entry *codeRangeTree::treeInsert(Address key, codeRange *value) +codeRangeTree::entry *codeRangeTree::treeInsert(Dyninst::Address key, codeRange *value) { entry* y = NULL; entry* x = setData; @@ -228,7 +228,7 @@ codeRangeTree::entry *codeRangeTree::treeSuccessor(entry* x) const{ } -codeRangeTree::entry *codeRangeTree::find_internal(Address element) const{ +codeRangeTree::entry *codeRangeTree::find_internal(Dyninst::Address element) const{ entry* x = setData; while(x != nil){ if (element < x->key) { @@ -319,7 +319,7 @@ void codeRangeTree::insert(codeRange *value) { setData->color = TREE_BLACK; } - void codeRangeTree::remove(Address key){ + void codeRangeTree::remove(Dyninst::Address key){ entry* z = find_internal(key); if(!z) { return; } if(z->key != key) { return; } @@ -359,7 +359,7 @@ void codeRangeTree::destroy(entry* node){ delete node; } -bool codeRangeTree::find(Address key, codeRange *& value) const{ +bool codeRangeTree::find(Dyninst::Address key, codeRange *& value) const{ value = NULL; if (!precessor(key, value)) return false; @@ -396,7 +396,7 @@ bool codeRangeTree::find(Address key, codeRange *& value) const{ #endif } -bool codeRangeTree::precessor(Address key, codeRange * &value) const{ +bool codeRangeTree::precessor(Dyninst::Address key, codeRange * &value) const{ entry *x = setData; entry *last = nil; while (x != nil) { @@ -427,7 +427,7 @@ bool codeRangeTree::precessor(Address key, codeRange * &value) const{ return false; } -bool codeRangeTree::successor(Address key, codeRange * &value) const{ +bool codeRangeTree::successor(Dyninst::Address key, codeRange * &value) const{ entry *x = setData; entry *last = nil; while (x != nil) { @@ -478,7 +478,7 @@ void codeRangeTree::clear() { } #define PRINT_COMMA if (print_comma) fprintf(stderr, ", "); print_comma = true -void codeRange::print_range(Address) { +void codeRange::print_range(Dyninst::Address) { bool print_comma = false; image *img_ptr = is_image(); mapped_object *mapped_ptr = is_mapped_object(); diff --git a/dyninstAPI/src/codeRange.h b/dyninstAPI/src/codeRange.h index ba47045bb9..b0639e7fd6 100644 --- a/dyninstAPI/src/codeRange.h +++ b/dyninstAPI/src/codeRange.h @@ -41,7 +41,7 @@ #include #include #include -#include "common/src/Types.h" +#include "dyntypes.h" #include "dyninstAPI/src/patch.h" /** template class for codeRangeTree. The implementation is based on red black @@ -66,10 +66,10 @@ class parse_block; class codeRange : public patchTarget { public: //These are now inherited from relocTarget - //virtual Address get_address() const = 0; + //virtual Dyninst::Address get_address() const = 0; //virtual unsigned get_size() const = 0; - virtual void *getPtrToInstruction(Address) const { assert(0); return NULL; } + virtual void *getPtrToInstruction(Dyninst::Address) const { assert(0); return NULL; } // This returns a local pointer to the "beginning" of the // code range - as opposed to get_address, which returns @@ -98,7 +98,7 @@ class codeRange : public patchTarget { inferiorRPCinProgress *is_inferior_rpc(); //Prints codeRange info to stderr. - void print_range(Address addr = 0); + void print_range(Dyninst::Address addr = 0); codeRange() = default; codeRange(const codeRange&) = default; @@ -111,7 +111,7 @@ class codeRangeTree { /** tree implementation structure. Used to implement the RB tree */ typedef struct entry { - Address key; + Dyninst::Address key; codeRange *value; color_t color; /* color of the node */ struct entry* left; /* left child */ @@ -132,7 +132,7 @@ class codeRangeTree { * @param d data element * @param e nill entry */ - entry(Address key_, codeRange *value_, entry* e) + entry(Dyninst::Address key_, codeRange *value_, entry* e) : key(key_), value(value_), color(TREE_RED), left(e), right(e), parent(NULL) {} @@ -169,7 +169,7 @@ class codeRangeTree { // insertion to a binary search tree. It returns the new element pointer // that is inserted. If element is already there it returns NULL - entry* treeInsert(Address, codeRange *); + entry* treeInsert(Dyninst::Address, codeRange *); // finds the elemnts in the tree that will be replaced with the element // being deleted in the deletion. That is the element with the largest @@ -178,7 +178,7 @@ class codeRangeTree { // method that returns the entry pointer for the element that is searched //for. If the entry is not found then it retuns NULL - entry* find_internal(Address) const; + entry* find_internal(Dyninst::Address) const; // infix traverse of the RB tree. It traverses the tree in ascending order void traverse(codeRange **,entry*,int&) const; @@ -222,22 +222,22 @@ class codeRangeTree { /** removes the element in the tree * @param 1 element that will be removed */ - void remove(Address); + void remove(Dyninst::Address); /** returns true if the argument is member of the codeRangeTree * @param e the element that will be searched for */ - bool find(Address, codeRange *&) const; + bool find(Dyninst::Address, codeRange *&) const; /** Returns the largest value less than or equal to the * key given */ - bool precessor(Address, codeRange *&) const; + bool precessor(Dyninst::Address, codeRange *&) const; /** Returns the smallest value greater than or equal to the * key given */ - bool successor(Address, codeRange *&) const; + bool successor(Dyninst::Address, codeRange *&) const; /** fill an buffer array with the sorted * elements of the codeRangeTree in ascending order according to comparison function diff --git a/dyninstAPI/src/codegen-x86.C b/dyninstAPI/src/codegen-x86.C index 03594508f1..d343234470 100644 --- a/dyninstAPI/src/codegen-x86.C +++ b/dyninstAPI/src/codegen-x86.C @@ -84,7 +84,7 @@ unsigned copy_prefixes(const unsigned char *&origInsn, unsigned char *&newInsn, return nPrefixes; } -//Copy all prefixes but the Operand-Size and Address-Size prefixes (0x66 and 0x67) +//Copy all prefixes but the Operand-Size and Dyninst::Address-Size prefixes (0x66 and 0x67) unsigned copy_prefixes_nosize(const unsigned char *&origInsn, unsigned char *&newInsn, unsigned insnType) { @@ -103,7 +103,7 @@ unsigned copy_prefixes_nosize(const unsigned char *&origInsn, unsigned char *&ne return retval; } -//Copy all prefixes but the Operand-Size and Address-Size prefixes (0x66 and 0x67) +//Copy all prefixes but the Operand-Size and Dyninst::Address-Size prefixes (0x66 and 0x67) // Returns the number of bytes copied unsigned copy_prefixes_nosize_or_segments(const unsigned char *&origInsn, unsigned char *&newInsn, unsigned insnType) @@ -211,7 +211,7 @@ void insnCodeGen::generateTrap(codeGen &gen) { */ void insnCodeGen::generateBranch(codeGen &gen, - Address fromAddr, Address toAddr) + Dyninst::Address fromAddr, Dyninst::Address toAddr) { GET_PTR(insn, gen); long disp; @@ -273,7 +273,7 @@ void insnCodeGen::generateBranch(codeGen &gen, // Unified the 64-bit push between branch and call -void insnCodeGen::generatePush64(codeGen &gen, Address val) +void insnCodeGen::generatePush64(codeGen &gen, Dyninst::Address val) { GET_PTR(insn, gen); #if 0 @@ -302,7 +302,7 @@ void insnCodeGen::generatePush64(codeGen &gen, Address val) SET_PTR(insn, gen); } -void insnCodeGen::generateBranch64(codeGen &gen, Address to) +void insnCodeGen::generateBranch64(codeGen &gen, Dyninst::Address to) { // "long jump" - generates sequence to jump to any 64-bit address // pushes the value on the stack (using 4 16-bit pushes) the uses a 'RET' @@ -315,7 +315,7 @@ void insnCodeGen::generateBranch64(codeGen &gen, Address to) } -void insnCodeGen::generateBranch32(codeGen &gen, Address to) +void insnCodeGen::generateBranch32(codeGen &gen, Dyninst::Address to) { // "long jump" - generates sequence to jump to any 32-bit address emitPushImm(to, gen); @@ -326,8 +326,8 @@ void insnCodeGen::generateBranch32(codeGen &gen, Address to) } void insnCodeGen::generateCall(codeGen &gen, - Address from, - Address target) + Dyninst::Address from, + Dyninst::Address target) { //assert(target); long disp = target - (from + CALL_REL32_SZ); @@ -394,7 +394,7 @@ pcRelJump::pcRelJump(patchTarget *t, const instruction &i, bool copyPrefixes) : { } -pcRelJump::pcRelJump(Address target, const instruction &i, bool copyPrefixes) : +pcRelJump::pcRelJump(Dyninst::Address target, const instruction &i, bool copyPrefixes) : pcRelRegion(i), addr_targ(target), targ(NULL), @@ -402,7 +402,7 @@ pcRelJump::pcRelJump(Address target, const instruction &i, bool copyPrefixes) : { } -Address pcRelJump::get_target() +Dyninst::Address pcRelJump::get_target() { if (targ) return targ->get_address(); @@ -413,7 +413,7 @@ pcRelJump::~pcRelJump() { } -unsigned pcRelJump::apply(Address addr) +unsigned pcRelJump::apply(Dyninst::Address addr) { const unsigned char *origInsn = orig_instruc.ptr(); unsigned insnType = orig_instruc.type(); @@ -456,14 +456,14 @@ pcRelJCC::pcRelJCC(patchTarget *t, const instruction &i) : { } -pcRelJCC::pcRelJCC(Address target, const instruction &i) : +pcRelJCC::pcRelJCC(Dyninst::Address target, const instruction &i) : pcRelRegion(i), addr_targ(target), targ(NULL) { } -Address pcRelJCC::get_target() +Dyninst::Address pcRelJCC::get_target() { if (targ) return targ->get_address(); @@ -474,12 +474,12 @@ pcRelJCC::~pcRelJCC() { } -unsigned pcRelJCC::apply(Address addr) +unsigned pcRelJCC::apply(Dyninst::Address addr) { const unsigned char *origInsn = orig_instruc.ptr(); unsigned insnType = orig_instruc.type(); - Address target = get_target(); - Address potential; + Dyninst::Address target = get_target(); + Dyninst::Address potential; signed long disp; codeBufIndex_t start = gen->getIndex(); GET_PTR(newInsn, *gen); @@ -547,7 +547,7 @@ unsigned pcRelJCC::apply(Address addr) // Original address is a little skewed... // We've moved past the original address (to the tune of nPrefixes + 2 (JCC) + 2 (J)) - Address currAddr = addr + (unsigned) gen->getIndex() - start; + Dyninst::Address currAddr = addr + (unsigned) gen->getIndex() - start; insnCodeGen::generateBranch(*gen, currAddr, target); codeBufIndex_t done = gen->getIndex(); @@ -586,14 +586,14 @@ pcRelCall::pcRelCall(patchTarget *t, const instruction &i) : { } -pcRelCall::pcRelCall(Address target, const instruction &i) : +pcRelCall::pcRelCall(Dyninst::Address target, const instruction &i) : pcRelRegion(i), targ_addr(target), targ(NULL) { } -Address pcRelCall::get_target() +Dyninst::Address pcRelCall::get_target() { if (targ) return targ->get_address(); @@ -604,7 +604,7 @@ pcRelCall::~pcRelCall() { } -unsigned pcRelCall::apply(Address addr) +unsigned pcRelCall::apply(Dyninst::Address addr) { const unsigned char *origInsn = orig_instruc.ptr(); unsigned insnType = orig_instruc.type(); @@ -634,7 +634,7 @@ bool pcRelCall::canPreApply() return gen->startAddr() && (!targ || get_target()); } -pcRelData::pcRelData(Address a, const instruction &i) : +pcRelData::pcRelData(Dyninst::Address a, const instruction &i) : pcRelRegion(i), data_addr(a) { @@ -643,13 +643,13 @@ pcRelData::pcRelData(Address a, const instruction &i) : #define REL_DATA_MAXSIZE 2/*push r*/ + 10/*movImmToReg64*/ + 7/*orig insn*/ + 2/*pop r*/ #if !defined(arch_x86_64) -unsigned pcRelData::apply(Address) { +unsigned pcRelData::apply(Dyninst::Address) { assert(0); return 0; } #else -unsigned pcRelData::apply(Address addr) +unsigned pcRelData::apply(Dyninst::Address addr) { // We may need to change these from 32-bit relative // to 64-bit absolute. This happens with the jumps and calls @@ -775,9 +775,9 @@ bool pcRelData::canPreApply() * The comments and naming schemes in this function assume some familiarity with * the IA32/IA32e instruction encoding. If you don't understand this, I suggest * you start with Chapter 2 of: - * _IA-32 Intel Architecture Software Developer's Manual, Volume 2a_ + * _IA-32 Intel Dyninst::Architecture Software Developer's Manual, Volume 2a_ * and appendix A of: - * _IA-32 Intel Architecture Software Developer's Manual, Volume 2b_ + * _IA-32 Intel Dyninst::Architecture Software Developer's Manual, Volume 2b_ * * This function takes an instruction that accesses memory, and emits a * copy of that instruction that has the load/store replaces with a load/store @@ -788,8 +788,8 @@ bool pcRelData::canPreApply() **/ bool insnCodeGen::generateMem(codeGen &gen, instruction & insn, - Address /*origAddr*/, - Address /*newAddr*/, + Dyninst::Address /*origAddr*/, + Dyninst::Address /*newAddr*/, Register loadExpr, Register storeExpr) { @@ -993,8 +993,8 @@ bool insnCodeGen::generateMem(codeGen &gen, } -bool insnCodeGen::modifyJump(Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { - Address from = gen.currAddr(); +bool insnCodeGen::modifyJump(Dyninst::Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { + Dyninst::Address from = gen.currAddr(); const unsigned char *origInsn = insn.ptr(); unsigned insnType = insn.type(); @@ -1011,12 +1011,12 @@ bool insnCodeGen::modifyJump(Address targetAddr, NS_x86::instruction &insn, code return true; } -bool insnCodeGen::modifyJcc(Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { +bool insnCodeGen::modifyJcc(Dyninst::Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { const unsigned char *origInsn = insn.ptr(); unsigned insnType = insn.type(); - Address from = gen.currAddr(); + Dyninst::Address from = gen.currAddr(); - Address potential; + Dyninst::Address potential; signed long disp; codeBufIndex_t start = gen.getIndex(); GET_PTR(newInsn, gen); @@ -1084,7 +1084,7 @@ bool insnCodeGen::modifyJcc(Address targetAddr, NS_x86::instruction &insn, codeG // Original address is a little skewed... // We've moved past the original address (to the tune of nPrefixes + 2 (JCC) + 2 (J)) - Address currAddr = from + (unsigned) gen.getIndex() - start; + Dyninst::Address currAddr = from + (unsigned) gen.getIndex() - start; insnCodeGen::generateBranch(gen, currAddr, targetAddr); codeBufIndex_t done = gen.getIndex(); @@ -1100,7 +1100,7 @@ bool insnCodeGen::modifyJcc(Address targetAddr, NS_x86::instruction &insn, codeG return true; } -bool insnCodeGen::modifyCall(Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { +bool insnCodeGen::modifyCall(Dyninst::Address targetAddr, NS_x86::instruction &insn, codeGen &gen) { // If we're within a 32-bit displacement, we reuse the original call. // Otherwise we say "welp, sucks to be us", strip any prefixes, // and do a 64-bit long thang @@ -1130,7 +1130,7 @@ bool insnCodeGen::modifyCall(Address targetAddr, NS_x86::instruction &insn, code return true; } -bool insnCodeGen::modifyData(Address targetAddr, instruction &insn, codeGen &gen) +bool insnCodeGen::modifyData(Dyninst::Address targetAddr, instruction &insn, codeGen &gen) { // We may need to change these from 32-bit relative // to 64-bit absolute. This happens with the jumps and calls @@ -1144,7 +1144,7 @@ bool insnCodeGen::modifyData(Address targetAddr, instruction &insn, codeGen &gen const unsigned char* origInsnStart = origInsn; // unsigned insnType = insn.type(); unsigned insnSz = insn.size(); - Address from = gen.currAddr(); + Dyninst::Address from = gen.currAddr(); bool is_data_abs64 = false; signed long newDisp = targetAddr - from; @@ -1249,7 +1249,7 @@ bool insnCodeGen::modifyData(Address targetAddr, instruction &insn, codeGen &gen return true; } -bool insnCodeGen::modifyDisp(signed long newDisp, instruction &insn, codeGen &gen, Architecture arch, Address addr) { +bool insnCodeGen::modifyDisp(signed long newDisp, instruction &insn, codeGen &gen, Dyninst::Architecture arch, Dyninst::Address addr) { relocation_cerr << "\t\tmodifyDisp " << std::hex << addr diff --git a/dyninstAPI/src/codegen-x86.h b/dyninstAPI/src/codegen-x86.h index 8f2b1dacd6..b72e24862b 100644 --- a/dyninstAPI/src/codegen-x86.h +++ b/dyninstAPI/src/codegen-x86.h @@ -34,7 +34,7 @@ #include #include "Architecture.h" #include "entryIDs.h" - +#include "dyntypes.h" #if !defined(arch_x86) && !defined(arch_x86_64) @@ -62,14 +62,14 @@ class insnCodeGen { public: // More code generation - static void generatePush64(codeGen &gen, Address val); + static void generatePush64(codeGen &gen, Dyninst::Address val); // Code generation - static void generateBranch(codeGen &gen, Address from, Address to); + static void generateBranch(codeGen &gen, Dyninst::Address from, Dyninst::Address to); static void generateBranch(codeGen &gen, int disp); - static void generateBranch64(codeGen &gen, Address to); - static void generateBranch32(codeGen &gen, Address to); - static void generateCall(codeGen &gen, Address from, Address to); + static void generateBranch64(codeGen &gen, Dyninst::Address to); + static void generateBranch32(codeGen &gen, Dyninst::Address to); + static void generateCall(codeGen &gen, Dyninst::Address from, Dyninst::Address to); // We may want to generate an efficient set 'o nops static void generateNOOP(codeGen &gen, unsigned size = 1); @@ -86,33 +86,33 @@ class insnCodeGen { static bool generate(codeGen &gen, instruction & insn, AddressSpace *addrSpace, - Address origAddr, - Address newAddr, + Dyninst::Address origAddr, + Dyninst::Address newAddr, patchTarget *fallthroughOverride = NULL, patchTarget *targetOverride = NULL); static bool generateMem(codeGen &gen, instruction & insn, - Address origAddr, - Address newAddr, + Dyninst::Address origAddr, + Dyninst::Address newAddr, Register newLoadReg, Register newStoreReg); - static bool modifyJump(Address target, + static bool modifyJump(Dyninst::Address target, NS_x86::instruction &insn, codeGen &gen); - static bool modifyJcc(Address target, + static bool modifyJcc(Dyninst::Address target, NS_x86::instruction &insn, codeGen &gen); - static bool modifyCall(Address target, + static bool modifyCall(Dyninst::Address target, NS_x86::instruction &insn, codeGen &gen); - static bool modifyData(Address target, + static bool modifyData(Dyninst::Address target, NS_x86::instruction &insn, codeGen &gen); static bool modifyDisp(signed long newDisp, NS_x86::instruction &insn, - codeGen &gen, Architecture arch, Address addr); + codeGen &gen, Dyninst::Architecture arch, Dyninst::Address addr); }; diff --git a/dyninstAPI/src/codegen.C b/dyninstAPI/src/codegen.C index ee0e46e881..b1b809a426 100644 --- a/dyninstAPI/src/codegen.C +++ b/dyninstAPI/src/codegen.C @@ -70,7 +70,7 @@ codeGen::codeGen() : thr_(NULL), rs_(NULL), t_(NULL), - addr_((Address)-1), + addr_((Dyninst::Address)-1), ip_(NULL), f_(NULL), bt_(NULL), @@ -94,7 +94,7 @@ codeGen::codeGen(unsigned size) : thr_(NULL), rs_(NULL), t_(NULL), - addr_((Address)-1), + addr_((Dyninst::Address)-1), ip_(NULL), f_(NULL), bt_(NULL), @@ -125,7 +125,7 @@ codeGen::codeGen(codeBuf_t *buffer, int size) : thr_(NULL), rs_(NULL), t_(NULL), - addr_((Address)-1), + addr_((Dyninst::Address)-1), ip_(NULL), f_(NULL), bt_(NULL), @@ -440,13 +440,13 @@ long codeGen::getDisplacement(codeBufIndex_t from, codeBufIndex_t to) { return ((to_l - from_l) * CODE_GEN_OFFSET_SIZE); } -Address codeGen::currAddr() const { - if(addr_ == (Address) -1) return (Address) -1; - assert(addr_ != (Address) -1); +Dyninst::Address codeGen::currAddr() const { + if(addr_ == (Dyninst::Address) -1) return (Dyninst::Address) -1; + assert(addr_ != (Dyninst::Address) -1); return currAddr(addr_); } -Address codeGen::currAddr(Address base) const { +Dyninst::Address codeGen::currAddr(Dyninst::Address base) const { return (offset_ * CODE_GEN_OFFSET_SIZE) + base; } @@ -529,7 +529,7 @@ void codeGen::addPCRelRegion(pcRelRegion *reg) { reg->gen = this; reg->cur_offset = used(); - if (startAddr() != (Address) -1 && reg->canPreApply()) { + if (startAddr() != (Dyninst::Address) -1 && reg->canPreApply()) { //If we already have addressess for everything (usually when relocating a function) // then don't bother creating the region, just generate the code. reg->apply(startAddr() + reg->cur_offset); @@ -542,7 +542,7 @@ void codeGen::addPCRelRegion(pcRelRegion *reg) { } } -void codeGen::applyPCRels(Address base) +void codeGen::applyPCRels(Dyninst::Address base) { vector::iterator i; @@ -633,7 +633,7 @@ void relocPatch::applyPatch() if (applied_) return; - Address addr = source_->get_address(); + Dyninst::Address addr = source_->get_address(); switch (ptype_) { @@ -666,7 +666,7 @@ std::string patchTarget::get_name() const { toAddressPatch::~toAddressPatch() { } -Address toAddressPatch::get_address() const +Dyninst::Address toAddressPatch::get_address() const { return addr; } @@ -675,7 +675,7 @@ unsigned toAddressPatch::get_size() const { return 0; } -void toAddressPatch::set_address(Address a) { +void toAddressPatch::set_address(Dyninst::Address a) { addr = a; } @@ -768,7 +768,7 @@ Dyninst::Architecture codeGen::getArch() const { return Arch_none; } -void codeGen::registerDefensivePad(block_instance *callBlock, Address padStart, unsigned padSize) { +void codeGen::registerDefensivePad(block_instance *callBlock, Dyninst::Address padStart, unsigned padSize) { // Register a match between a call instruction // and a padding area post-reloc-call for // control flow interception purposes. @@ -786,7 +786,7 @@ std::string codeGen::format() const { stringstream ret; - Address base = (addr_ != (Address)-1) ? addr_ : 0; + Dyninst::Address base = (addr_ != (Dyninst::Address)-1) ? addr_ : 0; InstructionDecoder deco (buffer_,used(),aSpace_->getArch()); Instruction insn = deco.decode(); diff --git a/dyninstAPI/src/codegen.h b/dyninstAPI/src/codegen.h index 7d663721e8..e32c85e55c 100644 --- a/dyninstAPI/src/codegen.h +++ b/dyninstAPI/src/codegen.h @@ -34,7 +34,7 @@ #include #include #include - +#include "dyntypes.h" #include "common/src/arch.h" #include "dyninstAPI/src/patch.h" @@ -169,8 +169,8 @@ class codeGen { // For code generation -- given the current state of // generation and a base address in the mutatee, // produce a "current" address. - Address currAddr() const; - Address currAddr(Address base) const; + Dyninst::Address currAddr() const; + Dyninst::Address currAddr(Dyninst::Address base) const; enum { cgNOP, cgTrap, cgIllegal }; @@ -186,7 +186,7 @@ class codeGen { //Have each region generate code with this codeGen object being // placed at addr - void applyPCRels(Address addr); + void applyPCRels(Dyninst::Address addr); //Return true if there are any active regions. bool hasPCRels() const; @@ -196,7 +196,7 @@ class codeGen { //Create a patch into the codeRange void addPatch(codeBufIndex_t index, patchTarget *source, - unsigned size = sizeof(Address), + unsigned size = sizeof(Dyninst::Address), relocPatch::patch_type_t ptype = relocPatch::patch_type_t::abs, Dyninst::Offset off = 0); @@ -208,7 +208,7 @@ class codeGen { void setAddrSpace(AddressSpace *a); void setThread(PCThread *t) { thr_ = t; } void setRegisterSpace(registerSpace *r) { rs_ = r; } - void setAddr(Address a) { addr_ = a; } + void setAddr(Dyninst::Address a) { addr_ = a; } void setPoint(instPoint *i) { ip_ = i; } void setRegTracker(regTracker_t *t) { t_ = t; } void setCodeEmitter(Emitter *emitter) { emitter_ = emitter; } @@ -219,7 +219,7 @@ class codeGen { unsigned width() const; AddressSpace *addrSpace() const; PCThread *thread(); - Address startAddr() const { return addr_; } + Dyninst::Address startAddr() const { return addr_; } instPoint *point() const; baseTramp *bt() const { return bt_; } func_instance *func() const; @@ -248,16 +248,16 @@ class codeGen { // SD-DYNINST // - typedef std::pair Extent; - void registerDefensivePad(block_instance *, Address, unsigned); + typedef std::pair Extent; + void registerDefensivePad(block_instance *, Dyninst::Address, unsigned); std::map &getDefensivePads() { return defensivePads_; } // Immediate uninstrumentation - void registerInstrumentation(baseTramp *bt, Address loc) { instrumentation_[bt] = loc; } - std::map &getInstrumentation() { return instrumentation_; } + void registerInstrumentation(baseTramp *bt, Dyninst::Address loc) { instrumentation_[bt] = loc; } + std::map &getInstrumentation() { return instrumentation_; } - void registerRemovedInstrumentation(baseTramp *bt, Address loc) { removedInstrumentation_[bt] = loc; } - std::map &getRemovedInstrumentation() { return removedInstrumentation_; } + void registerRemovedInstrumentation(baseTramp *bt, Dyninst::Address loc) { removedInstrumentation_[bt] = loc; } + std::map &getRemovedInstrumentation() { return removedInstrumentation_; } private: void realloc(unsigned newSize); @@ -275,7 +275,7 @@ class codeGen { PCThread *thr_; registerSpace *rs_; regTracker_t *t_; - Address addr_; + Dyninst::Address addr_; instPoint *ip_; func_instance *f_; baseTramp *bt_; @@ -293,8 +293,8 @@ class codeGen { std::vector pcrels_; std::map defensivePads_; - std::map instrumentation_; - std::map removedInstrumentation_; + std::map instrumentation_; + std::map removedInstrumentation_; }; #endif diff --git a/dyninstAPI/src/infHeap.h b/dyninstAPI/src/infHeap.h index edb853c210..a951e1ff8c 100644 --- a/dyninstAPI/src/infHeap.h +++ b/dyninstAPI/src/infHeap.h @@ -38,7 +38,7 @@ #include #include #include -#include "common/src/Types.h" +#include "dyntypes.h" #include "common/h/util.h" #include "util.h" @@ -50,7 +50,7 @@ typedef enum { textHeap=0x01, anyHeap=0x7, // OR of the previous three lowmemHeap=0x1000 } inferiorHeapType; -typedef std::vector
addrVecType; +typedef std::vector addrVecType; class heapItem { public: @@ -59,7 +59,7 @@ class heapItem { type(anyHeap), dynamic(true), status(HEAPfree), buffer(NULL) {} - heapItem(Address a, int n, + heapItem(Dyninst::Address a, int n, inferiorHeapType t, bool d = true, heapStatus s = HEAPfree) : @@ -88,7 +88,7 @@ class heapItem { void setBuffer(void *b) { buffer = b; } - Address addr; + Dyninst::Address addr; unsigned length; inferiorHeapType type; bool dynamic; // part of a dynamically allocated segment? @@ -125,7 +125,7 @@ class disabledItem { heapItem block; // inferior heap block std::vector pointsToCheck; // list of addresses to check against PCs - Address getPointer() const {return block.addr;} + Dyninst::Address getPointer() const {return block.addr;} inferiorHeapType getHeapType() const {return block.type;} const std::vector &getPointsToCheck() const {return pointsToCheck;} std::vector &getPointsToCheck() {return pointsToCheck;} @@ -139,19 +139,19 @@ class disabledItem { class heapDescriptor { public: heapDescriptor(const std::string name, - Address addr, + Dyninst::Address addr, unsigned int size, const inferiorHeapType type): name_(name),addr_(addr),size_(size), type_(type) {} heapDescriptor(): name_{},addr_{},size_{},type_(anyHeap) {} const std::string &name() const {return name_;} - const Address &addr() const {return addr_;} + const Dyninst::Address &addr() const {return addr_;} const unsigned &size() const {return size_;} const inferiorHeapType &type() const {return type_;} private: std::string name_; - Address addr_; + Dyninst::Address addr_; unsigned size_; inferiorHeapType type_; }; @@ -167,7 +167,7 @@ class inferiorHeap { inferiorHeap(const inferiorHeap &src); // create a new heap that is a copy // of src (used on fork) inferiorHeap& operator=(const inferiorHeap &src); - std::unordered_map heapActive; // active part of heap + std::unordered_map heapActive; // active part of heap std::vector heapFree; // free block of data inferior heap std::vector disabledList; // items waiting to be freed. int disabledListTotalMem; // total size of item waiting to free diff --git a/dyninstAPI/src/inst-x86.h b/dyninstAPI/src/inst-x86.h index 4264af5ca5..eee5b1b233 100644 --- a/dyninstAPI/src/inst-x86.h +++ b/dyninstAPI/src/inst-x86.h @@ -192,7 +192,7 @@ void emitMovImmToReg(RealRegister dest, int imm, codeGen &gen); void emitMovImmToRM(RealRegister base, int disp, int imm, codeGen &gen); void emitMovRegToRM(RealRegister base, int disp, RealRegister src, codeGen &gen); void emitMovRMToReg(RealRegister dest, RealRegister base, int disp, codeGen &gen); -void emitMovImmToMem(Address maddr, int imm, codeGen &gen); +void emitMovImmToMem(Dyninst::Address maddr, int imm, codeGen &gen); void emitPushImm(unsigned int imm, codeGen &gen); void emitSaveO(codeGen &gen); void emitRestoreO(codeGen &gen); @@ -217,7 +217,7 @@ void emitJccR8(int condition_code, char jump_offset, codeGen &gen); void emitJcc(int condition, int offset, codeGen &gen, bool willRegen=true); void emitPushImm(unsigned int imm, codeGen &gen); -void emitAddMemImm32(Address dest, int imm, codeGen &gen); +void emitAddMemImm32(Dyninst::Address dest, int imm, codeGen &gen); void emitCallRel32(unsigned disp32, codeGen &gen); void emitJmpMC(int condition, int offset, codeGen &gen); diff --git a/dyninstAPI/src/inst.C b/dyninstAPI/src/inst.C index bf9fdf688a..636b19fa25 100644 --- a/dyninstAPI/src/inst.C +++ b/dyninstAPI/src/inst.C @@ -76,8 +76,8 @@ unsigned findTags(const std::string ) { } unsigned generateAndWriteBranch(AddressSpace *proc, - Address fromAddr, - Address newAddr, + Dyninst::Address fromAddr, + Dyninst::Address newAddr, unsigned fillSize) { assert(fillSize != 0); diff --git a/dyninstAPI/src/inst.h b/dyninstAPI/src/inst.h index 92af4c94a9..d3064c2ba3 100644 --- a/dyninstAPI/src/inst.h +++ b/dyninstAPI/src/inst.h @@ -157,7 +157,7 @@ unsigned getPrimitiveCost(const std::string &name); * Generate an instruction. * Previously this was handled by the polymorphic "emit" function, which * took a variety of argument types and variously returned either an - * Address or a Register or nothing of value. The following family of + * Dyninst::Address or a Register or nothing of value. The following family of * functions replace "emit" with more strongly typed versions. */ @@ -184,25 +184,25 @@ void emitV(opCode op, Register src1, Register src2, Register dst, registerSpace *rs = NULL, int size = 4, const instPoint * location = NULL, AddressSpace * proc = NULL, bool s = true); -// for loadOp and loadConstOp (reading from an Address) -void emitVload(opCode op, Address src1, Register src2, Register dst, +// for loadOp and loadConstOp (reading from an Dyninst::Address) +void emitVload(opCode op, Dyninst::Address src1, Register src2, Register dst, codeGen &gen, bool noCost, registerSpace *rs = NULL, int size = 4, const instPoint * location = NULL, AddressSpace * proc = NULL); -// for storeOp (writing to an Address) -void emitVstore(opCode op, Register src1, Register src2, Address dst, +// for storeOp (writing to an Dyninst::Address) +void emitVstore(opCode op, Register src1, Register src2, Dyninst::Address dst, codeGen &gen, bool noCost, registerSpace *rs = NULL, int size = 4, const instPoint * location = NULL, AddressSpace * proc = NULL); -// for loadOp and loadConstOp (reading from an Address) +// for loadOp and loadConstOp (reading from an Dyninst::Address) void emitVload(opCode op, const image_variable* src1, Register src2, Register dst, codeGen &gen, bool noCost, registerSpace *rs = NULL, int size = 4, const instPoint * location = NULL, AddressSpace * proc = NULL); -// for storeOp (writing to an Address) +// for storeOp (writing to an Dyninst::Address) void emitVstore(opCode op, Register src1, Register src2, const image_variable* dst, codeGen &gen, bool noCost, registerSpace *rs = NULL, int size = 4, @@ -236,7 +236,7 @@ Register emitFuncCall(opCode op, codeGen &gen, Register emitFuncCall(opCode op, codeGen &gen, std::vector &operands, bool noCost, - Address callee_addr_); + Dyninst::Address callee_addr_); int getInsnCost(opCode t); @@ -252,23 +252,23 @@ extern std::string getProcessStatus(const AddressSpace *p); // expects the symbol name advanced past the underscore extern unsigned findTags(const std::string funcName); -extern Address getMaxBranch(); +extern Dyninst::Address getMaxBranch(); // find these internal functions before finding any other functions // extern std::unordered_map tagDict; extern std::map primitiveCosts; -bool writeFunctionPtr(AddressSpace *p, Address addr, func_instance *f); +bool writeFunctionPtr(AddressSpace *p, Dyninst::Address addr, func_instance *f); /** * A set of optimized emiters for common idioms. Return * false if the platform can't perform any optimizations. **/ //Store constant in memory at address -bool emitStoreConst(Address addr, int imm, codeGen &gen, bool noCost); +bool emitStoreConst(Dyninst::Address addr, int imm, codeGen &gen, bool noCost); //Add constant to memory at address -bool emitAddSignedImm(Address addr, long int imm, codeGen &gen, bool noCost); +bool emitAddSignedImm(Dyninst::Address addr, long int imm, codeGen &gen, bool noCost); //Subtract constant from memory at address -bool emitSubSignedImm(Address addr, long int imm, codeGen &gen, bool noCost); +bool emitSubSignedImm(Dyninst::Address addr, long int imm, codeGen &gen, bool noCost); #endif diff --git a/dyninstAPI/src/parRegion.C b/dyninstAPI/src/parRegion.C index 207bbbd624..89928e1f34 100644 --- a/dyninstAPI/src/parRegion.C +++ b/dyninstAPI/src/parRegion.C @@ -40,7 +40,7 @@ image_parRegion::image_parRegion(parse_func * imageFunc) { } -image_parRegion::image_parRegion(Address firstOffset, parse_func * imageFunc) +image_parRegion::image_parRegion(Dyninst::Address firstOffset, parse_func * imageFunc) : regionIf_(imageFunc), parentIf_(NULL), firstInsnOffset_(firstOffset), lastInsnOffset_(0), regionType(OMP_NONE) @@ -146,12 +146,12 @@ void image_parRegion::setClause(const char *key, int value) clauses[key] = value; } -void image_parRegion::setClauseLoc(const char *key, Address value) +void image_parRegion::setClauseLoc(const char *key, Dyninst::Address value) { clauses[key] = value; } -int_parRegion::int_parRegion(image_parRegion *ip, Address baseAddr, func_instance * iFunc) +int_parRegion::int_parRegion(image_parRegion *ip, Dyninst::Address baseAddr, func_instance * iFunc) { ip_ = ip; addr_ = baseAddr + ip->get_address(); @@ -177,12 +177,12 @@ int image_parRegion::getClause(const char * key) } -Address int_parRegion::getClauseLoc(const char * key) +Dyninst::Address int_parRegion::getClauseLoc(const char * key) { return ip_->getClauseLoc(key); } -Address image_parRegion::getClauseLoc(const char * key) +Dyninst::Address image_parRegion::getClauseLoc(const char * key) { if (clauses.find(key) != clauses.end()) return clauses[key]; @@ -195,9 +195,9 @@ int int_parRegion::replaceOMPParameter(const char * key, int value) { // parReg->replaceOMPParameter(key,value); - Address writeAddy = getClauseLoc(key); + Dyninst::Address writeAddy = getClauseLoc(key); - Address writeValue = 0x39000000; + Dyninst::Address writeValue = 0x39000000; if (value > 0 ) writeValue += (unsigned) value; diff --git a/dyninstAPI/src/parRegion.h b/dyninstAPI/src/parRegion.h index 673162d57d..39cd6ead83 100644 --- a/dyninstAPI/src/parRegion.h +++ b/dyninstAPI/src/parRegion.h @@ -40,6 +40,7 @@ #include "dyninstAPI/h/BPatch_parRegion.h" #include #include +#include "dyntypes.h" class mapped_module; class mapped_object; @@ -67,15 +68,15 @@ struct ltstr class image_parRegion : public codeRange { public: image_parRegion(parse_func * imageFunc); - image_parRegion(Address firstOffset, parse_func * imageFunc); + image_parRegion(Dyninst::Address firstOffset, parse_func * imageFunc); - Address firstInsnOffset() const { return firstInsnOffset_; } + Dyninst::Address firstInsnOffset() const { return firstInsnOffset_; } - void setLastInsn(Address last) { lastInsnOffset_ = last;} - Address lastInsnOffset() const { return lastInsnOffset_; } - Address getSize() const { return lastInsnOffset_ - firstInsnOffset_; } + void setLastInsn(Dyninst::Address last) { lastInsnOffset_ = last;} + Dyninst::Address lastInsnOffset() const { return lastInsnOffset_; } + Dyninst::Address getSize() const { return lastInsnOffset_ - firstInsnOffset_; } - Address get_address() const {return firstInsnOffset_; } + Dyninst::Address get_address() const {return firstInsnOffset_; } unsigned int get_size() const {return 0;} parRegType getRegionType(){return regionType;} @@ -90,8 +91,8 @@ class image_parRegion : public codeRange { void setClause(const char * key, int value); int getClause(const char * key); - void setClauseLoc(const char * key, Address value); - Address getClauseLoc(const char * key); + void setClauseLoc(const char * key, Dyninst::Address value); + Dyninst::Address getClauseLoc(const char * key); void printDetails(); @@ -100,21 +101,21 @@ class image_parRegion : public codeRange { private: parse_func *regionIf_; parse_func *parentIf_; - Address firstInsnOffset_; - Address lastInsnOffset_; + Dyninst::Address firstInsnOffset_; + Dyninst::Address lastInsnOffset_; parRegType regionType; std::map clauses; - std::map clause_locations; + std::map clause_locations; }; class int_parRegion { public: - int_parRegion(image_parRegion *ip, Address baseAddr, func_instance * ); + int_parRegion(image_parRegion *ip, Dyninst::Address baseAddr, func_instance * ); ~int_parRegion(); - Address firstInsnAddr() {return addr_;} - Address endAddr() {return endAddr_;} + Dyninst::Address firstInsnAddr() {return addr_;} + Dyninst::Address endAddr() {return endAddr_;} const image_parRegion * imagePar() const { return ip_; } @@ -123,12 +124,12 @@ class int_parRegion { const func_instance * intFunc() { return intFunc_;} int getClause(const char * key); - Address getClauseLoc(const char * key); + Dyninst::Address getClauseLoc(const char * key); int replaceOMPParameter(const char * key, int value); - Address addr_; /* Absolute address of start of region */ - Address endAddr_; /* Address of end of region */ + Dyninst::Address addr_; /* Absolute address of start of region */ + Dyninst::Address endAddr_; /* Dyninst::Address of end of region */ func_instance * intFunc_; diff --git a/dyninstAPI/src/patch.h b/dyninstAPI/src/patch.h index 12e7ac2a08..744a56073b 100644 --- a/dyninstAPI/src/patch.h +++ b/dyninstAPI/src/patch.h @@ -32,6 +32,7 @@ #define patch_h #include +#include "dyntypes.h" class codeGen; @@ -41,7 +42,7 @@ class codeGen; class patchTarget { public: - virtual Address get_address() const = 0; + virtual Dyninst::Address get_address() const = 0; virtual unsigned get_size() const = 0; virtual std::string get_name() const; patchTarget() = default; @@ -51,14 +52,14 @@ class patchTarget { class toAddressPatch : public patchTarget { private: - Address addr; + Dyninst::Address addr; public: - toAddressPatch(Address a) : addr(a) {} + toAddressPatch(Dyninst::Address a) : addr(a) {} virtual ~toAddressPatch(); - virtual Address get_address() const; + virtual Dyninst::Address get_address() const; virtual unsigned get_size() const; - void set_address(Address a); + void set_address(Dyninst::Address a); }; class relocPatch { @@ -98,7 +99,7 @@ class ifTargetPatch : public patchTarget signed int targetOffset; public: ifTargetPatch(signed int o) { targetOffset = o; } - virtual Address get_address() const { return (Address) targetOffset; } + virtual Dyninst::Address get_address() const { return (Dyninst::Address) targetOffset; } virtual unsigned get_size() const { return 0; } virtual std::string get_name() const { return std::string("ifTarget"); } virtual ~ifTargetPatch() { } diff --git a/dyninstAPI/src/pcEventHandler.h b/dyninstAPI/src/pcEventHandler.h index d9542ad585..dfd0efdb8d 100644 --- a/dyninstAPI/src/pcEventHandler.h +++ b/dyninstAPI/src/pcEventHandler.h @@ -35,7 +35,7 @@ #include "dyninstAPI/h/BPatch_process.h" #include -#include "common/src/Types.h" +#include "dyntypes.h" #include "common/src/dthread.h" #include "syscallNotification.h" @@ -57,7 +57,7 @@ class PCEventMuxer; */ class PCEventHandler { - typedef ProcControlAPI::Event::const_ptr EventPtr; + typedef Dyninst::ProcControlAPI::Event::const_ptr EventPtr; // Why syscallNotification is a friend: // // It is a friend because it reaches in to determine whether to install @@ -76,17 +76,17 @@ class PCEventHandler { bool handle_internal(EventPtr ev); - bool handleExit(ProcControlAPI::EventExit::const_ptr ev, PCProcess *evProc) const; - bool handleFork(ProcControlAPI::EventFork::const_ptr ev, PCProcess *evProc) const; - bool handleExec(ProcControlAPI::EventExec::const_ptr ev, PCProcess *&evProc) const; - bool handleCrash(ProcControlAPI::EventCrash::const_ptr ev, PCProcess *evProc) const; - bool handleForceTerminate(ProcControlAPI::EventForceTerminate::const_ptr ev, PCProcess *evProc) const; - bool handleThreadCreate(ProcControlAPI::EventNewThread::const_ptr ev, PCProcess *evProc) const; - bool handleThreadDestroy(ProcControlAPI::EventThreadDestroy::const_ptr ev, PCProcess *evProc) const; - bool handleSignal(ProcControlAPI::EventSignal::const_ptr ev, PCProcess *evProc) const; - bool handleLibrary(ProcControlAPI::EventLibrary::const_ptr ev, PCProcess *evProc) const; - bool handleBreakpoint(ProcControlAPI::EventBreakpoint::const_ptr ev, PCProcess *evProc) const; - bool handleRPC(ProcControlAPI::EventRPC::const_ptr ev, PCProcess *evProc) const; + bool handleExit(Dyninst::ProcControlAPI::EventExit::const_ptr ev, PCProcess *evProc) const; + bool handleFork(Dyninst::ProcControlAPI::EventFork::const_ptr ev, PCProcess *evProc) const; + bool handleExec(Dyninst::ProcControlAPI::EventExec::const_ptr ev, PCProcess *&evProc) const; + bool handleCrash(Dyninst::ProcControlAPI::EventCrash::const_ptr ev, PCProcess *evProc) const; + bool handleForceTerminate(Dyninst::ProcControlAPI::EventForceTerminate::const_ptr ev, PCProcess *evProc) const; + bool handleThreadCreate(Dyninst::ProcControlAPI::EventNewThread::const_ptr ev, PCProcess *evProc) const; + bool handleThreadDestroy(Dyninst::ProcControlAPI::EventThreadDestroy::const_ptr ev, PCProcess *evProc) const; + bool handleSignal(Dyninst::ProcControlAPI::EventSignal::const_ptr ev, PCProcess *evProc) const; + bool handleLibrary(Dyninst::ProcControlAPI::EventLibrary::const_ptr ev, PCProcess *evProc) const; + bool handleBreakpoint(Dyninst::ProcControlAPI::EventBreakpoint::const_ptr ev, PCProcess *evProc) const; + bool handleRPC(Dyninst::ProcControlAPI::EventRPC::const_ptr ev, PCProcess *evProc) const; enum RTBreakpointVal { NoRTBreakpoint, @@ -94,14 +94,14 @@ class PCEventHandler { SoftRTBreakpoint }; - bool handleRTBreakpoint(ProcControlAPI::EventBreakpoint::const_ptr ev, PCProcess *evProc) const; - bool handleStopThread(PCProcess *evProc, Address rt_arg) const; - bool handleUserMessage(PCProcess *evProc, BPatch_process *bpProc, Address rt_arg) const; - bool handleDynFuncCall(PCProcess *evProc, BPatch_process *bpProc, Address rt_arg) const; + bool handleRTBreakpoint(Dyninst::ProcControlAPI::EventBreakpoint::const_ptr ev, PCProcess *evProc) const; + bool handleStopThread(PCProcess *evProc, Dyninst::Address rt_arg) const; + bool handleUserMessage(PCProcess *evProc, BPatch_process *bpProc, Dyninst::Address rt_arg) const; + bool handleDynFuncCall(PCProcess *evProc, BPatch_process *bpProc, Dyninst::Address rt_arg) const; // platform-specific static bool shouldStopForSignal(int signal); - static bool isValidRTSignal(int signal, RTBreakpointVal breakpointVal, Address arg1, int status); + static bool isValidRTSignal(int signal, RTBreakpointVal breakpointVal, Dyninst::Address arg1, int status); static bool isCrashSignal(int signal); static bool isKillSignal(int signal); diff --git a/dyninstAPI/src/pcEventMuxer.h b/dyninstAPI/src/pcEventMuxer.h index 64e67723de..743db2f03a 100644 --- a/dyninstAPI/src/pcEventMuxer.h +++ b/dyninstAPI/src/pcEventMuxer.h @@ -77,14 +77,14 @@ class PCEventMailbox { PCEventMailbox(); ~PCEventMailbox(); - void enqueue(ProcControlAPI::Event::const_ptr ev); - ProcControlAPI::Event::const_ptr dequeue(bool block); + void enqueue(Dyninst::ProcControlAPI::Event::const_ptr ev); + Dyninst::ProcControlAPI::Event::const_ptr dequeue(bool block); unsigned int size(); bool find(PCProcess *proc); protected: std::map procCount; - std::queue eventQueue; + std::queue eventQueue; CondVar<> queueCond; }; @@ -165,8 +165,8 @@ class PCEventMuxer { * case 2: register the callback, insert the breakpoint * case 3: don't register the callback, insert the breakpoint */ - static bool useCallback(ProcControlAPI::EventType et); - static bool useBreakpoint(ProcControlAPI::EventType et); + static bool useCallback(Dyninst::ProcControlAPI::EventType et); + static bool useBreakpoint(Dyninst::ProcControlAPI::EventType et); private: // We need to use a separate thread so that we can fast-handle certain @@ -186,9 +186,9 @@ class PCEventMuxer { EventPtr dequeue(bool block); bool handle(EventPtr); - static ProcControlAPI::Process::cb_ret_t ret_stopped; - static ProcControlAPI::Process::cb_ret_t ret_continue; - static ProcControlAPI::Process::cb_ret_t ret_default; + static Dyninst::ProcControlAPI::Process::cb_ret_t ret_stopped; + static Dyninst::ProcControlAPI::Process::cb_ret_t ret_continue; + static Dyninst::ProcControlAPI::Process::cb_ret_t ret_default; PCEventMailbox mailbox_; diff --git a/dyninstAPI/src/pcrel.h b/dyninstAPI/src/pcrel.h index dc5d4189e9..8347117abb 100644 --- a/dyninstAPI/src/pcrel.h +++ b/dyninstAPI/src/pcrel.h @@ -39,7 +39,7 @@ class pcRelRegion { unsigned cur_offset; unsigned cur_size; pcRelRegion(const instruction &i); - virtual unsigned apply(Address addr) = 0; + virtual unsigned apply(Dyninst::Address addr) = 0; virtual unsigned maxSize() = 0; virtual bool canPreApply(); virtual ~pcRelRegion(); @@ -48,15 +48,15 @@ class pcRelRegion { class pcRelJump : public pcRelRegion { private: - Address addr_targ; + Dyninst::Address addr_targ; patchTarget *targ; bool copy_prefixes_; - Address get_target(); + Dyninst::Address get_target(); public: pcRelJump(patchTarget *t, const instruction &i, bool copyPrefixes = true); - pcRelJump(Address target, const instruction &i, bool copyPrefixes = true); - virtual unsigned apply(Address addr); + pcRelJump(Dyninst::Address target, const instruction &i, bool copyPrefixes = true); + virtual unsigned apply(Dyninst::Address addr); virtual unsigned maxSize(); virtual bool canPreApply(); virtual ~pcRelJump(); @@ -64,14 +64,14 @@ class pcRelJump : public pcRelRegion { class pcRelJCC : public pcRelRegion { private: - Address addr_targ; + Dyninst::Address addr_targ; patchTarget *targ; - Address get_target(); + Dyninst::Address get_target(); public: pcRelJCC(patchTarget *t, const instruction &i); - pcRelJCC(Address target, const instruction &i); - virtual unsigned apply(Address addr); + pcRelJCC(Dyninst::Address target, const instruction &i); + virtual unsigned apply(Dyninst::Address addr); virtual unsigned maxSize(); virtual bool canPreApply(); virtual ~pcRelJCC(); @@ -79,15 +79,15 @@ class pcRelJCC : public pcRelRegion { class pcRelCall: public pcRelRegion { private: - Address targ_addr; + Dyninst::Address targ_addr; patchTarget *targ; - Address get_target(); + Dyninst::Address get_target(); public: pcRelCall(patchTarget *t, const instruction &i); - pcRelCall(Address targ_addr, const instruction &i); + pcRelCall(Dyninst::Address targ_addr, const instruction &i); - virtual unsigned apply(Address addr); + virtual unsigned apply(Dyninst::Address addr); virtual unsigned maxSize(); virtual bool canPreApply(); ~pcRelCall(); @@ -95,10 +95,10 @@ class pcRelCall: public pcRelRegion { class pcRelData : public pcRelRegion { private: - Address data_addr; + Dyninst::Address data_addr; public: - pcRelData(Address a, const instruction &i); - virtual unsigned apply(Address addr); + pcRelData(Dyninst::Address a, const instruction &i); + virtual unsigned apply(Dyninst::Address addr); virtual unsigned maxSize(); virtual bool canPreApply(); }; diff --git a/dyninstAPI/src/trapMappings.h b/dyninstAPI/src/trapMappings.h index 60b7668295..5e98198c70 100644 --- a/dyninstAPI/src/trapMappings.h +++ b/dyninstAPI/src/trapMappings.h @@ -36,6 +36,7 @@ #include #include +#include "dyntypes.h" class AddressSpace; class int_variable; @@ -43,15 +44,15 @@ class int_variable; class trampTrapMappings { public: typedef struct { - Address from_addr; - Address to_addr; + Dyninst::Address from_addr; + Dyninst::Address to_addr; bool written; bool mutatee_side; unsigned cur_index; } tramp_mapping_t; private: - dyn_hash_map mapping; + dyn_hash_map mapping; std::set updated_mappings; static void arrange_mapping(tramp_mapping_t &m, bool should_sort, @@ -74,8 +75,8 @@ class trampTrapMappings { unsigned long table_used; unsigned long table_allocated; unsigned long table_mutatee_size; - Address current_table; - Address table_header; + Dyninst::Address current_table; + Dyninst::Address table_header; bool blockFlushes; public: @@ -83,9 +84,9 @@ class trampTrapMappings { void copyTrapMappings(trampTrapMappings *parent); void clearTrapMappings(); - void addTrapMapping(Address from, Address to, bool write_to_mutatee = false); - Address getTrapMapping(Address from); - bool definesTrapMapping(Address from); + void addTrapMapping(Dyninst::Address from, Dyninst::Address to, bool write_to_mutatee = false); + Dyninst::Address getTrapMapping(Dyninst::Address from); + bool definesTrapMapping(Dyninst::Address from); bool needsUpdating(); void flush(); void allocateTable(); diff --git a/patchAPI/h/AddrSpace.h b/patchAPI/h/AddrSpace.h index 742b0fc1fc..562905c347 100644 --- a/patchAPI/h/AddrSpace.h +++ b/patchAPI/h/AddrSpace.h @@ -37,6 +37,7 @@ #include #include #include "PatchCommon.h" +#include "dyntypes.h" namespace Dyninst { namespace PatchAPI { @@ -53,17 +54,17 @@ class PATCHAPI_EXPORT AddrSpace { virtual ~AddrSpace(); // Write data in mutatee's address space - virtual bool write(PatchObject* /*obj*/, Address /*to*/, - Address /*from*/, size_t /*size*/); + virtual bool write(PatchObject* /*obj*/, Dyninst::Address /*to*/, + Dyninst::Address /*from*/, size_t /*size*/); // Memory allocation / reallocation / deallocation in mutatee's addressSpace - virtual Address malloc(PatchObject* /*obj*/, size_t /*size*/, - Address /*near*/); + virtual Dyninst::Address malloc(PatchObject* /*obj*/, size_t /*size*/, + Dyninst::Address /*near*/); - virtual bool realloc(PatchObject* /*obj*/, Address /*orig*/, + virtual bool realloc(PatchObject* /*obj*/, Dyninst::Address /*orig*/, size_t /*size*/); - virtual bool free(PatchObject* /*obj*/, Address /*orig*/); + virtual bool free(PatchObject* /*obj*/, Dyninst::Address /*orig*/); // Load a binary oject into the address space virtual bool loadObject(PatchObject* obj); diff --git a/patchAPI/h/Point.h b/patchAPI/h/Point.h index 0849982cd3..5817c353fe 100644 --- a/patchAPI/h/Point.h +++ b/patchAPI/h/Point.h @@ -38,6 +38,7 @@ #include "PatchCommon.h" #include "Snippet.h" #include "util.h" +#include "dyntypes.h" namespace Dyninst { namespace PatchAPI { @@ -63,9 +64,9 @@ ExitSite_t(PatchFunction *f, PatchBlock *b) : func(f), block(b) {} struct InsnLoc_t { PatchBlock *block; - Address addr; + Dyninst::Address addr; InstructionAPI::Instruction insn; -InsnLoc_t(PatchBlock *b, Address a, InstructionAPI::Instruction i) : +InsnLoc_t(PatchBlock *b, Dyninst::Address a, InstructionAPI::Instruction i) : block(b), addr(a), insn(i) {} }; @@ -85,16 +86,16 @@ struct Location { static Location Instruction(InsnLoc_t l) { return Location(NULL, l.block, l.addr, l.insn, NULL, true, Instruction_); } - static Location Instruction(PatchBlock *b, Address a) { + static Location Instruction(PatchBlock *b, Dyninst::Address a) { return Location(NULL, b, a, InstructionAPI::Instruction(), NULL, false, Instruction_); } static Location InstructionInstance(PatchFunction *f, InsnLoc_t l, bool trusted = false) { return Location(f, l.block, l.addr, l.insn, NULL, trusted, InstructionInstance_); } - static Location InstructionInstance(PatchFunction *f, PatchBlock *b, Address a) { + static Location InstructionInstance(PatchFunction *f, PatchBlock *b, Dyninst::Address a) { return Location(f, b, a, InstructionAPI::Instruction(), NULL, false, InstructionInstance_); } - static Location InstructionInstance(PatchFunction *f, PatchBlock *b, Address a, + static Location InstructionInstance(PatchFunction *f, PatchBlock *b, Dyninst::Address a, InstructionAPI::Instruction i, bool trusted = false) { return Location(f, b, a, i, NULL, trusted, InstructionInstance_); } @@ -141,14 +142,14 @@ struct Location { PatchFunction *func; PatchBlock *block; - Address addr; + Dyninst::Address addr; InstructionAPI::Instruction insn; PatchEdge *edge; bool trusted; type_t type; private: -Location(PatchFunction *f, PatchBlock *b, Address a, InstructionAPI::Instruction i, PatchEdge *e, bool u, type_t t) : +Location(PatchFunction *f, PatchBlock *b, Dyninst::Address a, InstructionAPI::Instruction i, PatchEdge *e, bool u, type_t t) : func(f), block(b), addr(a), insn(i), edge(e), trusted(u), type(t) {} }; @@ -198,7 +199,7 @@ class PATCHAPI_EXPORT Point { }; template - static Point* create(Address addr, + static Point* create(Dyninst::Address addr, Point::Type type, PatchMgrPtr mgr, Scope* scope) { @@ -210,7 +211,7 @@ class PATCHAPI_EXPORT Point { // Block instrumentation /w/ optional function context Point(Point::Type t, PatchMgrPtr mgr, PatchBlock *, PatchFunction * = NULL); // Insn instrumentation /w/ optional function context - Point(Point::Type t, PatchMgrPtr mgr, PatchBlock *, Address, InstructionAPI::Instruction, PatchFunction * = NULL); + Point(Point::Type t, PatchMgrPtr mgr, PatchBlock *, Dyninst::Address, InstructionAPI::Instruction, PatchFunction * = NULL); // Function entry or during Point(Point::Type t, PatchMgrPtr mgr, PatchFunction *); // Function call or exit site @@ -233,7 +234,7 @@ class PATCHAPI_EXPORT Point { // Getters size_t size(); - Address addr() const { return addr_; } + Dyninst::Address addr() const { return addr_; } Type type() const {return type_;} bool empty() const { return instanceList_.empty();} @@ -267,7 +268,7 @@ class PATCHAPI_EXPORT Point { InstanceList instanceList_; - Address addr_{}; + Dyninst::Address addr_{}; Type type_{}; PatchMgrPtr mgr_; PatchBlock* the_block_{}; @@ -372,7 +373,7 @@ class PATCHAPI_EXPORT PointMaker { virtual Point *mkFuncPoint(Point::Type t, PatchMgrPtr m, PatchFunction *); virtual Point *mkFuncSitePoint(Point::Type t, PatchMgrPtr m, PatchFunction *, PatchBlock *); virtual Point *mkBlockPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, PatchFunction *context); - virtual Point *mkInsnPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, Address, InstructionAPI::Instruction, + virtual Point *mkInsnPoint(Point::Type t, PatchMgrPtr m, PatchBlock *, Dyninst::Address, InstructionAPI::Instruction, PatchFunction *context); virtual Point *mkEdgePoint(Point::Type t, PatchMgrPtr m, PatchEdge *, PatchFunction *context); @@ -381,7 +382,7 @@ class PATCHAPI_EXPORT PointMaker { }; // Collection classes -typedef std::map InsnPoints; +typedef std::map InsnPoints; struct BlockPoints { diff --git a/patchAPI/src/AddrSpace.C b/patchAPI/src/AddrSpace.C index 05d327b6d4..1f7e9590a4 100644 --- a/patchAPI/src/AddrSpace.C +++ b/patchAPI/src/AddrSpace.C @@ -29,7 +29,6 @@ */ /* Public Interface */ -#include "common/src/Types.h" #include "AddrSpace.h" #include "PatchObject.h" #include "PatchMgr.h" @@ -73,25 +72,25 @@ AddrSpace::~AddrSpace() { } bool -AddrSpace::write(PatchObject* /*obj*/, Address /*to*/, - Address /*from*/, size_t /*size*/) { +AddrSpace::write(PatchObject* /*obj*/, Dyninst::Address /*to*/, + Dyninst::Address /*from*/, size_t /*size*/) { return false; } -Address +Dyninst::Address AddrSpace::malloc(PatchObject* /*obj*/, size_t /*size*/, - Address /*near*/) { + Dyninst::Address /*near*/) { return false; } bool -AddrSpace::realloc(PatchObject* /*obj*/, Address /*orig*/, +AddrSpace::realloc(PatchObject* /*obj*/, Dyninst::Address /*orig*/, size_t /*size*/) { return false; } bool -AddrSpace::free(PatchObject* /*obj*/, Address /*orig*/) { +AddrSpace::free(PatchObject* /*obj*/, Dyninst::Address /*orig*/) { return false; } diff --git a/patchAPI/src/Point.C b/patchAPI/src/Point.C index 009cae098b..981386b265 100644 --- a/patchAPI/src/Point.C +++ b/patchAPI/src/Point.C @@ -113,7 +113,7 @@ PatchObject *Point::obj() const { } /* for single instruction */ -Point::Point(Point::Type type, PatchMgrPtr mgr, PatchBlock *b, Address a, InstructionAPI::Instruction i, PatchFunction *f) +Point::Point(Point::Type type, PatchMgrPtr mgr, PatchBlock *b, Dyninst::Address a, InstructionAPI::Instruction i, PatchFunction *f) :addr_(a), type_(type), mgr_(mgr), the_block_(b), the_edge_(NULL), the_func_(f), insn_(i) { initCodeStructure(); diff --git a/stackwalk/src/analysis_stepper.C b/stackwalk/src/analysis_stepper.C index e300fe2f7c..d7b79ddb1e 100644 --- a/stackwalk/src/analysis_stepper.C +++ b/stackwalk/src/analysis_stepper.C @@ -45,7 +45,7 @@ #elif defined(WITH_SYMTAB_API) #include "symtabAPI/h/Symtab.h" #include "symtabAPI/h/SymtabReader.h" -using namespace SymtabAPI; +using namespace Dyninst::SymtabAPI; #else #error "No defined symbol reader" #endif diff --git a/symtabAPI/src/emitElf.h b/symtabAPI/src/emitElf.h index d09874c334..72267b489b 100644 --- a/symtabAPI/src/emitElf.h +++ b/symtabAPI/src/emitElf.h @@ -54,7 +54,7 @@ extern const char *STRTAB_NAME; extern const char *SYMTAB_NAME; extern const char *INTERP_NAME; -extern const char *pdelf_get_shnames(Elf_X *elf); +extern const char *pdelf_get_shnames(Dyninst::Elf_X *elf); #define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */ diff --git a/symtabAPI/src/indexed_symbols.hpp b/symtabAPI/src/indexed_symbols.hpp index b6e697d967..80b0c85540 100644 --- a/symtabAPI/src/indexed_symbols.hpp +++ b/symtabAPI/src/indexed_symbols.hpp @@ -6,13 +6,14 @@ #include #include #include +#include "dyntypes.h" namespace st = Dyninst::SymtabAPI; struct indexed_symbols { typedef Dyninst::dyn_c_hash_map master_t; typedef std::vector symvec_t; - typedef Dyninst::dyn_c_hash_map by_offset_t; + typedef Dyninst::dyn_c_hash_map by_offset_t; typedef Dyninst::dyn_c_hash_map by_name_t; master_t master; @@ -24,7 +25,7 @@ struct indexed_symbols { // Only inserts if not present. Returns whether it inserted. // Operations on the indexed_symbols compound table. bool insert(st::Symbol *s) { - Offset o = s->getOffset(); + Dyninst::Offset o = s->getOffset(); master_t::accessor a; if (master.insert(a, std::make_pair(s, o))) { {