[Lldb-commits] [lldb] r343180 - [target] Fix typo and give bool a default value
Author: jdevlieghere Date: Wed Sep 26 23:59:15 2018 New Revision: 343180 URL: http://llvm.org/viewvc/llvm-project?rev=343180&view=rev Log: [target] Fix typo and give bool a default value This addresses Stella's review feedback in D51859. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=343180&r1=343179&r2=343180&view=diff == --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Sep 26 23:59:15 2018 @@ -1446,20 +1446,20 @@ void Target::SetExecutableModule(ModuleS FileSpecList dependent_files; ObjectFile *executable_objfile = executable_sp->GetObjectFile(); -bool load_dependens; +bool load_dependents = true; switch (load_dependent_files) { case eLoadDependentsDefault: - load_dependens = executable_sp->IsExecutable(); + load_dependents = executable_sp->IsExecutable(); break; case eLoadDependentsYes: - load_dependens = true; + load_dependents = true; break; case eLoadDependentsNo: - load_dependens = false; + load_dependents = false; break; } -if (executable_objfile && load_dependens) { +if (executable_objfile && load_dependents) { executable_objfile->GetDependentModules(dependent_files); for (uint32_t i = 0; i < dependent_files.GetSize(); i++) { FileSpec dependent_file_spec( ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343181 - Replace pointer to C-array of PropertyDefinition with llvm::ArrayRef
Author: tkrasnukha Date: Thu Sep 27 00:11:58 2018 New Revision: 343181 URL: http://llvm.org/viewvc/llvm-project?rev=343181&view=rev Log: Replace pointer to C-array of PropertyDefinition with llvm::ArrayRef Differential Revision: https://reviews.llvm.org/D52572 Modified: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h lldb/trunk/include/lldb/Interpreter/Property.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/OptionValueProperties.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h?rev=343181&r1=343180&r2=343181&view=diff == --- lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h Thu Sep 27 00:11:58 2018 @@ -62,7 +62,7 @@ public: void Apropos(llvm::StringRef keyword, std::vector &matching_properties) const; - void Initialize(const PropertyDefinition *setting_definitions); + void Initialize(const PropertyDefinitions &setting_definitions); //bool //GetQualifiedName (Stream &strm); Modified: lldb/trunk/include/lldb/Interpreter/Property.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Property.h?rev=343181&r1=343180&r2=343181&view=diff == --- lldb/trunk/include/lldb/Interpreter/Property.h (original) +++ lldb/trunk/include/lldb/Interpreter/Property.h Thu Sep 27 00:11:58 2018 @@ -32,6 +32,8 @@ struct PropertyDefinition { const char *description; }; +using PropertyDefinitions = llvm::ArrayRef; + class Property { public: Property(const PropertyDefinition &definition); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=343181&r1=343180&r2=343181&view=diff == --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 27 00:11:58 2018 @@ -278,8 +278,7 @@ static constexpr PropertyDefinition g_pr {"frame-format-unique", OptionValue::eTypeFormatEntity, true, 0, DEFAULT_FRAME_FORMAT_NO_ARGS, {}, "The default frame format string to use when displaying stack frame" - "information for threads from thread backtrace unique."}, -{nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, {}, nullptr}}; + "information for threads from thread backtrace unique."}}; enum { ePropertyAutoConfirm = 0, Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=343181&r1=343180&r2=343181&view=diff == --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Thu Sep 27 00:11:58 2018 @@ -74,8 +74,7 @@ static constexpr PropertyDefinition g_pr "the UUID of the executable."}, {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr, {}, - "The path to the clang modules cache directory (-fmodules-cache-path)."}, -{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}}; + "The path to the clang modules cache directory (-fmodules-cache-path)."}}; enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath }; Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=343181&r1=343180&r2=343181&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Sep 27 00:11:58 2018 @@ -89,8 +89,7 @@ static constexpr PropertyDefinition g_pr nullptr, {}, "If true, LLDB will stop running a 'command source'
[Lldb-commits] [PATCH] D52572: Replace pointer to C-array of PropertyDefinition with llvm::ArrayRef
This revision was automatically updated to reflect the committed changes. Closed by commit rL343181: Replace pointer to C-array of PropertyDefinition with llvm::ArrayRef (authored by tkrasnukha, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D52572?vs=167191&id=167242#toc Repository: rL LLVM https://reviews.llvm.org/D52572 Files: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h lldb/trunk/include/lldb/Interpreter/Property.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/OptionValueProperties.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp Index: lldb/trunk/include/lldb/Interpreter/Property.h === --- lldb/trunk/include/lldb/Interpreter/Property.h +++ lldb/trunk/include/lldb/Interpreter/Property.h @@ -32,6 +32,8 @@ const char *description; }; +using PropertyDefinitions = llvm::ArrayRef; + class Property { public: Property(const PropertyDefinition &definition); Index: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h === --- lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h +++ lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h @@ -62,7 +62,7 @@ void Apropos(llvm::StringRef keyword, std::vector &matching_properties) const; - void Initialize(const PropertyDefinition *setting_definitions); + void Initialize(const PropertyDefinitions &setting_definitions); //bool //GetQualifiedName (Stream &strm); Index: lldb/trunk/source/Core/ModuleList.cpp === --- lldb/trunk/source/Core/ModuleList.cpp +++ lldb/trunk/source/Core/ModuleList.cpp @@ -74,8 +74,7 @@ "the UUID of the executable."}, {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr, {}, - "The path to the clang modules cache directory (-fmodules-cache-path)."}, -{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}}; + "The path to the clang modules cache directory (-fmodules-cache-path)."}}; enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath }; Index: lldb/trunk/source/Core/Debugger.cpp === --- lldb/trunk/source/Core/Debugger.cpp +++ lldb/trunk/source/Core/Debugger.cpp @@ -278,8 +278,7 @@ {"frame-format-unique", OptionValue::eTypeFormatEntity, true, 0, DEFAULT_FRAME_FORMAT_NO_ARGS, {}, "The default frame format string to use when displaying stack frame" - "information for threads from thread backtrace unique."}, -{nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, {}, nullptr}}; + "information for threads from thread backtrace unique."}}; enum { ePropertyAutoConfirm = 0, Index: lldb/trunk/source/Target/Platform.cpp === --- lldb/trunk/source/Target/Platform.cpp +++ lldb/trunk/source/Target/Platform.cpp @@ -71,8 +71,7 @@ {"use-module-cache", OptionValue::eTypeBoolean, true, true, nullptr, {}, "Use module cache."}, {"module-cache-directory", OptionValue::eTypeFileSpec, true, 0, nullptr, - {}, "Root directory for cached modules."}, -{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}}; + {}, "Root directory for cached modules."}}; enum { ePropertyUseModuleCache, ePropertyModuleCacheDirectory }; Index: lldb/trunk/source/Target/Target.cpp === --- lldb/trunk/source/Target/Target.cpp +++ lldb/trunk/source/Target/Target.cpp @@ -3352,8 +3352,7 @@ nullptr, {}, "If true, LLDB will show variables that are meant to " "support the operation of a language's runtime support."}, {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {}, - "Disable lock-step debugging, instead control threads independently."}, -{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}}; + "Disable lock-step debugging, instead control threads independen
[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer
xbolva00 added inline comments. Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:179 + if (!m_die_array.empty()) { +lldbassert(!m_first_die || m_first_die == m_die_array.front()); +m_first_die = m_die_array.front(); @jankratochvil is this correct assert? Our downstream lldb based on lldb 7 with our custom targets hits this assert. If we remove it, we see no obvious breakages. Repository: rL LLVM https://reviews.llvm.org/D46810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer
xbolva00 added inline comments. Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:179 + if (!m_die_array.empty()) { +lldbassert(!m_first_die || m_first_die == m_die_array.front()); +m_first_die = m_die_array.front(); xbolva00 wrote: > @jankratochvil is this correct assert? Our downstream lldb based on lldb 7 > with our custom targets hits this assert. If we remove it, we see no obvious > breakages. cc @labath Repository: rL LLVM https://reviews.llvm.org/D46810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52561: Refactor ClangUserExpression::GetLanguageForExpr
xbolva00 accepted this revision. xbolva00 added a comment. This revision is now accepted and ready to land. looks fine, thanks :) Repository: rLLDB LLDB https://reviews.llvm.org/D52561 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52543: [DWARFSymbolFile] Adds the module lock to all virtual methods from SymbolFile
JDevlieghere added a comment. My first observations: - We call `ResolveTypeUID` without going through the symbol vendor (similar to `GetDeclContextForUID` in the stack trace). This is easy to fix, just add locking to these functions. - The module in the symbol vendor is different from the one in the symbol file. This seems more tricky and I'm not sure if this expected? I looked at TestCallCPPFunction where my newly added assertion triggered in `ParseCompileUnitSupportFiles` which I found odd since we're taking the module lock in symbol vendor. frame #4: 0x00010590c083 _lldb.so`lldb_private::SymbolFile::AssertModuleLock(this=0x00010388ac00) at SymbolFile.cpp:160 157// We assert that we have to module lock by trying to acquire the lock from a 158// different thread. Note that we must abort if the result is true to 159// guarantee correctness. -> 160assert(std::async( 161 std::launch::async, 162 [this] { 163 return this->GetObjectFile()->GetModule()->GetMutex().try_lock(); (lldb) p GetObjectFile()->GetModule() (lldb::ModuleSP) $1 = std::__1::shared_ptr::element_type @ 0x000118905378 strong=1 weak=1 { __ptr_ = 0x000118905378 } (lldb) fr sel 7 frame #7: 0x00010591035b _lldb.so`lldb_private::SymbolVendor::ParseCompileUnitSupportFiles(this=0x000100184f90, sc=0x7ffeefbf79a8, support_files=0x000118904d70) at SymbolVendor.cpp:171 168if (module_sp) { 169 std::lock_guard guard(module_sp->GetMutex()); 170 if (m_sym_file_ap.get()) -> 171return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); 172} 173return false; 174 } (lldb) p module_sp (lldb::ModuleSP) $0 = std::__1::shared_ptr::element_type @ 0x000100189ec0 strong=6 weak=18 { __ptr_ = 0x000100189ec0 } Repository: rLLDB LLDB https://reviews.llvm.org/D52543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52543: [DWARFSymbolFile] Adds the module lock to all virtual methods from SymbolFile
JDevlieghere updated this revision to Diff 167248. JDevlieghere added a comment. - Add assertions per Greg's suggestion. https://reviews.llvm.org/D52543 Files: include/lldb/Symbol/SymbolFile.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/SymbolFile.cpp Index: source/Symbol/SymbolFile.cpp === --- source/Symbol/SymbolFile.cpp +++ source/Symbol/SymbolFile.cpp @@ -19,6 +19,8 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private.h" +#include + using namespace lldb_private; void SymbolFile::PreloadSymbols() { @@ -150,3 +152,16 @@ types.Clear(); return 0; } + +void SymbolFile::AssertModuleLock() { + // We assert that we have to module lock by trying to acquire the lock from a + // different thread. Note that we must abort if the result is true to + // guarantee correctness. + assert(std::async( + std::launch::async, + [this] { + return this->GetObjectFile()->GetModule()->GetMutex().try_lock(); + }) + .get() == false && + "Module is not locked"); +} Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -262,6 +262,7 @@ } TypeList *SymbolFileDWARF::GetTypeList() { + AssertModuleLock(); SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) return debug_map_symfile->GetTypeList(); @@ -343,6 +344,7 @@ uint32_t type_mask, TypeList &type_list) { + AssertModuleLock(); TypeSet type_set; CompileUnit *comp_unit = NULL; @@ -854,6 +856,7 @@ } CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) { + AssertModuleLock(); CompUnitSP cu_sp; DWARFDebugInfo *info = DebugInfo(); if (info) { @@ -866,6 +869,7 @@ Function *SymbolFileDWARF::ParseCompileUnitFunction(const SymbolContext &sc, const DWARFDIE &die) { + AssertModuleLock(); if (die.IsValid()) { TypeSystem *type_system = GetTypeSystemForLanguage(die.GetCU()->GetLanguageType()); @@ -889,6 +893,7 @@ } lldb::LanguageType SymbolFileDWARF::ParseCompileUnitLanguage(const SymbolContext &sc) { + AssertModuleLock(); assert(sc.comp_unit); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) @@ -898,6 +903,7 @@ } size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { + AssertModuleLock(); assert(sc.comp_unit); size_t functions_added = 0; DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); @@ -920,6 +926,7 @@ bool SymbolFileDWARF::ParseCompileUnitSupportFiles( const SymbolContext &sc, FileSpecList &support_files) { + AssertModuleLock(); assert(sc.comp_unit); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) { @@ -945,6 +952,7 @@ bool SymbolFileDWARF::ParseCompileUnitIsOptimized( const lldb_private::SymbolContext &sc) { + AssertModuleLock(); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) return dwarf_cu->GetIsOptimized(); @@ -954,6 +962,7 @@ bool SymbolFileDWARF::ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) { + AssertModuleLock(); assert(sc.comp_unit); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) { @@ -1031,6 +1040,7 @@ } bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { + AssertModuleLock(); assert(sc.comp_unit); if (sc.comp_unit->GetLineTable() != NULL) return true; @@ -1116,6 +1126,7 @@ } bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) { + AssertModuleLock(); assert(sc.comp_unit); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); @@ -1295,6 +1306,8 @@ } SymbolFileDWARF *SymbolFileDWARF::GetDWARFForUID(lldb::user_id_t uid) { + std::lock_guard guard( + GetObjectFile()->GetModule()->GetMutex()); // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we // must make sure we use the correct DWARF file when resolving things. On // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple @@ -1311,6 +1324,8 @@ DWARFDIE SymbolFileDWARF::GetDIEFromUID(lldb::user_id_t uid) { + std::lock_guard guard( + GetObjectFile()->GetModule()->GetMutex()); // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we // must make sure we use the correct DWARF file when resolving things. On // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple @@ -1325,6 +1340,8 @@ } CompilerDecl SymbolFileDWARF::GetDeclForUID(lldb::user_id_t type_uid) { + std::lock_guard guard( + GetObjectFile()->GetModule()
[Lldb-commits] [PATCH] D52543: [DWARFSymbolFile] Adds the module lock to all virtual methods from SymbolFile
xbolva00 added inline comments. Comment at: source/Symbol/SymbolFile.cpp:160 + // guarantee correctness. + assert(std::async( + std::launch::async, lldbassert? https://reviews.llvm.org/D52543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343191 - Refactor ClangUserExpression::GetLanguageForExpr
Author: teemperor Date: Thu Sep 27 03:12:54 2018 New Revision: 343191 URL: http://llvm.org/viewvc/llvm-project?rev=343191&view=rev Log: Refactor ClangUserExpression::GetLanguageForExpr Summary: The `ClangUserExpression::GetLanguageForExpr` method is currently a big source of sadness, as it's name implies that it's an accessor method, but it actually is also initializing some variables that we need for parsing. This caused that we currently call this getter just for it's side effects while ignoring it's return value, which is confusing for the reader. This patch renames it to `UpdateLanguageForExpr` and merges all calls to the method into a single call in `ClangUserExpression::PrepareForParsing` (as calling this method is anyway mandatory for parsing to succeed) While looking at the code, I also found that we actually have two language variables in this class hierarchy. The normal `Language` from the UserExpression class and the `LanguageForExpr` that we implemented in this subclass. Both don't seem to actually contain the same value, so we probably should look at this next. Reviewers: xbolva00 Reviewed By: xbolva00 Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D52561 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=343191&r1=343190&r2=343191&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Thu Sep 27 03:12:54 2018 @@ -376,9 +376,9 @@ static void SetupDeclVendor(ExecutionCon } } -llvm::Optional ClangUserExpression::GetLanguageForExpr( +void ClangUserExpression::UpdateLanguageForExpr( DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown; std::string prefix = m_expr_prefix; @@ -390,17 +390,17 @@ llvm::Optional Clang m_expr_text.c_str())); if (m_in_cplusplus_method) - lang_type = lldb::eLanguageTypeC_plus_plus; + m_expr_lang = lldb::eLanguageTypeC_plus_plus; else if (m_in_objectivec_method) - lang_type = lldb::eLanguageTypeObjC; + m_expr_lang = lldb::eLanguageTypeObjC; else - lang_type = lldb::eLanguageTypeC; + m_expr_lang = lldb::eLanguageTypeC; -if (!source_code->GetText(m_transformed_text, lang_type, m_in_static_method, - exe_ctx)) { +if (!source_code->GetText(m_transformed_text, m_expr_lang, + m_in_static_method, exe_ctx)) { diagnostic_manager.PutString(eDiagnosticSeverityError, "couldn't construct expression body"); - return llvm::Optional(); + return; } // Find and store the start position of the original code inside the @@ -408,12 +408,11 @@ llvm::Optional Clang std::size_t original_start; std::size_t original_end; bool found_bounds = source_code->GetOriginalBodyBounds( -m_transformed_text, lang_type, original_start, original_end); +m_transformed_text, m_expr_lang, original_start, original_end); if (found_bounds) { m_user_expression_start_pos = original_start; } } - return lang_type; } bool ClangUserExpression::PrepareForParsing( @@ -437,6 +436,8 @@ bool ClangUserExpression::PrepareForPars ApplyObjcCastHack(m_expr_text); SetupDeclVendor(exe_ctx, m_target); + + UpdateLanguageForExpr(diagnostic_manager, exe_ctx); return true; } @@ -450,11 +451,6 @@ bool ClangUserExpression::Parse(Diagnost if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) { -lang_type = new_lang.getValue(); - } - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); @@ -514,7 +510,7 @@ bool ClangUserExpression::Parse(Diagnost const std::string &fixed_expression = diagnostic_manager.GetFixedExpression(); if (ExpressionSourceCode::GetOriginalBodyBounds( -fixed_expression, lang_type, fixed_start, fixed_end)) +fixed_expression, m_expr_lang, fixed_start, fixed_end)) m_fixed_text = fixed_expression.substr(fixed_start, fixed_end - fixed_start); } @@ -655,8 +651,6 @@ bool ClangUserExpression::Complete(Execu if (!PrepareForP
[Lldb-commits] [PATCH] D52561: Refactor ClangUserExpression::GetLanguageForExpr
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB343191: Refactor ClangUserExpression::GetLanguageForExpr (authored by teemperor, committed by ). Repository: rLLDB LLDB https://reviews.llvm.org/D52561 Files: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -177,8 +177,8 @@ lldb::addr_t struct_address, DiagnosticManager &diagnostic_manager) override; - llvm::Optional GetLanguageForExpr( - DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx); + void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager, + ExecutionContext &exe_ctx); bool SetupPersistentState(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx); bool PrepareForParsing(DiagnosticManager &diagnostic_manager, @@ -201,6 +201,9 @@ lldb::TargetSP m_target_sp; }; + /// The language type of the current expression. + lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown; + /// The absolute character position in the transformed source code where the /// user code (as typed by the user) starts. If the variable is empty, then we /// were not able to calculate this position. Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -376,9 +376,9 @@ } } -llvm::Optional ClangUserExpression::GetLanguageForExpr( +void ClangUserExpression::UpdateLanguageForExpr( DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown; std::string prefix = m_expr_prefix; @@ -390,30 +390,29 @@ m_expr_text.c_str())); if (m_in_cplusplus_method) - lang_type = lldb::eLanguageTypeC_plus_plus; + m_expr_lang = lldb::eLanguageTypeC_plus_plus; else if (m_in_objectivec_method) - lang_type = lldb::eLanguageTypeObjC; + m_expr_lang = lldb::eLanguageTypeObjC; else - lang_type = lldb::eLanguageTypeC; + m_expr_lang = lldb::eLanguageTypeC; -if (!source_code->GetText(m_transformed_text, lang_type, m_in_static_method, - exe_ctx)) { +if (!source_code->GetText(m_transformed_text, m_expr_lang, + m_in_static_method, exe_ctx)) { diagnostic_manager.PutString(eDiagnosticSeverityError, "couldn't construct expression body"); - return llvm::Optional(); + return; } // Find and store the start position of the original code inside the // transformed code. We need this later for the code completion. std::size_t original_start; std::size_t original_end; bool found_bounds = source_code->GetOriginalBodyBounds( -m_transformed_text, lang_type, original_start, original_end); +m_transformed_text, m_expr_lang, original_start, original_end); if (found_bounds) { m_user_expression_start_pos = original_start; } } - return lang_type; } bool ClangUserExpression::PrepareForParsing( @@ -437,6 +436,8 @@ ApplyObjcCastHack(m_expr_text); SetupDeclVendor(exe_ctx, m_target); + + UpdateLanguageForExpr(diagnostic_manager, exe_ctx); return true; } @@ -450,11 +451,6 @@ if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) { -lang_type = new_lang.getValue(); - } - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); @@ -514,7 +510,7 @@ const std::string &fixed_expression = diagnostic_manager.GetFixedExpression(); if (ExpressionSourceCode::GetOriginalBodyBounds( -fixed_expression, lang_type, fixed_start, fixed_end)) +fixed_expression, m_expr_lang, fixed_start, fixed_end)) m_fixed_text = fixed_expression.substr(fixed_start, fixed_end - fixed_start); } @@ -655,8 +651,6 @@ if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - GetLanguageForExpr(diagnostic_manager, exe_ctx); - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); ___
[Lldb-commits] [PATCH] D52604: Clean-up usage of OptionDefinition arrays
tatyana-krasnukha created this revision. tatyana-krasnukha added reviewers: clayborg, zturner. tatyana-krasnukha added a project: LLDB. Herald added a subscriber: lldb-commits. Removed unused static arrays from headers, removed sentinel entry from OptionDefinition array in Driver.cpp. Repository: rLLDB LLDB https://reviews.llvm.org/D52604 Files: include/lldb/Target/Platform.h source/Commands/CommandObjectDisassemble.h source/Commands/CommandObjectExpression.h tools/driver/Driver.cpp tools/driver/Driver.h Index: tools/driver/Driver.h === --- tools/driver/Driver.h +++ tools/driver/Driver.h @@ -68,8 +68,6 @@ void AddInitialCommand(const char *command, CommandPlacement placement, bool is_file, lldb::SBError &error); -// static OptionDefinition m_cmd_option_table[]; - struct InitialCmdEntry { InitialCmdEntry(const char *in_contents, bool in_is_file, bool is_cwd_lldbinit_file_read, bool in_quiet = false) Index: tools/driver/Driver.cpp === --- tools/driver/Driver.cpp +++ tools/driver/Driver.cpp @@ -87,7 +87,7 @@ #define LLDB_3_TO_5 LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5 #define LLDB_4_TO_5 LLDB_OPT_SET_4 | LLDB_OPT_SET_5 -static OptionDefinition g_options[] = { +static constexpr OptionDefinition g_options[] = { {LLDB_OPT_SET_1, true, "help", 'h', no_argument, 0, eArgTypeNone, "Prints out the usage information for the LLDB debugger."}, {LLDB_OPT_SET_2, true, "version", 'v', no_argument, 0, eArgTypeNone, @@ -159,8 +159,9 @@ {LLDB_OPT_SET_7, true, "repl", 'r', optional_argument, 0, eArgTypeNone, "Runs lldb in REPL mode with a stub process."}, {LLDB_OPT_SET_7, true, "repl-language", 'R', required_argument, 0, - eArgTypeNone, "Chooses the language for the REPL."}, -{0, false, NULL, 0, 0, 0, eArgTypeNone, NULL}}; + eArgTypeNone, "Chooses the language for the REPL."}}; + +static constexpr auto g_num_options = sizeof(g_options)/sizeof(OptionDefinition); static const uint32_t last_option_set_with_args = 2; @@ -229,8 +230,7 @@ } } -void ShowUsage(FILE *out, OptionDefinition *option_table, - Driver::OptionData data) { +static void ShowUsage(FILE *out, Driver::OptionData data) { uint32_t screen_width = 80; uint32_t indent_level = 0; const char *name = "lldb"; @@ -245,12 +245,10 @@ // [options-for-level-1] // etc. - uint32_t num_options; uint32_t num_option_sets = 0; - for (num_options = 0; option_table[num_options].long_option != NULL; - ++num_options) { -uint32_t this_usage_mask = option_table[num_options].usage_mask; + for (const auto &opt : g_options) { +uint32_t this_usage_mask = opt.usage_mask; if (this_usage_mask == LLDB_OPT_SET_ALL) { if (num_option_sets == 0) num_option_sets = 1; @@ -274,32 +272,32 @@ fprintf(out, "%*s%s", indent_level, "", name); bool is_help_line = false; -for (uint32_t i = 0; i < num_options; ++i) { - if (option_table[i].usage_mask & opt_set_mask) { -CommandArgumentType arg_type = option_table[i].argument_type; +for (const auto &opt : g_options) { + if (opt.usage_mask & opt_set_mask) { +CommandArgumentType arg_type = opt.argument_type; const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString(arg_type); // This is a bit of a hack, but there's no way to say certain options // don't have arguments yet... // so we do it by hand here. -if (option_table[i].short_option == 'h') +if (opt.short_option == 'h') is_help_line = true; -if (option_table[i].required) { - if (option_table[i].option_has_arg == required_argument) -fprintf(out, " -%c <%s>", option_table[i].short_option, arg_name); - else if (option_table[i].option_has_arg == optional_argument) -fprintf(out, " -%c [<%s>]", option_table[i].short_option, arg_name); +if (opt.required) { + if (opt.option_has_arg == required_argument) +fprintf(out, " -%c <%s>", opt.short_option, arg_name); + else if (opt.option_has_arg == optional_argument) +fprintf(out, " -%c [<%s>]", opt.short_option, arg_name); else -fprintf(out, " -%c", option_table[i].short_option); +fprintf(out, " -%c", opt.short_option); } else { - if (option_table[i].option_has_arg == required_argument) -fprintf(out, " [-%c <%s>]", option_table[i].short_option, arg_name); - else if (option_table[i].option_has_arg == optional_argument) -fprintf(out, " [-%c [<%s>]]", option_table[i].short_option, + if (opt.option_has_ar
[Lldb-commits] [PATCH] D52604: Clean-up usage of OptionDefinition arrays
tatyana-krasnukha added inline comments. Comment at: tools/driver/Driver.cpp:71 typedef struct { uint32_t usage_mask; // Used to mark options that can be used together. If (1 This type is duplicated here to not break the encapsulation of lldb's private types, am I right? Repository: rLLDB LLDB https://reviews.llvm.org/D52604 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer
jankratochvil added a comment. @xbolva00 As you gave no reprodudcer it would be good to know how those two `DWARFDebugInfoEntry`s differ. Without that I can look at it more only next week - travelling. Repository: rL LLVM https://reviews.llvm.org/D46810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.
grimar updated this revision to Diff 167287. grimar added a comment. Herald added subscribers: arichardson, emaste. Herald added a reviewer: espindola. - Addressed review comments. https://reviews.llvm.org/D52403 Files: include/lldb/lldb-enumerations.h lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml lit/Breakpoint/Inputs/single-file-split-dwarf.yaml lit/Breakpoint/single-file-split-dwarf.test source/Core/Section.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h source/Symbol/ObjectFile.cpp Index: source/Symbol/ObjectFile.cpp === --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -344,11 +344,13 @@ return AddressClass::eData; case eSectionTypeDebug: case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAbbrevDwo: case eSectionTypeDWARFDebugAddr: case eSectionTypeDWARFDebugAranges: case eSectionTypeDWARFDebugCuIndex: case eSectionTypeDWARFDebugFrame: case eSectionTypeDWARFDebugInfo: + case eSectionTypeDWARFDebugInfoDwo: case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: @@ -359,7 +361,9 @@ case eSectionTypeDWARFDebugPubTypes: case eSectionTypeDWARFDebugRanges: case eSectionTypeDWARFDebugStr: + case eSectionTypeDWARFDebugStrDwo: case eSectionTypeDWARFDebugStrOffsets: + case eSectionTypeDWARFDebugStrOffsetsDwo: case eSectionTypeDWARFDebugTypes: case eSectionTypeDWARFAppleNames: case eSectionTypeDWARFAppleTypes: Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -50,6 +50,12 @@ DWARFUnit *GetBaseCompileUnit() override; + const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override; + const lldb_private::DWARFDataExtractor &get_debug_addr_data() override; + const lldb_private::DWARFDataExtractor &get_debug_info_data() override; + const lldb_private::DWARFDataExtractor &get_debug_str_data() override; + const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override; + protected: void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data) override; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -61,14 +61,6 @@ } DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() { - // A clang module is found via a skeleton CU, but is not a proper DWO. - // Clang modules have a .debug_info section instead of the *_dwo variant. - if (auto *section_list = m_obj_file->GetSectionList(false)) -if (auto section_sp = -section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true)) - if (!section_sp->GetName().GetStringRef().endswith("dwo")) -return nullptr; - // Only dwo files with 1 compile unit is supported if (GetNumCompileUnits() == 1) return DebugInfo()->GetCompileUnitAtIndex(0); @@ -126,6 +118,37 @@ return m_base_dwarf_cu; } +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo, + m_data_debug_abbrev); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() { + // For single file split dwarf case (when we have .dwo sections in a .o), + // we do not want to use the .debug_addr section from .o file, + // but want to get one from the final executable. + // For regular split debug case, .dwo file does not contain the + // .debug_addr, so we would always fall back to such lookup anyways. + llvm::call_once(m_data_debug_addr.m_flag, [this] { +SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr, + std::ref(m_data_debug_addr.m_data)); + }); + return m_data_debug_addr.m_data; +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() { + return GetCachedSectionData(eSectionTypeDWARFD
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
sgraenitz updated this revision to Diff 167335. sgraenitz added a comment. Add test for breakpoint resolution in DWARF debug map, exercising different LTO and line-tables-only combinations https://reviews.llvm.org/D52375 Files: include/lldb/Symbol/Symtab.h packages/Python/lldbsuite/test/macosx/debug_map/Makefile packages/Python/lldbsuite/test/macosx/debug_map/TestDebugMap.py packages/Python/lldbsuite/test/macosx/debug_map/cu1.c packages/Python/lldbsuite/test/macosx/debug_map/cu1.h packages/Python/lldbsuite/test/macosx/debug_map/cu2.c packages/Python/lldbsuite/test/macosx/debug_map/cu2.h packages/Python/lldbsuite/test/macosx/debug_map/cu3.c packages/Python/lldbsuite/test/macosx/debug_map/cu3.h packages/Python/lldbsuite/test/macosx/debug_map/main.c source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Symbol/Symtab.cpp Index: source/Symbol/Symtab.cpp === --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -509,6 +509,16 @@ return indexes.size() - prev_size; } +bool Symtab::HasSymbolWithTypeAndFlags(lldb::SymbolType symbol_type, + uint32_t flags_value) const { + std::lock_guard guard(m_mutex); + for (const Symbol &symbol : m_symbols) +if (symbol.GetType() == symbol_type && symbol.GetFlags() == flags_value) + return true; + + return false; +} + uint32_t Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -131,7 +131,11 @@ uint32_t GetPluginVersion() override; protected: - enum { kHaveInitializedOSOs = (1 << 0), kNumFlags }; + enum { +kHaveInitializedOSOs = (1 << 0), +kHaveCheckedCUInfos = (1 << 1), +kNumFlags + }; friend class DebugMapModule; friend struct DIERef; @@ -172,13 +176,17 @@ first_symbol_id(UINT32_MAX), last_symbol_id(UINT32_MAX), file_range_map(), file_range_map_valid(false) {} +bool Init(lldb_private::Symbol *so, lldb_private::Symbol *oso); const FileRangeMap &GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile); }; //-- // Protected Member Functions //-- void InitOSO(); + bool HasCompileUnits(); + void ReportErrorInitOSO(lldb_private::Symbol *so_symbol, + lldb_private::Symbol *oso_symbol, uint32_t oso_idx); static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) { return (uint32_t)((uid >> 32ull) - 1ull); @@ -247,6 +255,11 @@ lldb::CompUnitSP GetCompileUnit(SymbolFileDWARF *oso_dwarf); + lldb::CompUnitSP GetCompileUnitByIndex(SymbolFileDWARF *oso_dwarf, + uint32_t cu_idx); + lldb::CompUnitSP GetCompileUnitByOffset(SymbolFileDWARF *oso_dwarf, + dw_offset_t cu_offset); + CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf); lldb::TypeSP @@ -297,6 +310,8 @@ // Member Variables //-- std::bitset m_flags; + bool m_has_compile_unit_infos; + std::vector m_oso_compile_unit_offset; std::vector m_compile_unit_infos; std::vector m_func_indexes; // Sorted by address std::vector m_glob_indexes; @@ -373,7 +388,7 @@ LinkOSOLineTable(SymbolFileDWARF *oso_symfile, lldb_private::LineTable *line_table); - size_t AddOSOARanges(SymbolFileDWARF *dwarf2Data, + size_t AddOSOARanges(SymbolFileDWARF *dwarf2Data, dw_offset_t cu_offset, DWARFDebugAranges *debug_aranges); }; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -37,6 +37,7 @@ #include "lldb/Symbol/VariableList.h" #include "llvm/Support/ScopedPrinter.h" +#include "DWARFCompileUnit.h" #include "LogChannelDWARF.h" #include "SymbolFileDWARF.h" @@ -169,6 +170,23 @@ return file_range_map; } +bool SymbolFileDWARFDebugMap::CompileUnitInfo::Init(Symbol *so, Symbol *oso) { + if (!so || so->GetType() != eSymbolTypeSourceFile) +return false; + + if (!oso || oso->GetType()
[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process
aleksandr.urakov created this revision. aleksandr.urakov added reviewers: zturner, asmith, stella.stamenova, labath. aleksandr.urakov added a project: LLDB. Herald added subscribers: lldb-commits, teemperor, abidh. This patch adds a basic implementation of `DoAllocateMemory` and `DoDeallocateMemory` for Windows processes. For now it considers only the executable permission (and always allows reads and writes). To run tests on x86 it requires https://reviews.llvm.org/D52613 Repository: rLLDB LLDB https://reviews.llvm.org/D52618 Files: lit/Expr/TestIRMemoryMap.test lit/Expr/TestIRMemoryMapWindows.test source/Plugins/Process/Windows/Common/ProcessWindows.cpp source/Plugins/Process/Windows/Common/ProcessWindows.h Index: source/Plugins/Process/Windows/Common/ProcessWindows.h === --- source/Plugins/Process/Windows/Common/ProcessWindows.h +++ source/Plugins/Process/Windows/Common/ProcessWindows.h @@ -84,6 +84,8 @@ Status &error) override; size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override; + lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override; + Status DoDeallocateMemory(lldb::addr_t ptr) override; Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override; Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp === --- source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -72,6 +72,20 @@ return file_name; } +DWORD ConvertLldbToWinApiProtect(uint32_t protect) { + // We also can process a read / write permissions here, but if the debugger + // will make later a write into the allocated memory, it will fail. To get + // around it is possible inside DoWriteMemory to remember memory permissions, + // allow write, write and restore permissions, but for now we process only + // the executable permission. + // + // TODO: Process permissions other than executable + if (protect & ePermissionsExecutable) +return PAGE_EXECUTE_READWRITE; + + return PAGE_READWRITE; +} + } // anonymous namespace namespace lldb_private { @@ -695,6 +709,54 @@ return bytes_written; } +lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t permissions, Status& error) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, permissions); + + if (!m_session_data) { +LLDB_LOG(log, "cannot allocate, there is no active debugger connection."); +error.SetErrorString("cannot allocate, there is no active debugger connection"); +return 0; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + auto protect = ConvertLldbToWinApiProtect(permissions); + auto result = VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); + if (!result) { +error.SetError(GetLastError(), eErrorTypeWin32); +LLDB_LOG(log, "allocating failed with error: {0}", error); +return 0; + } + + return reinterpret_cast(result); +} + +Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) { + Status result; + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to deallocate bytes at address {0}", ptr); + + if (!m_session_data) { +LLDB_LOG(log, "cannot deallocate, there is no active debugger connection."); +result.SetErrorString("cannot deallocate, there is no active debugger connection"); +return result; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (!VirtualFreeEx(handle, reinterpret_cast(ptr), 0, MEM_RELEASE)) { +result.SetError(GetLastError(), eErrorTypeWin32); +LLDB_LOG(log, "deallocating failed with error: {0}", result); +return result; + } + + return result; +} + Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) { Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); Index: lit/Expr/TestIRMemoryMapWindows.test === --- /dev/null +++ lit/Expr/TestIRMemoryMapWindows.test @@ -0,0 +1,12 @@ +# REQUIRES: windows + +# RUN: clang-cl /Zi %p/Inputs/call-function.cpp -o %t + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1 +# RUN: lldb-test ir-memory-map -host
[Lldb-commits] [PATCH] D52604: Clean-up usage of OptionDefinition arrays
clayborg accepted this revision. clayborg added inline comments. This revision is now accepted and ready to land. Comment at: tools/driver/Driver.cpp:71 typedef struct { uint32_t usage_mask; // Used to mark options that can be used together. If (1 tatyana-krasnukha wrote: > This type is duplicated here to not break the encapsulation of lldb's private > types, am I right? Correct. We want any tool that links against LLDB.framework on darwin, or liblldb.so on other platforms to use the lldb::SB API only. Comment at: tools/driver/Driver.cpp:581-585 + if (g_num_options == 0) { if (argc > 1) error.SetErrorStringWithFormat("invalid number of options"); return error; } Do we even need this if statement and its contents? maybe lldbassert(g_num_options > 0);? Repository: rLLDB LLDB https://reviews.llvm.org/D52604 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process
aleksandr.urakov updated this revision to Diff 167338. aleksandr.urakov added a comment. Clang-format patch. https://reviews.llvm.org/D52618 Files: lit/Expr/TestIRMemoryMap.test lit/Expr/TestIRMemoryMapWindows.test source/Plugins/Process/Windows/Common/ProcessWindows.cpp source/Plugins/Process/Windows/Common/ProcessWindows.h Index: source/Plugins/Process/Windows/Common/ProcessWindows.h === --- source/Plugins/Process/Windows/Common/ProcessWindows.h +++ source/Plugins/Process/Windows/Common/ProcessWindows.h @@ -84,6 +84,9 @@ Status &error) override; size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override; + lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, +Status &error) override; + Status DoDeallocateMemory(lldb::addr_t ptr) override; Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override; Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp === --- source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -72,6 +72,20 @@ return file_name; } +DWORD ConvertLldbToWinApiProtect(uint32_t protect) { + // We also can process a read / write permissions here, but if the debugger + // will make later a write into the allocated memory, it will fail. To get + // around it is possible inside DoWriteMemory to remember memory permissions, + // allow write, write and restore permissions, but for now we process only + // the executable permission. + // + // TODO: Process permissions other than executable + if (protect & ePermissionsExecutable) +return PAGE_EXECUTE_READWRITE; + + return PAGE_READWRITE; +} + } // anonymous namespace namespace lldb_private { @@ -695,6 +709,58 @@ return bytes_written; } +lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t permissions, + Status &error) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, + permissions); + + if (!m_session_data) { +LLDB_LOG(log, "cannot allocate, there is no active debugger connection."); +error.SetErrorString( +"cannot allocate, there is no active debugger connection"); +return 0; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + auto protect = ConvertLldbToWinApiProtect(permissions); + auto result = VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); + if (!result) { +error.SetError(GetLastError(), eErrorTypeWin32); +LLDB_LOG(log, "allocating failed with error: {0}", error); +return 0; + } + + return reinterpret_cast(result); +} + +Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) { + Status result; + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to deallocate bytes at address {0}", ptr); + + if (!m_session_data) { +LLDB_LOG(log, "cannot deallocate, there is no active debugger connection."); +result.SetErrorString( +"cannot deallocate, there is no active debugger connection"); +return result; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (!VirtualFreeEx(handle, reinterpret_cast(ptr), 0, MEM_RELEASE)) { +result.SetError(GetLastError(), eErrorTypeWin32); +LLDB_LOG(log, "deallocating failed with error: {0}", result); +return result; + } + + return result; +} + Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) { Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); Index: lit/Expr/TestIRMemoryMapWindows.test === --- /dev/null +++ lit/Expr/TestIRMemoryMapWindows.test @@ -0,0 +1,12 @@ +# REQUIRES: windows + +# RUN: clang-cl /Zi %p/Inputs/call-function.cpp -o %t + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1 +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-overlap1 + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-mix-malloc-free +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-mix-malloc-free Index: lit/Expr/TestIRMemoryMap.test
Re: [Lldb-commits] [PATCH] D46810: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer
> On May 14, 2018, at 6:36 AM, Pavel Labath via Phabricator > wrote: > > labath added a comment. > > In https://reviews.llvm.org/D46810#1097740, @jankratochvil wrote: > >> In https://reviews.llvm.org/D46810#1097503, @labath wrote: >> >>> (If that is true, then I think this is workable, but there are still some >>> details which need to be ironed out; e.g., `m_first_die.GetFirstChild()`) >> >> >> The current code calling `GetUnitDIEOnly()` (returning `DWARFDIE`) or >> `GetUnitDIEPtrOnly` (returning `DWARFDebugInfoEntry *`) is never dealing >> with child DIEs of what it gets - it also makes sense as there is no >> guarantee they have been read in. > > > I am not sure it's that simple. I've found at least one case > (`SymbolFileDWARF::ParseImportedModuleswhere we call GetFirstChild() on the > value returned by `GetUnitDIEOnly` (there may be others which are not easily > greppable). Previously that would work if one would call this only after he'd > know that all DIEs have been parsed. Now this will never work because > GetFirstChild will return whatever is in the memory after `m_first_die`. I am > not sure if this would be caught by asan straight away, though it will most > likely cause a crash very soon. > > I was thinking of making this safer by changing the `GetUnitDIEOnly` so that > the caller has to explicitly request (either with an argument, or by > splitting it into two functions) whether it wants a CU die, which can be used > to access other DIEs, or just a bare attribute-only DIE. In second case, we > would return &m_first_die, in the first case &m_die_array[0] (after making > sure it's properly initialized). Then `m_first_die` can have `has_children` > property set to false to enforce that noone accesses children that way. > > WDYT? One fix that would work it to make the DWARFDebugInfoEntry* inside the DWARFDie to be mutable and allow it to "fix" itself when a call is made. So the flow would be: auto CUDie = cu->GetUnitDIEOnly(); for (auto child = CUDie.GetFirstChild(); The call to DWARFDie::GetFirstChild() would replace "DWARFDebugInfoEntry *m_die" with the correct version by tracking if m_die is just the unit die only by making "DWARFDebugInfoEntry *m_die" into a llvm::PointerIntPair: PointerIntPair< DWARFDebugInfoEntry *, 1> m_die; We set the bit to 1 if m_die is just the unit DIE. Then we have an accessor on DWARFDie that can promote m_die to the full version if needed: void DWARFDie::PromoteIfNeeded() { if (m_die.getInt()) { m_die.setPointer(m_cu->DIEPtr()); m_die.setInt(false); } } > >> Thanks for checking validity of this patch, I was not sure whether LLDB code >> is intended to be thread-safe in the first place. > > Yeah, thread safety is tricky. I think the DWARF parser was very > single-threaded originally. Then, when we started building the index in a > multi-threaded manner we needed to make a bunch of code thread-safe, which > wasn't before. Now it looks like you are introducing even paralelization at > an even deeper level (can't say I understand full what that means yet), so > we'll need to make more code thread-safe. > > > https://reviews.llvm.org/D46810 > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.
clayborg requested changes to this revision. clayborg added a comment. This revision now requires changes to proceed. Just a few fixes. Looking good. Comment at: include/lldb/lldb-enumerations.h:643-660 + eSectionTypeDWARFDebugAbbrevDwo, eSectionTypeDWARFDebugAddr, eSectionTypeDWARFDebugAranges, eSectionTypeDWARFDebugCuIndex, eSectionTypeDWARFDebugFrame, eSectionTypeDWARFDebugInfo, + eSectionTypeDWARFDebugInfoDwo, Add all of these to the end of this enum for API stability since this is a public header used in the API. If an older binary runs against a newer liblldb.so, all of these enums will be off. Comment at: source/Symbol/ObjectFile.cpp:347 case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAbbrevDwo: case eSectionTypeDWARFDebugAddr: Check for other ObjectFile subclasses that override this function. I believe ObjectFileMachO does. https://reviews.llvm.org/D52403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
clayborg added inline comments. Comment at: source/Symbol/Symtab.cpp:520 + return false; +} + This function is still pretty specific. Any comments on my above inlined comment? https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process
clayborg added a comment. We really should be making a lldb-server that works on windows instead of making a native windows process plug-in that only works on windows. That will allow remote debugging to windows machines instead of requiring a local connection. It will also allows debug sessions to be logged using the GDB remote packets and avoids all of the debugging that goes on with a plug-in (ProcessWindows) that does event notifications and everything differently than other targets. https://reviews.llvm.org/D52618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343242 - Add an interactive mode to BSD archive parser.
Author: gclayton Date: Thu Sep 27 10:45:14 2018 New Revision: 343242 URL: http://llvm.org/viewvc/llvm-project?rev=343242&view=rev Log: Add an interactive mode to BSD archive parser. Modified: lldb/trunk/examples/python/bsd.py Modified: lldb/trunk/examples/python/bsd.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/bsd.py?rev=343242&r1=343241&r2=343242&view=diff == --- lldb/trunk/examples/python/bsd.py (original) +++ lldb/trunk/examples/python/bsd.py Thu Sep 27 10:45:14 2018 @@ -1,5 +1,6 @@ #!/usr/bin/python +import cmd import optparse import os import shlex @@ -76,6 +77,22 @@ class Object(object): self.file.seek(saved_pos, 0) return bytes +def save(self, path=None, overwrite=False): +''' +Save the contents of the object to disk using 'path' argument as +the path, or save it to the current working directory using the +object name. +''' + +if path is None: +path = self.name +if not overwrite and os.path.exists(path): +print('error: outfile "%s" already exists' % (path)) +return +print('Saving "%s" to "%s"...' % (self.name, path)) +with open(path, 'w') as f: +f.write(self.get_bytes()) + class StringTable(object): def __init__(self, bytes): @@ -186,6 +203,67 @@ class Archive(object): for obj in self.objects: obj.dump(f=f, flat=flat) +class Interactive(cmd.Cmd): +'''Interactive prompt for exploring contents of BSD archive files, type + "help" to see a list of supported commands.''' +image_option_parser = None + +def __init__(self, archives): +cmd.Cmd.__init__(self) +self.use_rawinput = False +self.intro = ('Interactive BSD archive prompt, type "help" to see a ' + 'list of supported commands.') +self.archives = archives +self.prompt = '% ' + +def default(self, line): +'''Catch all for unknown command, which will exit the interpreter.''' +print("unknown command: %s" % line) +return True + +def do_q(self, line): +'''Quit command''' +return True + +def do_quit(self, line): +'''Quit command''' +return True + +def do_extract(self, line): +args = shlex.split(line) +if args: +extracted = False +for object_name in args: +for archive in self.archives: +matches = archive.find(object_name) +if matches: +for object in matches: +object.save(overwrite=False) +extracted = True +if not extracted: +print('error: no object matches "%s" in any archives' % ( +object_name)) +else: +print('error: must specify the name of an object to extract') + +def do_ls(self, line): +args = shlex.split(line) +if args: +for object_name in args: +for archive in self.archives: +matches = archive.find(object_name) +if matches: +for object in matches: +object.dump(flat=False) +else: +print('error: no object matches "%s" in "%s"' % ( +object_name, archive.path)) +else: +for archive in self.archives: +archive.dump(flat=True) +print('') + + def main(): parser = optparse.OptionParser( @@ -243,9 +321,24 @@ def main(): 'then the extracted object file will be extracted into the ' 'current working directory if a file doesn\'t already exist ' 'with that name.')) +parser.add_option( +'-i', '--interactive', +action='store_true', +dest='interactive', +default=False, +help=('Enter an interactive shell that allows users to interactively ' + 'explore contents of .a files.')) (options, args) = parser.parse_args(sys.argv[1:]) +if options.interactive: +archives = [] +for path in args: +archives.append(Archive(path)) +interpreter = Interactive(archives) +interpreter.cmdloop() +return + for path in args: archive = Archive(path) if options.object_name: @@ -256,17 +349,7 @@ def main(): if options.extract: if len(matches) == 1: dump_all = False -if options.outfile is None: -outfile_path = matches[0].name -else: -outfile_path = options.outfile -
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
sgraenitz added inline comments. Comment at: source/Symbol/Symtab.cpp:520 + return false; +} + clayborg wrote: > This function is still pretty specific. Any comments on my above inlined > comment? Yes absolutely, but the same holds for most functions around here. This one is just a stripped-down version of the above `AppendSymbolIndexesWithTypeAndFlagsValue()`. Both of them are used exactly once (in `CalculateAbilities()` and `InitOSO()` respectively). Of course this is all overly specific. Instead it should be `HasSymbol(Predicate)` and `AppendSymbol(Predicate, Collection&)`, but I don't think we gain anything here by making one of them generic. My fix is very loosely connected to Symtab at all. IMHO it's preferable to keep the existing practice here. This code should be improved consistently in a refactoring commit with no semantic changes. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343243 - Fixes for GDB remote packet disassembler:
Author: gclayton Date: Thu Sep 27 10:55:36 2018 New Revision: 343243 URL: http://llvm.org/viewvc/llvm-project?rev=343243&view=rev Log: Fixes for GDB remote packet disassembler: - Add latency timings to GDB packet log summary if timestamps are on log - Add the ability to plot the latencies for each packet type with --plot - Don't crash the script when target xml register info is in wierd format Modified: lldb/trunk/examples/python/gdbremote.py Modified: lldb/trunk/examples/python/gdbremote.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/gdbremote.py?rev=343243&r1=343242&r2=343243&view=diff == --- lldb/trunk/examples/python/gdbremote.py (original) +++ lldb/trunk/examples/python/gdbremote.py Thu Sep 27 10:55:36 2018 @@ -685,32 +685,33 @@ def rsp_qXfer(options, cmd, cmd_args, rs if extension == '.xml': response = Packet(rsp) xml_string = response.get_hex_ascii_str() -ch = xml_string[0] -if ch == 'l': -xml_string = xml_string[1:] -xml_root = ET.fromstring(xml_string) -for reg_element in xml_root.findall("./feature/reg"): -if not 'value_regnums' in reg_element.attrib: -reg_info = RegisterInfo([]) -if 'name' in reg_element.attrib: -reg_info.info[ -'name'] = reg_element.attrib['name'] -else: -reg_info.info['name'] = 'unspecified' -if 'encoding' in reg_element.attrib: -reg_info.info['encoding'] = reg_element.attrib[ -'encoding'] -else: -reg_info.info['encoding'] = 'uint' -if 'offset' in reg_element.attrib: -reg_info.info[ -'offset'] = reg_element.attrib['offset'] -if 'bitsize' in reg_element.attrib: -reg_info.info[ -'bitsize'] = reg_element.attrib['bitsize'] -g_register_infos.append(reg_info) -print 'XML for "%s":' % (data[2]) -ET.dump(xml_root) +if xml_string: +ch = xml_string[0] +if ch == 'l': +xml_string = xml_string[1:] +xml_root = ET.fromstring(xml_string) +for reg_element in xml_root.findall("./feature/reg"): +if not 'value_regnums' in reg_element.attrib: +reg_info = RegisterInfo([]) +if 'name' in reg_element.attrib: +reg_info.info[ +'name'] = reg_element.attrib['name'] +else: +reg_info.info['name'] = 'unspecified' +if 'encoding' in reg_element.attrib: +reg_info.info['encoding'] = reg_element.attrib[ +'encoding'] +else: +reg_info.info['encoding'] = 'uint' +if 'offset' in reg_element.attrib: +reg_info.info[ +'offset'] = reg_element.attrib['offset'] +if 'bitsize' in reg_element.attrib: +reg_info.info[ +'bitsize'] = reg_element.attrib['bitsize'] +g_register_infos.append(reg_info) +print 'XML for "%s":' % (data[2]) +ET.dump(xml_root) def cmd_A(options, cmd, args): @@ -810,6 +811,14 @@ def cmd_s(options, cmd, args): return False +def cmd_qSpeedTest(options, cmd, args): +print("qSpeedTest: cmd='%s', args='%s'" % (cmd, args)) + + +def rsp_qSpeedTest(options, cmd, cmd_args, rsp): +print("qSpeedTest: rsp='%s' cmd='%s', args='%s'" % (rsp, cmd, args)) + + def cmd_vCont(options, cmd, args): if args == '?': print "%s: get supported extended continue modes" % (cmd) @@ -861,8 +870,10 @@ def rsp_vCont(options, cmd, cmd_args, rs s += 'step' elif mode == 'S': s += 'step with signal' -else: -s += 'unrecognized vCont mode: ', mode +elif mode == 't': +s += 'stop' +# else: +# s += 'unreco
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good then as long as all tests pass on Darwin. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
sgraenitz added inline comments. Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:468 // situation. Check the line tables and build the arange table from this. SymbolContext sc; sc.comp_unit = dwarf->GetCompUnitForDWARFCompUnit(this); sgraenitz wrote: > @clayborg Any idea how to reproduce this code path? I expected test_lt as > below would do, but debug_aranges is read from DIE even there. Is it (only) > for backwards compatibility? > ``` > clang -c -gline-tables-only -o main_lt.o main.c > clang -c -gline-tables-only -o cu1_lt.o cu1.c > clang -gline-tables-only main_lt.o cu1_lt.o -o test_lt > ``` > Found repros in the test suite. Some _dwarf and _gmodule variants seem to be failing due to my fix. Will investigate and post changes if necessary. Thanks for the review. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process
aleksandr.urakov added a comment. I didn't know about such a priority, thanks... But in this case `lldb-server` also must be able to allocate, read and write in a debuggee. Doesn't it use the process plugin for that? Or somehow duplicates this functionality? I have made some work on expressions evaluation on Windows, and it requires a possibility to allocate memory in a debuggee. Now I understand, that the priority is `lldb-server`, but is it a bad idea to apply now the changes I've made to proceed with expressions? I can look tomorrow what else was made with the process plugin, but it seems that there are not so many changes. Don't you know about the status of `lldb-server` on Windows? How much work requires it? https://reviews.llvm.org/D52618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process
zturner added a subscriber: aleksandr.urakov. zturner added a comment. It requires a lot of work (nobody has started porting it). lldb-server exists on other platforms but it basically needs a full port to Windows. It doesn’t use the same process plugin, but it would instead use a different plugin that would copy much of the low level code. Once it works well enough the existing process plugin would then be deleted. It would be great if someone had time to work on it, but I understand if for practical reasons other work has higher priority https://reviews.llvm.org/D52618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
aprantl added inline comments. Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:13 +# Set inputs empty, if not passed from the Python script. +CFLAGS ?= +LDFLAGS ?= This is a noop. You can remove it without affecting anything. Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:22 +# Everything goes as .o files directly to the linker +C_SOURCES := + same here, just remove it Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:24 + +MAKE_DSYM := NO +SHELL = /bin/sh -x If you do this, then you should also the NO_DEBUG_INFO_TESTCASE=True otherwise you're going to build dwarf and dsym variants of the test and they will be identical. Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:25 +MAKE_DSYM := NO +SHELL = /bin/sh -x + this was for debugging? Also remove it Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:30 +main.o: main.c + $(CC) -c -g $(CFLAGS) $(CFLAGS_MAIN) -o main.o $(SRCDIR)/main.c + ` $(CC) -c $(CFLAGS) $(CFLAGS_MAIN) -o $@ $^` -g should already be part of CFLAGS, no? Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:42 +a.out: main.o cu1.o cu2.o cu3.o + $(LD) main.o cu1.o cu2.o cu3.o -L. $(LDFLAGS) -o a.out ` $(LD) $^ -L. $(LDFLAGS) -o a.out` or even shorter, remove the entire line and just declare the dependencies, because the default rule from Makefile.rules will kick in then. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52626: [lldb] Remove an assertion in RichManglingContext::GetBufferRef() hit when debugging a native x86 Windows process
asmith created this revision. asmith added reviewers: aleksandr.urakov, zturner, lldb-commits. Herald added a subscriber: erik.pilkington. A RichManglingContext constructed with an invalid demangled name or with a demangled function name without any context will have an empty context. This triggers an assertion in RichManglingContext::GetBufferRef() when debugging a native Windows process on x86 when it shouldn't. Remove the assertion. Repository: rLLDB LLDB https://reviews.llvm.org/D52626 Files: include/lldb/Core/RichManglingContext.h unittests/Core/RichManglingContextTest.cpp Index: unittests/Core/RichManglingContextTest.cpp === --- unittests/Core/RichManglingContextTest.cpp +++ unittests/Core/RichManglingContextTest.cpp @@ -57,6 +57,29 @@ ItaniumRMC.ParseFullName(); CxxMethodRMC.ParseFullName(); EXPECT_TRUE(ItaniumRMC.GetBufferRef() == CxxMethodRMC.GetBufferRef()); + + // Construct with a random name. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName(ConstString("X"))); + +// We expect it is not a function. +EXPECT_FALSE(CxxMethodRMC.IsFunction()); + } + + // Construct with a function without a context. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName( +ConstString("void * operator new(unsigned __int64)"))); + +// We expect it is a function. +EXPECT_TRUE(CxxMethodRMC.IsFunction()); + +// We expect its context is empty. +CxxMethodRMC.ParseFunctionDeclContextName(); +EXPECT_TRUE(CxxMethodRMC.GetBufferRef().empty()); + } } TEST(RichManglingContextTest, SwitchProvider) { Index: include/lldb/Core/RichManglingContext.h === --- include/lldb/Core/RichManglingContext.h +++ include/lldb/Core/RichManglingContext.h @@ -64,7 +64,6 @@ /// most recent ParseXy() operation. The next ParseXy() call invalidates it. llvm::StringRef GetBufferRef() const { assert(m_provider != None && "Initialize a provider first"); -assert(m_buffer.data() != nullptr && "Parse first"); return m_buffer; } Index: unittests/Core/RichManglingContextTest.cpp === --- unittests/Core/RichManglingContextTest.cpp +++ unittests/Core/RichManglingContextTest.cpp @@ -57,6 +57,29 @@ ItaniumRMC.ParseFullName(); CxxMethodRMC.ParseFullName(); EXPECT_TRUE(ItaniumRMC.GetBufferRef() == CxxMethodRMC.GetBufferRef()); + + // Construct with a random name. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName(ConstString("X"))); + +// We expect it is not a function. +EXPECT_FALSE(CxxMethodRMC.IsFunction()); + } + + // Construct with a function without a context. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName( +ConstString("void * operator new(unsigned __int64)"))); + +// We expect it is a function. +EXPECT_TRUE(CxxMethodRMC.IsFunction()); + +// We expect its context is empty. +CxxMethodRMC.ParseFunctionDeclContextName(); +EXPECT_TRUE(CxxMethodRMC.GetBufferRef().empty()); + } } TEST(RichManglingContextTest, SwitchProvider) { Index: include/lldb/Core/RichManglingContext.h === --- include/lldb/Core/RichManglingContext.h +++ include/lldb/Core/RichManglingContext.h @@ -64,7 +64,6 @@ /// most recent ParseXy() operation. The next ParseXy() call invalidates it. llvm::StringRef GetBufferRef() const { assert(m_provider != None && "Initialize a provider first"); -assert(m_buffer.data() != nullptr && "Parse first"); return m_buffer; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52627: [lldb] Start a new line for the next output if there are no symbols in the current symtab
asmith created this revision. asmith added reviewers: zturner, aleksandr.urakov, lldb-commits. Repository: rLLDB LLDB https://reviews.llvm.org/D52627 Files: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp source/Plugins/ExpressionParser/Clang/ClangUserExpression.h source/Symbol/Symtab.cpp Index: source/Symbol/Symtab.cpp === --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -139,6 +139,8 @@ } break; } + } else { +s->PutCString("\n"); } } Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -204,7 +204,7 @@ /// The absolute character position in the transformed source code where the /// user code (as typed by the user) starts. If the variable is empty, then we /// were not able to calculate this position. - llvm::Optional m_user_expression_start_pos; + llvm::Optional m_user_expression_start_pos; ResultDelegate m_result_delegate; }; Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -620,7 +620,7 @@ /// The column in the line that contains the absolute position. /// The first character in a line is indexed as 0. //-- -static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code, +static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code, unsigned &line, unsigned &column) { // Reset to code position to beginning of the file. line = 0; Index: source/Symbol/Symtab.cpp === --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -139,6 +139,8 @@ } break; } + } else { +s->PutCString("\n"); } } Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -204,7 +204,7 @@ /// The absolute character position in the transformed source code where the /// user code (as typed by the user) starts. If the variable is empty, then we /// were not able to calculate this position. - llvm::Optional m_user_expression_start_pos; + llvm::Optional m_user_expression_start_pos; ResultDelegate m_result_delegate; }; Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp === --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -620,7 +620,7 @@ /// The column in the line that contains the absolute position. /// The first character in a line is indexed as 0. //-- -static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code, +static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code, unsigned &line, unsigned &column) { // Reset to code position to beginning of the file. line = 0; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52468: [PDB] Treat `char`, `signed char` and `unsigned char` as three different types
asmith accepted this revision. asmith added a comment. This revision is now accepted and ready to land. LGTM Repository: rLLDB LLDB https://reviews.llvm.org/D52468 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
dexonsmith added inline comments. Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:22 +# Everything goes as .o files directly to the linker +C_SOURCES := + aprantl wrote: > same here, just remove it I haven't read the full patch to see if this is relevant, but my maybe-out-of-date-Makefile-fu says this is not no-op. It defines `C_SOURCES` as a variable, as opposed to a function-like macro (which would be `C_SOURCES =`, no colon). IIRC, with the former, any changes to `C_SOURCES` (like `C_SOURCES += ...`) are evaluated immediately when it's a variable, lazily (on use) when it's a macro. Usually the behaviour you want is a variable. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap
aprantl added inline comments. Comment at: packages/Python/lldbsuite/test/macosx/debug_map/Makefile:22 +# Everything goes as .o files directly to the linker +C_SOURCES := + dexonsmith wrote: > aprantl wrote: > > same here, just remove it > I haven't read the full patch to see if this is relevant, but my > maybe-out-of-date-Makefile-fu says this is not no-op. It defines `C_SOURCES` > as a variable, as opposed to a function-like macro (which would be `C_SOURCES > =`, no colon). IIRC, with the former, any changes to `C_SOURCES` (like > `C_SOURCES += ...`) are evaluated immediately when it's a variable, lazily > (on use) when it's a macro. Usually the behaviour you want is a variable. What Duncan says is correct. For this particular Makefile though, that difference shouldn't matter and it would be better to keep the file short and simple. https://reviews.llvm.org/D52375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52468: [PDB] Treat `char`, `signed char` and `unsigned char` as three different types
zturner accepted this revision. zturner added a comment. Can you change the description of the patch before submitting it? It's hard to understand why the change does what the description says it does, because the description mentions 3 types of chars but the patch only handles 1. I would just make the description say "handle char as a builtin type" or something Repository: rLLDB LLDB https://reviews.llvm.org/D52468 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52627: [lldb] Start a new line for the next output if there are no symbols in the current symtab
zturner added a comment. Couple of options: 1. Can you give an example of before/after output? 2. Is the `size_t` change related? 3. Can you use -U99 in the future when generating patches? Repository: rLLDB LLDB https://reviews.llvm.org/D52627 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52627: [lldb] Start a new line for the next output if there are no symbols in the current symtab
zturner added a comment. s/options/comments/ Repository: rLLDB LLDB https://reviews.llvm.org/D52627 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52626: [lldb] Remove an assertion in RichManglingContext::GetBufferRef() hit when debugging a native x86 Windows process
zturner accepted this revision. zturner added a comment. This revision is now accepted and ready to land. BTW, I wrote a demangler for Windows ABI that should be 100% complete modulo bugs and can generate an AST that RichManglingContext should use. So it would be interesting if someone decided to start using that to make this actually work. Repository: rLLDB LLDB https://reviews.llvm.org/D52626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343292 - [lldb] Remove an assertion in RichManglingContext::GetBufferRef() hit when debugging a native x86 Windows process
Author: asmith Date: Thu Sep 27 19:33:51 2018 New Revision: 343292 URL: http://llvm.org/viewvc/llvm-project?rev=343292&view=rev Log: [lldb] Remove an assertion in RichManglingContext::GetBufferRef() hit when debugging a native x86 Windows process Summary: A RichManglingContext constructed with an invalid demangled name or with a demangled function name without any context will have an empty context. This triggers an assertion in RichManglingContext::GetBufferRef() when debugging a native Windows process on x86 when it shouldn't. Remove the assertion. Reviewers: aleksandr.urakov, zturner, lldb-commits Reviewed By: zturner Subscribers: erik.pilkington Differential Revision: https://reviews.llvm.org/D52626 Modified: lldb/trunk/include/lldb/Core/RichManglingContext.h lldb/trunk/unittests/Core/RichManglingContextTest.cpp Modified: lldb/trunk/include/lldb/Core/RichManglingContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RichManglingContext.h?rev=343292&r1=343291&r2=343292&view=diff == --- lldb/trunk/include/lldb/Core/RichManglingContext.h (original) +++ lldb/trunk/include/lldb/Core/RichManglingContext.h Thu Sep 27 19:33:51 2018 @@ -64,7 +64,6 @@ public: /// most recent ParseXy() operation. The next ParseXy() call invalidates it. llvm::StringRef GetBufferRef() const { assert(m_provider != None && "Initialize a provider first"); -assert(m_buffer.data() != nullptr && "Parse first"); return m_buffer; } Modified: lldb/trunk/unittests/Core/RichManglingContextTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/RichManglingContextTest.cpp?rev=343292&r1=343291&r2=343292&view=diff == --- lldb/trunk/unittests/Core/RichManglingContextTest.cpp (original) +++ lldb/trunk/unittests/Core/RichManglingContextTest.cpp Thu Sep 27 19:33:51 2018 @@ -57,6 +57,29 @@ TEST(RichManglingContextTest, FromCxxMet ItaniumRMC.ParseFullName(); CxxMethodRMC.ParseFullName(); EXPECT_TRUE(ItaniumRMC.GetBufferRef() == CxxMethodRMC.GetBufferRef()); + + // Construct with a random name. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName(ConstString("X"))); + +// We expect it is not a function. +EXPECT_FALSE(CxxMethodRMC.IsFunction()); + } + + // Construct with a function without a context. + { +RichManglingContext CxxMethodRMC; +EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName( +ConstString("void * operator new(unsigned __int64)"))); + +// We expect it is a function. +EXPECT_TRUE(CxxMethodRMC.IsFunction()); + +// We expect its context is empty. +CxxMethodRMC.ParseFunctionDeclContextName(); +EXPECT_TRUE(CxxMethodRMC.GetBufferRef().empty()); + } } TEST(RichManglingContextTest, SwitchProvider) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits