Skip to content

Commit

Permalink
Add patchAPI/src/Point.C
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 996141c commit 9664117
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
7 changes: 7 additions & 0 deletions docs/patchAPI/developer/Point.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ Point.h
.. cpp:class:: Point

.. cpp:function:: protected bool destroy()

1. Clear all snippet instances
2. Detach from PatchMgr object

.. cpp:function:: protected void initCodeStructure()

Associate this point with the block(s) and function(s) that contain it

.. cpp:function:: protected void changeBlock(PatchBlock *newBlock)

.. cpp:member:: protected InstanceList instanceList_
Expand Down
16 changes: 0 additions & 16 deletions patchAPI/src/Point.C
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Instance::destroy() {
return false;
}

/* If the Point is PreCall or PostCall */
PatchFunction*
Point::getCallee() {
if (type() != PreCall && type() != PostCall) return NULL;
Expand All @@ -89,8 +88,6 @@ Point::getCallee() {
return NULL;
}

/* Associate this point with the block(s) and function(s)
that contain it */
void
Point::initCodeStructure() {
assert(mgr_);
Expand All @@ -111,41 +108,34 @@ PatchObject *Point::obj() const {
return NULL;
}

/* for single instruction */
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();
}

/* for a block */
Point::Point(Type type, PatchMgrPtr mgr, PatchBlock* blk, PatchFunction *f)
: addr_(0), type_(type), mgr_(mgr), the_block_(blk), the_edge_(NULL), the_func_(f) {
initCodeStructure();
}

/* for an edge */
Point::Point(Type type, PatchMgrPtr mgr, PatchEdge* edge, PatchFunction *f)
: addr_(0), type_(type), mgr_(mgr), the_block_(NULL), the_edge_(edge), the_func_(f) {
initCodeStructure();
}

/* for a function */
Point::Point(Type type, PatchMgrPtr mgr, PatchFunction* func) :
addr_(0), type_(type), mgr_(mgr),
the_block_(NULL), the_edge_(NULL), the_func_(func) {
initCodeStructure();
}

/* for a call or exit site */
Point::Point(Type type, PatchMgrPtr mgr, PatchFunction* func, PatchBlock *b) :
addr_(0), type_(type), mgr_(mgr),
the_block_(b), the_edge_(NULL), the_func_(func) {
initCodeStructure();
}


/* old_instance, old_instance, <---new_instance */
InstancePtr
Point::pushBack(SnippetPtr snippet) {
InstancePtr instance = Instance::create(this, snippet);
Expand All @@ -155,7 +145,6 @@ Point::pushBack(SnippetPtr snippet) {
return instance;
}

/* new_instance--->, old_instance, old_instance */
InstancePtr
Point::pushFront(SnippetPtr snippet) {
InstancePtr instance = Instance::create(this, snippet);
Expand All @@ -165,14 +154,12 @@ Point::pushFront(SnippetPtr snippet) {
return instance;
}

/* Test whether the type contains a specific type. */
bool
Point::TestType(Point::Type types, Point::Type trg) {
if (types & trg) return true;
return false;
}

/* Add a specific type to a set of types */
void
Point::AddType(Point::Type& types, Point::Type trg) {
int trg_int = static_cast<int>(trg);
Expand All @@ -181,7 +168,6 @@ Point::AddType(Point::Type& types, Point::Type trg) {
types = (Point::Type)type_int;
}

/* Remove a specific type from a set of types */
void
Point::RemoveType(Point::Type& types, Point::Type trg) {
int trg_int = static_cast<int>(trg);
Expand Down Expand Up @@ -216,8 +202,6 @@ Point::clear() {
}
}

/* 1, Clear all snippet instances
2, Detach from PatchMgr object */
bool
Point::destroy() {
clear();
Expand Down

0 comments on commit 9664117

Please sign in to comment.