[Lldb-commits] [PATCH] D53375: [PDB] Improve performance of the PDB DIA plugin
aleksandr.urakov added a comment. In https://reviews.llvm.org/D53375#1271336, @Hui wrote: > I think parsing types e.g. SymbolFilePDB::ParseTypes also has speed bumps. > Will be good to have them cached too. We are already caching them, see `m_types` field. Repository: rLLDB LLDB https://reviews.llvm.org/D53375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added a comment. I think that it's worth it to rewrite the test with LIT and FileCheck because the python approach has some limitations, e.g. timeouts. You can find examples in `lldb/lit/tools/lldb-mi/`. Comment at: tools/lldb-mi/MICmdCmdGdbShow.cpp:369 +const CMIUtilString strOption(vrWords[0]); +if (CMIUtilString::Compare(strOption, "pending")) { +if (!m_rLLDBDebugSessionInfo.SharedDataRetrieve("breakpoint.pending", m_strValue)) { Following LLVM coding standarts, we should use early exits. In this case it might be like: ``` if (!CMIUtilString::Compare(strOption, "pending")) { // process error here } // success case here ... ``` https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345013 - [PDB] Improve performance of the PDB DIA plugin
Author: aleksandr.urakov Date: Tue Oct 23 01:29:17 2018 New Revision: 345013 URL: http://llvm.org/viewvc/llvm-project?rev=345013&view=rev Log: [PDB] Improve performance of the PDB DIA plugin Summary: This patch improves performance of `SymbolFilePDB` on huge executables in two ways: - cache names of public symbols by address. When creating variables we are trying to get a mangled name for each one, and in `GetMangledForPDBData` we are enumerating all public symbols, which takes O(n) for each variable. With the cache we can retrieve a mangled name in O(log(n)); - cache section contributions. When parsing variables for context we are enumerating all variables and check if the current one is belonging to the current compiland. So we are retrieving a compiland ID for the variable. But in `PDBSymbolData::getCompilandId` for almost every variable we are enumerating all section contributions to check if the variable is belonging to it, and get a compiland ID from the section contribution if so. It takes O(n) for each variable, but with caching it takes about O(log(n)). I've placed the cache in `SymbolFilePDB` and have created `GetCompilandId` there. It actually duplicates `PDBSymbolData::getCompilandId` except for the cache part. Another option is to support caching in `PDBSymbolData::getCompilandId` and to place cache in `DIASession`, but it seems that the last one doesn't imply such functionality, because it's a lightweight wrapper over DIA and whole its state is only a COM pointer to the DIA session. Moreover, `PDBSymbolData::getCompilandId` is used only inside of `SymbolFilePDB`, so I think that it's not a bad place to do such things. With this patch `PDBSymbolData::getCompilandId` is not used at all. This bottlenecks were found with profiling. I've discovered these on a simple demo project of Unreal Engine (x86 executable ~72M, PDB ~82M). This patch doesn't change external behavior of the plugin, so I think that there's no need for additional testing (already existing tests should warn us about regress, if any). Reviewers: zturner, asmith, labath Reviewed By: asmith Subscribers: Hui, lldb-commits, stella.stamenova Tags: #lldb Differential Revision: https://reviews.llvm.org/D53375 Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=345013&r1=345012&r2=345013&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Tue Oct 23 01:29:17 2018 @@ -534,7 +534,7 @@ SymbolFilePDB::ParseVariablesForContext( auto results = m_global_scope_up->findAllChildren(); if (results && results->getChildCount()) { while (auto result = results->getNext()) { -auto cu_id = result->getCompilandId(); +auto cu_id = GetCompilandId(*result); // FIXME: We are not able to determine variable's compile unit. if (cu_id == 0) continue; @@ -853,24 +853,16 @@ uint32_t SymbolFilePDB::ResolveSymbolCon } std::string SymbolFilePDB::GetMangledForPDBData(const PDBSymbolData &pdb_data) { - std::string decorated_name; - auto vm_addr = pdb_data.getVirtualAddress(); - if (vm_addr != LLDB_INVALID_ADDRESS && vm_addr) { -auto result_up = -m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol); -if (result_up) { - while (auto symbol_up = result_up->getNext()) { -if (symbol_up->getRawSymbol().getVirtualAddress() == vm_addr) { - decorated_name = symbol_up->getRawSymbol().getName(); - break; -} - } -} - } - if (!decorated_name.empty()) -return decorated_name; + // Cache public names at first + if (m_public_names.empty()) +if (auto result_up = +m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol)) + while (auto symbol_up = result_up->getNext()) +if (auto addr = symbol_up->getRawSymbol().getVirtualAddress()) + m_public_names[addr] = symbol_up->getRawSymbol().getName(); - return std::string(); + // Look up the name in the cache + return m_public_names.lookup(pdb_data.getVirtualAddress()); } VariableSP SymbolFilePDB::ParseVariableForPDBData( @@ -1070,15 +1062,15 @@ uint32_t SymbolFilePDB::FindGlobalVariab sc.module_sp = m_obj_file->GetModule(); lldbassert(sc.module_sp.get()); -sc.comp_unit = ParseCompileUnitForUID(pdb_data->getCompilandId()).get(); -// FIXME: We are not able to determine the compile unit. -if (sc.comp_unit == nullptr) - continue; - if (!name.GetStringRef().equals( PDBASTParser::PDBNameDropScope(pdb_data->getName( continue; +
[Lldb-commits] [PATCH] D53375: [PDB] Improve performance of the PDB DIA plugin
This revision was automatically updated to reflect the committed changes. Closed by commit rL345013: [PDB] Improve performance of the PDB DIA plugin (authored by aleksandr.urakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53375?vs=170004&id=170584#toc Repository: rL LLVM https://reviews.llvm.org/D53375 Files: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h === --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -169,6 +169,13 @@ const llvm::pdb::IPDBSession &GetPDBSession() const; private: + struct SecContribInfo { +uint32_t Offset; +uint32_t Size; +uint32_t CompilandId; + }; + using SecContribsMap = std::map>; + lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id, uint32_t index = UINT32_MAX); @@ -227,9 +234,14 @@ bool DeclContextMatchesThisSymbolFile( const lldb_private::CompilerDeclContext *decl_ctx); + uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data); + llvm::DenseMap m_comp_units; llvm::DenseMap m_types; llvm::DenseMap m_variables; + llvm::DenseMap m_public_names; + + SecContribsMap m_sec_contribs; std::vector m_builtin_types; std::unique_ptr m_session_up; Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -534,7 +534,7 @@ auto results = m_global_scope_up->findAllChildren(); if (results && results->getChildCount()) { while (auto result = results->getNext()) { -auto cu_id = result->getCompilandId(); +auto cu_id = GetCompilandId(*result); // FIXME: We are not able to determine variable's compile unit. if (cu_id == 0) continue; @@ -853,24 +853,16 @@ } std::string SymbolFilePDB::GetMangledForPDBData(const PDBSymbolData &pdb_data) { - std::string decorated_name; - auto vm_addr = pdb_data.getVirtualAddress(); - if (vm_addr != LLDB_INVALID_ADDRESS && vm_addr) { -auto result_up = -m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol); -if (result_up) { - while (auto symbol_up = result_up->getNext()) { -if (symbol_up->getRawSymbol().getVirtualAddress() == vm_addr) { - decorated_name = symbol_up->getRawSymbol().getName(); - break; -} - } -} - } - if (!decorated_name.empty()) -return decorated_name; + // Cache public names at first + if (m_public_names.empty()) +if (auto result_up = +m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol)) + while (auto symbol_up = result_up->getNext()) +if (auto addr = symbol_up->getRawSymbol().getVirtualAddress()) + m_public_names[addr] = symbol_up->getRawSymbol().getName(); - return std::string(); + // Look up the name in the cache + return m_public_names.lookup(pdb_data.getVirtualAddress()); } VariableSP SymbolFilePDB::ParseVariableForPDBData( @@ -1070,15 +1062,15 @@ sc.module_sp = m_obj_file->GetModule(); lldbassert(sc.module_sp.get()); -sc.comp_unit = ParseCompileUnitForUID(pdb_data->getCompilandId()).get(); -// FIXME: We are not able to determine the compile unit. -if (sc.comp_unit == nullptr) - continue; - if (!name.GetStringRef().equals( PDBASTParser::PDBNameDropScope(pdb_data->getName( continue; +sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get(); +// FIXME: We are not able to determine the compile unit. +if (sc.comp_unit == nullptr) + continue; + auto actual_parent_decl_ctx = GetDeclContextContainingUID(result->getSymIndexId()); if (actual_parent_decl_ctx != *parent_decl_ctx) @@ -1116,7 +1108,7 @@ sc.module_sp = m_obj_file->GetModule(); lldbassert(sc.module_sp.get()); -sc.comp_unit = ParseCompileUnitForUID(pdb_data->getCompilandId()).get(); +sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get(); // FIXME: We are not able to determine the compile unit. if (sc.comp_unit == nullptr) continue; @@ -1882,3 +1874,68 @@ return false; } + +uint32_t SymbolFilePDB::GetCompilandId(const llvm::pdb::PDBSymbolData &data) { + static const auto pred_upper = [](uint32_t lhs, SecContribInfo rhs) { +return lhs < rhs.Offset; + }; + + // Cache section contributions + if (m_sec_contribs.empty()) { +if (auto SecContribs = m_session_up->getSectionContribs()) { + while (auto SectionContrib = SecContribs->getNext()) { +auto comp_id = Sec
Re: [Lldb-commits] [lldb] r344982 - [ValueObject] Stop assuming types are non-zero sized.
You maybe able to add a test for that in C++: Clang types can have 0 size, the padding from 0 to 1 happens in the CodeGen IIRC. See also this bug: https://bugs.llvm.org/show_bug.cgi?id=31612 - Raphael Am Di., 23. Okt. 2018 um 02:33 Uhr schrieb Davide Italiano via lldb-commits : > > Author: davide > Date: Mon Oct 22 17:31:46 2018 > New Revision: 344982 > > URL: http://llvm.org/viewvc/llvm-project?rev=344982&view=rev > Log: > [ValueObject] Stop assuming types are non-zero sized. > > Some backends might violate this assumption. No test case > upstream unfortunately as this is not the case with C++, > but I'm going to add a test in swift language support. > > > > Modified: > lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > > Modified: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp?rev=344982&r1=344981&r2=344982&view=diff > == > --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp (original) > +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp Mon Oct 22 17:31:46 > 2018 > @@ -77,7 +77,13 @@ ValueObject *ValueObjectConstResultImpl: >ignore_array_bounds, child_name_str, child_byte_size, > child_byte_offset, >child_bitfield_bit_size, child_bitfield_bit_offset, > child_is_base_class, >child_is_deref_of_parent, m_impl_backend, language_flags); > - if (child_compiler_type && child_byte_size) { > + > + // One might think we should check that the size of the children > + // is always strictly positive, hence we could avoid creating a > + // ValueObject if that's not the case, but it turns out there > + // are languages out there which allow zero-size types with > + // children (e.g. Swift). > + if (child_compiler_type) { > if (synthetic_index) >child_byte_offset += child_byte_size * synthetic_index; > > > > ___ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB345016: [LLDB] - Implement the support for the .debug_loclists section. (authored by grimar, committed by ). Herald added a subscriber: abidh. Repository: rLLDB LLDB https://reviews.llvm.org/D53436 Files: include/lldb/Expression/DWARFExpression.h include/lldb/lldb-enumerations.h source/Core/Section.cpp source/Expression/DWARFExpression.cpp source/Expression/IRExecutionUnit.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp source/Symbol/ObjectFile.cpp Index: include/lldb/Expression/DWARFExpression.h === --- include/lldb/Expression/DWARFExpression.h +++ include/lldb/Expression/DWARFExpression.h @@ -41,6 +41,7 @@ NonLocationList, // Not a location list RegularLocationList, // Location list format used in non-split dwarf files SplitDwarfLocationList, // Location list format used in split dwarf files +LocLists, // Location list format used in DWARF v5 (.debug_loclists). }; //-- Index: include/lldb/lldb-enumerations.h === --- include/lldb/lldb-enumerations.h +++ include/lldb/lldb-enumerations.h @@ -676,6 +676,7 @@ eSectionTypeOther, eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists + eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists }; FLAGS_ENUM(EmulateInstructionOptions){ Index: source/Core/Section.cpp === --- source/Core/Section.cpp +++ source/Core/Section.cpp @@ -77,6 +77,8 @@ return "dwarf-line-str"; case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; + case eSectionTypeDWARFDebugLocLists: +return "dwarf-loclists"; case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; case eSectionTypeDWARFDebugMacro: Index: source/Symbol/ObjectFile.cpp === --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -352,6 +352,7 @@ case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp === --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1199,6 +1199,7 @@ case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: @@ -1457,6 +1458,7 @@ static ConstString g_sect_name_dwarf_debug_info("__debug_info"); static ConstString g_sect_name_dwarf_debug_line("__debug_line"); static ConstString g_sect_name_dwarf_debug_loc("__debug_loc"); + static ConstString g_sect_name_dwarf_debug_loclists("__debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo("__debug_macinfo"); static ConstString g_sect_name_dwarf_debug_names("__debug_names"); static ConstString g_sect_name_dwarf_debug_pubnames("__debug_pubnames"); @@ -1486,6 +1488,8 @@ return eSectionTypeDWARFDebugLine; if (section_name == g_sect_name_dwarf_debug_loc) return eSectionTypeDWARFDebugLoc; + if (section_name == g_sect_name_dwarf_debug_loclists) +return eSectionTypeDWARFDebugLocLists; if (section_name == g_sect_name_dwarf_debug_macinfo) return eSectionTypeDWARFDebugMacInfo; if (section_name == g_sect_name_dwarf_debug_names) Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp === --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -691,6 +691,7 @@ static ConstString g_sect_name_dwarf_debug_info(".debug_info"); static ConstString g_sect_name_dwarf_debug_line(".debug_line"); static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); +static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists"); st
[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.
This revision was automatically updated to reflect the committed changes. Closed by commit rL345016: [LLDB] - Implement the support for the .debug_loclists section. (authored by grimar, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53436?vs=170468&id=170595#toc Repository: rL LLVM https://reviews.llvm.org/D53436 Files: lldb/trunk/include/lldb/Expression/DWARFExpression.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Expression/IRExecutionUnit.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp lldb/trunk/source/Symbol/ObjectFile.cpp Index: lldb/trunk/source/Core/Section.cpp === --- lldb/trunk/source/Core/Section.cpp +++ lldb/trunk/source/Core/Section.cpp @@ -77,6 +77,8 @@ return "dwarf-line-str"; case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; + case eSectionTypeDWARFDebugLocLists: +return "dwarf-loclists"; case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; case eSectionTypeDWARFDebugMacro: Index: lldb/trunk/source/Symbol/ObjectFile.cpp === --- lldb/trunk/source/Symbol/ObjectFile.cpp +++ lldb/trunk/source/Symbol/ObjectFile.cpp @@ -352,6 +352,7 @@ case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp === --- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -691,6 +691,7 @@ static ConstString g_sect_name_dwarf_debug_info(".debug_info"); static ConstString g_sect_name_dwarf_debug_line(".debug_line"); static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); +static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); static ConstString g_sect_name_dwarf_debug_names(".debug_names"); static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames"); @@ -736,6 +737,8 @@ section_type = eSectionTypeDWARFDebugLine; else if (const_sect_name == g_sect_name_dwarf_debug_loc) section_type = eSectionTypeDWARFDebugLoc; +else if (const_sect_name == g_sect_name_dwarf_debug_loclists) + section_type = eSectionTypeDWARFDebugLocLists; else if (const_sect_name == g_sect_name_dwarf_debug_macinfo) section_type = eSectionTypeDWARFDebugMacInfo; else if (const_sect_name == g_sect_name_dwarf_debug_names) Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1790,6 +1790,7 @@ static ConstString g_sect_name_dwarf_debug_line(".debug_line"); static ConstString g_sect_name_dwarf_debug_line_str(".debug_line_str"); static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); + static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); static ConstString g_sect_name_dwarf_debug_macro(".debug_macro"); static ConstString g_sect_name_dwarf_debug_names(".debug_names"); @@ -1807,6 +1808,7 @@ static ConstString g_sect_name_dwarf_debug_line_str_dwo(".debug_line_str.dwo"); static ConstString g_sect_name_dwarf_debug_macro_dwo(".debug_macro.dwo"); static ConstString g_sect_name_dwarf_debug_loc_dwo(".debug_loc.dwo"); + static ConstString g_sect_name_dwarf_debug_loclists_dwo(".debug_loclists.dwo"); static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo"); static ConstString g_sect_name_dwarf_debug_str_offsets_dwo( ".debug_str_offsets.dwo"); @@ -1868,6 +1870,8 @@ sect_type = eSectionTypeDWARFDebugLineStr; else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARF
[Lldb-commits] [PATCH] D53361: [API] Extend the `SBThreadPlan` interface
aleksandr.urakov added a comment. Ok, I'll do it, thanks! Repository: rLLDB LLDB https://reviews.llvm.org/D53361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53368: [Symbol] Search symbols with name and type in a symbol file
aleksandr.urakov added a comment. Ok, I'll reimplement this, thanks! Repository: rLLDB LLDB https://reviews.llvm.org/D53368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53506: [ClangASTContext] Extract VTable pointers from C++ objects
aleksandr.urakov added a reviewer: zturner. aleksandr.urakov added a comment. In https://reviews.llvm.org/D53506#1270933, @zturner wrote: > So, the point is, just because we don't have access to the info via DIA > doesn't mean we won't have access to the info once the native pdb plugin is > complete. Just something to think about. Yes, I also try to see low-level PDB dumps now (since the case with FPO :) ), but in this case it seems that we still have no required info to retrieve VBase offsets. Consider the following example: struct A { int a = 1; }; struct B : virtual A { int b = 2; }; struct C : virtual A { int c = 3; }; struct D : virtual B, virtual C { int d = 4; }; int main() { D d{}; return 0; } Here for `D` we have the next `LF_FIELDLIST` (assume that the application is MSVC compiled): 0x1016 | LF_FIELDLIST [size = 96, hash = 0x415A] - LF_VBCLASS base = 0x1002, vbptr = 0x1004, vbptr offset = 0, vtable index = 2 attrs = public - LF_VBCLASS base = 0x1005, vbptr = 0x1004, vbptr offset = 0, vtable index = 3 attrs = public - LF_IVBCLASS base = 0x1006, vbptr = 0x1004, vbptr offset = 0, vtable index = 1 attrs = public - LF_MEMBER [name = `d`, Type = 0x0074 (int), offset = 4, attrs = public] - LF_METHOD [name = `D`, # overloads = 3, overload list = 0x1011] - LF_METHOD [name = `operator=`, # overloads = 2, overload list = 0x1015] 0x1017 | LF_STRUCTURE [size = 32, hash = 0xC4D] `D` unique name: `.?AUD@@` vtable: , base list: , field list: 0x1016 options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 28 `vbptr offset` here is an offset to VBTable pointer, not to VBase. `MicrosoftRecordLayoutBuilder` requires exactly offsets to VBases as if they were non-virtual base classes. In general it is wrong, but it works ok if we know a real full type of the variable. `ClangASTContext` when retrieving a virtual base offset tries at first to retrieve it in the "fair" way: - retrieve the pointer to VTable; - read the offset to the VBase from VTable. If it fails somewhere, then it gets the VBase offset from the record layout. It is an "unfair" VBase offset, which was put there by `MicrosoftRecordLayoutBuilder`. And what I mean is that we have no info about it in PDB (to give it to `MicrosoftRecordLayoutBuilder`). What this patch makes is it allows the "fair" way to work in the case, when an object is already read from the debuggee. Then we will have `eAddressTypeHost` as an address type of `ValueObject`, and it used to lead to the situation when the "fair" way is failing and the "unfair" way is used. This patch allows to still process it by the "fair" way. To make things more clear consider the structures layout: class A size(4): +--- 0| a +--- class B size(12): +--- 0| {vbptr} 4| b +--- +--- (virtual base A) 8| a +--- class C size(12): +--- 0| {vbptr} 4| c +--- +--- (virtual base A) 8| a +--- class D size(28): +--- 0| {vbptr} 4| d +--- +--- (virtual base A) 8| a +--- +--- (virtual base B) 12| {vbptr} 16| b +--- +--- (virtual base C) 20| {vbptr} 24| c +--- `MicrosoftRecordsLayoutBuilder` waits that we will give it 8 as the VBase offset for `A` in `B`, `C` and `D`. In `D` for `B` it wants 12, and for `C` it wants 20. It's an info we are missing in PDB. Also this example can show how this patch should improve behavior on non-Windows too. If you will stand on `return 0` and call `print d`, then an invalid value should be printed for `A` inside `B` or `C`. If you call `frame variable d` then the value printed should be ok. It's because in the first case an object is already fully read from the debuggee, and without the patch the "unfair" way works, and it uses the offset to `A` from `B` (or `C`) as if `B` (or `C`) would be a real type of the variable (for the layout above it would use 8). But the real type is `D`, so offsets to `A` from `B` (or `C`) inside `D` are different (for the layout above it would be -4 from `B` and -12 from `C`). That's why "unfair" way doesn't work in this case. This patch should also fix it. Repository: rLLDB LLDB https://reviews.llvm.org/D53506 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)
grimar added a comment. Ping. https://reviews.llvm.org/D53140 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r344982 - [ValueObject] Stop assuming types are non-zero sized.
This is a little different. It's not an empty structural type, it's a children with zero size, that has an implicit representation (swift uses tagged bits to represent cases in an enumeration, hence IRGen says the size of the type is zero). I don't think there's any equivalent of this in C++, but I might be wrong, so I'll give this a try, but no promises I'll succeed. -- Davide On Tue, Oct 23, 2018 at 2:21 AM Raphael Isemann via lldb-commits wrote: > > You maybe able to add a test for that in C++: Clang types can have 0 > size, the padding from 0 to 1 happens in the CodeGen IIRC. See also > this bug: https://bugs.llvm.org/show_bug.cgi?id=31612 > > - Raphael > Am Di., 23. Okt. 2018 um 02:33 Uhr schrieb Davide Italiano via > lldb-commits : > > > > Author: davide > > Date: Mon Oct 22 17:31:46 2018 > > New Revision: 344982 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=344982&view=rev > > Log: > > [ValueObject] Stop assuming types are non-zero sized. > > > > Some backends might violate this assumption. No test case > > upstream unfortunately as this is not the case with C++, > > but I'm going to add a test in swift language support. > > > > > > > > Modified: > > lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > > > > Modified: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > > URL: > > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp?rev=344982&r1=344981&r2=344982&view=diff > > == > > --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp (original) > > +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp Mon Oct 22 > > 17:31:46 2018 > > @@ -77,7 +77,13 @@ ValueObject *ValueObjectConstResultImpl: > >ignore_array_bounds, child_name_str, child_byte_size, > > child_byte_offset, > >child_bitfield_bit_size, child_bitfield_bit_offset, > > child_is_base_class, > >child_is_deref_of_parent, m_impl_backend, language_flags); > > - if (child_compiler_type && child_byte_size) { > > + > > + // One might think we should check that the size of the children > > + // is always strictly positive, hence we could avoid creating a > > + // ValueObject if that's not the case, but it turns out there > > + // are languages out there which allow zero-size types with > > + // children (e.g. Swift). > > + if (child_compiler_type) { > > if (synthetic_index) > >child_byte_offset += child_byte_size * synthetic_index; > > > > > > > > ___ > > lldb-commits mailing list > > lldb-commits@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits > ___ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53511: [NativePDB] Support type lookup by name
aleksandr.urakov accepted this revision. aleksandr.urakov added a comment. Looks good to me, thank you! https://reviews.llvm.org/D53511 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53530: Fix (and improve) the support for C99 variable length array types
clayborg requested changes to this revision. clayborg added a comment. This revision now requires changes to proceed. Parsing a type shouldn't need an execution context and we shouldn't be re-parsing a type over and over for each frame. We should be encoding the array expression somewhere that we can access it when we need to get the number of children using the current execution context. The way I would prefer to see this: - Revert all SymbolFile changes that added an execution context to type parsing - Change the type parsing logic in SymbolFileDWARF to store the array count expression in some format that is associated with the clang opaque type (clang type metadata maybe?). - Change "virtual uint32_t TypeSystem::GetNumChildren(...);" and "virtual CompilerType TypeSystem::GetChildCompilerTypeAtIndex(...);" to take an execution context that defaults to nothing like you did with the type parsing in the first patch. This execution context can be used to evaluate the count expression as needed. We can attempt to grab the count expression from the clang opaque type that we stored in the above step, and if one exists, use the current frame to evaluate it correctly. Comment at: source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp:213-229 + // Handle variables with incomplete array types. + auto *type = in_value.GetCompilerType().GetOpaqueQualType(); + auto qual_type = clang::QualType::getFromOpaquePtr(type).getCanonicalType(); + if (qual_type->getTypeClass() == clang::Type::IncompleteArray) { +if (auto variable = in_value.GetVariable()) { + auto *lldb_type = variable->GetType(); + auto *symbol_file = lldb_type->GetSymbolFile(); We must abstract this via the TypeSystem stuff and make this happen via the CompilerType interface. What happens when "in_value" is a swift type or other type from the type system? Crash https://reviews.llvm.org/D53530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345047 - [NativePDB] Add basic support for tag types to the native pdb plugin.
Author: zturner Date: Tue Oct 23 09:37:53 2018 New Revision: 345047 URL: http://llvm.org/viewvc/llvm-project?rev=345047&view=rev Log: [NativePDB] Add basic support for tag types to the native pdb plugin. This adds support to LLDB for named types (class, struct, union, and enum). This is true cross platform support, and hits the PDB file directly without a dependency on Windows. Tests are added which compile a program with certain interesting types and then use load the target in LLDB and use "type lookup -- " to dump the layout of the type in LLDB without a running process. Currently only fields are parsed -- we do not parse methods. Also we don't deal with bitfields or virtual bases correctly. Those will make good followups. Differential Revision: https://reviews.llvm.org/D53511 Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit lldb/trunk/lit/SymbolFile/NativePDB/tag-types.cpp lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit?rev=345047&view=auto == --- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit (added) +++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit Tue Oct 23 09:37:53 2018 @@ -0,0 +1,8 @@ +type lookup -- Struct +type lookup -- Class +type lookup -- Union +type lookup -- Derived +type lookup -- Derived2 +type lookup -- EnumInt +type lookup -- EnumShort +type lookup -- InvalidType Added: lldb/trunk/lit/SymbolFile/NativePDB/tag-types.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/tag-types.cpp?rev=345047&view=auto == --- lldb/trunk/lit/SymbolFile/NativePDB/tag-types.cpp (added) +++ lldb/trunk/lit/SymbolFile/NativePDB/tag-types.cpp Tue Oct 23 09:37:53 2018 @@ -0,0 +1,236 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s +// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \ +// RUN: %p/Inputs/tag-types.lldbinit | FileCheck %s + +// Test struct +struct Struct { + // Test builtin types, which are represented by special CodeView type indices. + boolB; + charC; + signed char SC; + unsigned char UC; + char16_tC16; + char32_tC32; + wchar_t WC; + short S; + unsigned short US; + int I; + unsigned intUI; + longL; + unsigned long UL; + long long LL; + unsigned long long ULL; + float F; + double D; + long double LD; +}; + +// Test class +class Class { +public: + // Test pointers to builtin types, which are represented by different special + // CodeView type indices. + bool*PB; + char*PC; + signed char *PSC; + unsigned char *PUC; + char16_t*PC16; + char32_t*PC32; + wchar_t *PWC; + short *PS; + unsigned short *PUS; + int *PI; + unsigned int*PUI; + long*PL; + unsigned long *PUL; + long long *PLL; + unsigned long long *PULL; + float *PF; + double *PD; + long double *PLD; +}; + +// Test union +union Union { + // Test modified types. + const bool*PB; + const char*PC; + const signed char *PSC; + const unsigned char *PUC; + const char16_t*PC16; + const char32_t*PC32; + const wchar_t *PWC; + const short *PS; + const unsigned short *PUS; + const int *PI; + const unsigned int*PUI; + const long*PL; + const unsigned long *PUL; + const long long *PLL; + const unsigned long long *PULL; + const float *PF; + const double *PD; + const long double *PLD; +}; + +struct OneMember { + int N = 0; +}; + + +// Test single inheritance. +class Derived : public Class { +public: + explicit Derived() +: Reference(*this), RefMember(Member), RValueRefMember((OneMember&&)Member) {} + + // Test reference to self, to make sure we don't
[Lldb-commits] [PATCH] D53511: [NativePDB] Support type lookup by name
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB345047: [NativePDB] Add basic support for tag types to the native pdb plugin. (authored by zturner, committed by ). Herald added subscribers: teemperor, abidh. Changed prior to commit: https://reviews.llvm.org/D53511?vs=170447&id=170683#toc Repository: rLLDB LLDB https://reviews.llvm.org/D53511 Files: lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit lit/SymbolFile/NativePDB/tag-types.cpp source/Plugins/SymbolFile/NativePDB/CMakeLists.txt source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h Index: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h === --- source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -10,6 +10,7 @@ #ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H #define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H +#include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Symbol/SymbolFile.h" #include "llvm/ADT/DenseMap.h" @@ -144,22 +145,63 @@ llvm::pdb::PDBFile &GetPDBFile() { return m_index->pdb(); } const llvm::pdb::PDBFile &GetPDBFile() const { return m_index->pdb(); } + ClangASTContext &GetASTContext() { return *m_clang; } + ClangASTImporter &GetASTImporter() { return *m_importer; } + private: + void AddBaseClassesToLayout(CompilerType &derived_ct, + ClangASTImporter::LayoutInfo &layout, + const llvm::codeview::ClassRecord &record); + void AddMembersToLayout(ClangASTImporter::LayoutInfo &layout, + const llvm::codeview::TagRecord &record); + void AddMethodsToLayout(ClangASTImporter::LayoutInfo &layout, + const llvm::codeview::TagRecord &record); + + size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches, + TypeMap &types); + + lldb::TypeSP CreateModifierType(PdbSymUid type_uid, + const llvm::codeview::ModifierRecord &mr); + lldb::TypeSP CreatePointerType(PdbSymUid type_uid, + const llvm::codeview::PointerRecord &pr); + lldb::TypeSP CreateSimpleType(llvm::codeview::TypeIndex ti); + lldb::TypeSP CreateTagType(PdbSymUid type_uid, + const llvm::codeview::ClassRecord &cr); + lldb::TypeSP CreateTagType(PdbSymUid type_uid, + const llvm::codeview::EnumRecord &er); + lldb::TypeSP CreateTagType(PdbSymUid type_uid, + const llvm::codeview::UnionRecord &ur); + lldb::TypeSP + CreateClassStructUnion(PdbSymUid type_uid, llvm::StringRef name, size_t size, + clang::TagTypeKind ttk, + clang::MSInheritanceAttr::Spelling inheritance); + lldb::FunctionSP GetOrCreateFunction(PdbSymUid func_uid, const SymbolContext &sc); lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci); + lldb::TypeSP GetOrCreateType(PdbSymUid type_uid); + lldb::TypeSP GetOrCreateType(llvm::codeview::TypeIndex ti); lldb::FunctionSP CreateFunction(PdbSymUid func_uid, const SymbolContext &sc); lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci); + lldb::TypeSP CreateType(PdbSymUid type_uid); + lldb::TypeSP CreateAndCacheType(PdbSymUid type_uid); llvm::BumpPtrAllocator m_allocator; lldb::addr_t m_obj_load_address = 0; std::unique_ptr m_index; + std::unique_ptr m_importer; + ClangASTContext *m_clang = nullptr; + + llvm::DenseMap m_decl_to_status; + + llvm::DenseMap m_uid_to_decl; llvm::DenseMap m_functions; llvm::DenseMap m_compilands; + llvm::DenseMap m_types; }; } // namespace npdb Index: source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp === --- source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -0,0 +1,188 @@ +#include "UdtRecordCompleter.h" + +#include "PdbIndex.h" +#include "PdbSymUid.h" +#include "PdbUtil.h" +#include "SymbolFileNativePDB.h" + +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" + +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +using namespace llvm::codeview; +using namespace llvm::pdb; +using namespace lldb; +using nam
[Lldb-commits] [lldb] r345055 - Change two methods from const char* to StringRef [NFC].
Author: zturner Date: Tue Oct 23 10:22:02 2018 New Revision: 345055 URL: http://llvm.org/viewvc/llvm-project?rev=345055&view=rev Log: Change two methods from const char* to StringRef [NFC]. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=345055&r1=345054&r2=345055&view=diff == --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Oct 23 10:22:02 2018 @@ -833,7 +833,7 @@ public: // Modifying RecordType //-- static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, -const char *name, +llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size); @@ -843,7 +843,7 @@ public: static void SetIsPacked(const CompilerType &type); static clang::VarDecl *AddVariableToRecordType(const CompilerType &type, - const char *name, + llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=345055&r1=345054&r2=345055&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Oct 23 10:22:02 2018 @@ -3029,7 +3029,7 @@ bool DWARFASTParserClang::ParseChildMemb if (anon_field_info.IsValid()) { clang::FieldDecl *unnamed_bitfield_decl = ClangASTContext::AddFieldToRecordType( -class_clang_type, NULL, +class_clang_type, llvm::StringRef(), m_ast.GetBuiltinTypeForEncodingAndBitSize( eEncodingSint, word_width), accessibility, anon_field_info.bit_size); Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp?rev=345055&r1=345054&r2=345055&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp Tue Oct 23 10:22:02 2018 @@ -108,8 +108,7 @@ Error UdtRecordCompleter::visitKnownMemb lldb::AccessType access = TranslateMemberAccess(static_data_member.getAccess()); ClangASTContext::AddVariableToRecordType( - m_derived_ct, static_data_member.Name.str().c_str(), complete_member_type, - access); + m_derived_ct, static_data_member.Name, complete_member_type, access); // FIXME: Add a PdbSymUid namespace for field list members and update // the m_uid_to_decl map with this decl. @@ -130,8 +129,7 @@ Error UdtRecordCompleter::visitKnownMemb lldb::AccessType access = TranslateMemberAccess(data_member.getAccess()); clang::FieldDecl *decl = ClangASTContext::AddFieldToRecordType( - m_derived_ct, data_member.Name.str().c_str(), complete_member_type, - access, 0); + m_derived_ct, data_member.Name, complete_member_type, access, 0); // FIXME: Add a PdbSymUid namespace for field list members and update // the m_uid_to_decl map with this decl. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=345055&r1=345054&r2=345055&view=diff == --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct 23 10:22:02 2018 @@ -7778,7 +7778,7 @@ ClangASTContext::GetAsObjCInterfaceDecl( } clang::FieldDecl *ClangASTContext::AddFieldToRecordType( -const CompilerType &type, const char *
[Lldb-commits] [lldb] r345061 - Skip test with older versions of clang
Author: jdevlieghere Date: Tue Oct 23 10:49:51 2018 New Revision: 345061 URL: http://llvm.org/viewvc/llvm-project?rev=345061&view=rev Log: Skip test with older versions of clang This was failing for the bots that build with older clangs: http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-clang-5.0.2/ http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-clang-6.0.1/ Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py?rev=345061&r1=345060&r2=345061&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py Tue Oct 23 10:49:51 2018 @@ -15,6 +15,7 @@ class TestTailCallFrameSBAPI(TestBase): # each debug info format. NO_DEBUG_INFO_TESTCASE = True +@skipIf(compiler="clang", compiler_version=['<', '7.0']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265") def test_tail_call_frame_sbapi(self): self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53590: Refactor SetBaseClassesForType and DeleteBaseClasses to be more C++'y
zturner created this revision. zturner added reviewers: labath, davide, clayborg. Herald added a subscriber: JDevlieghere. [NFC] Refactor SetBaseClasses and DeleteBaseClasses. We currently had a 2-step process where we had to call SetBaseClassesForType and DeleteBaseClasses. Every single caller followed this exact 2-step process, and there was manual memory management going on with raw pointers. We can do better than this by storing a vector of unique_ptrs and passing this around. This makes for a cleaner API, and we only need to call one method so there is no possibility of a user forgetting to call DeleteBaseClassSpecifiers. In addition to this, it also makes for a *simpler* API. Part of why I wanted to do this is because when I was implementing the native PDB interface I had to spend some time understanding exactly what I was deleting and why. ClangAST has significant mental overhead associated with it, and reducing the API surface can go along way to making it simpler for people to understand. https://reviews.llvm.org/D53590 Files: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/unittests/Symbol/TestClangASTContext.cpp Index: lldb/unittests/Symbol/TestClangASTContext.cpp === --- lldb/unittests/Symbol/TestClangASTContext.cpp +++ lldb/unittests/Symbol/TestClangASTContext.cpp @@ -337,15 +337,19 @@ EXPECT_NE(nullptr, non_empty_base_field_decl); EXPECT_TRUE(ClangASTContext::RecordHasFields(non_empty_base_decl)); + std::vector> bases; + // Test that a record with no direct fields, but fields in a base returns true CompilerType empty_derived = m_ast->CreateRecordType( nullptr, lldb::eAccessPublic, "EmptyDerived", clang::TTK_Struct, lldb::eLanguageTypeC_plus_plus, nullptr); ClangASTContext::StartTagDeclarationDefinition(empty_derived); - CXXBaseSpecifier *non_empty_base_spec = m_ast->CreateBaseClassSpecifier( - non_empty_base.GetOpaqueQualType(), lldb::eAccessPublic, false, false); - bool result = m_ast->SetBaseClassesForClassType( - empty_derived.GetOpaqueQualType(), &non_empty_base_spec, 1); + std::unique_ptr non_empty_base_spec = + m_ast->CreateBaseClassSpecifier(non_empty_base.GetOpaqueQualType(), + lldb::eAccessPublic, false, false); + bases.push_back(std::move(non_empty_base_spec)); + bool result = m_ast->TransferBaseClasses(empty_derived.GetOpaqueQualType(), + std::move(bases)); ClangASTContext::CompleteTagDeclarationDefinition(empty_derived); EXPECT_TRUE(result); CXXRecordDecl *empty_derived_non_empty_base_cxx_decl = @@ -363,10 +367,12 @@ nullptr, lldb::eAccessPublic, "EmptyDerived2", clang::TTK_Struct, lldb::eLanguageTypeC_plus_plus, nullptr); ClangASTContext::StartTagDeclarationDefinition(empty_derived2); - CXXBaseSpecifier *non_empty_vbase_spec = m_ast->CreateBaseClassSpecifier( - non_empty_base.GetOpaqueQualType(), lldb::eAccessPublic, true, false); - result = m_ast->SetBaseClassesForClassType(empty_derived2.GetOpaqueQualType(), - &non_empty_vbase_spec, 1); + std::unique_ptr non_empty_vbase_spec = + m_ast->CreateBaseClassSpecifier(non_empty_base.GetOpaqueQualType(), + lldb::eAccessPublic, true, false); + bases.push_back(std::move(non_empty_vbase_spec)); + result = m_ast->TransferBaseClasses(empty_derived2.GetOpaqueQualType(), + std::move(bases)); ClangASTContext::CompleteTagDeclarationDefinition(empty_derived2); EXPECT_TRUE(result); CXXRecordDecl *empty_derived_non_empty_vbase_cxx_decl = @@ -377,9 +383,6 @@ empty_derived_non_empty_vbase_cxx_decl, false)); EXPECT_TRUE( ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl)); - - delete non_empty_base_spec; - delete non_empty_vbase_spec; } TEST_F(TestClangASTContext, TemplateArguments) { Index: lldb/source/Symbol/ClangASTContext.cpp === --- lldb/source/Symbol/ClangASTContext.cpp +++ lldb/source/Symbol/ClangASTContext.cpp @@ -8239,39 +8239,37 @@ #pragma mark C++ Base Classes -clang::CXXBaseSpecifier * +std::unique_ptr ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, AccessType access, bool is_virtual, bool base_of_class) { - if (type) -return new clang::CXXBaseSpecifier(
[Lldb-commits] [PATCH] D53532: [FileSpec] Add VFS support
labath added a comment. Back when the FileSystem class was introduced, the idea was that *it* would eventually become the gateway to the real filesystem, and FileSpec would just deal with abstract path manipulation. I still think that is a good idea, particularly in light of this patch. So I would propose to integrate this VFS functionality into that class, and then remove any operations that touch real files from the file spec class. (Also, given that now about 50% of filesystem operations go through FileSpec and the other half through FileSystem (or other methods), any attempts to use FileSpec to control how filenames are interpreted will not be complete). Repository: rLLDB LLDB https://reviews.llvm.org/D53532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
zturner created this revision. zturner added reviewers: clayborg, jingham, labath. Herald added subscribers: atanasyan, JDevlieghere, sdardis. When we get the `resolve_scope` parameter from the SB API, it's a `uint32_t`. We then pass it through all of LLDB this way, as a uint32. This is unfortunate, because it means the user of an API never actually knows what they're dealing with. We can call it something like `resolve_scope` and have comments saying "this is a value from the `SymbolContextItem` enumeration, but it makes more sense to just have it actually *be* the correct type in the actual C++ type system to begin with. This way the person reading the code just knows what it is. There is one thing here which I'm a little uncertain about, which is that I included a file from llvm `llvm/ADT/BitmaskEnum.h` from `lldb/lldb-enumerations.h`, which is a public header.` This is only done for convenience, and has two effects. 1. It allows us to use bitwise operations on enums so we don't have to write things like `Foo x = Foo(eFoo1 | eFoo2)` 2. More subtly, it inserts an enumerator into the enum. But (!) it doesn't change the value of any existing enumerators and it does so with a name that won't cause any clashes, so the important thing is that it shouldn't cause any name clashes. Putting this all together, I think this should be an ABI-compatible change as far as SWIG is concerned, and I can't see any differences on my end. But if anyone can see any reason why we should be wary of this, speak up. Assuming all goes well with this patch, I plan to repeat the same thing with `SymbolFile::GetTypes` which currently has a `uint32_t types_mask` https://reviews.llvm.org/D53597 Files: lldb/include/lldb/Core/Address.h lldb/include/lldb/Core/Module.h lldb/include/lldb/Core/ModuleList.h lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/SymbolVendor.h lldb/include/lldb/Target/StackFrame.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBAddress.cpp lldb/source/API/SBFrame.cpp lldb/source/API/SBModule.cpp lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Core/Address.cpp lldb/source/Core/Disassembler.cpp lldb/source/Core/Module.cpp lldb/source/Core/ModuleList.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/SymbolFile.cpp lldb/source/Symbol/SymbolVendor.cpp lldb/source/Target/StackFrame.cpp Index: lldb/source/Target/StackFrame.cpp === --- lldb/source/Target/StackFrame.cpp +++ lldb/source/Target/StackFrame.cpp @@ -35,6 +35,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-enumerations.h" + using namespace lldb; using namespace lldb_private; @@ -262,7 +264,8 @@ // StackFrame object, everyone will have as much information as possible and no // one will ever have to look things up manually. //-- -const SymbolContext &StackFrame::GetSymbolContext(uint32_t resolve_scope) { +const SymbolContext & +StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { std::lock_guard guard(m_mutex); // Copy our internal symbol context into "sc". if ((m_flags.Get() & resolve_scope) != resolve_scope) { @@ -314,7 +317,7 @@ // haven't already tried to lookup one of those things. If we haven't // then we will do the query. - uint32_t actual_resolve_scope = 0; + SymbolContextItem actual_resolve_scope = SymbolContextItem(0); if (resolve_scope & eSymbolContextCompUnit) { if (m_flags.IsClear(eSymbolContextCompUnit)) { Index: lldb/source/Symbol/SymbolVendor.cpp === --- lldb/source/Symbol/SymbolVendor.cpp +++ lldb/source/Symbol/SymbolVendor.cpp @@ -235,7 +235,7 @@ } uint32_t SymbolVendor::Res
[Lldb-commits] [lldb] r345069 - Add UdtRecordCompleter.cpp.
Author: jmolenda Date: Tue Oct 23 12:03:52 2018 New Revision: 345069 URL: http://llvm.org/viewvc/llvm-project?rev=345069&view=rev Log: Add UdtRecordCompleter.cpp. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=345069&r1=345068&r2=345069&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct 23 12:03:52 2018 @@ -998,6 +998,7 @@ 54067BF11DF2041B00749AA5 /* UBSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */; }; 2579065D1BD0488100178368 /* UDPSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2579065B1BD0488100178368 /* UDPSocket.cpp */; }; 49CA97001E6AACC900C03FEE /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */; }; + AF0578C4217FA80700CF9D80 /* UdtRecordCompleter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */; }; 268900CD13353E5F00698AC0 /* UniqueDWARFASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B8B42312EEC52A00A831B2 /* UniqueDWARFASTType.cpp */; }; 2689010C13353E6F00698AC0 /* UnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00987011500B4300F316B0 /* UnixSignals.cpp */; }; 9A2057201F3B8D2500F6C293 /* UnixSignalsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A20571E1F3B8D2100F6C293 /* UnixSignalsTest.cpp */; }; @@ -3162,6 +3163,8 @@ 2579065B1BD0488100178368 /* UDPSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UDPSocket.cpp; sourceTree = ""; }; 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UUID.cpp; path = source/Utility/UUID.cpp; sourceTree = ""; }; 49CA96F51E6AAC8E00C03FEE /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Utility/UUID.h; sourceTree = ""; }; + AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UdtRecordCompleter.cpp; path = source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp; sourceTree = SOURCE_ROOT; }; + AF0578C1217FA80700CF9D80 /* UdtRecordCompleter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UdtRecordCompleter.h; path = source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h; sourceTree = SOURCE_ROOT; }; 268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = ""; }; 26B8B42312EEC52A00A831B2 /* UniqueDWARFASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueDWARFASTType.cpp; sourceTree = ""; }; 26B8B42212EEC52A00A831B2 /* UniqueDWARFASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueDWARFASTType.h; sourceTree = ""; }; @@ -6925,6 +6928,8 @@ AFD966BE217140C8006714AC /* PdbUtil.h */, AFD966B7217140B6006714AC /* SymbolFileNativePDB.cpp */, AFD966C0217140C8006714AC /* SymbolFileNativePDB.h */, + AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */, + AF0578C1217FA80700CF9D80 /* UdtRecordCompleter.h */, ); name = NativePDB; path = "New Group"; @@ -7865,6 +7870,7 @@ 2689FFFB13353DB600698AC0 /* BreakpointLocationList.cpp in Sources */, AFD966B9217140B6006714AC /* PdbUtil.cpp in Sources */, 2689FFFD13353DB600698AC0 /* BreakpointOptions.cpp in Sources */, + AF0578C4217FA80700CF9D80 /* UdtRecordCompleter.cpp in Sources */, 268913353DB600698AC0 /* BreakpointResolver.cpp in Sources */, 25420ECD1A6490B8009ADBCB /* OptionValueChar.cpp in Sources */, 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm
[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer
kubamracek updated this revision to Diff 170724. kubamracek added a comment. Updating patch, addressing most comments. Changed '-m' to '-s'. Added 'frame recognizer info' subcommand. Improved wording in documentation. I didn't add the possibility to specify multiple '-s' and '-n' args. Do you think I should add this to the first iteration of this or can we leave it as a future improvement? https://reviews.llvm.org/D44603 Files: include/lldb/API/SBVariablesOptions.h include/lldb/Interpreter/OptionGroupVariable.h include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Target/StackFrame.h include/lldb/Target/StackFrameRecognizer.h include/lldb/lldb-forward.h lldb.xcodeproj/project.pbxproj packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py scripts/Python/python-wrapper.swig scripts/interface/SBVariablesOptions.i source/API/SBFrame.cpp source/API/SBVariablesOptions.cpp source/API/SystemInitializerFull.cpp source/Commands/CommandObjectFrame.cpp source/Interpreter/OptionGroupVariable.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h source/Target/CMakeLists.txt source/Target/StackFrame.cpp source/Target/StackFrameRecognizer.cpp www/python-reference.html Index: www/python-reference.html === --- www/python-reference.html +++ www/python-reference.html @@ -928,11 +928,64 @@ # We do have a symbol, print some info for the symbol print symbol - - + + + + + +Writing LLDB frame recognizers in Python + + +Frame recognizers allow for retrieving information about special frames based on +ABI, arguments or other special properties of that frame, even without source +code or debug info. Currently, one use case is to extract function arguments +that would otherwise be unaccesible, or augment existing arguments. + +Adding a custom frame recognizer is done by implementing a Python class +and using the 'frame recognizer add' command. The Python class should have a +'get_recognized_arguments' method and it will receive an argument of type +lldb.SBFrame representing the current frame that we are trying to recognize. +The method should return a (possibly empty) list of lldb.SBValue objects that +represent the recognized arguments. + +An example of a recognizer that retrieves the file descriptor values from libc +functions 'read', 'write' and 'close' follows: + + class LibcFdRecognizer(object): +def get_recognized_arguments(self, frame): + if frame.name in ["read", "write", "close"]: +fd = frame.EvaluateExpression("$arg1").unsigned +value = lldb.target.CreateValueFromExpression("fd", "(int)%d" % fd) +return [value] + return [] + + +The file containing this implementation can be imported via 'command script +import' and then we can register this recognizer with 'frame recognizer add'. +It's important to restrict the recognizer to the libc library (which is +libsystem_kernel.dylib on macOS) to avoid matching functions with the same name in other modules: + +(lldb) command script import .../fd_recognizer.py +(lldb) frame recognizer add -l fd_recognizer.LibcFdRecognizer -n read -s libsystem_kernel.dylib + + +When the program is stopped at the beginning of the 'read' function in libc, we +can view the recognizer arguments in 'frame variable': + +(lldb) b read +(lldb) r +Process 1234 stopped +* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.3 +frame #0: 0x7fff06013ca0 libsystem_kernel.dylib`read +(lldb) frame variable +(int) fd = 3 + - - + + + + + Index: source/Target/StackFrameRecognizer.cpp === --- source/Target/StackFrameRecognizer.cpp +++ source/Target/StackFrameRecognizer.cpp @@ -0,0 +1,191 @@ +//===-- StackFrameRecognizer.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +// C Includes +//
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
jingham added a comment. It would be great not to have to use comments to express what these values mean. OTOH, having to put in static casts whenever you want to or values together would be a pain, so if there's no way to do it without magic, I'm a little less enthused... But on the magic: It looks like BitMaskEnum.h pulls in MathTypes.h which pulls in Compiler.h which then pulls in llvm-config.h. You are supposed to be able to build tools on top of lldb with just the headers that go in LLDB.framework, you are not required to have the full source tree for an lldb build. I don't want to impose that restriction without very good reason, and fixing this wart doesn't rise to that level. Anyway, so if we want to include BitMaskEnum.h we would be required to ship a bunch of llvm headers (including some build produced ones IIUC). I don't think that's a very good idea. It also looks to me like the value of the largest item + 1 gets baked into the operator overloading code. What would happen if we decided to add an element to the enum? https://reviews.llvm.org/D53597 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53590: Refactor SetBaseClassesForType and DeleteBaseClasses to be more C++'y
shafik added a comment. +1 for modernizing code! Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2262 + // assertion in the call to clang_type.TransferBaseClasses() + for (auto &base_class : bases) { clang::TypeSourceInfo *type_source_info = `const auto &` Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:3274 + if (!result) +break; + Is this correct? the if/else below does not seem dependent on this result? https://reviews.llvm.org/D53590 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
zturner added a comment. In https://reviews.llvm.org/D53597#1273087, @jingham wrote: > It would be great not to have to use comments to express what these values > mean. OTOH, having to put in static casts whenever you want to or values > together would be a pain, so if there's no way to do it without magic, I'm a > little less enthused... > > But on the magic: It looks like BitMaskEnum.h pulls in MathTypes.h which > pulls in Compiler.h which then pulls in llvm-config.h. You are supposed to > be able to build tools on top of lldb with just the headers that go in > LLDB.framework, you are not required to have the full source tree for an lldb > build. I don't want to impose that restriction without very good reason, and > fixing this wart doesn't rise to that level. Anyway, so if we want to > include BitMaskEnum.h we would be required to ship a bunch of llvm headers > (including some build produced ones IIUC). I don't think that's a very good > idea. > > It also looks to me like the value of the largest item + 1 gets baked into > the operator overloading code. What would happen if we decided to add an > element to the enum? It's not the largest item +1, it's actually just that the largest item gets a second internal name. If you add a new element to the enum you need to just make sure you update the `LLVM_MARK_AS_BITMASK_ENUM()` to contain the new largest value. Anyway, your point about `llvm-config.h` is a good one, so what I can perhaps do instead is make something called `LLDB_DEFINE_BITMASK_ENUM(EnumName)` which basically just defines the overloads for a particular enum, then we can have it be a two step process. 1. Make the enum, 2. Call `LLDB_DEFINE_BITMASK_ENUM(Enum)`. This way there's no external header dependencies. I'll upload a new patch shortly. https://reviews.llvm.org/D53597 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
jingham added a comment. That would be great! https://reviews.llvm.org/D53597 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53590: Refactor SetBaseClassesForType and DeleteBaseClasses to be more C++'y
zturner added inline comments. Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:3273-3274 + is_virtual, is_base_of_class); + if (!result) +break; + If the result is a `nullptr`, then there is no base to begin with. This indicates an error, so continuing doesn't make sense. In fact, I think this was a bug with the previous implementation. We were pushing back a null base onto the list of base classes. I suspect it never actually happened in practice, though. https://reviews.llvm.org/D53590 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53590: Refactor SetBaseClassesForType and DeleteBaseClasses to be more C++'y
zturner added inline comments. Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:3273-3274 + is_virtual, is_base_of_class); + if (!result) +break; + zturner wrote: > If the result is a `nullptr`, then there is no base to begin with. This > indicates an error, so continuing doesn't make sense. In fact, I think this > was a bug with the previous implementation. We were pushing back a null base > onto the list of base classes. I suspect it never actually happened in > practice, though. One alternative would be to assert that it is *not* null, then continue as the previous code did. WDYT? https://reviews.llvm.org/D53590 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
zturner updated this revision to Diff 170737. zturner added a comment. Remove the reference to `llvm/ADT/BitmaskEnu.h` and define the operators ourselves. Also, removed a few casts that got left in. https://reviews.llvm.org/D53597 Files: lldb/include/lldb/Core/Address.h lldb/include/lldb/Core/Module.h lldb/include/lldb/Core/ModuleList.h lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/SymbolVendor.h lldb/include/lldb/Target/StackFrame.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBAddress.cpp lldb/source/API/SBFrame.cpp lldb/source/API/SBModule.cpp lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Core/Address.cpp lldb/source/Core/Disassembler.cpp lldb/source/Core/Module.cpp lldb/source/Core/ModuleList.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/SymbolFile.cpp lldb/source/Symbol/SymbolVendor.cpp lldb/source/Target/StackFrame.cpp Index: lldb/source/Target/StackFrame.cpp === --- lldb/source/Target/StackFrame.cpp +++ lldb/source/Target/StackFrame.cpp @@ -35,6 +35,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-enumerations.h" + using namespace lldb; using namespace lldb_private; @@ -262,7 +264,8 @@ // StackFrame object, everyone will have as much information as possible and no // one will ever have to look things up manually. //-- -const SymbolContext &StackFrame::GetSymbolContext(uint32_t resolve_scope) { +const SymbolContext & +StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { std::lock_guard guard(m_mutex); // Copy our internal symbol context into "sc". if ((m_flags.Get() & resolve_scope) != resolve_scope) { @@ -314,7 +317,7 @@ // haven't already tried to lookup one of those things. If we haven't // then we will do the query. - uint32_t actual_resolve_scope = 0; + SymbolContextItem actual_resolve_scope = SymbolContextItem(0); if (resolve_scope & eSymbolContextCompUnit) { if (m_flags.IsClear(eSymbolContextCompUnit)) { Index: lldb/source/Symbol/SymbolVendor.cpp === --- lldb/source/Symbol/SymbolVendor.cpp +++ lldb/source/Symbol/SymbolVendor.cpp @@ -235,7 +235,7 @@ } uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr, -uint32_t resolve_scope, +SymbolContextItem resolve_scope, SymbolContext &sc) { ModuleSP module_sp(GetModule()); if (module_sp) { @@ -248,7 +248,7 @@ uint32_t SymbolVendor::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, -uint32_t resolve_scope, +SymbolContextItem resolve_scope, SymbolContextList &sc_list) { ModuleSP module_sp(GetModule()); if (module_sp) { Index: lldb/source/Symbol/SymbolFile.cpp === --- lldb/source/Symbol/SymbolFile.cpp +++ lldb/source/Symbol/SymbolFile.cpp @@ -97,7 +97,7 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { return 0; } Index: lldb/source/Symbol/CompileUnit.cpp === --- lldb/source/Symbol/Co
[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer
aprantl added inline comments. Comment at: include/lldb/Target/StackFrameRecognizer.h:25 + +class RecognizedStackFrame +: std::enable_shared_from_this { Would you mind adding doxygen comments to each of the new classes to explain what they are good for? https://reviews.llvm.org/D44603 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53597: Don't type-erase the SymbolContextItem enum
jingham added a comment. That looks good to me, though you should wait for Greg to weigh in. He might notice something I missed. https://reviews.llvm.org/D53597 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer
jingham added a comment. This is good. The addition of the "info" command will be helpful for people trying to debug their recognizers. It's okay to add multiple -s and -n's later - though the fact that you don't allow "apply to all frames" may make us want the ability to provide more than one option sooner rather than later... Sorry for this thought coming late, but I worry a little bit about the fact that the class name is the recognizers identity, particularly for deleting. I might have a good recognizer class that I want to add to one library, then later in the session want to apply it to another library as well. The second addition will mean that the name now exists twice but with different shared libraries, and then since I only provide the name to "delete" I can't tell which one I've deleted. It also makes the API's a little odd, since the name of the recognizer is important to the commands for handling it, but it isn't clear from the API's that I have to provide a unique name for them. I think it would be better to have the RecognizerManager keep an ID for each recognizer, and have list print and delete take the index. Also, it might be convenient to have "frame recognizer delete" with no arguments query "Do you want to delete all recognizers" and then delete them. That's the way "break delete" works so it's an accepted pattern in lldb. This could be done as a follow-on, however. Comment at: packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py:54 + +self.runCmd("b foo") +self.runCmd("r") Would you mind using: lldbutil.run_break_set_by_symbol(self, "foo") instead of this runCmd. The lldbutil routine will check that the breakpoint got set and error out here if it didn't. That will reduce the head-scratching if for some reason we fail to set the breakpoint and then the test falls over downstream. Comment at: packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py:91 +""" +self.runCmd("b bar") +self.runCmd("c") Also here. https://reviews.llvm.org/D44603 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345086 - Remove unused variable.
Author: echristo Date: Tue Oct 23 14:55:41 2018 New Revision: 345086 URL: http://llvm.org/viewvc/llvm-project?rev=345086&view=rev Log: Remove unused variable. Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=345086&r1=345085&r2=345086&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Tue Oct 23 14:55:41 2018 @@ -868,7 +868,6 @@ TypeSP SymbolFileNativePDB::CreateAndCac lldbassert(record_decl); TypeIndex ti(type_id.index); -CVType cvt = m_index->tpi().getType(ti); m_uid_to_decl[best_uid.toOpaqueId()] = record_decl; m_decl_to_status[record_decl] = DeclStatus(best_uid.toOpaqueId(), Type::eResolveStateForward); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53616: Don't type-erase the FunctionNameType or TypeClass enums
zturner created this revision. zturner added reviewers: davide, jingham, clayborg. Herald added a subscriber: JDevlieghere. This is a followup to https://reviews.llvm.org/D53597, with 2 more enums. Assuming that patch is good, I see no reason why this wasn't isn't good as well, but I'm throwing it out here for review anyway if nothing else as an FYI. I'll wait for a final LGTM on https://reviews.llvm.org/D53597, but assuming that's good, I'll probably submit both of these unless someone has a comment or comments on this one first. I think this is the last of the type-erased enums, so after this, all of our flags enums should be strongly typed through the system. https://reviews.llvm.org/D53616 Files: lldb/include/lldb/Breakpoint/BreakpointResolverName.h lldb/include/lldb/Core/Module.h lldb/include/lldb/Core/ModuleList.h lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/SymbolVendor.h lldb/include/lldb/Target/Target.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBCompileUnit.cpp lldb/source/API/SBModule.cpp lldb/source/API/SBTarget.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Core/Module.cpp lldb/source/Core/ModuleList.cpp lldb/source/Expression/IRExecutionUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/source/Symbol/SymbolFile.cpp lldb/source/Symbol/SymbolVendor.cpp lldb/source/Target/Target.cpp Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -415,12 +415,11 @@ false); } -BreakpointSP -Target::CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_name, uint32_t func_name_type_mask, - LanguageType language, lldb::addr_t offset, - LazyBool skip_prologue, bool internal, bool hardware) { +BreakpointSP Target::CreateBreakpoint( +const FileSpecList *containingModules, +const FileSpecList *containingSourceFiles, const char *func_name, +FunctionNameType func_name_type_mask, LanguageType language, +lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; if (func_name) { SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList( @@ -443,9 +442,9 @@ Target::CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector &func_names, - uint32_t func_name_type_mask, LanguageType language, - lldb::addr_t offset, LazyBool skip_prologue, - bool internal, bool hardware) { + FunctionNameType func_name_type_mask, + LanguageType language, lldb::addr_t offset, + LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; size_t num_names = func_names.size(); if (num_names > 0) { @@ -465,11 +464,13 @@ return bp_sp; } -BreakpointSP Target::CreateBreakpoint( -const FileSpecList *containingModules, -const FileSpecList *containingSourceFiles, const char *func_names[], -size_t num_names, uint32_t func_name_type_mask, LanguageType language, -lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) { +BreakpointSP +Target::CreateBreakpoint(const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, + const char *func_names[], size_t num_names, + FunctionNameType func_name_type_mask, + LanguageType language, lldb::addr_t offset, + LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; if (num_names > 0) { SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList( Index: lldb/source/Symbol/SymbolVendor.cpp === --- lldb/source/Symbol/SymbolVendor.cpp +++ lldb/source/Symbol/SymbolVendor.cpp @@ -288,7 +288,7 @@ size_t SymbolVendor::FindFunctions(const ConstString &name, c
[Lldb-commits] [lldb] r345092 - Remove unused private methods.
Author: zturner Date: Tue Oct 23 15:15:27 2018 New Revision: 345092 URL: http://llvm.org/viewvc/llvm-project?rev=345092&view=rev Log: Remove unused private methods. Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h?rev=345092&r1=345091&r2=345092&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Tue Oct 23 15:15:27 2018 @@ -149,14 +149,6 @@ public: ClangASTImporter &GetASTImporter() { return *m_importer; } private: - void AddBaseClassesToLayout(CompilerType &derived_ct, - ClangASTImporter::LayoutInfo &layout, - const llvm::codeview::ClassRecord &record); - void AddMembersToLayout(ClangASTImporter::LayoutInfo &layout, - const llvm::codeview::TagRecord &record); - void AddMethodsToLayout(ClangASTImporter::LayoutInfo &layout, - const llvm::codeview::TagRecord &record); - size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345091 - Fix some comments pointed out by Leonard Mosescu.
Author: zturner Date: Tue Oct 23 15:15:05 2018 New Revision: 345091 URL: http://llvm.org/viewvc/llvm-project?rev=345091&view=rev Log: Fix some comments pointed out by Leonard Mosescu. These were originally pointed out in D53511 but I forgot to incorporate them in my patch. Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=345091&r1=345090&r2=345091&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Tue Oct 23 15:15:05 2018 @@ -310,7 +310,7 @@ static llvm::StringRef GetSimpleTypeName return "char"; case SimpleTypeKind::SignedCharacter: case SimpleTypeKind::SByte: -return "signed chr"; +return "signed char"; case SimpleTypeKind::Character16: return "char16_t"; case SimpleTypeKind::Character32: @@ -332,7 +332,7 @@ static llvm::StringRef GetSimpleTypeName return "__int128"; case SimpleTypeKind::Int64: case SimpleTypeKind::Int64Quad: -return "__int64"; +return "int64_t"; case SimpleTypeKind::Int32: return "int"; case SimpleTypeKind::Int16: @@ -341,7 +341,7 @@ static llvm::StringRef GetSimpleTypeName return "unsigned __int128"; case SimpleTypeKind::UInt64: case SimpleTypeKind::UInt64Quad: -return "unsigned __int64"; +return "uint64_t"; case SimpleTypeKind::HResult: return "HRESULT"; case SimpleTypeKind::UInt32: @@ -644,7 +644,7 @@ lldb::TypeSP SymbolFileNativePDB::Create TypeSP direct_sp = GetOrCreateType(ti.makeDirect()); CompilerType ct = direct_sp->GetFullCompilerType(); ct = ct.GetPointerType(); -uint32_t pointer_size = 4; +uint32_t pointer_size = 0; switch (ti.getSimpleMode()) { case SimpleTypeMode::FarPointer32: case SimpleTypeMode::NearPointer32: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53094: [pecoff] Implement ObjectFilePECOFF::GetDependedModules()
asmith added a comment. I think this addresses all the previous comments. https://reviews.llvm.org/D53094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53094: [pecoff] Implement ObjectFilePECOFF::GetDependedModules()
asmith updated this revision to Diff 170781. https://reviews.llvm.org/D53094 Files: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h unittests/ObjectFile/CMakeLists.txt unittests/ObjectFile/PECOFF/CMakeLists.txt unittests/ObjectFile/PECOFF/Inputs/BasicsTest.cpp unittests/ObjectFile/PECOFF/Inputs/BasicsTest.exe unittests/ObjectFile/PECOFF/Inputs/DllA.cpp unittests/ObjectFile/PECOFF/Inputs/DllA.dll unittests/ObjectFile/PECOFF/Inputs/DllB.cpp unittests/ObjectFile/PECOFF/Inputs/DllB.dll unittests/ObjectFile/PECOFF/ObjectFilePECOFFTests.cpp Index: unittests/ObjectFile/PECOFF/ObjectFilePECOFFTests.cpp === --- /dev/null +++ unittests/ObjectFile/PECOFF/ObjectFilePECOFFTests.cpp @@ -0,0 +1,134 @@ +//===-- ObjectFilePECOFFTests.cpp ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" +#include "TestingSupport/TestUtilities.h" +#include "lldb/Core/Address.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/Section.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Utility/FileSpec.h" +#include "llvm/Support/Path.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +class ObjectFilePECOFFTests : public testing::Test { +public: + void SetUp() override { +HostInfo::Initialize(); +ObjectFilePECOFF::Initialize(); + +m_BasicsTest_exe = GetInputFilePath("BasicsTest.exe"); +m_DllA = GetInputFilePath("DllA.dll"); +m_DllB = GetInputFilePath("DllB.dll"); + } + + void TearDown() override { +ObjectFilePECOFF::Terminate(); +HostInfo::Terminate(); + } + +protected: + std::string m_BasicsTest_exe; + std::string m_DllA; + std::string m_DllB; +}; + +TEST_F(ObjectFilePECOFFTests, TestPECOFFBasics) { + ModuleSpec spec{FileSpec(m_BasicsTest_exe, false)}; + auto module = std::make_shared(spec); + auto list = module->GetSectionList(); + ASSERT_NE(nullptr, list); + + EXPECT_NE(nullptr, list->FindSectionByName(ConstString(".text"))); + EXPECT_NE(nullptr, list->FindSectionByName(ConstString(".data"))); + EXPECT_NE(nullptr, list->FindSectionByName(ConstString(".reloc"))); + EXPECT_NE(nullptr, list->FindSectionByName(ConstString(".pdata"))); + + auto obj = module->GetObjectFile(); + ASSERT_NE(nullptr, obj); + + EXPECT_STREQ("pe-coff", obj->GetPluginName().AsCString()); + EXPECT_TRUE(obj->IsExecutable()); + + // TODO: Check UUID + + // BasicsTest.exe is compiled without debug information. No exports either. + auto fspecs = obj->GetDebugSymbolFilePaths(); + EXPECT_EQ(0u, fspecs.GetSize()); + + auto symtab = obj->GetSymtab(); + ASSERT_NE(nullptr, symtab); + + EXPECT_EQ(0u, symtab->GetNumSymbols()); +} + +TEST_F(ObjectFilePECOFFTests, TestDLL) { + ModuleSpec spec{FileSpec(m_DllA, false)}; + auto module = std::make_shared(spec); + auto list = module->GetSectionList(); + ASSERT_NE(nullptr, list); + + auto text = list->FindSectionByName(ConstString(".text")); + ASSERT_NE(nullptr, text); + + auto obj = module->GetObjectFile(); + ASSERT_NE(nullptr, obj); + + EXPECT_FALSE(obj->IsExecutable()); + + { +ModuleSpecList specs; +auto fspec = FileSpec(m_DllA, false); +ASSERT_EQ(1u, obj->GetModuleSpecifications(fspec, 0, 0, specs)); + } + + auto symtab = obj->GetSymtab(); + ASSERT_NE(nullptr, symtab); + + ASSERT_EQ(1u, symtab->GetNumSymbols()); + + // DllA.dll is compiled without any debug information. + // We expect the symtab is searched. + auto symbol = + module->FindFirstSymbolWithNameAndType(ConstString("?DllFuncA@@YAHH@Z")); + ASSERT_NE(nullptr, symbol); + + // We expect the symbol is valid. + EXPECT_GT(symbol->GetByteSize(), 0); + EXPECT_EQ(text, symbol->GetAddress().GetSection()); + + // We expect the symbol from symtab has no debug information. + auto Symbol = *symbol; + EXPECT_EQ(nullptr, Symbol.CalculateSymbolContextFunction()); + EXPECT_EQ(0u, Symbol.GetPrologueByteSize()); +} + +TEST_F(ObjectFilePECOFFTests, TestDependModules) { + ModuleSpec spec{FileSpec(m_BasicsTest_exe, false)}; + auto module = std::make_shared(spec); + auto obj = module->GetObjectFile(); + ASSERT_NE(nullptr, obj); + + FileSpecList deps; + auto num_of_deps = obj->GetDependentModules(deps); + ASSERT_EQ(3u, num_of_deps); + + std::vector Deps; + for (uint32_t i = 0; i < num_of_deps; ++i) +Deps.push_back(deps.GetFileSpecAtIndex(i).GetFilename().AsCString()); + llvm::sort(Deps.begin(), Deps.end()); + + EXPECT_STREQ("DllA.dll", Deps[0].c_str()); + EXPECT_STREQ("DllB.dll", Deps[1].c_str()); + EXPECT_STREQ("KERNEL32.dll", Deps[2].c_str(
[Lldb-commits] [PATCH] D53094: [pecoff] Implement ObjectFilePECOFF::GetDependedModules()
zturner added a comment. In https://reviews.llvm.org/D53094#1273556, @asmith wrote: > I think this addresses all the previous comments. Still didn't get a clear answer if the mutex being used needs to be recursive. If it doesn't, perhaps `std::mutex` can be used instead of `std::recursive_mutex`? Not everyone agrees with me, but I often prefer to be too strict rather than too relaxed. https://reviews.llvm.org/D53094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345106 - Support nwere versions of the Segger J-Link jtag board software.
Author: jmolenda Date: Tue Oct 23 16:45:56 2018 New Revision: 345106 URL: http://llvm.org/viewvc/llvm-project?rev=345106&view=rev Log: Support nwere versions of the Segger J-Link jtag board software. Add support in ProcessGDBRemote::GetGDBServerRegisterInfo for recognizing a generic "arm" architecture that will be used if nothing better is available so that we don't ignore the register definitions if we didn't already have an architecture set. Also in ProcessGDBRemote::DoConnectRemote don't set the target arch unless we have a valid architecture to set it to. Platform::ConnectProcess will try to get the current target's architecture, or the default architecture, when creating the target for the connection to be attempted. If lldb was started with a target binary, we want to create this target with that architecture in case the remote gdb stub doesn't supply a qHostInfo arch. Add logging to Target::MergeArchitecture. Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestArmRegisterDefinition.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/Target.cpp Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestArmRegisterDefinition.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestArmRegisterDefinition.py?rev=345106&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestArmRegisterDefinition.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestArmRegisterDefinition.py Tue Oct 23 16:45:56 2018 @@ -0,0 +1,130 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + +class TestArmRegisterDefinition(GDBRemoteTestBase): + +@skipIfXmlSupportMissing +@skipIfRemote +def test(self): +""" +Test lldb's parsing of the tag in the target.xml register +description packet. +""" +class MyResponder(MockGDBServerResponder): + +def qXferRead(self, obj, annex, offset, length): +if annex == "target.xml": +return """ + + +arm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""", False +else: +return None, False + +def readRegister(self, regnum): +return "E01" + +def readRegisters(self): +return "2000f836002000102fcb0008f8360020a0360020200c0020b87f0120b7d100082ed200080001b87f0120" + +def haltReason(self): +return "S05" + +def qfThreadInfo(self): +return "mdead" + +
[Lldb-commits] [PATCH] D48226: [lldb] Remove enableThreadSanitizer from shared Xcode schemes
kubamracek added a reviewer: aprantl. kubamracek added a comment. Ping. https://reviews.llvm.org/D48226 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer
kubamracek updated this revision to Diff 170809. kubamracek added a comment. Adding class comments, adding IDs to recognizers. https://reviews.llvm.org/D44603 Files: include/lldb/API/SBVariablesOptions.h include/lldb/Interpreter/OptionGroupVariable.h include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Target/StackFrame.h include/lldb/Target/StackFrameRecognizer.h include/lldb/lldb-forward.h lldb.xcodeproj/project.pbxproj packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py scripts/Python/python-wrapper.swig scripts/interface/SBVariablesOptions.i source/API/SBFrame.cpp source/API/SBVariablesOptions.cpp source/API/SystemInitializerFull.cpp source/Commands/CommandObjectFrame.cpp source/Interpreter/OptionGroupVariable.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h source/Target/CMakeLists.txt source/Target/StackFrame.cpp source/Target/StackFrameRecognizer.cpp www/python-reference.html Index: www/python-reference.html === --- www/python-reference.html +++ www/python-reference.html @@ -928,11 +928,64 @@ # We do have a symbol, print some info for the symbol print symbol - - + + + + + +Writing LLDB frame recognizers in Python + + +Frame recognizers allow for retrieving information about special frames based on +ABI, arguments or other special properties of that frame, even without source +code or debug info. Currently, one use case is to extract function arguments +that would otherwise be unaccesible, or augment existing arguments. + +Adding a custom frame recognizer is done by implementing a Python class +and using the 'frame recognizer add' command. The Python class should have a +'get_recognized_arguments' method and it will receive an argument of type +lldb.SBFrame representing the current frame that we are trying to recognize. +The method should return a (possibly empty) list of lldb.SBValue objects that +represent the recognized arguments. + +An example of a recognizer that retrieves the file descriptor values from libc +functions 'read', 'write' and 'close' follows: + + class LibcFdRecognizer(object): +def get_recognized_arguments(self, frame): + if frame.name in ["read", "write", "close"]: +fd = frame.EvaluateExpression("$arg1").unsigned +value = lldb.target.CreateValueFromExpression("fd", "(int)%d" % fd) +return [value] + return [] + + +The file containing this implementation can be imported via 'command script +import' and then we can register this recognizer with 'frame recognizer add'. +It's important to restrict the recognizer to the libc library (which is +libsystem_kernel.dylib on macOS) to avoid matching functions with the same name in other modules: + +(lldb) command script import .../fd_recognizer.py +(lldb) frame recognizer add -l fd_recognizer.LibcFdRecognizer -n read -s libsystem_kernel.dylib + + +When the program is stopped at the beginning of the 'read' function in libc, we +can view the recognizer arguments in 'frame variable': + +(lldb) b read +(lldb) r +Process 1234 stopped +* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.3 +frame #0: 0x7fff06013ca0 libsystem_kernel.dylib`read +(lldb) frame variable +(int) fd = 3 + - - + + + + + Index: source/Target/StackFrameRecognizer.cpp === --- source/Target/StackFrameRecognizer.cpp +++ source/Target/StackFrameRecognizer.cpp @@ -0,0 +1,190 @@ +//===-- StackFrameRecognizer.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +// C Includes +// C++ Includes +#include +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Module.h" +#include "lldb/Interpreter/ScriptInterpreter.h" +#include "lldb/Symbol/Symbol.h" +#include "lldb/Target/StackFrame.h" +#include "lldb/Target/StackFra