Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/dyninst/symtabAPI/h/Collections.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

217 lines
7.7 KiB
C++

/*
* See the dyninst/COPYRIGHT file for copyright information.
*
* We provide the Paradyn Tools (below described as "Paradyn")
* on an AS IS basis, and do not warrant its validity or performance.
* We reserve the right to update, modify, or discontinue this
* software at any time. We shall have no obligation to supply such
* updates or modifications or any other form of support to you.
*
* By your use of Paradyn, you understand and agree that we (or any
* other person or entity with proprietary rights in Paradyn) are
* under no obligation to provide either maintenance services,
* update services, notices of latent defects, or correction of
* defects for Paradyn.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _Collections_h_
#define _Collections_h_
#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
#include "concurrent.h"
#include "Type.h"
#include "Variable.h"
#include <dyncompat/core/enable_if.hpp>
#include <dyncompat/type_traits/is_same.hpp>
namespace Dyninst {
namespace SymtabAPI {
class Module;
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;
bool addItem_impl(localVar *);
public:
localVarCollection(){}
~localVarCollection();
void addLocalVar(localVar * var);
localVar * findLocalVar(std::string &name);
const dyn_c_vector<localVar *> &getAllVars() const;
};
/*
* 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;
friend class Object;
friend class Module;
friend class Type;
friend class DwarfWalker;
dyn_c_hash_map<std::string, dyncompat::shared_ptr<Type>> typesByName;
dyn_c_hash_map<std::string, dyncompat::shared_ptr<Type>> globalVarsByName;
dyn_c_hash_map<int, dyncompat::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:
typeCollection();
~typeCollection();
public:
static void addDeferredLookup(int, dataClass, dyncompat::shared_ptr<Type> *);
static dyncompat::mutex create_lock;
static typeCollection *getModTypeCollection(Module *mod);
// DWARF...
bool dwarfParsed() { return dwarfParsed_; }
void setDwarfParsed() { dwarfParsed_ = true; }
dyncompat::shared_ptr<Type> findType(std::string name, Type::do_share_t);
Type* findType(std::string n) { return findType(n, Type::share).get(); }
dyncompat::shared_ptr<Type> findType(const int ID, Type::do_share_t);
Type* findType(const int i) { return findType(i, Type::share).get(); }
dyncompat::shared_ptr<Type> findTypeLocal(std::string name, Type::do_share_t);
Type* findTypeLocal(std::string n) { return findTypeLocal(n, Type::share).get(); }
dyncompat::shared_ptr<Type> findTypeLocal(const int ID, Type::do_share_t);
Type* findTypeLocal(const int i) { return findTypeLocal(i, Type::share).get(); }
void addType(dyncompat::shared_ptr<Type> type);
void addType(Type* t) { addType(t->reshare()); }
void addType(dyncompat::shared_ptr<Type> type, dyn_mutex::unique_lock&);
void addType(Type* t, dyn_mutex::unique_lock& g) {
addType(t->reshare(), g);
}
void addGlobalVariable(dyncompat::shared_ptr<Type> type);
void addGlobalVariable(Type* t) {
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. */
dyncompat::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>
typename std::enable_if<
!std::is_same<Type, T>::value,
dyncompat::shared_ptr<Type>>::type addOrUpdateType(dyncompat::shared_ptr<T> type);
template<class T>
T* addOrUpdateType(T* t) {
return &dynamic_cast<T&>(*addOrUpdateType(dyncompat::dynamic_pointer_cast<T>(t->reshare())));
}
dyncompat::shared_ptr<Type> findVariableType(std::string &name, Type::do_share_t);
Type* findVariableType(std::string& n) { return findVariableType(n, Type::share).get(); }
void getAllTypes(std::vector<dyncompat::shared_ptr<Type>>&);
std::vector<Type*>* getAllTypes() {
std::vector<dyncompat::shared_ptr<Type>> v;
getAllTypes(v);
auto r = new std::vector<Type*>(v.size());
for(std::size_t i = 0; i < v.size(); i++) (*r)[i] = v[i].get();
return r;
}
void getAllGlobalVariables(std::vector<std::pair<std::string, dyncompat::shared_ptr<Type>>>&);
std::vector<std::pair<std::string, Type*>>* getAllGlobalVariables() {
std::vector<std::pair<std::string, dyncompat::shared_ptr<Type>>> v;
getAllGlobalVariables(v);
auto r = new std::vector<std::pair<std::string, Type*>>(v.size());
for(std::size_t i = 0; i < v.size(); i++)
(*r)[i] = {v[i].first, v[i].second.get()};
return r;
}
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, dyncompat::shared_ptr<Type>> builtInTypesByID;
dyn_c_hash_map<std::string, dyncompat::shared_ptr<Type>> builtInTypesByName;
public:
builtInTypeCollection();
~builtInTypeCollection();
dyncompat::shared_ptr<Type> findBuiltInType(std::string &name, Type::do_share_t);
Type* findBuiltInType(std::string& n) { return findBuiltInType(n, Type::share).get(); }
dyncompat::shared_ptr<Type> findBuiltInType(const int ID, Type::do_share_t);
Type* findBuiltInType(const int i) { return findBuiltInType(i, Type::share).get(); }
void addBuiltInType(dyncompat::shared_ptr<Type>);
void addBuiltInType(Type* t) { addBuiltInType(t->reshare()); }
void getAllBuiltInTypes(std::vector<dyncompat::shared_ptr<Type>>&);
std::vector<Type*>* getAllBuiltInTypes() {
std::vector<dyncompat::shared_ptr<Type>> v;
getAllBuiltInTypes(v);
auto r = new std::vector<Type*>(v.size());
for(std::size_t i = 0; i < v.size(); i++) (*r)[i] = v[i].get();
return r;
}
};
}// namespace SymtabAPI
}// namespace Dyninst
#endif /* _Collections_h_ */