Skip to content

Commit

Permalink
Add dyninstAPI/src/block.C
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 985a5cc commit 74d4fa4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
17 changes: 17 additions & 0 deletions docs/dyninstAPI/developer/block.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ using edge_instances instead of ParseAPI edges...
.. cpp:class:: block_instance : public Dyninst::PatchAPI::PatchBlock

.. cpp:function:: block_instance(ParseAPI::Block *ib, mapped_object *obj)

We create edges lazily

.. cpp:function:: block_instance(const block_instance *parent, mapped_object *child)

We also need to copy edges. Thing is, those blocks may not exist yet. So we wait, and do edges
after all blocks have been created

.. cpp:function:: ~block_instance()

Edges are deleted at the mapped_object layer

.. cpp:function:: mapped_object *obj() const
.. cpp:function:: AddressSpace *addrSpace() const
.. cpp:function:: AddressSpace *proc() const
.. cpp:function:: template <class OutputIterator> void getFuncs(OutputIterator result)
.. cpp:function:: void triggerModified()

KEVINTODO: implement this: remove block from Relocation info caching.

.. cpp:function:: void setNotAbruptEnd()
.. cpp:function:: parse_block *llb() const
.. cpp:function:: void *getPtrToInstruction(Address addr) const
Expand All @@ -58,6 +71,10 @@ using edge_instances instead of ParseAPI edges...
.. cpp:function:: Address GetBlockStartingAddress()
.. cpp:function:: virtual void markModified()
.. cpp:function:: private void updateCallTarget(func_instance *func)

Update a sink-typed call edge to have an inter-module target preserving original behavior
on sink edges only.

.. cpp:function:: private func_instance *findFunction(ParseAPI::Function *)
.. cpp:function:: private func_instance *callee(std::string const &)

Expand Down
14 changes: 0 additions & 14 deletions dyninstAPI/src/block.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,13 @@ using namespace Dyninst::ParseAPI;
block_instance::block_instance(ParseAPI::Block *ib,
mapped_object *obj)
: PatchBlock(ib, obj), _ignorePowerPreamble(false) {
// We create edges lazily
}

// Fork constructor
block_instance::block_instance(const block_instance *parent,
mapped_object *childObj)
: PatchBlock(parent, childObj), _ignorePowerPreamble(parent->_ignorePowerPreamble) {
// We also need to copy edges.
// Thing is, those blocks may not exist yet...
// So we wait, and do edges after all blocks have
// been created
}

// Edges are deleted at the mapped_object layer
block_instance::~block_instance()
{
}
Expand Down Expand Up @@ -110,7 +103,6 @@ Address block_instance::GetBlockStartingAddress() {

using namespace Dyninst::Relocation;
void block_instance::triggerModified() {
// KEVINTODO: implement this: remove block from Relocation info caching...
//PCSensitiveTransformer::invalidateCache(this);
}

Expand All @@ -127,16 +119,10 @@ void block_instance::setNotAbruptEnd()
}

std::string block_instance::calleeName() {
// How the heck do we do this again?
return obj()->getCalleeName(this);
}

void block_instance::updateCallTarget(func_instance *func) {
// Update a sink-typed call edge to
// have an inter-module target
//
// Preserving original behavior on sink edges only
//
edge_instance *e = getTarget();
if (e && e->sinkEdge()) {
PatchAPI::PatchModifier::redirect(e, func->entryBlock());
Expand Down

0 comments on commit 74d4fa4

Please sign in to comment.