Skip to content

Commit

Permalink
[lldb][NFC] clang-format some files as preparation for https://review…
Browse files Browse the repository at this point in the history
…s.llvm.org/D114627

Reviewed By: werat

Differential Revision: https://reviews.llvm.org/D115110
  • Loading branch information
lfolger authored and werat committed Dec 9, 2021
1 parent 6f9afad commit b2e2eec
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 67 deletions.
57 changes: 28 additions & 29 deletions lldb/include/lldb/Core/Module.h
Expand Up @@ -21,8 +21,8 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/XcodeSDK.h"
#include "lldb/Utility/UUID.h"
#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
Expand Down Expand Up @@ -128,7 +128,7 @@ class Module : public std::enable_shared_from_this<Module>,
Module(const ModuleSpec &module_spec);

template <typename ObjFilePlugin, typename... Args>
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&... args) {
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args) {
// Must create a module and place it into a shared pointer before we can
// create an object file since it has a std::weak_ptr back to the module,
// so we need to control the creation carefully in this static function
Expand Down Expand Up @@ -255,8 +255,7 @@ class Module : public std::enable_shared_from_this<Module>,
/// Returns a valid symbol pointer if a symbol was found,
/// nullptr otherwise.
const Symbol *FindFirstSymbolWithNameAndType(
ConstString name,
lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
ConstString name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);

void FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
Expand Down Expand Up @@ -439,12 +438,13 @@ class Module : public std::enable_shared_from_this<Module>,
///
/// \param searched_symbol_files
/// Prevents one file from being visited multiple times.
void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
void
FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

lldb::TypeSP FindFirstType(const SymbolContext &sc,
ConstString type_name, bool exact_match);
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name,
bool exact_match);

/// Find types by name that are in a namespace. This function is used by the
/// expression parser when searches need to happen in an exact namespace
Expand Down Expand Up @@ -788,8 +788,7 @@ class Module : public std::enable_shared_from_this<Module>,
const FileSpec &file_spec, uint32_t line, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);

void SetFileSpecAndObjectName(const FileSpec &file,
ConstString object_name);
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name);

bool GetIsDynamicLinkEditor();

Expand Down Expand Up @@ -876,7 +875,7 @@ class Module : public std::enable_shared_from_this<Module>,
/// The value is returned as a reference to allow it to be updated by the
/// ElapsedTime RAII object.
StatsDuration &GetSymtabParseTime() { return m_symtab_parse_time; }

/// Accessor for the symbol table index time metric.
///
/// The value is returned as a reference to allow it to be updated by the
Expand Down Expand Up @@ -949,27 +948,27 @@ class Module : public std::enable_shared_from_this<Module>,
protected:
// Member Variables
mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
///in multi-threaded environments.
/// in multi-threaded environments.

/// The modification time for this module when it was created.
llvm::sys::TimePoint<> m_mod_time;

ArchSpec m_arch; ///< The architecture for this module.
ArchSpec m_arch; ///< The architecture for this module.
UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
///match it up to debug symbols.
/// match it up to debug symbols.
FileSpec m_file; ///< The file representation on disk for this module (if
///there is one).
/// there is one).
FileSpec m_platform_file; ///< The path to the module on the platform on which
///it is being debugged
/// it is being debugged
FileSpec m_remote_install_file; ///< If set when debugging on remote
///platforms, this module will be installed at
///this location
/// platforms, this module will be installed
/// at this location
FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
///that _will_ be used as the symbol file for this
///module
/// that _will_ be used as the symbol file for this
/// module
ConstString m_object_name; ///< The name an object within this module that is
///selected, or empty of the module is represented
///by \a m_file.
/// selected, or empty of the module is represented
/// by \a m_file.
uint64_t m_object_offset = 0;
llvm::sys::TimePoint<> m_object_mod_time;

Expand All @@ -979,20 +978,20 @@ class Module : public std::enable_shared_from_this<Module>,
lldb::DataBufferSP m_data_sp;

lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
///parser for this module as it may or may
///not be shared with the SymbolFile
/// parser for this module as it may or may
/// not be shared with the SymbolFile
llvm::Optional<UnwindTable> m_unwind_table; ///< Table of FuncUnwinders
/// objects created for this
/// Module's functions
lldb::SymbolVendorUP
m_symfile_up; ///< A pointer to the symbol vendor for this module.
std::vector<lldb::SymbolVendorUP>
m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
///changes the symbol file,
/// changes the symbol file,
///< we need to keep all old symbol files around in case anyone has type
///references to them
TypeSystemMap m_type_system_map; ///< A map of any type systems associated
///with this module
/// references to them
TypeSystemMap m_type_system_map; ///< A map of any type systems associated
/// with this module
/// Module specific source remappings for when you have debug info for a
/// module that doesn't match where the sources currently are.
PathMappingList m_source_mappings =
Expand Down
10 changes: 2 additions & 8 deletions lldb/include/lldb/Symbol/SymbolFile.h
Expand Up @@ -181,7 +181,6 @@ class SymbolFile : public PluginInterface {
virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0;
virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0;


/// The characteristics of an array type.
struct ArrayInfo {
int64_t first_index = 0;
Expand Down Expand Up @@ -318,19 +317,14 @@ class SymbolFile : public PluginInterface {
///
/// \returns 0.0 if no information has been parsed or if there is
/// no computational cost to parsing the debug information.
virtual StatsDuration GetDebugInfoParseTime() {
return StatsDuration(0.0);
}
virtual StatsDuration GetDebugInfoParseTime() { return StatsDuration(0.0); }

/// Return the time it took to index the debug information in the object
/// file.
///
/// \returns 0.0 if the file doesn't need to be indexed or if it
/// hasn't been indexed yet, or a valid duration if it has.
virtual StatsDuration GetDebugInfoIndexTime() {
return StatsDuration(0.0);
}

virtual StatsDuration GetDebugInfoIndexTime() { return StatsDuration(0.0); }

protected:
void AssertModuleLock();
Expand Down
31 changes: 15 additions & 16 deletions lldb/source/Core/Module.cpp
Expand Up @@ -233,8 +233,8 @@ Module::Module(const ModuleSpec &module_spec)
Module::Module(const FileSpec &file_spec, const ArchSpec &arch,
const ConstString *object_name, lldb::offset_t object_offset,
const llvm::sys::TimePoint<> &object_mod_time)
: m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_arch(arch),
m_file(file_spec), m_object_offset(object_offset),
: m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
m_arch(arch), m_file(file_spec), m_object_offset(object_offset),
m_object_mod_time(object_mod_time), m_file_has_changed(false),
m_first_file_changed_log(false) {
// Scope for locker below...
Expand Down Expand Up @@ -559,9 +559,8 @@ uint32_t Module::ResolveSymbolContextForAddress(
// that the symbol has been resolved.
if (so_addr.GetOffset() ==
addr_range.GetBaseAddress().GetOffset() ||
so_addr.GetOffset() ==
addr_range.GetBaseAddress().GetOffset() +
addr_range.GetByteSize()) {
so_addr.GetOffset() == addr_range.GetBaseAddress().GetOffset() +
addr_range.GetByteSize()) {
resolved_flags |= flags;
}
} else {
Expand Down Expand Up @@ -765,8 +764,7 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
// pull anything out
ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
ConstString full_name(sc.GetFunctionName());
if (mangled_name != m_name && full_name != m_name)
{
if (mangled_name != m_name && full_name != m_name) {
CPlusPlusLanguage::MethodName cpp_method(full_name);
if (cpp_method.IsValid()) {
if (cpp_method.GetContext().empty()) {
Expand Down Expand Up @@ -959,8 +957,8 @@ void Module::FindTypesInNamespace(ConstString type_name,
}
}

lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
ConstString name, bool exact_match) {
lldb::TypeSP Module::FindFirstType(const SymbolContext &sc, ConstString name,
bool exact_match) {
TypeList type_list;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
Expand Down Expand Up @@ -1331,18 +1329,17 @@ void Module::SymbolIndicesToSymbolContextList(
}
}

void Module::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
void Module::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list) {
LLDB_SCOPED_TIMERF("Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
name.AsCString(), name_type_mask);
if (Symtab *symtab = GetSymtab())
symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
}

void Module::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) {
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
// already thread safe.
if (Symtab *symtab = GetSymtab()) {
Expand Down Expand Up @@ -1604,14 +1601,16 @@ bool Module::FindSourceFile(const FileSpec &orig_spec,
return false;
}

llvm::Optional<std::string> Module::RemapSourceFile(llvm::StringRef path) const {
llvm::Optional<std::string>
Module::RemapSourceFile(llvm::StringRef path) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (auto remapped = m_source_mappings.RemapPath(path))
return remapped->GetPath();
return {};
}

void Module::RegisterXcodeSDK(llvm::StringRef sdk_name, llvm::StringRef sysroot) {
void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
llvm::StringRef sysroot) {
XcodeSDK sdk(sdk_name.str());
llvm::StringRef sdk_path(HostInfo::GetXcodeSDKPath(sdk));
if (sdk_path.empty())
Expand Down
11 changes: 6 additions & 5 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Expand Up @@ -1097,7 +1097,8 @@ bool SymbolFileDWARF::ParseImportedModules(
if (const char *include_path = module_die.GetAttributeValueAsString(
DW_AT_LLVM_include_path, nullptr)) {
FileSpec include_spec(include_path, dwarf_cu->GetPathStyle());
MakeAbsoluteAndRemap(include_spec, *dwarf_cu, m_objfile_sp->GetModule());
MakeAbsoluteAndRemap(include_spec, *dwarf_cu,
m_objfile_sp->GetModule());
module.search_path = ConstString(include_spec.GetPath());
}
if (const char *sysroot = dwarf_cu->DIE().GetAttributeValueAsString(
Expand Down Expand Up @@ -1924,7 +1925,7 @@ void SymbolFileDWARF::ResolveFunctionAndBlock(lldb::addr_t file_vm_addr,
block_die = function_die.LookupDeepestBlock(file_vm_addr);
}

if (!sc.function || ! lookup_block)
if (!sc.function || !lookup_block)
return;

Block &block = sc.function->GetBlock(true);
Expand Down Expand Up @@ -2319,7 +2320,8 @@ void SymbolFileDWARF::FindFunctions(ConstString name,
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, sc_list)",
"SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, "
"sc_list)",
name.GetCString(), name_type_mask);
}

Expand Down Expand Up @@ -2352,8 +2354,7 @@ void SymbolFileDWARF::FindFunctions(ConstString name,
log,
"SymbolFileDWARF::FindFunctions (name=\"%s\", "
"name_type_mask=0x%x, include_inlines=%d, sc_list) => %u",
name.GetCString(), name_type_mask, include_inlines,
num_matches);
name.GetCString(), name_type_mask, include_inlines, num_matches);
}
}

Expand Down
12 changes: 6 additions & 6 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Expand Up @@ -253,8 +253,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
ExternalTypeModuleMap;

/// Return the list of Clang modules imported by this SymbolFile.
const ExternalTypeModuleMap& getExternalTypeModules() const {
return m_external_type_modules;
const ExternalTypeModuleMap &getExternalTypeModules() const {
return m_external_type_modules;
}

virtual DWARFDIE GetDIE(const DIERef &die_ref);
Expand Down Expand Up @@ -328,7 +328,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
return m_parse_time;
}


protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
Expand Down Expand Up @@ -428,9 +427,10 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
virtual lldb::TypeSP
FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);

virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation);
virtual lldb::TypeSP
FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die,
lldb_private::ConstString type_name,
bool must_be_implementation);

lldb_private::Symbol *
GetObjCClassSymbol(lldb_private::ConstString objc_class_name);
Expand Down
8 changes: 5 additions & 3 deletions lldb/source/Symbol/SymbolFile.cpp
Expand Up @@ -147,9 +147,11 @@ void SymbolFile::AssertModuleLock() {
// We assert that we have to module lock by trying to acquire the lock from a
// different thread. Note that we must abort if the result is true to
// guarantee correctness.
assert(std::async(std::launch::async,
[this] { return this->GetModuleMutex().try_lock(); })
.get() == false &&
assert(std::async(
std::launch::async,
[this] {
return this->GetModuleMutex().try_lock();
}).get() == false &&
"Module is not locked");
#endif
}
Expand Down

0 comments on commit b2e2eec

Please sign in to comment.