Skip to content

Commit

Permalink
Remove AddressSpace::getAddressWidth from public API (#797)
Browse files Browse the repository at this point in the history
This was originally part of #317.
  • Loading branch information
hainest committed Oct 16, 2020
1 parent 03b2ab8 commit 7270afc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
9 changes: 9 additions & 0 deletions dyninstAPI/src/addressSpace.C
Original file line number Diff line number Diff line change
Expand Up @@ -2304,3 +2304,12 @@ bool uninstrument(Dyninst::PatchAPI::Instance::Ptr inst) {
return true;

}


unsigned AddressSpace::getAddressWidth() const {
if( mapped_objects.size() > 0 ) {
return mapped_objects[0]->parse_img()->codeObject()->cs()->getAddressWidth();
}
// We can call this before we've attached...best effort guess
return sizeof(Address);
}
4 changes: 3 additions & 1 deletion dyninstAPI/src/addressSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class AddressSpace : public InstructionSource {
virtual bool isValidAddress(const Address) const;
virtual void *getPtrToInstruction(const Address) const;
virtual void *getPtrToData(const Address a) const { return getPtrToInstruction(a); }
virtual unsigned getAddressWidth() const = 0;

bool usesDataLoadAddress() const; // OS-specific
virtual bool isCode(const Address) const;
virtual bool isData(const Address) const;
Expand Down Expand Up @@ -368,6 +368,8 @@ class AddressSpace : public InstructionSource {
bool needsPIC(func_instance *f);
bool needsPIC(AddressSpace *s);

unsigned getAddressWidth() const;

//////////////////////////////////////////////////////
// BPatch-level stuff
//////////////////////////////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions dyninstAPI/src/binaryEdit.C
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ Architecture BinaryEdit::getArch() const {
return mapped_objects[0]->parse_img()->codeObject()->cs()->getArch();
}

unsigned BinaryEdit::getAddressWidth() const {
assert(!mapped_objects.empty());
return mapped_objects[0]->parse_img()->codeObject()->cs()->getAddressWidth();
}
Address BinaryEdit::offset() const {
fprintf(stderr,"error BinaryEdit::offset() unimpl\n");
return 0;
Expand Down
2 changes: 0 additions & 2 deletions dyninstAPI/src/binaryEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class BinaryEdit : public AddressSpace {
virtual void inferiorFree(Address item);
virtual bool inferiorRealloc(Address item, unsigned newSize);

/* AddressSpace pure virtual implementation */
unsigned getAddressWidth() const;
Address offset() const;
Address length() const;
Architecture getArch() const;
Expand Down
9 changes: 0 additions & 9 deletions dyninstAPI/src/dynProcess.C
Original file line number Diff line number Diff line change
Expand Up @@ -1515,15 +1515,6 @@ int PCProcess::incrementThreadIndex() {
return ret;
}

unsigned PCProcess::getAddressWidth() const {
if( mapped_objects.size() > 0 ) {
return mapped_objects[0]->parse_img()->codeObject()->cs()->getAddressWidth();
}

// We can call this before we've attached...best effort guess
return sizeof(Address);
}

PCEventHandler * PCProcess::getPCEventHandler() const {
return eventHandler_;
}
Expand Down
2 changes: 1 addition & 1 deletion dyninstAPI/src/dynProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class PCProcess : public AddressSpace {
bool removeThread(dynthread_t tid);

int getPid() const;
unsigned getAddressWidth() const;

bool wasRunningWhenAttached() const;
bool wasCreatedViaAttach() const;
bool wasCreatedViaFork() const;
Expand Down

0 comments on commit 7270afc

Please sign in to comment.