Skip to content

Commit

Permalink
Don't type-erase the FunctionNameType or TypeClass enums.
Browse files Browse the repository at this point in the history
This is similar to D53597, but following up with 2 more enums.
After this, all flag enums should be strongly typed all the way
through to the symbol files plugins.

Differential Revision: https://reviews.llvm.org/D53616

llvm-svn: 345314
  • Loading branch information
Zachary Turner committed Oct 25, 2018
1 parent 991e445 commit 117b1fa
Show file tree
Hide file tree
Showing 28 changed files with 186 additions and 152 deletions.
14 changes: 9 additions & 5 deletions lldb/include/lldb/Breakpoint/BreakpointResolverName.h
Expand Up @@ -31,20 +31,23 @@ namespace lldb_private {
class BreakpointResolverName : public BreakpointResolver {
public:
BreakpointResolverName(Breakpoint *bkpt, const char *name,
uint32_t name_type_mask, lldb::LanguageType language,
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language,
Breakpoint::MatchType type, lldb::addr_t offset,
bool skip_prologue);

// This one takes an array of names. It is always MatchType = Exact.
BreakpointResolverName(Breakpoint *bkpt, const char *names[],
size_t num_names, uint32_t name_type_mask,
size_t num_names,
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language, lldb::addr_t offset,
bool skip_prologue);

// This one takes a C++ array of names. It is always MatchType = Exact.
BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
uint32_t name_type_mask, lldb::LanguageType language,
lldb::addr_t offset, bool skip_prologue);
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language, lldb::addr_t offset,
bool skip_prologue);

// Creates a function breakpoint by regular expression. Takes over control
// of the lifespan of func_regex.
Expand Down Expand Up @@ -89,7 +92,8 @@ class BreakpointResolverName : public BreakpointResolver {
lldb::LanguageType m_language;
bool m_skip_prologue;

void AddNameLookup(const ConstString &name, uint32_t name_type_mask);
void AddNameLookup(const ConstString &name,
lldb::FunctionNameType name_type_mask);
};

} // namespace lldb_private
Expand Down
40 changes: 24 additions & 16 deletions lldb/include/lldb/Core/Module.h
Expand Up @@ -380,7 +380,7 @@ class Module : public std::enable_shared_from_this<Module>,
//------------------------------------------------------------------
size_t FindFunctions(const ConstString &name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask, bool symbols_ok,
lldb::FunctionNameType name_type_mask, bool symbols_ok,
bool inlines_ok, bool append,
SymbolContextList &sc_list);

Expand Down Expand Up @@ -1028,9 +1028,10 @@ class Module : public std::enable_shared_from_this<Module>,
public:
LookupInfo()
: m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown),
m_name_type_mask(0), m_match_name_after_lookup(false) {}
m_name_type_mask(lldb::eFunctionNameTypeNone),
m_match_name_after_lookup(false) {}

LookupInfo(const ConstString &name, uint32_t name_type_mask,
LookupInfo(const ConstString &name, lldb::FunctionNameType name_type_mask,
lldb::LanguageType language);

const ConstString &GetName() const { return m_name; }
Expand All @@ -1041,24 +1042,31 @@ class Module : public std::enable_shared_from_this<Module>,

void SetLookupName(const ConstString &name) { m_lookup_name = name; }

uint32_t GetNameTypeMask() const { return m_name_type_mask; }
lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; }

void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; }
void SetNameTypeMask(lldb::FunctionNameType mask) {
m_name_type_mask = mask;
}

void Prune(SymbolContextList &sc_list, size_t start_idx) const;

protected:
ConstString m_name; ///< What the user originally typed
ConstString m_lookup_name; ///< The actual name will lookup when calling in
///the object or symbol file
lldb::LanguageType
m_language; ///< Limit matches to only be for this language
uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType
///that indicate what kind of names we are
///looking for
bool m_match_name_after_lookup; ///< If \b true, then demangled names that
///match will need to contain "m_name" in
///order to be considered a match
/// What the user originally typed
ConstString m_name;

/// The actual name will lookup when calling in the object or symbol file
ConstString m_lookup_name;

/// Limit matches to only be for this language
lldb::LanguageType m_language;

/// One or more bits from lldb::FunctionNameType that indicate what kind of
/// names we are looking for
lldb::FunctionNameType m_name_type_mask;

///< If \b true, then demangled names that match will need to contain
///< "m_name" in order to be considered a match
bool m_match_name_after_lookup;
};

protected:
Expand Down
6 changes: 4 additions & 2 deletions lldb/include/lldb/Core/ModuleList.h
Expand Up @@ -300,14 +300,16 @@ class ModuleList {
//------------------------------------------------------------------
/// @see Module::FindFunctions ()
//------------------------------------------------------------------
size_t FindFunctions(const ConstString &name, uint32_t name_type_mask,
size_t FindFunctions(const ConstString &name,
lldb::FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines, bool append,
SymbolContextList &sc_list) const;

//------------------------------------------------------------------
/// @see Module::FindFunctionSymbols ()
//------------------------------------------------------------------
size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
size_t FindFunctionSymbols(const ConstString &name,
lldb::FunctionNameType name_type_mask,
SymbolContextList &sc_list);

//------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions lldb/include/lldb/Symbol/SymbolFile.h
Expand Up @@ -170,8 +170,9 @@ class SymbolFile : public PluginInterface {
VariableList &variables);
virtual uint32_t FindFunctions(const ConstString &name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask, bool include_inlines,
bool append, SymbolContextList &sc_list);
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list);
virtual uint32_t FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
SymbolContextList &sc_list);
Expand All @@ -192,7 +193,7 @@ class SymbolFile : public PluginInterface {
// types) = 0;
virtual TypeList *GetTypeList();
virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
uint32_t type_mask,
lldb::TypeClass type_mask,
lldb_private::TypeList &type_list) = 0;

virtual void PreloadSymbols();
Expand Down
9 changes: 5 additions & 4 deletions lldb/include/lldb/Symbol/SymbolVendor.h
Expand Up @@ -90,8 +90,9 @@ class SymbolVendor : public ModuleChild, public PluginInterface {

virtual size_t FindFunctions(const ConstString &name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask, bool include_inlines,
bool append, SymbolContextList &sc_list);
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
SymbolContextList &sc_list);

virtual size_t FindFunctions(const RegularExpression &regex,
bool include_inlines, bool append,
Expand Down Expand Up @@ -122,8 +123,8 @@ class SymbolVendor : public ModuleChild, public PluginInterface {

const TypeList &GetTypeList() const { return m_type_list; }

virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
TypeList &type_list);
virtual size_t GetTypes(SymbolContextScope *sc_scope,
lldb::TypeClass type_mask, TypeList &type_list);

SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }

Expand Down
32 changes: 15 additions & 17 deletions lldb/include/lldb/Target/Target.h
Expand Up @@ -608,14 +608,12 @@ class Target : public std::enable_shared_from_this<Target>,
// eLazyBoolCalculate, we use the current target setting, else we use the
// values passed in. func_name_type_mask is or'ed values from the
// FunctionNameType enum.
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const char *func_name,
uint32_t func_name_type_mask,
lldb::LanguageType language,
lldb::addr_t offset,
LazyBool skip_prologue, bool internal,
bool request_hardware);
lldb::BreakpointSP CreateBreakpoint(
const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles, const char *func_name,
lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
lldb::addr_t offset, LazyBool skip_prologue, bool internal,
bool request_hardware);

lldb::BreakpointSP
CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
Expand All @@ -637,20 +635,20 @@ class Target : public std::enable_shared_from_this<Target>,
// the case where you just want to set a breakpoint on a set of names you
// already know. func_name_type_mask is or'ed values from the
// FunctionNameType enum.
lldb::BreakpointSP
CreateBreakpoint(const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const char *func_names[], size_t num_names,
uint32_t func_name_type_mask, lldb::LanguageType language,
lldb::addr_t offset, LazyBool skip_prologue, bool internal,
bool request_hardware);
lldb::BreakpointSP CreateBreakpoint(
const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles, const char *func_names[],
size_t num_names, lldb::FunctionNameType func_name_type_mask,
lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
bool internal, bool request_hardware);

lldb::BreakpointSP
CreateBreakpoint(const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask, lldb::LanguageType language,
lldb::addr_t m_offset, LazyBool skip_prologue, bool internal,
lldb::FunctionNameType func_name_type_mask,
lldb::LanguageType language, lldb::addr_t m_offset,
LazyBool skip_prologue, bool internal,
bool request_hardware);

// Use this to create a general breakpoint:
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-enumerations.h
Expand Up @@ -735,6 +735,7 @@ FLAGS_ENUM(FunctionNameType){
eFunctionNameTypeAny =
eFunctionNameTypeAuto // DEPRECATED: use eFunctionNameTypeAuto
};
LLDB_MARK_AS_BITMASK_ENUM(FunctionNameType)

//----------------------------------------------------------------------
// Basic types enumeration for the public API SBType::GetBasicType()
Expand Down Expand Up @@ -809,6 +810,7 @@ FLAGS_ENUM(TypeClass){
eTypeClassOther = (1u << 31),
// Define a mask that can be used for any type when finding types
eTypeClassAny = (0xffffffffu)};
LLDB_MARK_AS_BITMASK_ENUM(TypeClass)

enum TemplateArgumentKind {
eTemplateArgumentKindNull = 0,
Expand Down
26 changes: 15 additions & 11 deletions lldb/source/API/SBCompileUnit.cpp
Expand Up @@ -135,17 +135,21 @@ uint32_t SBCompileUnit::GetNumSupportFiles() const {
lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) {
SBTypeList sb_type_list;

if (m_opaque_ptr) {
ModuleSP module_sp(m_opaque_ptr->GetModule());
if (module_sp) {
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (vendor) {
TypeList type_list;
vendor->GetTypes(m_opaque_ptr, type_mask, type_list);
sb_type_list.m_opaque_ap->Append(type_list);
}
}
}
if (!m_opaque_ptr)
return sb_type_list;

ModuleSP module_sp(m_opaque_ptr->GetModule());
if (!module_sp)
return sb_type_list;

SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (!vendor)
return sb_type_list;

TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
vendor->GetTypes(m_opaque_ptr, type_class, type_list);
sb_type_list.m_opaque_ap->Append(type_list);
return sb_type_list;
}

Expand Down
23 changes: 13 additions & 10 deletions lldb/source/API/SBModule.cpp
Expand Up @@ -365,8 +365,9 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
const bool append = true;
const bool symbols_ok = true;
const bool inlines_ok = true;
module_sp->FindFunctions(ConstString(name), NULL, name_type_mask,
symbols_ok, inlines_ok, append, *sb_sc_list);
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
module_sp->FindFunctions(ConstString(name), NULL, type, symbols_ok,
inlines_ok, append, *sb_sc_list);
}
return sb_sc_list;
}
Expand Down Expand Up @@ -484,14 +485,16 @@ lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) {
SBTypeList sb_type_list;

ModuleSP module_sp(GetSP());
if (module_sp) {
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (vendor) {
TypeList type_list;
vendor->GetTypes(NULL, type_mask, type_list);
sb_type_list.m_opaque_ap->Append(type_list);
}
}
if (!module_sp)
return sb_type_list;
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (!vendor)
return sb_type_list;

TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
vendor->GetTypes(NULL, type_class, type_list);
sb_type_list.m_opaque_ap->Append(type_list);
return sb_type_list;
}

Expand Down
39 changes: 21 additions & 18 deletions lldb/source/API/SBTarget.cpp
Expand Up @@ -790,7 +790,7 @@ lldb::SBBreakpoint
SBTarget::BreakpointCreateByName(const char *symbol_name,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list) {
uint32_t name_type_mask = eFunctionNameTypeAuto;
lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
return BreakpointCreateByName(symbol_name, name_type_mask,
eLanguageTypeUnknown, module_list,
comp_unit_list);
Expand All @@ -817,9 +817,10 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
sb_bp = target_sp->CreateBreakpoint(
module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
symbol_language, 0, skip_prologue, internal, hardware);
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(),
symbol_name, mask, symbol_language, 0,
skip_prologue, internal, hardware);
}

if (log)
Expand Down Expand Up @@ -860,11 +861,11 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool internal = false;
const bool hardware = false;
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
const LazyBool skip_prologue = eLazyBoolCalculate;
sb_bp = target_sp->CreateBreakpoint(
module_list.get(), comp_unit_list.get(), symbol_names, num_names,
name_type_mask, symbol_language, offset, skip_prologue, internal,
hardware);
module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask,
symbol_language, offset, skip_prologue, internal, hardware);
}

if (log) {
Expand Down Expand Up @@ -1735,17 +1736,19 @@ bool SBTarget::GetDescription(SBStream &description,
lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
uint32_t name_type_mask) {
lldb::SBSymbolContextList sb_sc_list;
if (name && name[0]) {
TargetSP target_sp(GetSP());
if (target_sp) {
const bool symbols_ok = true;
const bool inlines_ok = true;
const bool append = true;
target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask,
symbols_ok, inlines_ok, append,
*sb_sc_list);
}
}
if (!name | !name[0])
return sb_sc_list;

TargetSP target_sp(GetSP());
if (!target_sp)
return sb_sc_list;

const bool symbols_ok = true;
const bool inlines_ok = true;
const bool append = true;
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
inlines_ok, append, *sb_sc_list);
return sb_sc_list;
}

Expand Down

0 comments on commit 117b1fa

Please sign in to comment.