LLDB mainline
SymbolFileDWARF.cpp File Reference
#include "SymbolFileDWARF.h"
#include "clang/Basic/ABI.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/Threading.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Progress.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/Timer.h"
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileWasm.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "AppleDWARFIndex.h"
#include "DWARFASTParser.h"
#include "DWARFASTParserClang.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugMacro.h"
#include "DWARFDeclContext.h"
#include "DWARFFormValue.h"
#include "DWARFTypeUnit.h"
#include "DWARFUnit.h"
#include "DebugNamesDWARFIndex.h"
#include "LogChannelDWARF.h"
#include "ManualDWARFIndex.h"
#include "SymbolFileDWARFDebugMap.h"
#include "SymbolFileDWARFDwo.h"
#include "lldb/lldb-private-enumerations.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <map>
#include <memory>
#include <optional>
#include <cctype>
#include <cstring>
#include "SymbolFileDWARFProperties.inc"
#include "SymbolFileDWARFPropertiesEnum.inc"

Go to the source code of this file.

Macros

#define DEBUG_PRINTF(fmt, ...)
#define LLDB_PROPERTIES_symbolfiledwarf
#define LLDB_PROPERTIES_symbolfiledwarf

Functions

bool IsStructOrClassTag (llvm::dwarf::Tag Tag)
static PluginProperties & GetGlobalPluginProperties ()
static const llvm::DWARFDebugLine::LineTable * ParseLLVMLineTable (DWARFContext &context, llvm::DWARFDebugLine &line, dw_offset_t line_offset, dw_offset_t unit_offset)
static bool ParseLLVMLineTablePrologue (DWARFContext &context, llvm::DWARFDebugLine::Prologue &prologue, dw_offset_t line_offset, dw_offset_t unit_offset)
static std::optional< std::string > GetFileByIndex (const llvm::DWARFDebugLine::Prologue &prologue, size_t idx, llvm::StringRef compile_dir, FileSpec::Style style)
static void ParseSupportFilesFromPrologue (SupportFileList &support_files, const lldb::ModuleSP &module, const llvm::DWARFDebugLine::Prologue &prologue, FileSpec::Style style, llvm::StringRef compile_dir={})
static ConstString GetDWARFMachOSegmentName ()
static std::set< dw_form_tGetUnsupportedForms (llvm::DWARFDebugAbbrev *debug_abbrev)
static void MakeAbsoluteAndRemap (FileSpec &file_spec, DWARFUnit &dwarf_cu, const ModuleSP &module_sp)
 Make an absolute path out of file_spec and remap it using the module's source remapping dictionary.
static const char * GetDWOName (DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
 Return the DW_AT_(GNU_)dwo_name.
static std::optional< uint64_t > GetDWOId (DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
 Return the DW_AT_(GNU_)dwo_id.
static llvm::StringRef ClangToItaniumCtorKind (clang::CXXCtorType kind)
static llvm::StringRef ClangToItaniumDtorKind (clang::CXXDtorType kind)
static llvm::StringRef GetItaniumCtorDtorVariant (llvm::StringRef discriminator)
static bool SplitTemplateParams (llvm::StringRef fullname, llvm::StringRef &basename, llvm::StringRef &template_params)
 Split a name up into a basename and template parameters.
static bool UpdateCompilerContextForSimpleTemplateNames (TypeQuery &match)
static DWARFExpressionList GetExprListFromAtLocation (DWARFFormValue form_value, ModuleSP module, const DWARFDIE &die, const addr_t func_low_pc)
 Creates a DWARFExpressionList from an DW_AT_location form_value.
static DWARFExpressionList GetExprListFromAtConstValue (DWARFFormValue form_value, ModuleSP module, const DWARFDIE &die)
 Creates a DWARFExpressionList from an DW_AT_const_value.
static SymbolfixupExternalAddrZeroVariable (SymbolFileDWARFDebugMap &debug_map_symfile, llvm::StringRef name, DWARFExpressionList &expr_list, const DWARFDIE &die)
 Global variables that are not initialized may have their address set to zero.
static CallSiteParameterArray CollectCallSiteParameters (ModuleSP module, DWARFDIE call_site_die)
 Collect call site parameters in a DW_TAG_call_site DIE.

Macro Definition Documentation

◆ DEBUG_PRINTF

#define DEBUG_PRINTF ( fmt,
... )

Definition at line 104 of file SymbolFileDWARF.cpp.

◆ LLDB_PROPERTIES_symbolfiledwarf [1/2]

#define LLDB_PROPERTIES_symbolfiledwarf

Definition at line 118 of file SymbolFileDWARF.cpp.

◆ LLDB_PROPERTIES_symbolfiledwarf [2/2]

#define LLDB_PROPERTIES_symbolfiledwarf

Definition at line 118 of file SymbolFileDWARF.cpp.

Function Documentation

◆ ClangToItaniumCtorKind()

llvm::StringRef ClangToItaniumCtorKind ( clang::CXXCtorType kind)
static

Definition at line 2492 of file SymbolFileDWARF.cpp.

Referenced by GetItaniumCtorDtorVariant().

◆ ClangToItaniumDtorKind()

llvm::StringRef ClangToItaniumDtorKind ( clang::CXXDtorType kind)
static

Definition at line 2508 of file SymbolFileDWARF.cpp.

Referenced by GetItaniumCtorDtorVariant().

◆ CollectCallSiteParameters()

◆ fixupExternalAddrZeroVariable()

Symbol * fixupExternalAddrZeroVariable ( SymbolFileDWARFDebugMap & debug_map_symfile,
llvm::StringRef name,
DWARFExpressionList & expr_list,
const DWARFDIE & die )
static

Global variables that are not initialized may have their address set to zero.

Since multiple variables may have this address, we cannot apply the OSO relink address approach we normally use. However, the executable will have a matching symbol with a good address; this function attempts to find the correct address by looking into the executable's symbol table. If it succeeds, the expr_list is updated with the new address and the executable's symbol is returned.

Definition at line 3534 of file SymbolFileDWARF.cpp.

References lldb_private::Symtab::eDebugYes, lldb::eSymbolTypeData, lldb_private::Symtab::eVisibilityExtern, lldb_private::Symtab::FindFirstSymbolWithNameAndType(), lldb_private::Symbol::GetAddressRef(), lldb_private::plugin::dwarf::DWARFBaseDIE::GetCU(), lldb_private::Address::GetFileAddress(), lldb_private::DWARFExpressionList::GetMutableExpressionAtAddress(), lldb_private::SymbolFileCommon::GetObjectFile(), lldb_private::ObjectFile::GetSymtab(), LLDB_INVALID_ADDRESS, lldb_private::DWARFExpression::Update_DW_OP_addr(), and lldb_private::Symbol::ValueIsAddress().

Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::ParseVariableDIE().

◆ GetDWARFMachOSegmentName()

ConstString GetDWARFMachOSegmentName ( )
static

◆ GetDWOId()

std::optional< uint64_t > GetDWOId ( DWARFCompileUnit & dwarf_cu,
const DWARFDebugInfoEntry & cu_die )
static

Return the DW_AT_(GNU_)dwo_id.

Definition at line 1755 of file SymbolFileDWARF.cpp.

References lldb_private::plugin::dwarf::DWARFDebugInfoEntry::GetAttributeValueAsOptionalUnsigned().

◆ GetDWOName()

◆ GetExprListFromAtConstValue()

◆ GetExprListFromAtLocation()

◆ GetFileByIndex()

std::optional< std::string > GetFileByIndex ( const llvm::DWARFDebugLine::Prologue & prologue,
size_t idx,
llvm::StringRef compile_dir,
FileSpec::Style style )
static

Definition at line 205 of file SymbolFileDWARF.cpp.

◆ GetGlobalPluginProperties()

PluginProperties & GetGlobalPluginProperties ( )
static

Definition at line 149 of file SymbolFileDWARF.cpp.

◆ GetItaniumCtorDtorVariant()

llvm::StringRef GetItaniumCtorDtorVariant ( llvm::StringRef discriminator)
static

◆ GetUnsupportedForms()

std::set< dw_form_t > GetUnsupportedForms ( llvm::DWARFDebugAbbrev * debug_abbrev)
static

◆ IsStructOrClassTag()

◆ MakeAbsoluteAndRemap()

void MakeAbsoluteAndRemap ( FileSpec & file_spec,
DWARFUnit & dwarf_cu,
const ModuleSP & module_sp )
static

◆ ParseLLVMLineTable()

◆ ParseLLVMLineTablePrologue()

◆ ParseSupportFilesFromPrologue()

void ParseSupportFilesFromPrologue ( SupportFileList & support_files,
const lldb::ModuleSP & module,
const llvm::DWARFDebugLine::Prologue & prologue,
FileSpec::Style style,
llvm::StringRef compile_dir = {} )
static

Wrap a path for an in-DWARF source file. Lazily write it to disk when Materialize() is called.

The file contents buffer.

Deletes the temporary file at the end.

Write the file contents to a temporary file.

Definition at line 221 of file SymbolFileDWARF.cpp.

Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::GetTypeUnitSupportFiles(), and lldb_private::plugin::dwarf::SymbolFileDWARF::ParseSupportFiles().

◆ SplitTemplateParams()

bool SplitTemplateParams ( llvm::StringRef fullname,
llvm::StringRef & basename,
llvm::StringRef & template_params )
static

Split a name up into a basename and template parameters.

Definition at line 2809 of file SymbolFileDWARF.cpp.

Referenced by UpdateCompilerContextForSimpleTemplateNames().

◆ UpdateCompilerContextForSimpleTemplateNames()

bool UpdateCompilerContextForSimpleTemplateNames ( TypeQuery & match)
static