Skip to content

Commit

Permalink
Add dyninstAPI/block.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 2095d9c commit bd19b56
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
65 changes: 65 additions & 0 deletions docs/dyninstAPI/developer/block.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,68 @@
block.h
#######

This is somewhat mangled, but allows Dyninst to access the iteration predicates of Dyninst without having
to go back and template that code. Just wrap a ParseAPI predicate in a EdgePredicateAdapter and poof you're
using edge_instances instead of ParseAPI edges...

.. cpp:class:: edge_instance : public Dyninst::PatchAPI::PatchEdge

.. cpp:function:: block_instance *src() const
.. cpp:function:: block_instance *trg() const
.. cpp:function:: AddressSpace *proc()
.. cpp:function:: edge_instance(ParseAPI::Edge *edge, block_instance *src, block_instance *trg)
.. cpp:function:: edge_instance(const edge_instance *parent, mapped_object *child)
.. cpp:function:: ~edge_instance()

.. cpp:class:: EdgePredicateAdapter : public ParseAPI::iterator_predicate<edge_instance *, edge_instance *>

.. cpp:function:: EdgePredicateAdapter()
.. cpp:function:: EdgePredicateAdapter(ParseAPI::EdgePredicate *intPred)
.. cpp:function:: virtual ~EdgePredicateAdapter()
.. cpp:function:: virtual bool pred_impl(edge_instance *const e) const
.. cpp:member:: private ParseAPI::EdgePredicate *int_

.. cpp:class:: block_instance : public Dyninst::PatchAPI::PatchBlock

.. cpp:function:: block_instance(ParseAPI::Block *ib, mapped_object *obj)
.. cpp:function:: block_instance(const block_instance *parent, mapped_object *child)
.. cpp:function:: ~block_instance()
.. 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()
.. cpp:function:: void setNotAbruptEnd()
.. cpp:function:: parse_block *llb() const
.. cpp:function:: void *getPtrToInstruction(Address addr) const
.. cpp:function:: edge_instance *getTarget()
.. cpp:function:: edge_instance *getFallthrough()
.. cpp:function:: block_instance *getFallthroughBlock()

NULL if not conclusive

.. cpp:function:: func_instance *callee()
.. cpp:function:: std::string calleeName()
.. cpp:member:: bool _ignorePowerPreamble
.. cpp:function:: int id() const
.. cpp:function:: func_instance *entryOfFunc() const

......

.. rubric::
These are convinence wrappers for really expensive lookups, and thus should be avoided.

.. cpp:function:: bool isFuncExit() const
.. cpp:function:: Address GetBlockStartingAddress()
.. cpp:function:: virtual void markModified()
.. cpp:function:: private void updateCallTarget(func_instance *func)
.. cpp:function:: private func_instance *findFunction(ParseAPI::Function *)
.. cpp:function:: private func_instance *callee(std::string const &)


.. cpp:struct:: BlockInstanceAddrCompare

.. cpp:function:: private bool operator()(block_instance *const &b1, block_instance *const &b2) const

.. cpp:type:: std::set<block_instance *, BlockInstanceAddrCompare> AddrOrderedBlockSet

12 changes: 0 additions & 12 deletions dyninstAPI/src/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class edge_instance : public Dyninst::PatchAPI::PatchEdge {
~edge_instance();
};

// This is somewhat mangled, but allows Dyninst to access the
// iteration predicates of Dyninst without having to go back and
// template that code. Just wrap a ParseAPI predicate in a
// EdgePredicateAdapter and *poof* you're using edge_instances
// instead of ParseAPI edges...

class EdgePredicateAdapter
: public ParseAPI::iterator_predicate <
edge_instance *,
Expand All @@ -92,7 +86,6 @@ class block_instance : public Dyninst::PatchAPI::PatchBlock {
block_instance(const block_instance *parent, mapped_object *child);
~block_instance();

// Up-accessors
mapped_object *obj() const { return SCAST_MO(obj_); }
AddressSpace *addrSpace() const;
AddressSpace *proc() const { return addrSpace(); }
Expand All @@ -108,20 +101,15 @@ class block_instance : public Dyninst::PatchAPI::PatchBlock {
//const edgelist &sources();
//const edgelist &targets();

// Shortcuts
edge_instance *getTarget();
edge_instance *getFallthrough();
// NULL if not conclusive
block_instance *getFallthroughBlock();

func_instance *callee();
std::string calleeName();
bool _ignorePowerPreamble;
int id() const;

// Functions to avoid
// These are convinence wrappers for really expensive
// lookups, and thus should be avoided.
func_instance *entryOfFunc() const;
bool isFuncExit() const;
// static void destroy(block_instance *b); // doesn't need to do anything
Expand Down

0 comments on commit bd19b56

Please sign in to comment.