[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs
nikic accepted this revision. nikic added a comment. This revision is now accepted and ready to land. Herald added a subscriber: StephenFan. LGTM, only the inheritance graph is useful, which this preserves if I understand correctly (CLASS_GRAPH is still YES). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149641/new/ https://reviews.llvm.org/D149641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs
kwk accepted this revision. kwk added a comment. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149641/new/ https://reviews.llvm.org/D149641 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGeadf6db585e1: [docs] Hide collaboration and include graphs in doxygen docs (authored by tbaeder). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149641/new/ https://reviews.llvm.org/D149641 Files: bolt/docs/doxygen.cfg.in clang-tools-extra/docs/doxygen.cfg.in clang/docs/doxygen.cfg.in flang/docs/doxygen.cfg.in lldb/docs/doxygen.cfg.in llvm/docs/doxygen.cfg.in mlir/docs/doxygen.cfg.in openmp/docs/doxygen.cfg.in openmp/runtime/doc/doxygen/config polly/docs/doxygen.cfg.in Index: polly/docs/doxygen.cfg.in === --- polly/docs/doxygen.cfg.in +++ polly/docs/doxygen.cfg.in @@ -2103,7 +2103,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -COLLABORATION_GRAPH= YES +COLLABORATION_GRAPH= NO # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for # groups, showing the direct groups dependencies. @@ -2148,7 +2148,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing @@ -2157,7 +2157,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. Index: openmp/runtime/doc/doxygen/config === --- openmp/runtime/doc/doxygen/config +++ openmp/runtime/doc/doxygen/config @@ -1671,7 +1671,7 @@ # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. -COLLABORATION_GRAPH= YES +COLLABORATION_GRAPH= NO # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies @@ -1703,14 +1703,14 @@ # file showing the direct and indirect include dependencies of the file with # other documented files. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function Index: openmp/docs/doxygen.cfg.in === --- openmp/docs/doxygen.cfg.in +++ openmp/docs/doxygen.cfg.in @@ -2091,7 +2091,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -COLLABORATION_GRAPH= YES +COLLABORATION_GRAPH= NO # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for # groups, showing the direct groups dependencies. @@ -2136,7 +2136,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing @@ -2145,7 +2145,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. Index: mlir/docs/doxygen.cfg.in === --- mlir/docs/doxygen.cfg.in +++ mlir/docs/doxygen.cfg.in @@ -2091,7 +2091,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -COLLABORATION_GRAPH= YES +COLLABORATION_GRAPH= NO # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for # groups, showing the direct groups dependencies. @@ -2136,7 +2136,7 @@ # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing @@ -2145,7 +2145,7 @@ # The default value is: YES. # This tag requires that the ta
[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public
JDevlieghere added inline comments. Comment at: lldb/include/lldb/Core/Debugger.h:505 + /// that directly use the \a lldb_private namespace and want to use the + /// default LLDB event handler thread instead of defining their own. + bool StartEventHandlerThread(); Comment at: lldb/include/lldb/Core/Debugger.h:508-509 + + /// Stop the global event handler thread. It should only be used by programs + /// that manually invoked \a Debugger::StartEventHandlerThread(). + void StopEventHandlerThread(); `used by programs` is rather vague. Comment at: lldb/include/lldb/Core/Debugger.h:512 + + /// Force flushing the process's pending stdout and stderr to the debuggers' + /// asynchronous stdout and stderr streams. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149717/new/ https://reviews.llvm.org/D149717 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public
wallace updated this revision to Diff 519542. wallace added a comment. address comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149717/new/ https://reviews.llvm.org/D149717 Files: lldb/include/lldb/Core/Debugger.h Index: lldb/include/lldb/Core/Debugger.h === --- lldb/include/lldb/Core/Debugger.h +++ lldb/include/lldb/Core/Debugger.h @@ -500,6 +500,19 @@ SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton); + /// Manually start the global event handler thread. It is useful to plugins + /// that directly use the \a lldb_private namespace and want to use the + /// debugger's default event handler thread instead of defining their own. + bool StartEventHandlerThread(); + + /// Manually stop the debugger's default event handler. + void StopEventHandlerThread(); + + /// Force flushing the process's pending stdout and stderr to the debugger's + /// asynchronous stdout and stderr streams. + void FlushProcessOutput(Process &process, bool flush_stdout, + bool flush_stderr); + protected: friend class CommandInterpreter; friend class REPL; @@ -548,10 +561,6 @@ void PrintProgress(const ProgressEventData &data); - bool StartEventHandlerThread(); - - void StopEventHandlerThread(); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler = true); @@ -587,8 +596,6 @@ // Ensures two threads don't attempt to flush process output in parallel. std::mutex m_output_flush_mutex; - void FlushProcessOutput(Process &process, bool flush_stdout, - bool flush_stderr); SourceManager::SourceFileCache &GetSourceFileCache() { return m_source_file_cache; Index: lldb/include/lldb/Core/Debugger.h === --- lldb/include/lldb/Core/Debugger.h +++ lldb/include/lldb/Core/Debugger.h @@ -500,6 +500,19 @@ SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton); + /// Manually start the global event handler thread. It is useful to plugins + /// that directly use the \a lldb_private namespace and want to use the + /// debugger's default event handler thread instead of defining their own. + bool StartEventHandlerThread(); + + /// Manually stop the debugger's default event handler. + void StopEventHandlerThread(); + + /// Force flushing the process's pending stdout and stderr to the debugger's + /// asynchronous stdout and stderr streams. + void FlushProcessOutput(Process &process, bool flush_stdout, + bool flush_stderr); + protected: friend class CommandInterpreter; friend class REPL; @@ -548,10 +561,6 @@ void PrintProgress(const ProgressEventData &data); - bool StartEventHandlerThread(); - - void StopEventHandlerThread(); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler = true); @@ -587,8 +596,6 @@ // Ensures two threads don't attempt to flush process output in parallel. std::mutex m_output_flush_mutex; - void FlushProcessOutput(Process &process, bool flush_stdout, - bool flush_stderr); SourceManager::SourceFileCache &GetSourceFileCache() { return m_source_file_cache; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated
bulbazord added inline comments. Comment at: lldb/include/lldb/Expression/REPL.h:124 +const lldb::ValueObjectSP &result_valobj_sp, +const Status &error) { +return llvm::Error::success(); Do you still need the `Status` parameter? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149719/new/ https://reviews.llvm.org/D149719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public
bulbazord accepted this revision. bulbazord added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149717/new/ https://reviews.llvm.org/D149717 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
JDevlieghere updated this revision to Diff 519570. JDevlieghere added a comment. Use C++17 to simplify things CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149774/new/ https://reviews.llvm.org/D149774 Files: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/UserSettingsController.h lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Interpreter/Property.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp Index: lldb/source/Target/Thread.cpp === --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -112,7 +112,7 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() { const uint32_t idx = ePropertyStepAvoidRegex; - return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(idx); + return GetPropertyAtIndexAs(idx); } FileSpecList ThreadProperties::GetLibrariesToAvoid() const { @@ -125,26 +125,26 @@ bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } uint64_t ThreadProperties::GetMaxBacktraceDepth() const { const uint32_t idx = ePropertyMaxBacktraceDepth; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value); } // Thread Event Data Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4136,7 +4136,7 @@ exp_property->GetValue()->GetAsProperties(); if (exp_values) return exp_values -->GetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, exe_ctx) +->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) .value_or(true); else return true; @@ -4149,8 +4149,7 @@ OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -exp_values->SetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, true, -exe_ctx); +exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); } ArchSpec TargetProperties::GetDefaultArchitecture() const { @@ -4170,75 +4169,75 @@ bool TargetProperties::GetMoveToNearestCode() const { const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const { const uint32_t idx = ePropertyPreferDynamic; - return (lldb::DynamicValueType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) { const uint32_t idx = ePropertyPreferDynamic; - return m_collection_sp->SetPropertyAtIn
[Lldb-commits] [lldb] eee32d6 - [lldb] Remove unused g_objc_Tagged_ISA constants (NFC)
Author: Dave Lee Date: 2023-05-04T11:01:37-07:00 New Revision: eee32d66febfbfa6fea44adc8a4416c5896b8c97 URL: https://github.com/llvm/llvm-project/commit/eee32d66febfbfa6fea44adc8a4416c5896b8c97 DIFF: https://github.com/llvm/llvm-project/commit/eee32d66febfbfa6fea44adc8a4416c5896b8c97.diff LOG: [lldb] Remove unused g_objc_Tagged_ISA constants (NFC) Last use removed in f7420453e80b9294273009efcebaceac2383269e. Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Removed: diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index bc8738094316c..95a3694c64b00 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -96,18 +96,6 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime { void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false) override; - // none of these are valid ISAs - we use them to infer the type - // of tagged pointers - if we have something meaningful to say - // we report an actual type - otherwise, we just say tagged - // there is no connection between the values here and the tagged pointers map - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA = 1; - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSAtom = 2; - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSNumber = 3; - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSDateTS = 4; - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSManagedObject = - 5; - static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSDate = 6; - protected: lldb::BreakpointResolverSP CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
JDevlieghere updated this revision to Diff 519580. JDevlieghere added a comment. Remove duplicate if-clause CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149774/new/ https://reviews.llvm.org/D149774 Files: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/UserSettingsController.h lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Interpreter/Property.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp Index: lldb/source/Target/Thread.cpp === --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -112,7 +112,7 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() { const uint32_t idx = ePropertyStepAvoidRegex; - return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(idx); + return GetPropertyAtIndexAs(idx); } FileSpecList ThreadProperties::GetLibrariesToAvoid() const { @@ -125,26 +125,26 @@ bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } uint64_t ThreadProperties::GetMaxBacktraceDepth() const { const uint32_t idx = ePropertyMaxBacktraceDepth; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value); } // Thread Event Data Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4136,7 +4136,7 @@ exp_property->GetValue()->GetAsProperties(); if (exp_values) return exp_values -->GetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, exe_ctx) +->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) .value_or(true); else return true; @@ -4149,8 +4149,7 @@ OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -exp_values->SetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, true, -exe_ctx); +exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); } ArchSpec TargetProperties::GetDefaultArchitecture() const { @@ -4170,75 +4169,75 @@ bool TargetProperties::GetMoveToNearestCode() const { const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const { const uint32_t idx = ePropertyPreferDynamic; - return (lldb::DynamicValueType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) { const uint32_t idx = ePropertyPreferDynamic; - return m_collection_sp->SetPropertyAtInde
[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated
wallace added inline comments. Comment at: lldb/include/lldb/Expression/REPL.h:124 +const lldb::ValueObjectSP &result_valobj_sp, +const Status &error) { +return llvm::Error::success(); bulbazord wrote: > Do you still need the `Status` parameter? that status is the result of the expression evaluation, so it's useful to have it here Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149719/new/ https://reviews.llvm.org/D149719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected
tstellar added inline comments. Herald added subscribers: ekilmer, jplehr. Comment at: cmake/Modules/GetClangResourceDir.cmake:13 + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") +set(ret_dir bin/${CLANG_RESOURCE_DIR}) + else() Why is the bin prefix here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141907/new/ https://reviews.llvm.org/D141907 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] db5f745 - [lldb] Make some functions useful to REPLs public
Author: walter erquinigo Date: 2023-05-04T14:44:03-05:00 New Revision: db5f745a2bfcd1b93fc298da6cfcf5ed2f00e98f URL: https://github.com/llvm/llvm-project/commit/db5f745a2bfcd1b93fc298da6cfcf5ed2f00e98f DIFF: https://github.com/llvm/llvm-project/commit/db5f745a2bfcd1b93fc298da6cfcf5ed2f00e98f.diff LOG: [lldb] Make some functions useful to REPLs public `StartEventHandlerThread` and `StopEventHandlerThread` are available to the SwiftREPL even though they are protected because SwiftREPL is a friend class of Debugger. I'm developing my own REPL and having access to these functions, including `FlushProcessOutput`, is desirable. Differential Revision: https://reviews.llvm.org/D149717 Added: Modified: lldb/include/lldb/Core/Debugger.h Removed: diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 12c1c046fbcef..a7487e159e2c7 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -500,6 +500,19 @@ class Debugger : public std::enable_shared_from_this, SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton); + /// Manually start the global event handler thread. It is useful to plugins + /// that directly use the \a lldb_private namespace and want to use the + /// debugger's default event handler thread instead of defining their own. + bool StartEventHandlerThread(); + + /// Manually stop the debugger's default event handler. + void StopEventHandlerThread(); + + /// Force flushing the process's pending stdout and stderr to the debugger's + /// asynchronous stdout and stderr streams. + void FlushProcessOutput(Process &process, bool flush_stdout, + bool flush_stderr); + protected: friend class CommandInterpreter; friend class REPL; @@ -548,10 +561,6 @@ class Debugger : public std::enable_shared_from_this, void PrintProgress(const ProgressEventData &data); - bool StartEventHandlerThread(); - - void StopEventHandlerThread(); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler = true); @@ -587,8 +596,6 @@ class Debugger : public std::enable_shared_from_this, // Ensures two threads don't attempt to flush process output in parallel. std::mutex m_output_flush_mutex; - void FlushProcessOutput(Process &process, bool flush_stdout, - bool flush_stderr); SourceManager::SourceFileCache &GetSourceFileCache() { return m_source_file_cache; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bfb7c99 - [LLDB] Add a hook to notify REPLs that an expression was evaluated
Author: walter erquinigo Date: 2023-05-04T14:44:03-05:00 New Revision: bfb7c99f3aeab09236adf1f684f7144f384c6dd7 URL: https://github.com/llvm/llvm-project/commit/bfb7c99f3aeab09236adf1f684f7144f384c6dd7 DIFF: https://github.com/llvm/llvm-project/commit/bfb7c99f3aeab09236adf1f684f7144f384c6dd7.diff LOG: [LLDB] Add a hook to notify REPLs that an expression was evaluated REPL implementations don't have an easy way to know that an expression has been evaluated, so I'm adding a simple function for that. In the future we can add another hook for meta commands. Differential Revision: https://reviews.llvm.org/D149719 Added: Modified: lldb/include/lldb/Expression/REPL.h lldb/source/Expression/REPL.cpp Removed: diff --git a/lldb/include/lldb/Expression/REPL.h b/lldb/include/lldb/Expression/REPL.h index a0df53eb9b4c1..edfe7c0b341da 100644 --- a/lldb/include/lldb/Expression/REPL.h +++ b/lldb/include/lldb/Expression/REPL.h @@ -107,6 +107,24 @@ class REPL : public IOHandlerDelegate { CompletionRequest &request) override; protected: + /// Method that can be optionally overriden by subclasses to get notified + /// whenever an expression has been evaluated. The params of this method + /// include the inputs and outputs of the expression evaluation. + /// + /// Note: meta commands that start with : are not covered by this method. + /// + /// \return + /// An \a Error object that, if it is a failure, aborts the regular + /// REPL expression result handling. + virtual llvm::Error + OnExpressionEvaluated(const ExecutionContext &exe_ctx, llvm::StringRef code, +const EvaluateExpressionOptions &expr_options, +lldb::ExpressionResults execution_results, +const lldb::ValueObjectSP &result_valobj_sp, +const Status &error) { +return llvm::Error::success(); + } + static int CalculateActualIndentation(const StringList &lines); // Subclasses should override these functions to implement a functional REPL. diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp index 5b1937245d967..31c9978b24226 100644 --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -342,9 +342,11 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { expr_prefix, result_valobj_sp, error, nullptr); // fixed expression - // CommandInterpreter &ci = debugger.GetCommandInterpreter(); - - if (process_sp && process_sp->IsAlive()) { + if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options, + execution_results, + result_valobj_sp, error)) { +*error_sp << llvm::toString(std::move(err)) << "\n"; + } else if (process_sp && process_sp->IsAlive()) { bool add_to_code = true; bool handled = false; if (result_valobj_sp) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated
This revision was automatically updated to reflect the committed changes. Closed by commit rGbfb7c99f3aea: [LLDB] Add a hook to notify REPLs that an expression was evaluated (authored by wallace). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149719/new/ https://reviews.llvm.org/D149719 Files: lldb/include/lldb/Expression/REPL.h lldb/source/Expression/REPL.cpp Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -342,9 +342,11 @@ expr_prefix, result_valobj_sp, error, nullptr); // fixed expression - // CommandInterpreter &ci = debugger.GetCommandInterpreter(); - - if (process_sp && process_sp->IsAlive()) { + if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options, + execution_results, + result_valobj_sp, error)) { +*error_sp << llvm::toString(std::move(err)) << "\n"; + } else if (process_sp && process_sp->IsAlive()) { bool add_to_code = true; bool handled = false; if (result_valobj_sp) { Index: lldb/include/lldb/Expression/REPL.h === --- lldb/include/lldb/Expression/REPL.h +++ lldb/include/lldb/Expression/REPL.h @@ -107,6 +107,24 @@ CompletionRequest &request) override; protected: + /// Method that can be optionally overriden by subclasses to get notified + /// whenever an expression has been evaluated. The params of this method + /// include the inputs and outputs of the expression evaluation. + /// + /// Note: meta commands that start with : are not covered by this method. + /// + /// \return + /// An \a Error object that, if it is a failure, aborts the regular + /// REPL expression result handling. + virtual llvm::Error + OnExpressionEvaluated(const ExecutionContext &exe_ctx, llvm::StringRef code, +const EvaluateExpressionOptions &expr_options, +lldb::ExpressionResults execution_results, +const lldb::ValueObjectSP &result_valobj_sp, +const Status &error) { +return llvm::Error::success(); + } + static int CalculateActualIndentation(const StringList &lines); // Subclasses should override these functions to implement a functional REPL. Index: lldb/source/Expression/REPL.cpp === --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -342,9 +342,11 @@ expr_prefix, result_valobj_sp, error, nullptr); // fixed expression - // CommandInterpreter &ci = debugger.GetCommandInterpreter(); - - if (process_sp && process_sp->IsAlive()) { + if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options, + execution_results, + result_valobj_sp, error)) { +*error_sp << llvm::toString(std::move(err)) << "\n"; + } else if (process_sp && process_sp->IsAlive()) { bool add_to_code = true; bool handled = false; if (result_valobj_sp) { Index: lldb/include/lldb/Expression/REPL.h === --- lldb/include/lldb/Expression/REPL.h +++ lldb/include/lldb/Expression/REPL.h @@ -107,6 +107,24 @@ CompletionRequest &request) override; protected: + /// Method that can be optionally overriden by subclasses to get notified + /// whenever an expression has been evaluated. The params of this method + /// include the inputs and outputs of the expression evaluation. + /// + /// Note: meta commands that start with : are not covered by this method. + /// + /// \return + /// An \a Error object that, if it is a failure, aborts the regular + /// REPL expression result handling. + virtual llvm::Error + OnExpressionEvaluated(const ExecutionContext &exe_ctx, llvm::StringRef code, +const EvaluateExpressionOptions &expr_options, +lldb::ExpressionResults execution_results, +const lldb::ValueObjectSP &result_valobj_sp, +const Status &error) { +return llvm::Error::success(); + } + static int CalculateActualIndentation(const StringList &lines); // Subclasses should override these functions to implement a functional REPL. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public
This revision was automatically updated to reflect the committed changes. Closed by commit rGdb5f745a2bfc: [lldb] Make some functions useful to REPLs public (authored by wallace). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149717/new/ https://reviews.llvm.org/D149717 Files: lldb/include/lldb/Core/Debugger.h Index: lldb/include/lldb/Core/Debugger.h === --- lldb/include/lldb/Core/Debugger.h +++ lldb/include/lldb/Core/Debugger.h @@ -500,6 +500,19 @@ SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton); + /// Manually start the global event handler thread. It is useful to plugins + /// that directly use the \a lldb_private namespace and want to use the + /// debugger's default event handler thread instead of defining their own. + bool StartEventHandlerThread(); + + /// Manually stop the debugger's default event handler. + void StopEventHandlerThread(); + + /// Force flushing the process's pending stdout and stderr to the debugger's + /// asynchronous stdout and stderr streams. + void FlushProcessOutput(Process &process, bool flush_stdout, + bool flush_stderr); + protected: friend class CommandInterpreter; friend class REPL; @@ -548,10 +561,6 @@ void PrintProgress(const ProgressEventData &data); - bool StartEventHandlerThread(); - - void StopEventHandlerThread(); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler = true); @@ -587,8 +596,6 @@ // Ensures two threads don't attempt to flush process output in parallel. std::mutex m_output_flush_mutex; - void FlushProcessOutput(Process &process, bool flush_stdout, - bool flush_stderr); SourceManager::SourceFileCache &GetSourceFileCache() { return m_source_file_cache; Index: lldb/include/lldb/Core/Debugger.h === --- lldb/include/lldb/Core/Debugger.h +++ lldb/include/lldb/Core/Debugger.h @@ -500,6 +500,19 @@ SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton); + /// Manually start the global event handler thread. It is useful to plugins + /// that directly use the \a lldb_private namespace and want to use the + /// debugger's default event handler thread instead of defining their own. + bool StartEventHandlerThread(); + + /// Manually stop the debugger's default event handler. + void StopEventHandlerThread(); + + /// Force flushing the process's pending stdout and stderr to the debugger's + /// asynchronous stdout and stderr streams. + void FlushProcessOutput(Process &process, bool flush_stdout, + bool flush_stderr); + protected: friend class CommandInterpreter; friend class REPL; @@ -548,10 +561,6 @@ void PrintProgress(const ProgressEventData &data); - bool StartEventHandlerThread(); - - void StopEventHandlerThread(); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler = true); @@ -587,8 +596,6 @@ // Ensures two threads don't attempt to flush process output in parallel. std::mutex m_output_flush_mutex; - void FlushProcessOutput(Process &process, bool flush_stdout, - bool flush_stderr); SourceManager::SourceFileCache &GetSourceFileCache() { return m_source_file_cache; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149792: Add AArch64 MASK watchpoint support to debugserver
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. Some small nits but LGTM Comment at: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp:1079 + // masked off) -- a MASK value of 31. + uint64_t mask = __builtin_popcountl(wp.aligned_size - 1) << 24; + // A '0b' BAS value needed for mask watchpoints plus a I assume this can be `const`? Comment at: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp:1082 + // nonzero mask value. + uint64_t not_bas_wp = 0xff << 5; + `const` too? Comment at: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp:1260-1262 + bool is_bas_watchpoint = false; + if (mask == 0) +is_bas_watchpoint = true; ```const bool is_bas_watchpoint = (mask ==0);``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149792/new/ https://reviews.llvm.org/D149792 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149804: [lldb][NFCI] Add unittests for ObjCLanguage::MethodName
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149804/new/ https://reviews.llvm.org/D149804 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4fac08f - Recognize `addressing_bits` kv in stop reply packet
Author: Jason Molenda Date: 2023-05-04T13:14:10-07:00 New Revision: 4fac08ff1dcd02c89c677365b10921399caf79df URL: https://github.com/llvm/llvm-project/commit/4fac08ff1dcd02c89c677365b10921399caf79df DIFF: https://github.com/llvm/llvm-project/commit/4fac08ff1dcd02c89c677365b10921399caf79df.diff LOG: Recognize `addressing_bits` kv in stop reply packet If a remote stub provides the addressing_bits kv pair in the stop reply packet, update the Process address masks with that value as it possibly changes during the process runtime. This is an unusual situation, most likely a JTAG remote stub and some very early startup code that is setting up the page tables. Nearly all debug sessions will have a single address mask that cannot change during the lifetime of a Process. Differential Revision: https://reviews.llvm.org/D149803 rdar://61900565 Added: Modified: lldb/docs/lldb-gdb-remote.txt lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Removed: diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt index 570e70f9e54a9..b426978a94907 100644 --- a/lldb/docs/lldb-gdb-remote.txt +++ b/lldb/docs/lldb-gdb-remote.txt @@ -1636,6 +1636,24 @@ for this region. // Example: // thread-pcs:dec14,2cf872b0,2cf8681c,2d02d68c,2cf716a8; // +// "addressing_bits" unsigned optional Specifies how many bits in addresses +// are significant for addressing, base +// 10. If bits 38..0 in a 64-bit +// pointer are significant for +// addressing, then the value is 39. +// This is needed on e.g. AArch64 +// v8.3 ABIs that use pointer +// authentication in the high bits. +// This value is normally sent in the +// qHostInfo packet response, and if the +// value cannot change during the process +// lifetime, it does not need to be +// duplicated here in the stop packet. +// For a firmware environment with early +// start code that may be changing the +// page table setup, a dynamically set +// value may be needed. +// // BEST PRACTICES: // Since register values can be supplied with this packet, it is often useful // to return the PC, SP, FP, LR (if any), and FLAGS registers so that separate diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 06f57967c5acb..7047ae62d07c6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2257,6 +2257,13 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { StreamString ostr; ostr.Printf("%" PRIu64 " %" PRIu64, pid_tid->first, pid_tid->second); description = std::string(ostr.GetString()); + } else if (key.compare("addressing_bits") == 0) { +uint64_t addressing_bits; +if (!value.getAsInteger(0, addressing_bits)) { + addr_t address_mask = ~((1ULL << addressing_bits) - 1); + SetCodeAddressMask(address_mask); + SetDataAddressMask(address_mask); +} } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = UINT32_MAX; if (!key.getAsInteger(16, reg)) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149803: Use the `addressing_bits` kv in the stop packet from the remote stub, if present
This revision was automatically updated to reflect the committed changes. Closed by commit rG4fac08ff1dcd: Recognize `addressing_bits` kv in stop reply packet (authored by jasonmolenda). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149803/new/ https://reviews.llvm.org/D149803 Files: lldb/docs/lldb-gdb-remote.txt lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2257,6 +2257,13 @@ StreamString ostr; ostr.Printf("%" PRIu64 " %" PRIu64, pid_tid->first, pid_tid->second); description = std::string(ostr.GetString()); + } else if (key.compare("addressing_bits") == 0) { +uint64_t addressing_bits; +if (!value.getAsInteger(0, addressing_bits)) { + addr_t address_mask = ~((1ULL << addressing_bits) - 1); + SetCodeAddressMask(address_mask); + SetDataAddressMask(address_mask); +} } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = UINT32_MAX; if (!key.getAsInteger(16, reg)) Index: lldb/docs/lldb-gdb-remote.txt === --- lldb/docs/lldb-gdb-remote.txt +++ lldb/docs/lldb-gdb-remote.txt @@ -1636,6 +1636,24 @@ // Example: // thread-pcs:dec14,2cf872b0,2cf8681c,2d02d68c,2cf716a8; // +// "addressing_bits" unsigned optional Specifies how many bits in addresses +// are significant for addressing, base +// 10. If bits 38..0 in a 64-bit +// pointer are significant for +// addressing, then the value is 39. +// This is needed on e.g. AArch64 +// v8.3 ABIs that use pointer +// authentication in the high bits. +// This value is normally sent in the +// qHostInfo packet response, and if the +// value cannot change during the process +// lifetime, it does not need to be +// duplicated here in the stop packet. +// For a firmware environment with early +// start code that may be changing the +// page table setup, a dynamically set +// value may be needed. +// // BEST PRACTICES: // Since register values can be supplied with this packet, it is often useful // to return the PC, SP, FP, LR (if any), and FLAGS registers so that separate Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2257,6 +2257,13 @@ StreamString ostr; ostr.Printf("%" PRIu64 " %" PRIu64, pid_tid->first, pid_tid->second); description = std::string(ostr.GetString()); + } else if (key.compare("addressing_bits") == 0) { +uint64_t addressing_bits; +if (!value.getAsInteger(0, addressing_bits)) { + addr_t address_mask = ~((1ULL << addressing_bits) - 1); + SetCodeAddressMask(address_mask); + SetDataAddressMask(address_mask); +} } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = UINT32_MAX; if (!key.getAsInteger(16, reg)) Index: lldb/docs/lldb-gdb-remote.txt === --- lldb/docs/lldb-gdb-remote.txt +++ lldb/docs/lldb-gdb-remote.txt @@ -1636,6 +1636,24 @@ // Example: // thread-pcs:dec14,2cf872b0,2cf8681c,2d02d68c,2cf716a8; // +// "addressing_bits" unsigned optional Specifies how many bits in addresses +// are significant for addressing, base +// 10. If bits 38..0 in a 64-bit +// pointer are significant for +// addressing, then the value is 39. +// This is needed on e.g. AArch64 +// v8.3 ABIs that use pointer +// aut
[Lldb-commits] [PATCH] D149792: Add AArch64 MASK watchpoint support to debugserver
jasonmolenda updated this revision to Diff 519629. jasonmolenda added a comment. Update patch with Dan and Jonas' feedback. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149792/new/ https://reviews.llvm.org/D149792 Files: lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h Index: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h === --- lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h +++ lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h @@ -86,7 +86,8 @@ bool write, bool also_set_on_task) override; uint32_t SetBASWatchpoint(WatchpointSpec wp, bool read, bool write, bool also_set_on_task); - uint32_t SetMASKWatchpoint(WatchpointSpec wp); + uint32_t SetMASKWatchpoint(WatchpointSpec wp, bool read, bool write, + bool also_set_on_task); bool DisableHardwareWatchpoint(uint32_t hw_break_index, bool also_set_on_task) override; bool DisableHardwareWatchpoint_helper(uint32_t hw_break_index, Index: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp === --- lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp +++ lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp @@ -42,11 +42,6 @@ #define WCR_LOAD ((uint32_t)(1u << 3)) #define WCR_STORE ((uint32_t)(1u << 4)) -// Enable breakpoint, watchpoint, and vector catch debug exceptions. -// (MDE bit in the MDSCR_EL1 register. Equivalent to the MDBGen bit in -// DBGDSCRext in Aarch32) -#define MDE_ENABLE ((uint32_t)(1u << 15)) - // Single instruction step // (SS bit in the MDSCR_EL1 register) #define SS_ENABLE ((uint32_t)(1u)) @@ -807,8 +802,6 @@ (uint64_t)m_state.dbg.__bvr[i], (uint32_t)m_state.dbg.__bcr[i]); - // The kernel will set the MDE_ENABLE bit in the MDSCR_EL1 for us - // automatically, don't need to do it here. kret = SetDBGState(also_set_on_task); DNBLogThreadedIf(LOG_WATCHPOINTS, @@ -848,9 +841,10 @@ /// Round up \a requested_size to the next power-of-2 size, at least 8 /// bytes - /// requested_size == 3 -> aligned_size == 8 - /// requested_size == 13 -> aligned_size == 16 - /// requested_size == 16 -> aligned_size == 16 + /// requested_size == 8 -> aligned_size == 8 + /// requested_size == 9 -> aligned_size == 16 + /// requested_size == 15 -> aligned_size == 16 + /// requested_size == 192 -> aligned_size == 256 /// Could be `std::bit_ceil(aligned_size)` when we build with C++20? aligned_size = 1ULL << (addr_bit_size - __builtin_clzll(aligned_size - 1)); @@ -922,7 +916,7 @@ if (wps[0].aligned_size <= 8) return SetBASWatchpoint(wps[0], read, write, also_set_on_task); else - return INVALID_NUB_HW_INDEX; + return SetMASKWatchpoint(wps[0], read, write, also_set_on_task); } // We have multiple WatchpointSpecs @@ -1024,9 +1018,6 @@ (uint64_t)m_state.dbg.__wvr[i], (uint32_t)m_state.dbg.__wcr[i]); - // The kernel will set the MDE_ENABLE bit in the MDSCR_EL1 for us - // automatically, don't need to do it here. - kret = SetDBGState(also_set_on_task); // DumpDBGState(m_state.dbg); @@ -1042,6 +1033,81 @@ return INVALID_NUB_HW_INDEX; } +uint32_t +DNBArchMachARM64::SetMASKWatchpoint(DNBArchMachARM64::WatchpointSpec wp, +bool read, bool write, +bool also_set_on_task) { + const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints(); + + // Read the debug state + kern_return_t kret = GetDBGState(false); + if (kret != KERN_SUCCESS) +return INVALID_NUB_HW_INDEX; + + // Check to make sure we have the needed hardware support + uint32_t i = 0; + + for (i = 0; i < num_hw_watchpoints; ++i) { +if ((m_state.dbg.__wcr[i] & WCR_ENABLE) == 0) + break; // We found an available hw watchpoint slot + } + if (i == num_hw_watchpoints) { +DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchMachARM64::" + "SetMASKWatchpoint(): All " + "hardware resources (%u) are in use.", + num_hw_watchpoints); +return INVALID_NUB_HW_INDEX; + } + + DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchMachARM64::" + "SetMASKWatchpoint() " +
[Lldb-commits] [lldb] 2e16e41 - Add AArch64 MASK watchpoint support in debugserver
Author: Jason Molenda Date: 2023-05-04T13:23:51-07:00 New Revision: 2e16e41b28b1b1e027d0303e1a37ccbded96a46f URL: https://github.com/llvm/llvm-project/commit/2e16e41b28b1b1e027d0303e1a37ccbded96a46f DIFF: https://github.com/llvm/llvm-project/commit/2e16e41b28b1b1e027d0303e1a37ccbded96a46f.diff LOG: Add AArch64 MASK watchpoint support in debugserver Add suport for MASK style watchpoints on AArch64 in debugserver on Darwin systems, for watching power-of-2 sized memory ranges. More work needed in lldb before this can be exposed to the user (because they will often try watching memory ranges that are not exactly power-of-2 in size/alignment) but this is the first part of adding that capability. Differential Revision: https://reviews.llvm.org/D149792 rdar://108233371 Added: lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c Modified: lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h Removed: diff --git a/lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile b/lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile new file mode 100644 index 0..10495940055b6 --- /dev/null +++ b/lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py b/lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py new file mode 100644 index 0..e8d88024547bf --- /dev/null +++ b/lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py @@ -0,0 +1,59 @@ +""" +Watch larger-than-8-bytes regions of memory, confirm that +writes to those regions are detected. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class UnalignedWatchpointTestCase(TestBase): + +def continue_and_report_stop_reason(self, process, iter_str): +process.Continue() +self.assertIn(process.GetState(), [lldb.eStateStopped, lldb.eStateExited], + iter_str) +thread = process.GetSelectedThread() +return thread.GetStopReason() + + +NO_DEBUG_INFO_TESTCASE = True +# debugserver on AArch64 has this feature. +@skipIf(archs=no_match(['arm64', 'arm64e', 'aarch64'])) +@skipUnlessDarwin + +# debugserver only gained the ability to watch larger regions +# with this patch. +@skipIfOutOfTreeDebugserver + +def test_large_watchpoint(self): +"""Test watchpoint that covers a large region of memory.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "break here", self.main_source_file) + +frame = thread.GetFrameAtIndex(0) + +array_addr = frame.GetValueForVariablePath("array").GetValueAsUnsigned() + +# watch 256 uint32_t elements in the middle of the array, +# don't assume that the heap allocated array is aligned +# to a 1024 byte boundary to begin with, force alignment. +wa_256_addr = ((array_addr + 1024) & ~(1024-1)) +err = lldb.SBError() +wp = target.WatchAddress(wa_256_addr, 1024, False, True, err) +self.assertTrue(wp.IsValid()) +self.assertSuccess(err) + +c_count = 0 +reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) +while reason == lldb.eStopReasonWatchpoint: +c_count = c_count + 1 +reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) +self.assertLessEqual(c_count, 16) + +self.assertEqual(c_count, 16) diff --git a/lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c b/lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c new file mode 100644 index 0..0b0d3f2c80477 --- /dev/null +++ b/lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include +int main() { + const int count = 65535; + int *array = (int*) malloc(sizeof (int) * count); + memset (array, 0, count * sizeof (int)); + + puts ("break here"); + + for (int i = 0; i < count - 16; i += 16) +array[i] += 10; + + puts ("done, exiting."); +} diff --git a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAdd
[Lldb-commits] [PATCH] D149792: Add AArch64 MASK watchpoint support to debugserver
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG2e16e41b28b1: Add AArch64 MASK watchpoint support in debugserver (authored by jasonmolenda). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149792/new/ https://reviews.llvm.org/D149792 Files: lldb/test/API/functionalities/watchpoint/large-watchpoint/Makefile lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py lldb/test/API/functionalities/watchpoint/large-watchpoint/main.c lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h Index: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h === --- lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h +++ lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h @@ -86,7 +86,8 @@ bool write, bool also_set_on_task) override; uint32_t SetBASWatchpoint(WatchpointSpec wp, bool read, bool write, bool also_set_on_task); - uint32_t SetMASKWatchpoint(WatchpointSpec wp); + uint32_t SetMASKWatchpoint(WatchpointSpec wp, bool read, bool write, + bool also_set_on_task); bool DisableHardwareWatchpoint(uint32_t hw_break_index, bool also_set_on_task) override; bool DisableHardwareWatchpoint_helper(uint32_t hw_break_index, Index: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp === --- lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp +++ lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp @@ -42,11 +42,6 @@ #define WCR_LOAD ((uint32_t)(1u << 3)) #define WCR_STORE ((uint32_t)(1u << 4)) -// Enable breakpoint, watchpoint, and vector catch debug exceptions. -// (MDE bit in the MDSCR_EL1 register. Equivalent to the MDBGen bit in -// DBGDSCRext in Aarch32) -#define MDE_ENABLE ((uint32_t)(1u << 15)) - // Single instruction step // (SS bit in the MDSCR_EL1 register) #define SS_ENABLE ((uint32_t)(1u)) @@ -807,8 +802,6 @@ (uint64_t)m_state.dbg.__bvr[i], (uint32_t)m_state.dbg.__bcr[i]); - // The kernel will set the MDE_ENABLE bit in the MDSCR_EL1 for us - // automatically, don't need to do it here. kret = SetDBGState(also_set_on_task); DNBLogThreadedIf(LOG_WATCHPOINTS, @@ -848,9 +841,10 @@ /// Round up \a requested_size to the next power-of-2 size, at least 8 /// bytes - /// requested_size == 3 -> aligned_size == 8 - /// requested_size == 13 -> aligned_size == 16 - /// requested_size == 16 -> aligned_size == 16 + /// requested_size == 8 -> aligned_size == 8 + /// requested_size == 9 -> aligned_size == 16 + /// requested_size == 15 -> aligned_size == 16 + /// requested_size == 192 -> aligned_size == 256 /// Could be `std::bit_ceil(aligned_size)` when we build with C++20? aligned_size = 1ULL << (addr_bit_size - __builtin_clzll(aligned_size - 1)); @@ -922,7 +916,7 @@ if (wps[0].aligned_size <= 8) return SetBASWatchpoint(wps[0], read, write, also_set_on_task); else - return INVALID_NUB_HW_INDEX; + return SetMASKWatchpoint(wps[0], read, write, also_set_on_task); } // We have multiple WatchpointSpecs @@ -1024,9 +1018,6 @@ (uint64_t)m_state.dbg.__wvr[i], (uint32_t)m_state.dbg.__wcr[i]); - // The kernel will set the MDE_ENABLE bit in the MDSCR_EL1 for us - // automatically, don't need to do it here. - kret = SetDBGState(also_set_on_task); // DumpDBGState(m_state.dbg); @@ -1042,6 +1033,81 @@ return INVALID_NUB_HW_INDEX; } +uint32_t +DNBArchMachARM64::SetMASKWatchpoint(DNBArchMachARM64::WatchpointSpec wp, +bool read, bool write, +bool also_set_on_task) { + const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints(); + + // Read the debug state + kern_return_t kret = GetDBGState(false); + if (kret != KERN_SUCCESS) +return INVALID_NUB_HW_INDEX; + + // Check to make sure we have the needed hardware support + uint32_t i = 0; + + for (i = 0; i < num_hw_watchpoints; ++i) { +if ((m_state.dbg.__wcr[i] & WCR_ENABLE) == 0) + break; // We found an available hw watchpoint slot + } + if (i == num_hw_watchpoints) { +DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchMachARM64::" + "SetMASKWatchpoint(): All " + "hardware resources (%u) are in use.", + num_hw_watchpoints); +return INVALID_NUB_HW_INDEX; + } + + DNBLogThreade
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
bulbazord created this revision. bulbazord added reviewers: JDevlieghere, jingham, mib, aprantl. Herald added a project: All. bulbazord requested review of this revision. Herald added a reviewer: jdoerfert. Herald added subscribers: lldb-commits, jplehr, sstefan1. Herald added a project: LLDB. There are many situations where we'll iterate over a SymbolContextList with the pattern: SymbolContextList sc_list; // Fill in sc_list here for (auto i = 0; i < sc_list.GetSize(); i++) { SymbolContext sc; sc_list.GetSymbolAtContext(i, sc); // Do work with sc } Adding an iterator to iterate over the instances directly means we don't have to do bounds checking or create a copy of every element of the SymbolContextList. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D149900 Files: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Symbol/UnwindTable.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Symbol/UnwindTable.cpp Index: lldb/source/Symbol/UnwindTable.cpp === --- lldb/source/Symbol/UnwindTable.cpp +++ lldb/source/Symbol/UnwindTable.cpp @@ -86,8 +86,8 @@ UnwindTable::~UnwindTable() = default; -std::optional UnwindTable::GetAddressRange(const Address &addr, - SymbolContext &sc) { +std::optional +UnwindTable::GetAddressRange(const Address &addr, const SymbolContext &sc) { AddressRange range; // First check the unwind info from the object file plugin @@ -150,9 +150,8 @@ // don't add it to the UnwindTable. This is intended for use by target modules // show-unwind where we want to create new UnwindPlans, not re-use existing // ones. -FuncUnwindersSP -UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr, - SymbolContext &sc) { +FuncUnwindersSP UnwindTable::GetUncachedFuncUnwindersContainingAddress( +const Address &addr, const SymbolContext &sc) { Initialize(); auto range_or = GetAddressRange(addr, sc); Index: lldb/source/Symbol/SymbolContext.cpp === --- lldb/source/Symbol/SymbolContext.cpp +++ lldb/source/Symbol/SymbolContext.cpp @@ -771,14 +771,11 @@ Module *module = module_sp.get(); auto ProcessMatches = [this, &name, &target, - module](SymbolContextList &sc_list, + module](const SymbolContextList &sc_list, Status &error) -> const Symbol * { llvm::SmallVector external_symbols; llvm::SmallVector internal_symbols; -const uint32_t matches = sc_list.GetSize(); -for (uint32_t i = 0; i < matches; ++i) { - SymbolContext sym_ctx; - sc_list.GetContextAtIndex(i, sym_ctx); +for (const auto &sym_ctx : sc_list) { if (sym_ctx.symbol) { const Symbol *symbol = sym_ctx.symbol; const Address sym_address = symbol->GetAddress(); Index: lldb/source/Symbol/Symbol.cpp === --- lldb/source/Symbol/Symbol.cpp +++ lldb/source/Symbol/Symbol.cpp @@ -488,15 +488,9 @@ lldb_private::SymbolContextList sc_list; module_sp->FindSymbolsWithNameAndType(reexport_name, eSymbolTypeAny, sc_list); -const size_t num_scs = sc_list.GetSize(); -if (num_scs > 0) { - for (size_t i = 0; i < num_scs; ++i) { -lldb_private::SymbolContext sc; -if (sc_list.GetContextAtIndex(i, sc)) { - if (sc.symbol->IsExternal()) -return sc.symbol; -} - } +for (const auto &sc : sc_list) { + if (sc.symbol->IsExternal()) +return sc.symbol; } // If we didn't find the symbol in this module, it may be because this // module re-exports some whole other library. We have to search those as Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp ===
[Lldb-commits] [lldb] dc39d98 - [lldb][NFCI] Add unittests for ObjCLanguage::MethodName
Author: Alex Langford Date: 2023-05-04T13:50:57-07:00 New Revision: dc39d98c3faa81ea48b89489b17ba80dae38c9b9 URL: https://github.com/llvm/llvm-project/commit/dc39d98c3faa81ea48b89489b17ba80dae38c9b9 DIFF: https://github.com/llvm/llvm-project/commit/dc39d98c3faa81ea48b89489b17ba80dae38c9b9.diff LOG: [lldb][NFCI] Add unittests for ObjCLanguage::MethodName I have a patch to refactor this class and I'd like a unittest in place to make sure I don't break anything. Differential Revision: https://reviews.llvm.org/D149804 Added: lldb/unittests/Language/ObjC/CMakeLists.txt lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp Modified: lldb/unittests/Language/CMakeLists.txt Removed: diff --git a/lldb/unittests/Language/CMakeLists.txt b/lldb/unittests/Language/CMakeLists.txt index 3cca831956ab6..6f173568c76e6 100644 --- a/lldb/unittests/Language/CMakeLists.txt +++ b/lldb/unittests/Language/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(CPlusPlus) add_subdirectory(CLanguages) add_subdirectory(Highlighting) +add_subdirectory(ObjC) diff --git a/lldb/unittests/Language/ObjC/CMakeLists.txt b/lldb/unittests/Language/ObjC/CMakeLists.txt new file mode 100644 index 0..82cc847e1045f --- /dev/null +++ b/lldb/unittests/Language/ObjC/CMakeLists.txt @@ -0,0 +1,6 @@ +add_lldb_unittest(LanguageObjCTests + ObjCLanguageTest.cpp + + LINK_LIBS +lldbPluginObjCLanguage +) diff --git a/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp b/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp new file mode 100644 index 0..e9cb5d1b32143 --- /dev/null +++ b/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp @@ -0,0 +1,114 @@ +//===-- ObjCLanguageTest.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "Plugins/Language/ObjC/ObjCLanguage.h" +#include "lldb/lldb-enumerations.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +#include "llvm/ADT/StringRef.h" + +using namespace lldb_private; + +TEST(ObjCLanguage, MethodNameParsing) { + struct TestCase { +llvm::StringRef input; +llvm::StringRef full_name_sans_category; +llvm::StringRef class_name; +llvm::StringRef class_name_with_category; +llvm::StringRef category; +llvm::StringRef selector; + }; + + TestCase strict_cases[] = { + {"-[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"+[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"-[MyClass(my_category) mySelector:]", "-[MyClass mySelector:]", + "MyClass", "MyClass(my_category)", "my_category", "mySelector:"}, + {"+[MyClass(my_category) mySelector:]", "+[MyClass mySelector:]", + "MyClass", "MyClass(my_category)", "my_category", "mySelector:"}, + }; + + TestCase lax_cases[] = { + {"[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"[MyClass(my_category) mySelector:]", "[MyClass mySelector:]", "MyClass", + "MyClass(my_category)", "my_category", "mySelector:"}, + }; + + // First, be strict + for (const auto &test : strict_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ true); +EXPECT_TRUE(method.IsValid(/*strict = */ true)); +EXPECT_EQ( +test.full_name_sans_category, +method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) +.GetStringRef()); +EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +EXPECT_EQ(test.class_name_with_category, + method.GetClassNameWithCategory().GetStringRef()); +EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); +EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + } + + // We should make sure strict parsing does not accept lax cases + for (const auto &test : lax_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ true); +EXPECT_FALSE(method.IsValid(/*strict = */ true)); + } + + // All strict cases should work when not lax + for (const auto &test : strict_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ false); +EXPECT_TRUE(method.IsValid(/*strict = */ false)); +EXPECT_EQ( +test.full_name_sans_category, +method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) +.GetStringRef()); +EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +EXPECT_EQ(test.class_name_with_category, + method.GetClassNameWithCategory().GetStringRef()); +EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); +EXPECT_EQ(test.selector, method.GetSelector().G
[Lldb-commits] [PATCH] D149804: [lldb][NFCI] Add unittests for ObjCLanguage::MethodName
This revision was automatically updated to reflect the committed changes. Closed by commit rGdc39d98c3faa: [lldb][NFCI] Add unittests for ObjCLanguage::MethodName (authored by bulbazord). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149804/new/ https://reviews.llvm.org/D149804 Files: lldb/unittests/Language/CMakeLists.txt lldb/unittests/Language/ObjC/CMakeLists.txt lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp Index: lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp === --- /dev/null +++ lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp @@ -0,0 +1,114 @@ +//===-- ObjCLanguageTest.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "Plugins/Language/ObjC/ObjCLanguage.h" +#include "lldb/lldb-enumerations.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +#include "llvm/ADT/StringRef.h" + +using namespace lldb_private; + +TEST(ObjCLanguage, MethodNameParsing) { + struct TestCase { +llvm::StringRef input; +llvm::StringRef full_name_sans_category; +llvm::StringRef class_name; +llvm::StringRef class_name_with_category; +llvm::StringRef category; +llvm::StringRef selector; + }; + + TestCase strict_cases[] = { + {"-[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"+[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"-[MyClass(my_category) mySelector:]", "-[MyClass mySelector:]", + "MyClass", "MyClass(my_category)", "my_category", "mySelector:"}, + {"+[MyClass(my_category) mySelector:]", "+[MyClass mySelector:]", + "MyClass", "MyClass(my_category)", "my_category", "mySelector:"}, + }; + + TestCase lax_cases[] = { + {"[MyClass mySelector:]", "", "MyClass", "MyClass", "", "mySelector:"}, + {"[MyClass(my_category) mySelector:]", "[MyClass mySelector:]", "MyClass", + "MyClass(my_category)", "my_category", "mySelector:"}, + }; + + // First, be strict + for (const auto &test : strict_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ true); +EXPECT_TRUE(method.IsValid(/*strict = */ true)); +EXPECT_EQ( +test.full_name_sans_category, +method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) +.GetStringRef()); +EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +EXPECT_EQ(test.class_name_with_category, + method.GetClassNameWithCategory().GetStringRef()); +EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); +EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + } + + // We should make sure strict parsing does not accept lax cases + for (const auto &test : lax_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ true); +EXPECT_FALSE(method.IsValid(/*strict = */ true)); + } + + // All strict cases should work when not lax + for (const auto &test : strict_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ false); +EXPECT_TRUE(method.IsValid(/*strict = */ false)); +EXPECT_EQ( +test.full_name_sans_category, +method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) +.GetStringRef()); +EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +EXPECT_EQ(test.class_name_with_category, + method.GetClassNameWithCategory().GetStringRef()); +EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); +EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + } + + // Make sure non-strict parsing works + for (const auto &test : lax_cases) { +ObjCLanguage::MethodName method(test.input, /*strict = */ false); +EXPECT_TRUE(method.IsValid(/*strict = */ false)); +EXPECT_EQ( +test.full_name_sans_category, +method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) +.GetStringRef()); +EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +EXPECT_EQ(test.class_name_with_category, + method.GetClassNameWithCategory().GetStringRef()); +EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); +EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + } +} + +TEST(CPlusPlusLanguage, InvalidMethodNameParsing) { + // Tests that we correctly reject malformed function names + + llvm::StringRef test_cases[] = {"+[Uh oh!", + "-[Definitely not...", + "[Nice try ] :)", + "+MaybeIfYouSquintYourEyes]", +
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Please do more of this! I haven't checked all the replacements for correctness but the direction is good. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
mib added a comment. LGTM but I'd prefer if we kept the type in the for loop for (const SymbolContext &sym_ctx : sc_list) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
JDevlieghere accepted this revision. JDevlieghere added a comment. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
mib added a comment. Very cool stuff! Comment at: lldb/include/lldb/Interpreter/OptionValue.h:325-344 + template ::value, bool> = true> + std::optional GetValueAs() const { +if constexpr (std::is_same_v) + return GetUInt64Value(); +if constexpr (std::is_same_v) + return GetSInt64Value(); nit: In the template argument, you use `std::is_pointer::value` instead of `std::is_pointer_v` and the in the if statement you do the opposite (`std::is_same_v` vs `std::is_same::value`). I personally not a fan of the `_v` alias but what I'm saying here is it would be good to stay consistent. Comment at: lldb/include/lldb/Interpreter/OptionValueProperties.h:162-173 + template + auto GetPropertyAtIndexAs(uint32_t idx, +const ExecutionContext *exe_ctx = nullptr) const { +if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { + if (OptionValue *value = property->GetValue().get()) +return value->GetValueAs(); +} Very interesting! Comment at: lldb/source/Interpreter/Property.cpp:229 } + assert(m_value_sp && "invalid property definition"); } May be we should print a warning or error to the user ? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149774/new/ https://reviews.llvm.org/D149774 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149914: [lldb] Refactor ObjCLanguage::MethodName
bulbazord created this revision. bulbazord added reviewers: JDevlieghere, aprantl, mib, jingham, kastiglione. Herald added a subscriber: arphaman. Herald added a reviewer: shafik. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. The goal of this patch is to make it easier to reason about the state of ObjCLanguage::MethodName. I do that in several ways: - Instead of using the constructor directly, you go through a factory method. It returns a std::optional so either you got an ObjCLanguage::MethodName or you didn't. No more checking if it's valid to know if you can use it or not. - ObjCLanguage::MethodName is now immutable. You cannot change its internals once it is created. - ObjCLanguage::MethodName::GetFullNameWithoutCategory previously had a parameter that let you get back an empty string if the method had no category. Every caller of this method was enabling this behavior so I dropped the parameter and made it the default behavior. - No longer store all the various components of the method name as ConstStrings. The relevant `Get` methods now return llvm::StringRefs backed by the MethodName's internal storage. The lifetime of these StringRefs are tied to the MethodName itself, so if you need to persist these you need to create copies. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D149914 Files: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp Index: lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp === --- lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp +++ lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp @@ -42,53 +42,51 @@ // First, be strict for (const auto &test : strict_cases) { -ObjCLanguage::MethodName method(test.input, /*strict = */ true); -EXPECT_TRUE(method.IsValid(/*strict = */ true)); -EXPECT_EQ( -test.full_name_sans_category, -method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) -.GetStringRef()); -EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +std::optional method = +ObjCLanguage::MethodName::Create(test.input, /*strict = */ true); +EXPECT_TRUE(method.has_value()); +EXPECT_EQ(test.full_name_sans_category, + method->GetFullNameWithoutCategory()); +EXPECT_EQ(test.class_name, method->GetClassName()); EXPECT_EQ(test.class_name_with_category, - method.GetClassNameWithCategory().GetStringRef()); -EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); -EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + method->GetClassNameWithCategory()); +EXPECT_EQ(test.category, method->GetCategory()); +EXPECT_EQ(test.selector, method->GetSelector()); } // We should make sure strict parsing does not accept lax cases for (const auto &test : lax_cases) { -ObjCLanguage::MethodName method(test.input, /*strict = */ true); -EXPECT_FALSE(method.IsValid(/*strict = */ true)); +std::optional method = +ObjCLanguage::MethodName::Create(test.input, /*strict = */ true); +EXPECT_FALSE(method.has_value()); } // All strict cases should work when not lax for (const auto &test : strict_cases) { -ObjCLanguage::MethodName method(test.input, /*strict = */ false); -EXPECT_TRUE(method.IsValid(/*strict = */ false)); -EXPECT_EQ( -test.full_name_sans_category, -method.GetFullNameWithoutCategory(/*empty_if_no_category = */ true) -.GetStringRef()); -EXPECT_EQ(test.class_name, method.GetClassName().GetStringRef()); +std::optional method = +ObjCLanguage::MethodName::Create(test.input, /*strict = */ false); +EXPECT_TRUE(method.has_value()); +EXPECT_EQ(test.full_name_sans_category, + method->GetFullNameWithoutCategory()); +EXPECT_EQ(test.class_name, method->GetClassName()); EXPECT_EQ(test.class_name_with_category, - method.GetClassNameWithCategory().GetStringRef()); -EXPECT_EQ(test.category, method.GetCategory().GetStringRef()); -EXPECT_EQ(test.selector, method.GetSelector().GetStringRef()); + method->GetClassNameWithCategory()); +EXPECT_EQ(test.category, method->GetCategory()); +EXPECT_EQ(test.selector, method->GetSelector()); } // Make sure non-strict parsing works for (const auto &test : lax_cases) { -ObjCLanguage::MethodName method(test.input, /*strict = */ false); -EXPECT_TRUE(method.IsValid(/*strict = */ false)); -EXPECT_EQ( -test.full_name_sans_category, -method.GetFullNameWithoutCategory(/*empty_if_no_category = */ t
[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
JDevlieghere marked 2 inline comments as done. JDevlieghere added inline comments. Comment at: lldb/include/lldb/Interpreter/OptionValue.h:325-344 + template ::value, bool> = true> + std::optional GetValueAs() const { +if constexpr (std::is_same_v) + return GetUInt64Value(); +if constexpr (std::is_same_v) + return GetSInt64Value(); mib wrote: > nit: In the template argument, you use `std::is_pointer::value` instead of > `std::is_pointer_v` and the in the if statement you do the opposite > (`std::is_same_v` vs `std::is_same::value`). I personally not a fan of > the `_v` alias but what I'm saying here is it would be good to stay > consistent. Good point, I've unified everything to use the `_v` variant. Comment at: lldb/source/Interpreter/Property.cpp:229 } + assert(m_value_sp && "invalid property definition"); } mib wrote: > May be we should print a warning or error to the user ? Properties are all tablegen'd so if this fires we did something wrong. There's nothing actionable here for a user. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149774/new/ https://reviews.llvm.org/D149774 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
bulbazord updated this revision to Diff 519690. bulbazord added a comment. Explicitly write out type Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 Files: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Symbol/UnwindTable.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Symbol/UnwindTable.cpp Index: lldb/source/Symbol/UnwindTable.cpp === --- lldb/source/Symbol/UnwindTable.cpp +++ lldb/source/Symbol/UnwindTable.cpp @@ -86,8 +86,8 @@ UnwindTable::~UnwindTable() = default; -std::optional UnwindTable::GetAddressRange(const Address &addr, - SymbolContext &sc) { +std::optional +UnwindTable::GetAddressRange(const Address &addr, const SymbolContext &sc) { AddressRange range; // First check the unwind info from the object file plugin @@ -150,9 +150,8 @@ // don't add it to the UnwindTable. This is intended for use by target modules // show-unwind where we want to create new UnwindPlans, not re-use existing // ones. -FuncUnwindersSP -UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr, - SymbolContext &sc) { +FuncUnwindersSP UnwindTable::GetUncachedFuncUnwindersContainingAddress( +const Address &addr, const SymbolContext &sc) { Initialize(); auto range_or = GetAddressRange(addr, sc); Index: lldb/source/Symbol/SymbolContext.cpp === --- lldb/source/Symbol/SymbolContext.cpp +++ lldb/source/Symbol/SymbolContext.cpp @@ -771,14 +771,11 @@ Module *module = module_sp.get(); auto ProcessMatches = [this, &name, &target, - module](SymbolContextList &sc_list, + module](const SymbolContextList &sc_list, Status &error) -> const Symbol * { llvm::SmallVector external_symbols; llvm::SmallVector internal_symbols; -const uint32_t matches = sc_list.GetSize(); -for (uint32_t i = 0; i < matches; ++i) { - SymbolContext sym_ctx; - sc_list.GetContextAtIndex(i, sym_ctx); +for (const SymbolContext &sym_ctx : sc_list) { if (sym_ctx.symbol) { const Symbol *symbol = sym_ctx.symbol; const Address sym_address = symbol->GetAddress(); Index: lldb/source/Symbol/Symbol.cpp === --- lldb/source/Symbol/Symbol.cpp +++ lldb/source/Symbol/Symbol.cpp @@ -488,15 +488,9 @@ lldb_private::SymbolContextList sc_list; module_sp->FindSymbolsWithNameAndType(reexport_name, eSymbolTypeAny, sc_list); -const size_t num_scs = sc_list.GetSize(); -if (num_scs > 0) { - for (size_t i = 0; i < num_scs; ++i) { -lldb_private::SymbolContext sc; -if (sc_list.GetContextAtIndex(i, sc)) { - if (sc.symbol->IsExternal()) -return sc.symbol; -} - } +for (const SymbolContext &sc : sc_list) { + if (sc.symbol->IsExternal()) +return sc.symbol; } // If we didn't find the symbol in this module, it may be because this // module re-exports some whole other library. We have to search those as Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -4028,52 +4028,45 @@ lldb_private::SymbolContextList sc_list; process->GetTarget().GetImages().FindSymbolsWithNameAndType( ConstString(symbol_name), eSymbolTypeAny, sc_list); - if (!sc_list.IsEmpty()) { -const size_t num_scs = sc_list.GetSize(); -for (size_t sc_idx = 0; - sc_i
[Lldb-commits] [lldb] 04aa943 - [lldb] Expose a const iterator for SymbolContextList
Author: Alex Langford Date: 2023-05-04T16:36:44-07:00 New Revision: 04aa943be8ed5c03092e2a90112ac638360ec253 URL: https://github.com/llvm/llvm-project/commit/04aa943be8ed5c03092e2a90112ac638360ec253 DIFF: https://github.com/llvm/llvm-project/commit/04aa943be8ed5c03092e2a90112ac638360ec253.diff LOG: [lldb] Expose a const iterator for SymbolContextList There are many situations where we'll iterate over a SymbolContextList with the pattern: ``` SymbolContextList sc_list; // Fill in sc_list here for (auto i = 0; i < sc_list.GetSize(); i++) { SymbolContext sc; sc_list.GetSymbolAtContext(i, sc); // Do work with sc } ``` Adding an iterator to iterate over the instances directly means we don't have to do bounds checking or create a copy of every element of the SymbolContextList. Differential Revision: https://reviews.llvm.org/D149900 Added: Modified: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Symbol/UnwindTable.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Symbol/UnwindTable.cpp Removed: diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 5864a284d6f1e..3747e6d2d9a22 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -59,7 +59,7 @@ class BreakpointResolverFileLine : public BreakpointResolver { protected: void FilterContexts(SymbolContextList &sc_list); - void DeduceSourceMapping(SymbolContextList &sc_list); + void DeduceSourceMapping(const SymbolContextList &sc_list); friend class Breakpoint; SourceLocationSpec m_location_spec; diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 73fa25514aff3..68bef70f3bcfe 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -451,11 +451,15 @@ class SymbolContextList { protected: typedef std::vector collection; ///< The collection type for the list. + typedef collection::const_iterator const_iterator; // Member variables. collection m_symbol_contexts; ///< The list of symbol contexts. public: + const_iterator begin() const { return m_symbol_contexts.begin(); } + const_iterator end() const { return m_symbol_contexts.end(); } + typedef AdaptedIterable SymbolContextIterable; SymbolContextIterable SymbolContexts() { diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index a3026504dbdfe..f0ce7047de2d1 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -53,7 +53,7 @@ class UnwindTable { // problem. lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, -SymbolContext &sc); +const SymbolContext &sc); ArchSpec GetArchitecture(); @@ -62,7 +62,7 @@ class UnwindTable { void Initialize(); std::optional GetAddressRange(const Address &addr, - SymbolContext &sc); + const SymbolContext &sc); typedef std::map collection; typedef collection::iterator iterator; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index ef8a0ab8f9d46..35cc45d79c57a 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -847,20 +847,14 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, SymbolContextList sc_list; frame_sc.comp_unit->ResolveSymbolContext(location_spec, eSymbolContextLineEntry, sc_list); -const uint32_t num_matches = sc_list.GetSize(); -if (num_matches > 0) { - SymbolContext sc; - for (uint32_t i = 0; i < num_matches; ++i) { -if (sc_list.GetContextAtIndex(i, sc))
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG04aa943be8ed: [lldb] Expose a const iterator for SymbolContextList (authored by bulbazord). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 Files: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Symbol/UnwindTable.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Symbol/UnwindTable.cpp Index: lldb/source/Symbol/UnwindTable.cpp === --- lldb/source/Symbol/UnwindTable.cpp +++ lldb/source/Symbol/UnwindTable.cpp @@ -86,8 +86,8 @@ UnwindTable::~UnwindTable() = default; -std::optional UnwindTable::GetAddressRange(const Address &addr, - SymbolContext &sc) { +std::optional +UnwindTable::GetAddressRange(const Address &addr, const SymbolContext &sc) { AddressRange range; // First check the unwind info from the object file plugin @@ -150,9 +150,8 @@ // don't add it to the UnwindTable. This is intended for use by target modules // show-unwind where we want to create new UnwindPlans, not re-use existing // ones. -FuncUnwindersSP -UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr, - SymbolContext &sc) { +FuncUnwindersSP UnwindTable::GetUncachedFuncUnwindersContainingAddress( +const Address &addr, const SymbolContext &sc) { Initialize(); auto range_or = GetAddressRange(addr, sc); Index: lldb/source/Symbol/SymbolContext.cpp === --- lldb/source/Symbol/SymbolContext.cpp +++ lldb/source/Symbol/SymbolContext.cpp @@ -771,14 +771,11 @@ Module *module = module_sp.get(); auto ProcessMatches = [this, &name, &target, - module](SymbolContextList &sc_list, + module](const SymbolContextList &sc_list, Status &error) -> const Symbol * { llvm::SmallVector external_symbols; llvm::SmallVector internal_symbols; -const uint32_t matches = sc_list.GetSize(); -for (uint32_t i = 0; i < matches; ++i) { - SymbolContext sym_ctx; - sc_list.GetContextAtIndex(i, sym_ctx); +for (const SymbolContext &sym_ctx : sc_list) { if (sym_ctx.symbol) { const Symbol *symbol = sym_ctx.symbol; const Address sym_address = symbol->GetAddress(); Index: lldb/source/Symbol/Symbol.cpp === --- lldb/source/Symbol/Symbol.cpp +++ lldb/source/Symbol/Symbol.cpp @@ -488,15 +488,9 @@ lldb_private::SymbolContextList sc_list; module_sp->FindSymbolsWithNameAndType(reexport_name, eSymbolTypeAny, sc_list); -const size_t num_scs = sc_list.GetSize(); -if (num_scs > 0) { - for (size_t i = 0; i < num_scs; ++i) { -lldb_private::SymbolContext sc; -if (sc_list.GetContextAtIndex(i, sc)) { - if (sc.symbol->IsExternal()) -return sc.symbol; -} - } +for (const SymbolContext &sc : sc_list) { + if (sc.symbol->IsExternal()) +return sc.symbol; } // If we didn't find the symbol in this module, it may be because this // module re-exports some whole other library. We have to search those as Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -4028,52 +4028,45 @@ lldb_private::SymbolContextList sc_list; process->GetTarget().GetImages().FindSymbolsWithNameAndType( ConstString(symbol_name), eSymbolTypeAny, sc_list); - if (!sc_list.
[Lldb-commits] [lldb] 6f8b33f - [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
Author: Jonas Devlieghere Date: 2023-05-04T16:42:46-07:00 New Revision: 6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3 URL: https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3 DIFF: https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3.diff LOG: [lldb] Use templates to simplify {Get,Set}PropertyAtIndex (NFC) Use templates to simplify {Get,Set}PropertyAtIndex. It has always bothered me how cumbersome those calls are when adding new properties. After this patch, SetPropertyAtIndex infers the type from its arguments and GetPropertyAtIndex required a single template argument for the return value. As an added benefit, this enables us to remove a bunch of wrappers from UserSettingsController and OptionValueProperties. Differential revision: https://reviews.llvm.org/D149774 Added: Modified: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/UserSettingsController.h lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Interpreter/Property.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp Removed: diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index a7487e159e2c7..f05d8d4e6b231 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -269,7 +269,7 @@ class Debugger : public std::enable_shared_from_this, const FormatEntity::Entry *GetFrameFormatUnique() const; - uint32_t GetStopDisassemblyMaxSize() const; + uint64_t GetStopDisassemblyMaxSize() const; const FormatEntity::Entry *GetThreadFormat() const; @@ -283,7 +283,7 @@ class Debugger : public std::enable_shared_from_this, bool SetREPLLanguage(lldb::LanguageType repl_lang); - uint32_t GetTerminalWidth() const; + uint64_t GetTerminalWidth() const; bool SetTerminalWidth(uint32_t term_width); @@ -329,11 +329,11 @@ class Debugger : public std::enable_shared_from_this, llvm::StringRef GetStopShowColumnAnsiSuffix() const; - uint32_t GetStopSourceLineCount(bool before) const; + uint64_t GetStopSourceLineCount(bool before) const; StopDisassemblyType GetStopDisassemblyDisplay() const; - uint32_t GetDisassemblyLineCount() const; + uint64_t GetDisassemblyLineCount() const; llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const; @@ -349,7 +349,7 @@ class Debugger : public std::enable_shared_from_this, bool SetPrintDecls(bool b); - uint32_t GetTabSize() const; + uint64_t GetTabSize() const; bool SetTabSize(uint32_t tab_size); diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index 19b080d125a35..f320057ef120d 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -9,6 +9,7 @@ #ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H #define LLDB_CORE_USERSETTINGSCONTROLLER_H +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" @@ -82,6 +83,27 @@ class Properties { static bool IsSettingExperimental(llvm::StringRef setting); + template + T GetPropertyAtIndexAs(uint32_t idx, T default_value, + const ExecutionContext *exe_ctx = nullptr) const { +return m_collection_sp->GetPropertyAtIndexAs(idx, exe_ctx) +.value_or(default_value); + } + + template ::type, +std::enable_if_t, bool> = true> + const U * + GetPropertyAtIndexAs(uint32_t idx, + const ExecutionContext *exe_ctx = nullptr) const { +return m_collection_sp->GetPropertyAtIndexAs(idx, exe_ctx); + } + + template + bool SetPropertyAtIndex(uint32_t idx, T t, + const ExecutionContext *exe_ctx = nullptr) const { +return m_collection_sp->SetPropertyAtIndex(idx, t, exe_ctx); + } + protected: lldb::OptionValuePropertiesSP m_collection_sp; }; diff --git a/lldb/include/lldb/Interprete
[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)
This revision was automatically updated to reflect the committed changes. JDevlieghere marked 2 inline comments as done. Closed by commit rG6f8b33f6dfd0: [lldb] Use templates to simplify {Get,Set}PropertyAtIndex (NFC) (authored by JDevlieghere). Herald added a project: LLDB. Changed prior to commit: https://reviews.llvm.org/D149774?vs=519580&id=519695#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149774/new/ https://reviews.llvm.org/D149774 Files: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/UserSettingsController.h lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Interpreter/Property.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp Index: lldb/source/Target/Thread.cpp === --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -112,7 +112,7 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() { const uint32_t idx = ePropertyStepAvoidRegex; - return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(idx); + return GetPropertyAtIndexAs(idx); } FileSpecList ThreadProperties::GetLibrariesToAvoid() const { @@ -125,26 +125,26 @@ bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } uint64_t ThreadProperties::GetMaxBacktraceDepth() const { const uint32_t idx = ePropertyMaxBacktraceDepth; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value); } // Thread Event Data Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4136,7 +4136,7 @@ exp_property->GetValue()->GetAsProperties(); if (exp_values) return exp_values -->GetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, exe_ctx) +->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) .value_or(true); else return true; @@ -4149,8 +4149,7 @@ OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -exp_values->SetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, true, -exe_ctx); +exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); } ArchSpec TargetProperties::GetDefaultArchitecture() const { @@ -4170,75 +4169,75 @@ bool TargetProperties::GetMoveToNearestCode() const { const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const { const uint32_t idx = ePropertyPreferDynamic; - return (lldb::DynamicValueType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value);
[Lldb-commits] [PATCH] D149900: [lldb] Expose a const iterator for SymbolContextList
bulbazord added a comment. Looks like this may have broken the Debian buildbot: https://lab.llvm.org/buildbot/#/builders/68/builds/52162/steps/6/logs/stdio I'm taking a look and will try to fix forward. If I can't figure it out quickly, I will revert. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149900/new/ https://reviews.llvm.org/D149900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3d6073a - Revert "[lldb] Expose a const iterator for SymbolContextList"
Author: Alex Langford Date: 2023-05-04T16:49:30-07:00 New Revision: 3d6073a9c33005abf8c6fc074e434c90b36dccb9 URL: https://github.com/llvm/llvm-project/commit/3d6073a9c33005abf8c6fc074e434c90b36dccb9 DIFF: https://github.com/llvm/llvm-project/commit/3d6073a9c33005abf8c6fc074e434c90b36dccb9.diff LOG: Revert "[lldb] Expose a const iterator for SymbolContextList" This reverts commit 04aa943be8ed5c03092e2a90112ac638360ec253. This broke the debian buildbot and I'm not sure why. Reverting so I can investigate. Added: Modified: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Symbol/UnwindTable.h lldb/source/API/SBThread.cpp lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Core/SourceManager.cpp lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Symbol/UnwindTable.cpp Removed: diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 3747e6d2d9a22..5864a284d6f1e 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -59,7 +59,7 @@ class BreakpointResolverFileLine : public BreakpointResolver { protected: void FilterContexts(SymbolContextList &sc_list); - void DeduceSourceMapping(const SymbolContextList &sc_list); + void DeduceSourceMapping(SymbolContextList &sc_list); friend class Breakpoint; SourceLocationSpec m_location_spec; diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 68bef70f3bcfe..73fa25514aff3 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -451,15 +451,11 @@ class SymbolContextList { protected: typedef std::vector collection; ///< The collection type for the list. - typedef collection::const_iterator const_iterator; // Member variables. collection m_symbol_contexts; ///< The list of symbol contexts. public: - const_iterator begin() const { return m_symbol_contexts.begin(); } - const_iterator end() const { return m_symbol_contexts.end(); } - typedef AdaptedIterable SymbolContextIterable; SymbolContextIterable SymbolContexts() { diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index f0ce7047de2d1..a3026504dbdfe 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -53,7 +53,7 @@ class UnwindTable { // problem. lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, -const SymbolContext &sc); +SymbolContext &sc); ArchSpec GetArchitecture(); @@ -62,7 +62,7 @@ class UnwindTable { void Initialize(); std::optional GetAddressRange(const Address &addr, - const SymbolContext &sc); + SymbolContext &sc); typedef std::map collection; typedef collection::iterator iterator; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 35cc45d79c57a..ef8a0ab8f9d46 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -847,14 +847,20 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, SymbolContextList sc_list; frame_sc.comp_unit->ResolveSymbolContext(location_spec, eSymbolContextLineEntry, sc_list); -for (const SymbolContext &sc : sc_list) { - addr_t step_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(target); - if (step_addr != LLDB_INVALID_ADDRESS) { -if (fun_range.ContainsLoadAddress(step_addr, target)) - step_over_until_addrs.push_back(step_addr); -else - all_in_function = false; +const uint32_t num_matches = sc_list.GetSize(); +if (num_matches > 0) { + SymbolContext sc; + for (uint32_t i = 0; i < num_matches; ++i) { +if (sc_list.G
[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected
paperchalice added inline comments. Comment at: cmake/Modules/GetClangResourceDir.cmake:13 + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") +set(ret_dir bin/${CLANG_RESOURCE_DIR}) + else() tstellar wrote: > Why is the bin prefix here? See https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152 `GetResourcesPath` will return `/lib/` when `CLANG_RESOURCE_DIR` is empty, `/bin/CLANG_RESOURCE_DIR` otherwise. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141907/new/ https://reviews.llvm.org/D141907 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected
tstellar added inline comments. Comment at: cmake/Modules/GetClangResourceDir.cmake:13 + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") +set(ret_dir bin/${CLANG_RESOURCE_DIR}) + else() paperchalice wrote: > tstellar wrote: > > Why is the bin prefix here? > See > https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152 > `GetResourcesPath` will return `/lib/` when > `CLANG_RESOURCE_DIR` is empty, `/bin/CLANG_RESOURCE_DIR` otherwise. > `GetResourcesPath` calls `sys::path::parent_path` twice on the path to the clang executable which is going to give you `/usr ` on most Linux systems, so it's returning `/CLANG_RESOURCE_DIR` not `/bin/CLANG_RESOURCE_DIR`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141907/new/ https://reviews.llvm.org/D141907 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected
tstellar added inline comments. Comment at: cmake/Modules/GetClangResourceDir.cmake:13 + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") +set(ret_dir bin/${CLANG_RESOURCE_DIR}) + else() tstellar wrote: > paperchalice wrote: > > tstellar wrote: > > > Why is the bin prefix here? > > See > > https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152 > > `GetResourcesPath` will return `/lib/` when > > `CLANG_RESOURCE_DIR` is empty, `/bin/CLANG_RESOURCE_DIR` otherwise. > > > `GetResourcesPath` calls `sys::path::parent_path` twice on the path to the > clang executable which is going to give you `/usr ` on most Linux systems, so > it's returning `/CLANG_RESOURCE_DIR` not > `/bin/CLANG_RESOURCE_DIR`. Sorry, you are correct. I was looking at the wrong branch. It's really strange that it does that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141907/new/ https://reviews.llvm.org/D141907 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div
Michael137 added a comment. I tried the new test case on my Mac but it's now hitting an assertion: TEST 'lldb-shell :: SymbolFile/DWARF/x86/DW_OP_div-with-signed.s' FAILED Script: -- : 'RUN: at line 2'; /Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang --target=specify-a-target-or-use-a-_host-substitution -c --target=x86_64-pc-linux -o /Users/michaelbuch/Git/lldb-build-main-no-mod ules/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/DW_OP_div-with-signed.s.tmp /Users/michaelbuch/Git/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s : 'RUN: at line 3'; /Users/michaelbuch/Git/lldb-build-main-no-modules/bin/lldb --no-lldbinit -S /Users/michaelbuch/Git/lldb-build-main-no-modules/tools/lldb/test/Shell/lit-lldb-init-quiet /Users/michaelbuch/Git /lldb-build-main-no-modules/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/DW_OP_div-with-signed.s.tmp -o "expression -T -- g" -o "exit" | /Users/michaelbuch/Git/lldb-build-main-no-modules/bin/FileCheck /Users /michaelbuch/Git/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s -- Exit Code: 1 Command Output (stderr): -- Assertion failed: ((!RootFile.Name.empty() || MCDwarfFiles.size() >= 1) && "No root file and no .file directives"), function emitV5FileDirTables, file MCDwarf.cpp, line 473. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang --target=specify-a-target-or-use-a-_host-substitution -c --target=x86_64-pc-linux -o /Users/michaelbuch/Git/lldb-build-main-n o-modules/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/DW_OP_div-with-signed.s.tmp /Users/michaelbuch/Git/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s #0 0x00010940 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x104682660) #1 0x000109466bf8 PrintStackTraceSignalHandler(void*) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x104682bf8) #2 0x0001094649d0 llvm::sys::RunSignalHandlers() (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x1046809d0) #3 0x000109465e10 llvm::sys::CleanupOnSignal(unsigned long) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x104681e10) #4 0x0001093245c8 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x1045405c8) #5 0x000109324a64 CrashRecoverySignalHandler(int) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x104540a64) #6 0x00018ddc2a24 (/usr/lib/system/libsystem_platform.dylib+0x18042ea24) #7 0x00018dd93c28 (/usr/lib/system/libsystem_pthread.dylib+0x1803ffc28) #8 0x00018dca1ae8 (/usr/lib/system/libsystem_c.dylib+0x18030dae8) #9 0x00018dca0e44 (/usr/lib/system/libsystem_c.dylib+0x18030ce44) #10 0x000108c3ad04 llvm::MCDwarfLineTableHeader::emitV5FileDirTables(llvm::MCStreamer*, std::__1::optional&) const (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103e5 6d04) #11 0x000108c39ff8 llvm::MCDwarfLineTableHeader::Emit(llvm::MCStreamer*, llvm::MCDwarfLineTableParams, llvm::ArrayRef, std::__1::optional&) const (/Users/michaelbuch/Git/lldb-build -main-no-modules/bin/clang-17+0x103e55ff8) #12 0x000108c3a178 llvm::MCDwarfLineTableHeader::Emit(llvm::MCStreamer*, llvm::MCDwarfLineTableParams, std::__1::optional&) const (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/c lang-17+0x103e56178) #13 0x000108c39920 llvm::MCDwarfLineTable::emitCU(llvm::MCStreamer*, llvm::MCDwarfLineTableParams, std::__1::optional&) const (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang -17+0x103e55920) #14 0x000108c397b4 llvm::MCDwarfLineTable::emit(llvm::MCStreamer*, llvm::MCDwarfLineTableParams) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103e557b4) #15 0x000108c80320 llvm::MCObjectStreamer::finishImpl() (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103e9c320) #16 0x000108c528e4 llvm::MCELFStreamer::finishImpl() (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103e6e8e4) #17 0x000108cb0b88 llvm::MCStreamer::finish(llvm::SMLoc) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103eccb88) #18 0x000108d51fb4 (anonymous namespace)::AsmParser::Run(bool, bool) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x103f6dfb4) #19 0x000104e15b74 ExecuteAssemblerImpl((anonymous namespace)::AssemblerInvocation&, clang::DiagnosticsEngine&) (/Users/michaelbuch/Git/lldb-build-main-no-modules/bin/clang-17+0x100031b74)
[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div
jwnhy updated this revision to Diff 519733. jwnhy added a comment. Update the patch to pass the assertion. Sorry I forget to enable these on my machine. Given that said, this assertion seems pretty weird to me. Since this assembly is also generated by clang (with handcrafted DWARF, this assertion means that any assembly generated from a single file will be rejected? Anyway, I have added a dummy ".file 1" directive to pass this assertion. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147370/new/ https://reviews.llvm.org/D147370 Files: lldb/source/Expression/DWARFExpression.cpp lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s Index: lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s === --- /dev/null +++ lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s @@ -0,0 +1,231 @@ + # Test handling of values represented via DW_OP_div + # RUN: %clang -c --target=x86_64-pc-linux -o %t %s + # RUN: %lldb %t -o "expression -T -- g" -o "exit" | FileCheck %s + + # Failing case was: + # (int) $0 = 0 + # CHECK: (int) $0 = 2 + # + # This file is crafted by hand on the basis of a very simple C program. + + # The original (NOT THIS FILE) error-triggering code is: + # #include "stdint.h" + # static volatile uint64_t g = 0; + # static const int32_t f() + # { + #uint32_t i; + #for (i = 0; (i != 10); i++) + # ++g; + #return 0; + # + # } + # + # int main() + # { + #f(); + #return 0; + # + # } + # When the above code is compiled by Clang 15.0.7 with -O1, it generates desired DW_OP_div for testing. + # Due to cross-platform issue, this case is hand-crafted for testing. + .text + .file "DW_OP_div-with-signed.c" + .file 1 "DUMMY.c" # to pass assertion + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .loc 0 4 0 # DW_OP_div-with-signed.c:4:0 + .cfi_startproc +# %bb.0: + .loc 0 5 5 prologue_end # DW_OP_div-with-signed.c:5:5 + xorl %eax, %eax + retq +.Ltmp0: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc +# -- End function + .type g,@object # @g + .data + .globl g + .p2align 2, 0x0 +g: + .long 3735928559 # 0xdeadbeef + .size g, 4 + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 37 # DW_FORM_strx1 + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 37 # DW_FORM_strx1 + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHI
[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div
jwnhy updated this revision to Diff 519735. jwnhy added a comment. Update the patch for better naming. The assertion is correct, I somehow delete a file directive from the assembly generated by clang. It should work now...Thanks a lot for checking this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147370/new/ https://reviews.llvm.org/D147370 Files: lldb/source/Expression/DWARFExpression.cpp lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s Index: lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s === --- /dev/null +++ lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s @@ -0,0 +1,232 @@ + # Test handling of values represented via DW_OP_div + # RUN: %clang -c --target=x86_64-pc-linux -o %t %s + # RUN: %lldb %t -o "expression -T -- g" -o "exit" | FileCheck %s + + # Failing case was: + # (int) $0 = 0 + # CHECK: (int) $0 = 2 + # + # This file is crafted by hand on the basis of a very simple C program. + + # The original (NOT THIS FILE) error-triggering code is: + # #include "stdint.h" + # static volatile uint64_t g = 0; + # static const int32_t f() + # { + #uint32_t i; + #for (i = 0; (i != 10); i++) + # ++g; + #return 0; + # + # } + # + # int main() + # { + #f(); + #return 0; + # + # } + # When the above code is compiled by Clang 15.0.7 with -O1, it generates desired DW_OP_div for testing. + # Due to cross-platform issue, this case is hand-crafted for testing. + + .text + .file "DW_OP_div-with-signed.c" + .file 0 "DW_OP_div-with-signed.c" # Dummy file + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .loc 0 4 0 # DW_OP_div-with-signed.c:4:0 + .cfi_startproc +# %bb.0: + .loc 0 5 5 prologue_end # DW_OP_div-with-signed.c:5:5 + xorl %eax, %eax + retq +.Ltmp0: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc +# -- End function + .type g,@object # @g + .data + .globl g + .p2align 2, 0x0 +g: + .long 3735928559 # 0xdeadbeef + .size g, 4 + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 37 # DW_FORM_strx1 + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 37 # DW_FORM_strx1 + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 62 # DW_AT_encoding + .byte 11
[Lldb-commits] [lldb] b193bd3 - [lldb] Remove SetPropertyAtIndexAsLanguage (NFC)
Author: Jonas Devlieghere Date: 2023-05-04T21:48:14-07:00 New Revision: b193bd3f28acba2686e6f7d376884deb82ae43c6 URL: https://github.com/llvm/llvm-project/commit/b193bd3f28acba2686e6f7d376884deb82ae43c6 DIFF: https://github.com/llvm/llvm-project/commit/b193bd3f28acba2686e6f7d376884deb82ae43c6.diff LOG: [lldb] Remove SetPropertyAtIndexAsLanguage (NFC) After 6f8b33f6dfd0 this function has no callers anymore. Added: Modified: lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Interpreter/OptionValueProperties.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 3251a5ed5e2e2..617fedc7d13ee 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -112,9 +112,6 @@ class OptionValueProperties OptionValueLanguage *GetPropertyAtIndexAsOptionValueLanguage( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - bool SetPropertyAtIndexAsLanguage(uint32_t idx, lldb::LanguageType lang, -const ExecutionContext *exe_ctx = nullptr); - bool GetPropertyAtIndexAsArgs(uint32_t idx, Args &args, const ExecutionContext *exe_ctx = nullptr) const; diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index 53f3c3a808446..fdf5500d53c69 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -210,17 +210,6 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage( return nullptr; } -bool OptionValueProperties::SetPropertyAtIndexAsLanguage( -uint32_t idx, const LanguageType lang, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { -OptionValue *value = property->GetValue().get(); -if (value) - return value->SetLanguageValue(lang); - } - return false; -} - bool OptionValueProperties::GetPropertyAtIndexAsArgs( uint32_t idx, Args &args, const ExecutionContext *exe_ctx) const { const Property *property = GetPropertyAtIndex(idx, exe_ctx); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 917b3a7 - [lldb] Move Core/FileSpecList -> Utility/FileSpecList (NFC)
Author: Jonas Devlieghere Date: 2023-05-04T22:00:17-07:00 New Revision: 917b3a7e62063398d2cbc4f8fe56feb68b0fae4f URL: https://github.com/llvm/llvm-project/commit/917b3a7e62063398d2cbc4f8fe56feb68b0fae4f DIFF: https://github.com/llvm/llvm-project/commit/917b3a7e62063398d2cbc4f8fe56feb68b0fae4f.diff LOG: [lldb] Move Core/FileSpecList -> Utility/FileSpecList (NFC) There's no reason for FileSpecList to live in lldb/Core while FileSpec lives in lldb/Utility. Move FileSpecList next to FileSpec. Added: lldb/include/lldb/Utility/FileSpecList.h lldb/source/Utility/FileSpecList.cpp Modified: lldb/include/lldb/Core/SearchFilter.h lldb/include/lldb/Interpreter/CommandCompletions.h lldb/include/lldb/Interpreter/OptionValueFileSpecList.h lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/LocateSymbolFile.h lldb/include/lldb/Symbol/ObjectFile.h lldb/source/API/SBFileSpecList.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Core/CMakeLists.txt lldb/source/Core/FileLineResolver.cpp lldb/source/Core/Module.cpp lldb/source/Core/ModuleList.cpp lldb/source/Expression/ObjectFileJIT.cpp lldb/source/Interpreter/CommandObject.cpp lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h lldb/source/Utility/CMakeLists.txt lldb/unittests/Core/FileSpecListTest.cpp Removed: lldb/include/lldb/Core/FileSpecList.h lldb/source/Core/FileSpecList.cpp diff --git a/lldb/include/lldb/Core/SearchFilter.h b/lldb/include/lldb/Core/SearchFilter.h index 491e3ddc5985f..7645499e948d0 100644 --- a/lldb/include/lldb/Core/SearchFilter.h +++ b/lldb/include/lldb/Core/SearchFilter.h @@ -9,7 +9,7 @@ #ifndef LLDB_CORE_SEARCHFILTER_H #define LLDB_CORE_SEARCHFILTER_H -#include "lldb/Core/FileSpecList.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/FileSpec.h" diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index c13bc4997ff3e..8578782e9fdd7 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -11,10 +11,10 @@ #include -#include "lldb/Core/FileSpecList.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/lldb-private.h" diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h index 29641c3a20879..bda6b5071d599 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -11,8 +11,8 @@ #include -#include "lldb/Core/FileSpecList.h" #include "lldb/Interpreter/OptionValue.h" +#include "lldb/Utility/FileSpecList.h" namespace lldb_private { diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h index 44e1d673f1fd1..229ee2d27a703 100644 --- a/lldb/include/lldb/Symbol/CompileUnit.h +++ b/lldb/include/lldb/Symbol/CompileUnit.h @@ -9,13 +9,13 @@ #ifndef LLDB_SYMBOL_COMPILEUNIT_H #define LLDB_SYMBOL_COMPILEUNIT_H -#include "lldb/Core/FileSpecList.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/SourceLocationSpec.h" #include "lldb/Symbol/DebugMacros.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SourceModule.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" diff --git a/lldb/include/lldb/Symbol/LocateSymbolFile.h b/lldb/include/lldb/Symbol/LocateSymbolFile.h index 6f0506e671ce4..0bf6555909676 100644 --- a/lldb/include/lldb/Symbol/LocateSymbolFile.h +++ b/lldb/include/lldb/Symbol/LocateSymbolFile.h @@ -11,8 +11,8 @@ #include -#include "lldb/Core/FileSpecList.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 8862630495e60..9b006dfe05e7e 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -9,7 +9,6 @@ #ifndef LLDB_SYMBOL_OBJECTFILE_H #define LLDB_SYMBOL_OBJECTFILE_H -#include "lldb/Core/FileSpecList.h" #include "lldb
[Lldb-commits] [lldb] ab73a9c - [lldb] Eliminate {Get, Set}PropertyAtIndexAsFileSpec (NFC)
Author: Jonas Devlieghere Date: 2023-05-04T22:10:28-07:00 New Revision: ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f URL: https://github.com/llvm/llvm-project/commit/ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f DIFF: https://github.com/llvm/llvm-project/commit/ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f.diff LOG: [lldb] Eliminate {Get,Set}PropertyAtIndexAsFileSpec (NFC) This patch is a continuation of 6f8b33f6dfd0 and eliminates the {Get,Set}PropertyAtIndexAsFileSpec functions. Added: Modified: lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValue.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index eef7d67eb034c..41dc6c4405937 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -13,6 +13,7 @@ #include "lldb/Utility/Cloneable.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-private-enumerations.h" @@ -269,9 +270,9 @@ class OptionValue { bool SetEnumerationValue(int64_t value); - FileSpec GetFileSpecValue() const; + std::optional GetFileSpecValue() const; - bool SetFileSpecValue(const FileSpec &file_spec); + bool SetFileSpecValue(FileSpec file_spec); FileSpecList GetFileSpecListValue() const; @@ -334,6 +335,8 @@ class OptionValue { return GetCharValue(); if constexpr (std::is_same_v) return GetFormatValue(); +if constexpr (std::is_same_v) + return GetFileSpecValue(); if constexpr (std::is_same_v) return GetLanguageValue(); if constexpr (std::is_same_v) @@ -362,6 +365,8 @@ class OptionValue { bool SetValueAs(lldb::LanguageType v) { return SetLanguageValue(v); } + bool SetValueAs(FileSpec v) { return SetFileSpecValue(v); } + template , bool> = true> bool SetValueAs(T t) { return SetEnumerationValue(t); diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 617fedc7d13ee..004ed55e3b119 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -134,13 +134,6 @@ class OptionValueProperties OptionValueFileSpec *GetPropertyAtIndexAsOptionValueFileSpec( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - FileSpec - GetPropertyAtIndexAsFileSpec(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsFileSpec(uint32_t idx, const FileSpec &file_spec, -const ExecutionContext *exe_ctx = nullptr); - OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 39caa21b21b5c..256b4afa7bd6c 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -112,25 +112,23 @@ bool ModuleListProperties::GetEnableBackgroundLookup() const { } FileSpec ModuleListProperties::GetClangModulesCachePath() const { - return m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpec(ePropertyClangModulesCachePath) - ->GetCurrentValue(); + const uint32_t idx = ePropertyClangModulesCachePath; + return GetPropertyAtIndexAs(idx, {}); } bool ModuleListProperties::SetClangModulesCachePath(const FileSpec &path) { - return m_collection_sp->SetPropertyAtIndexAsFileSpec( - ePropertyClangModulesCachePath, path); + const uint32_t idx = ePropertyClangModulesCachePath; + return SetPropertyAtIndex(idx, path); } FileSpec ModuleListProperties::GetLLDBIndexCachePath() const { - return m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpec(ePropertyLLDBIndexCachePath) - ->GetCurrentValue(); + const uint32_t idx = ePropertyLLDBIndexCachePath; + return GetPropertyAtIndexAs(idx, {}); } bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) { - return m_collection_sp->SetPropertyAtIndexAsFileSpec( - ePropertyLLDBIndexCachePath, path); + const uint32_t idx = ePropertyLLDBIndexCachePath; + return SetPropertyAtIndex(idx, path); } bool ModuleListProperties::GetEnableLLDBIndexCache() const { diff
[Lldb-commits] [lldb] 300dce9 - [lldb] Migrate to GetPropertyAtIndexAs for FileSpecList (NFC)
Author: Jonas Devlieghere Date: 2023-05-04T22:24:23-07:00 New Revision: 300dce986f656a2d787b8e882381f39746d2fc0a URL: https://github.com/llvm/llvm-project/commit/300dce986f656a2d787b8e882381f39746d2fc0a DIFF: https://github.com/llvm/llvm-project/commit/300dce986f656a2d787b8e882381f39746d2fc0a.diff LOG: [lldb] Migrate to GetPropertyAtIndexAs for FileSpecList (NFC) Use the templated GetPropertyAtIndexAs helper for FileSpecList. Added: Modified: lldb/include/lldb/Interpreter/OptionValue.h lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/OptionValue.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 41dc6c440593..8735106c3d14 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -14,6 +14,7 @@ #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-private-enumerations.h" @@ -274,7 +275,9 @@ class OptionValue { bool SetFileSpecValue(FileSpec file_spec); - FileSpecList GetFileSpecListValue() const; + bool AppendFileSpecValue(FileSpec file_spec); + + std::optional GetFileSpecListValue() const; std::optional GetFormatValue() const; @@ -337,6 +340,8 @@ class OptionValue { return GetFormatValue(); if constexpr (std::is_same_v) return GetFileSpecValue(); +if constexpr (std::is_same_v) + return GetFileSpecListValue(); if constexpr (std::is_same_v) return GetLanguageValue(); if constexpr (std::is_same_v) diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 256b4afa7bd6..212b1186b4ef 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -161,9 +161,7 @@ uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() { void ModuleListProperties::UpdateSymlinkMappings() { FileSpecList list = - m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpecList(ePropertySymLinkPaths) - ->GetCurrentValue(); + GetPropertyAtIndexAs(ePropertySymLinkPaths, {}); llvm::sys::ScopedWriter lock(m_symlink_paths_mutex); const bool notify = false; m_symlink_paths.Clear(notify); diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index dd293047695a..b9da1f122ebe 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -312,11 +312,18 @@ bool OptionValue::SetFileSpecValue(FileSpec file_spec) { return false; } -FileSpecList OptionValue::GetFileSpecListValue() const { - const OptionValueFileSpecList *option_value = GetAsFileSpecList(); - if (option_value) +bool OptionValue::AppendFileSpecValue(FileSpec file_spec) { + if (OptionValueFileSpecList *option_value = GetAsFileSpecList()) { +option_value->AppendCurrentValue(file_spec); +return true; + } + return false; +} + +std::optional OptionValue::GetFileSpecListValue() const { + if (const OptionValueFileSpecList *option_value = GetAsFileSpecList()) return option_value->GetCurrentValue(); - return FileSpecList(); + return {}; } std::optional OptionValue::GetFormatValue() const { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index a50d35b7d40a..c29007fb9a34 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -201,10 +201,7 @@ class PlatformDarwinKernelProperties : public Properties { FileSpecList GetKextDirectories() const { const uint32_t idx = ePropertyKextDirectories; -const OptionValueFileSpecList *option_value = -m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); -assert(option_value); -return option_value->GetCurrentValue(); +return GetPropertyAtIndexAs(idx, {}); } }; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 1290281d8c27..091027342110 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4390,26 +4390,17 @@ void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) { FileSpecList TargetProperties::GetExecutableSearchPaths() { const uint32_t idx = ePropertyExecutableSearchPaths; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); }