Skip to content

Commit

Permalink
Add symtab/Collections.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 92afadb commit 1032d62
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 38 deletions.
1 change: 1 addition & 0 deletions docs/symtabAPI/developer/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SymtabAPI
Aggregate.h
annotations.h
Archive.h
Collections.h
debug.h
dwarfWalker.h
emitElf.h
Expand Down
79 changes: 79 additions & 0 deletions docs/symtabAPI/developer/Collections.h.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.. _`sec:Collections.h`:

Collections.h
#############

.. cpp:namespace:: Dyninst::SymtabAPI

.. cpp:class:: localVarCollection

Each function will have one of these objects associated with it.
This object will store all the local variables within this function.

.. cpp:function:: localVarCollection()
.. cpp:function:: void addLocalVar(localVarvar)
.. cpp:function:: localVarfindLocalVar(std::string &name)
.. cpp:function:: const dyn_c_vector<localVar *> &getAllVars() const

.. cpp:class:: typeCollection

Due to DWARF weirdness, this can be shared between multiple BPatch_modules.
So we reference-count to make life easier.

.. cpp:member:: private static dyn_c_hash_map< void *, typeCollection> fileToTypesMap

Cache type collections on a per-image basis. (Since BPatch_functions are solitons,
we don't have to cache them.)

.. cpp:member:: static boost::mutex create_lock

.. cpp:function:: typeCollection()
.. cpp:function:: static void addDeferredLookup(int, dataClass, boost::shared_ptr<Type> *)
.. cpp:function:: static typeCollection *getModTypeCollection(Module *mod)
.. cpp:function:: bool dwarfParsed()
.. cpp:function:: void setDwarfParsed()
.. cpp:function:: boost::shared_ptr<Type> findType(std::string name, Type::do_share_t)
.. cpp:function:: Type* findType(std::string n)
.. cpp:function:: boost::shared_ptr<Type> findType(const int ID, Type::do_share_t)
.. cpp:function:: Type* findType(const int i)
.. cpp:function:: boost::shared_ptr<Type> findTypeLocal(std::string name, Type::do_share_t)
.. cpp:function:: Type* findTypeLocal(std::string n)
.. cpp:function:: boost::shared_ptr<Type> findTypeLocal(const int ID, Type::do_share_t)
.. cpp:function:: Type* findTypeLocal(const int i)
.. cpp:function:: void addType(boost::shared_ptr<Type> type)
.. cpp:function:: void addType(Type* t)
.. cpp:function:: void addType(boost::shared_ptr<Type> type, dyn_mutex::unique_lock&)
.. cpp:function:: void addType(Type* t, dyn_mutex::unique_lock& g)

.. cpp:function:: template <class T> typename boost::enable_if<boost::integral_constant<bool, \
!bool(boost::is_same<Type, T>::value)>, boost::shared_ptr<Type>>::type \
addOrUpdateType(boost::shared_ptr<T> type)

.. cpp:function:: template <class T> T* addOrUpdateType(T* t)


.. cpp:class:: builtInTypeCollection

This class defines the collection for the built-in Types gnu use negative numbers to define other types
in terms of these built-in types.
This collection is global and built in the BPatch_image constructor.
This means that only one collection of built-in types is made per image.

.. cpp:function:: builtInTypeCollection()
.. cpp:function:: boost::shared_ptr<Type> findBuiltInType(std::string &name, Type::do_share_t)
.. cpp:function:: Type* findBuiltInType(std::string& n)
.. cpp:function:: boost::shared_ptr<Type> findBuiltInType(const int ID, Type::do_share_t)
.. cpp:function:: Type* findBuiltInType(const int i)
.. cpp:function:: void addBuiltInType(boost::shared_ptr<Type>)
.. cpp:function:: void addBuiltInType(Type* t)
.. cpp:function:: void getAllBuiltInTypes(std::vector<boost::shared_ptr<Type>>&)
.. cpp:function:: std::vector<Type*>* getAllBuiltInTypes()


Notes
=====

Some debug formats allow forward references. Rather than fill in forward in a second
pass, generate placeholder types, and fill them in as we go. Because we require One
True Pointer for each type, when updating a type, return that One True Pointer.

1 change: 0 additions & 1 deletion docs/symtabAPI/public/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ SymtabAPI
:maxdepth: 1

Aggregate.h
Collections.h
ExceptionBlock.h
Function.h
LineInformation.h
Expand Down
5 changes: 0 additions & 5 deletions docs/symtabAPI/public/Collections.h.rst

This file was deleted.

32 changes: 0 additions & 32 deletions symtabAPI/h/Collections.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ class Symtab;
class localVar;
class DwarfWalker;

/*
* This class contains a collection of local variables.
* Each function will have one of these objects associated with it.
* This object will store all the local variables within this function.
* Note: This class is unaware of scope.
*/


class SYMTAB_EXPORT localVarCollection {

dyn_c_vector<localVar* > localVars;
Expand All @@ -74,10 +66,6 @@ class SYMTAB_EXPORT localVarCollection {



/*
* Due to DWARF weirdness, this can be shared between multiple BPatch_modules.
* So we reference-count to make life easier.
*/
class SYMTAB_EXPORT typeCollection
{
friend class Symtab;
Expand All @@ -91,13 +79,9 @@ class SYMTAB_EXPORT typeCollection
dyn_c_hash_map<int, boost::shared_ptr<Type>> typesByID;


// DWARF:
/* Cache type collections on a per-image basis. (Since
BPatch_functions are solitons, we don't have to cache them.) */
static dyn_c_hash_map< void *, typeCollection * > fileToTypesMap;
static bool doDeferredLookups(typeCollection *);

// DWARF...
bool dwarfParsed_;

public:
Expand All @@ -109,7 +93,6 @@ class SYMTAB_EXPORT typeCollection

static typeCollection *getModTypeCollection(Module *mod);

// DWARF...
bool dwarfParsed() { return dwarfParsed_; }
void setDwarfParsed() { dwarfParsed_ = true; }

Expand All @@ -132,11 +115,6 @@ class SYMTAB_EXPORT typeCollection
addGlobalVariable(t->reshare());
}

/* Some debug formats allow forward references. Rather than
fill in forward in a second pass, generate placeholder
types, and fill them in as we go. Because we require
One True Pointer for each type, when
updating a type, return that One True Pointer. */
boost::shared_ptr<Type> findOrCreateType( const int ID, Type::do_share_t );
Type* findOrCreateType(const int i) { return findOrCreateType(i, Type::share).get(); }
template<class T>
Expand Down Expand Up @@ -171,16 +149,6 @@ class SYMTAB_EXPORT typeCollection
void clearNumberedTypes();
};

/*
* This class defines the collection for the built-in Types
* gnu use negative numbers to define other types
* in terms of these built-in types.
* This collection is global and built in the BPatch_image constructor.
* This means that only one collection of built-in types is made
* per image. jdd 4/21/99
*
*/

class SYMTAB_EXPORT builtInTypeCollection {

dyn_c_hash_map<int, boost::shared_ptr<Type>> builtInTypesByID;
Expand Down

0 comments on commit 1032d62

Please sign in to comment.