[Lldb-commits] [lldb] [lldb] Fix updating persistent variables without JIT (PR #149642)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/149642 This patch fixes updating persistent variables when memory cannot be allocated in an inferior process: ``` > lldb -c test.core (lldb) expr int $i = 5 (lldb) expr $i = 55 (int) $0 = 55 (lldb) expr $i (int) $i = 5 ``` With this patch, the last command prints: ``` (int) $i = 55 ``` The issue was introduced in #145599. >From f524fdc952592d715aee1e3d5ec75c4180f75509 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 18 Jul 2025 23:45:39 -0700 Subject: [PATCH] [lldb] Fix updating persistent variables without JIT This patch fixes updating persistent variables when memory cannot be allocated in an inferior process: ``` > lldb -c test.core (lldb) expr int $i = 5 (lldb) expr $i = 55 (int) $0 = 55 (lldb) expr $i (int) $i = 5 ``` With this patch, the last command prints: ``` (int) $i = 55 ``` The issue was introduced in #145599. --- lldb/source/Expression/Materializer.cpp | 21 ++- .../postmortem/elf-core/expr/TestExpr.py | 4 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 17ea1596806d0..329768dd7915a 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -102,22 +102,23 @@ class EntityPersistentVariable : public Materializer::Entity { m_persistent_variable_sp->GetName(), mem, eAddressTypeLoad, map.GetAddressByteSize()); -if (m_persistent_variable_sp->m_flags & -ExpressionVariable::EVKeepInTarget) { - if (used_policy == IRMemoryMap::eAllocationPolicyMirror) { +if (used_policy == IRMemoryMap::eAllocationPolicyMirror) { + if (m_persistent_variable_sp->m_flags & + ExpressionVariable::EVKeepInTarget) { // Clear the flag if the variable will never be deallocated. Status leak_error; map.Leak(mem, leak_error); m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVNeedsAllocation; - } else { -// If the variable cannot be kept in target, clear this flag... -m_persistent_variable_sp->m_flags &= -~ExpressionVariable::EVKeepInTarget; -// ...and set the flag to copy the value during dematerialization. -m_persistent_variable_sp->m_flags |= -ExpressionVariable::EVNeedsFreezeDry; } +} else { + // If we cannot allocate memory in the process, + // - clear the 'EVKeepInTarget' flag to ensure that 'm_live_sp' is reset + // during dematerialization, + m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVKeepInTarget; + // - set the 'EVNeedsFreezeDry' flag so that the value is copied to + // 'm_frozen_sp' during dematerialization. + m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsFreezeDry; } // Write the contents of the variable to the area. diff --git a/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py b/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py index dd03a0cc836a7..9dfc6859af8bf 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py @@ -37,6 +37,10 @@ def test_persist_var(self): self.target.EvaluateExpression("int $my_int = 5") self.expect_expr("$my_int * 2", result_type="int", result_value="10") +# Try assigning the persistent variable a new value. +self.target.EvaluateExpression("$my_int = 55") +self.expect_expr("$my_int", result_type="int", result_value="55") + def test_context_object(self): """Test expression evaluation in context of an object.""" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix updating persistent variables without JIT (PR #149642)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Igor Kudrin (igorkudrin) Changes This patch fixes updating persistent variables when memory cannot be allocated in an inferior process: ``` > lldb -c test.core (lldb) expr int $i = 5 (lldb) expr $i = 55 (int) $0 = 55 (lldb) expr $i (int) $i = 5 ``` With this patch, the last command prints: ``` (int) $i = 55 ``` The issue was introduced in #145599. --- Full diff: https://github.com/llvm/llvm-project/pull/149642.diff 2 Files Affected: - (modified) lldb/source/Expression/Materializer.cpp (+11-10) - (modified) lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py (+4) ``diff Rate limit · GitHub body { background-color: #f6f8fa; color: rgba(0, 0, 0, 0.5); font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; } .c { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { text-decoration: none; } a:hover { text-decoration: underline; } h1 { color: #24292e; line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; } p { margin: 20px 0 40px; } #s { margin-top: 35px; } #s a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Access has been restricted You have triggered a rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus `` https://github.com/llvm/llvm-project/pull/149642 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Proofread python-reference.rst (PR #149643)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/149643.diff 1 Files Affected: - (modified) lldb/docs/use/python-reference.rst (+6-6) ``diff diff --git a/lldb/docs/use/python-reference.rst b/lldb/docs/use/python-reference.rst index 325d0685d9d38..4292714c9c208 100644 --- a/lldb/docs/use/python-reference.rst +++ b/lldb/docs/use/python-reference.rst @@ -748,7 +748,7 @@ For instance, if the string you are completing is "Test" and the available compl return {"completion": "Test1", "mode" : "partial"} -and then lldb will add the "1" at the curson and advance it after the added string, +and then lldb will add the "1" at the cursor and advance it after the added string, waiting for more completions. But if "Test1" is the only completion, return: .. code-block:: python @@ -933,7 +933,7 @@ that goal: Using the lldb.py module in Python -- -LLDB has all of its core code build into a shared library which gets used by +LLDB has all of its core code built into a shared library which gets used by the `lldb` command line application. On macOS this shared library is a framework: LLDB.framework and on other unix variants the program is a shared library: lldb.so. LLDB also provides an lldb.py module that contains the @@ -956,7 +956,7 @@ For sh and bash: $ export PYTHONPATH=`lldb -P` -Alternately, you can append the LLDB Python directory to the sys.path list +Alternatively, you can append the LLDB Python directory to the sys.path list directly in your Python code before importing the lldb module. Now your python scripts are ready to import the lldb module. Below is a python @@ -1093,11 +1093,11 @@ Writing Target Stop-Hooks in Python Stop hooks fire whenever the process stops just before control is returned to the user. Stop hooks can either be a set of lldb command-line commands, or can -be implemented by a suitably defined Python class. The Python based stop-hooks -can also be passed as set of -key -value pairs when they are added, and those +be implemented by a suitably defined Python class. The Python-based stop-hooks +can also be passed as a set of -key -value pairs when they are added, and those will get packaged up into a SBStructuredData Dictionary and passed to the constructor of the Python object managing the stop hook. This allows for -parametrization of the stop hooks. +parameterization of the stop hooks. To add a Python-based stop hook, first define a class with the following methods: `` https://github.com/llvm/llvm-project/pull/149643 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Proofread python-reference.rst (PR #149643)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/149643 None >From fe1bf575f69b88108a3efdd668944ce060a02349 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 18 Jul 2025 19:43:06 -0700 Subject: [PATCH] [lldb] Proofread python-reference.rst --- lldb/docs/use/python-reference.rst | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lldb/docs/use/python-reference.rst b/lldb/docs/use/python-reference.rst index 325d0685d9d38..4292714c9c208 100644 --- a/lldb/docs/use/python-reference.rst +++ b/lldb/docs/use/python-reference.rst @@ -748,7 +748,7 @@ For instance, if the string you are completing is "Test" and the available compl return {"completion": "Test1", "mode" : "partial"} -and then lldb will add the "1" at the curson and advance it after the added string, +and then lldb will add the "1" at the cursor and advance it after the added string, waiting for more completions. But if "Test1" is the only completion, return: .. code-block:: python @@ -933,7 +933,7 @@ that goal: Using the lldb.py module in Python -- -LLDB has all of its core code build into a shared library which gets used by +LLDB has all of its core code built into a shared library which gets used by the `lldb` command line application. On macOS this shared library is a framework: LLDB.framework and on other unix variants the program is a shared library: lldb.so. LLDB also provides an lldb.py module that contains the @@ -956,7 +956,7 @@ For sh and bash: $ export PYTHONPATH=`lldb -P` -Alternately, you can append the LLDB Python directory to the sys.path list +Alternatively, you can append the LLDB Python directory to the sys.path list directly in your Python code before importing the lldb module. Now your python scripts are ready to import the lldb module. Below is a python @@ -1093,11 +1093,11 @@ Writing Target Stop-Hooks in Python Stop hooks fire whenever the process stops just before control is returned to the user. Stop hooks can either be a set of lldb command-line commands, or can -be implemented by a suitably defined Python class. The Python based stop-hooks -can also be passed as set of -key -value pairs when they are added, and those +be implemented by a suitably defined Python class. The Python-based stop-hooks +can also be passed as a set of -key -value pairs when they are added, and those will get packaged up into a SBStructuredData Dictionary and passed to the constructor of the Python object managing the stop hook. This allows for -parametrization of the stop hooks. +parameterization of the stop hooks. To add a Python-based stop hook, first define a class with the following methods: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 224e221 - [NFC][lldb] fix extra line after documentation (#149482)
Author: Charles Zablit Date: 2025-07-19T10:46:28+02:00 New Revision: 224e221f1bcb64cf20d81a4ad2855043e445d9bf URL: https://github.com/llvm/llvm-project/commit/224e221f1bcb64cf20d81a4ad2855043e445d9bf DIFF: https://github.com/llvm/llvm-project/commit/224e221f1bcb64cf20d81a4ad2855043e445d9bf.diff LOG: [NFC][lldb] fix extra line after documentation (#149482) Formatting patch which removes an extra line after a docstring. Added: Modified: lldb/include/lldb/Utility/Stream.h Removed: diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 37bcdc9924171..fc547ed739239 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -270,7 +270,6 @@ class Stream { /// \param[in] suffix /// The ANSI color code to end colorization. This is /// environment-dependent. - void PutCStringColorHighlighted( llvm::StringRef text, std::optional settings = std::nullopt); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] fix extra line after documentation (PR #149482)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/149482 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/148877 >From f640beff5da2edb9d928e3a0b1ce4128194c055b Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 15 Nov 2024 01:59:36 + Subject: [PATCH 1/2] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels --- lldb/include/lldb/Core/Module.h | 4 +- lldb/include/lldb/Expression/Expression.h | 35 ++ lldb/include/lldb/Symbol/SymbolFile.h | 14 lldb/source/Core/Module.cpp | 19 +- lldb/source/Expression/Expression.cpp | 65 +++ lldb/source/Expression/IRExecutionUnit.cpp| 63 ++ .../Clang/ClangExpressionDeclMap.cpp | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 44 - .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 45 + .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 + .../SymbolFile/NativePDB/PdbAstBuilder.cpp| 6 +- .../NativePDB/UdtRecordCompleter.cpp | 5 +- .../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 7 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 33 -- .../TypeSystem/Clang/TypeSystemClang.h| 5 +- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 12 ++-- 16 files changed, 318 insertions(+), 44 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 8bb55c95773bc..3991a12997541 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -86,7 +86,8 @@ struct ModuleFunctionSearchOptions { /// /// The module will parse more detailed information as more queries are made. class Module : public std::enable_shared_from_this, - public SymbolContextScope { + public SymbolContextScope, + public UserID { public: class LookupInfo; // Static functions that can track the lifetime of module objects. This is @@ -97,6 +98,7 @@ class Module : public std::enable_shared_from_this, // using the "--global" (-g for short). static size_t GetNumberAllocatedModules(); + static Module *GetAllocatedModuleWithUID(lldb::user_id_t uid); static Module *GetAllocatedModuleAtIndex(size_t idx); static std::recursive_mutex &GetAllocationModuleCollectionMutex(); diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h index 8de9364436ccf..5cf21eb505dac 100644 --- a/lldb/include/lldb/Expression/Expression.h +++ b/lldb/include/lldb/Expression/Expression.h @@ -96,6 +96,41 @@ class Expression { ///invalid. }; +/// Holds parsed information about a function call label that +/// LLDB attaches as an AsmLabel to function AST nodes it parses +/// from debug-info. +/// +/// The format being: +/// +/// ::: +/// +/// The label string needs to stay valid for the entire lifetime +/// of this object. +struct FunctionCallLabel { + /// Mostly for debuggability. + llvm::StringRef m_pubname; + + lldb::user_id_t m_die_id; + lldb::user_id_t m_module_id; +}; + +/// LLDB attaches this prefix to mangled names of functions that it get called +/// from JITted expressions. +inline constexpr llvm::StringRef FunctionCallLabelPrefix = "$__lldb_func"; + +bool consumeFunctionCallLabelPrefix(llvm::StringRef &name); +bool hasFunctionCallLabelPrefix(llvm::StringRef name); + +/// Returns the components of the specified function call label. +/// +/// The format of \c label is described in \c FunctionCallLabel. +/// The label prefix is not one of the components. +llvm::Expected> +splitFunctionCallLabel(llvm::StringRef label); + +// Decodes the function label into a \c FunctionCallLabel. +llvm::Expected makeFunctionCallLabel(llvm::StringRef label); + } // namespace lldb_private #endif // LLDB_EXPRESSION_EXPRESSION_H diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index e95f95553c17c..70dc20664df20 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -18,6 +18,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SourceModule.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeSystem.h" @@ -328,6 +329,19 @@ class SymbolFile : public PluginInterface { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names); + /// Resolves the function DIE uniquely identified by \c uid within + /// this SymbolFile. + /// + /// \param[in,out] sc_list The resolved functions will be appended to this + /// list. + /// + /// \param[in] uid The UID of the function DIE to resolve. + /// + virtual llvm::Error ResolveFunctionUID(SymbolContextList &sc_list, + lldb::user_id_t uid) { +return llvm::createStringError("Not implemented"); + } + vi
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/148877 >From b8e611658f462d2963a3f63018823c9f8908c772 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 15 Nov 2024 01:59:36 + Subject: [PATCH 1/2] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels --- lldb/include/lldb/Core/Module.h | 4 +- lldb/include/lldb/Expression/Expression.h | 16 + lldb/include/lldb/Symbol/SymbolFile.h | 14 lldb/source/Core/Module.cpp | 19 +- lldb/source/Expression/Expression.cpp | 66 +++ lldb/source/Expression/IRExecutionUnit.cpp| 63 ++ .../Clang/ClangExpressionDeclMap.cpp | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 44 - .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 45 + .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 + .../SymbolFile/NativePDB/PdbAstBuilder.cpp| 6 +- .../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 7 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 33 -- .../TypeSystem/Clang/TypeSystemClang.h| 5 +- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 12 ++-- 15 files changed, 298 insertions(+), 41 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 8bb55c95773bc..3991a12997541 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -86,7 +86,8 @@ struct ModuleFunctionSearchOptions { /// /// The module will parse more detailed information as more queries are made. class Module : public std::enable_shared_from_this, - public SymbolContextScope { + public SymbolContextScope, + public UserID { public: class LookupInfo; // Static functions that can track the lifetime of module objects. This is @@ -97,6 +98,7 @@ class Module : public std::enable_shared_from_this, // using the "--global" (-g for short). static size_t GetNumberAllocatedModules(); + static Module *GetAllocatedModuleWithUID(lldb::user_id_t uid); static Module *GetAllocatedModuleAtIndex(size_t idx); static std::recursive_mutex &GetAllocationModuleCollectionMutex(); diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h index 8de9364436ccf..10051f017224d 100644 --- a/lldb/include/lldb/Expression/Expression.h +++ b/lldb/include/lldb/Expression/Expression.h @@ -96,6 +96,22 @@ class Expression { ///invalid. }; +struct FunctionCallLabel { + llvm::StringRef m_mangled_name; + lldb::user_id_t m_die_id; + lldb::user_id_t m_module_id; +}; + +/// LLDB attaches this prefix to mangled names of functions that it get called +/// from JITted expressions. +inline constexpr llvm::StringRef FunctionCallLabelPrefix = "$__lldb_func"; + +bool consumeFunctionCallLabelPrefix(llvm::StringRef &name); +bool hasFunctionCallLabelPrefix(llvm::StringRef name); +llvm::Expected> +splitFunctionCallLabel(llvm::StringRef label); +llvm::Expected makeFunctionCallLabel(llvm::StringRef label); + } // namespace lldb_private #endif // LLDB_EXPRESSION_EXPRESSION_H diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index e95f95553c17c..70dc20664df20 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -18,6 +18,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SourceModule.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeSystem.h" @@ -328,6 +329,19 @@ class SymbolFile : public PluginInterface { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names); + /// Resolves the function DIE uniquely identified by \c uid within + /// this SymbolFile. + /// + /// \param[in,out] sc_list The resolved functions will be appended to this + /// list. + /// + /// \param[in] uid The UID of the function DIE to resolve. + /// + virtual llvm::Error ResolveFunctionUID(SymbolContextList &sc_list, + lldb::user_id_t uid) { +return llvm::createStringError("Not implemented"); + } + virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) = 0; diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 90997dada3666..edd79aff5d065 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -121,6 +121,15 @@ size_t Module::GetNumberAllocatedModules() { return GetModuleCollection().size(); } +Module *Module::GetAllocatedModuleWithUID(lldb::user_id_t uid) { + std::lock_guard guard( + GetAllocationModuleCollectionMutex()); + for (Module *mod
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/148877 >From f640beff5da2edb9d928e3a0b1ce4128194c055b Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 15 Nov 2024 01:59:36 + Subject: [PATCH 1/3] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels --- lldb/include/lldb/Core/Module.h | 4 +- lldb/include/lldb/Expression/Expression.h | 35 ++ lldb/include/lldb/Symbol/SymbolFile.h | 14 lldb/source/Core/Module.cpp | 19 +- lldb/source/Expression/Expression.cpp | 65 +++ lldb/source/Expression/IRExecutionUnit.cpp| 63 ++ .../Clang/ClangExpressionDeclMap.cpp | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 44 - .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 45 + .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 + .../SymbolFile/NativePDB/PdbAstBuilder.cpp| 6 +- .../NativePDB/UdtRecordCompleter.cpp | 5 +- .../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 7 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 33 -- .../TypeSystem/Clang/TypeSystemClang.h| 5 +- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 12 ++-- 16 files changed, 318 insertions(+), 44 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 8bb55c95773bc..3991a12997541 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -86,7 +86,8 @@ struct ModuleFunctionSearchOptions { /// /// The module will parse more detailed information as more queries are made. class Module : public std::enable_shared_from_this, - public SymbolContextScope { + public SymbolContextScope, + public UserID { public: class LookupInfo; // Static functions that can track the lifetime of module objects. This is @@ -97,6 +98,7 @@ class Module : public std::enable_shared_from_this, // using the "--global" (-g for short). static size_t GetNumberAllocatedModules(); + static Module *GetAllocatedModuleWithUID(lldb::user_id_t uid); static Module *GetAllocatedModuleAtIndex(size_t idx); static std::recursive_mutex &GetAllocationModuleCollectionMutex(); diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h index 8de9364436ccf..5cf21eb505dac 100644 --- a/lldb/include/lldb/Expression/Expression.h +++ b/lldb/include/lldb/Expression/Expression.h @@ -96,6 +96,41 @@ class Expression { ///invalid. }; +/// Holds parsed information about a function call label that +/// LLDB attaches as an AsmLabel to function AST nodes it parses +/// from debug-info. +/// +/// The format being: +/// +/// ::: +/// +/// The label string needs to stay valid for the entire lifetime +/// of this object. +struct FunctionCallLabel { + /// Mostly for debuggability. + llvm::StringRef m_pubname; + + lldb::user_id_t m_die_id; + lldb::user_id_t m_module_id; +}; + +/// LLDB attaches this prefix to mangled names of functions that it get called +/// from JITted expressions. +inline constexpr llvm::StringRef FunctionCallLabelPrefix = "$__lldb_func"; + +bool consumeFunctionCallLabelPrefix(llvm::StringRef &name); +bool hasFunctionCallLabelPrefix(llvm::StringRef name); + +/// Returns the components of the specified function call label. +/// +/// The format of \c label is described in \c FunctionCallLabel. +/// The label prefix is not one of the components. +llvm::Expected> +splitFunctionCallLabel(llvm::StringRef label); + +// Decodes the function label into a \c FunctionCallLabel. +llvm::Expected makeFunctionCallLabel(llvm::StringRef label); + } // namespace lldb_private #endif // LLDB_EXPRESSION_EXPRESSION_H diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index e95f95553c17c..70dc20664df20 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -18,6 +18,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SourceModule.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeSystem.h" @@ -328,6 +329,19 @@ class SymbolFile : public PluginInterface { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names); + /// Resolves the function DIE uniquely identified by \c uid within + /// this SymbolFile. + /// + /// \param[in,out] sc_list The resolved functions will be appended to this + /// list. + /// + /// \param[in] uid The UID of the function DIE to resolve. + /// + virtual llvm::Error ResolveFunctionUID(SymbolContextList &sc_list, + lldb::user_id_t uid) { +return llvm::createStringError("Not implemented"); + } + vi
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
@@ -96,6 +96,41 @@ class Expression { ///invalid. }; +/// Holds parsed information about a function call label that +/// LLDB attaches as an AsmLabel to function AST nodes it parses +/// from debug-info. +/// +/// The format being: +/// +/// ::: +/// +/// The label string needs to stay valid for the entire lifetime +/// of this object. +struct FunctionCallLabel { + /// Mostly for debuggability. + llvm::StringRef m_pubname; + + lldb::user_id_t m_die_id; Michael137 wrote: Technically we could just encode the mangled name and module ID. Since we're just doing a mangled name lookup within the module anyway. https://github.com/llvm/llvm-project/pull/148877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/148877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add an extra optional did_read_live_memory to Target::ReadMemory (PR #149620)
https://github.com/jasonmolenda approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/149620 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/148877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/148877 >From f640beff5da2edb9d928e3a0b1ce4128194c055b Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 15 Nov 2024 01:59:36 + Subject: [PATCH 1/3] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels --- lldb/include/lldb/Core/Module.h | 4 +- lldb/include/lldb/Expression/Expression.h | 35 ++ lldb/include/lldb/Symbol/SymbolFile.h | 14 lldb/source/Core/Module.cpp | 19 +- lldb/source/Expression/Expression.cpp | 65 +++ lldb/source/Expression/IRExecutionUnit.cpp| 63 ++ .../Clang/ClangExpressionDeclMap.cpp | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 44 - .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 45 + .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 + .../SymbolFile/NativePDB/PdbAstBuilder.cpp| 6 +- .../NativePDB/UdtRecordCompleter.cpp | 5 +- .../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 7 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 33 -- .../TypeSystem/Clang/TypeSystemClang.h| 5 +- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 12 ++-- 16 files changed, 318 insertions(+), 44 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 8bb55c95773bc..3991a12997541 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -86,7 +86,8 @@ struct ModuleFunctionSearchOptions { /// /// The module will parse more detailed information as more queries are made. class Module : public std::enable_shared_from_this, - public SymbolContextScope { + public SymbolContextScope, + public UserID { public: class LookupInfo; // Static functions that can track the lifetime of module objects. This is @@ -97,6 +98,7 @@ class Module : public std::enable_shared_from_this, // using the "--global" (-g for short). static size_t GetNumberAllocatedModules(); + static Module *GetAllocatedModuleWithUID(lldb::user_id_t uid); static Module *GetAllocatedModuleAtIndex(size_t idx); static std::recursive_mutex &GetAllocationModuleCollectionMutex(); diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h index 8de9364436ccf..5cf21eb505dac 100644 --- a/lldb/include/lldb/Expression/Expression.h +++ b/lldb/include/lldb/Expression/Expression.h @@ -96,6 +96,41 @@ class Expression { ///invalid. }; +/// Holds parsed information about a function call label that +/// LLDB attaches as an AsmLabel to function AST nodes it parses +/// from debug-info. +/// +/// The format being: +/// +/// ::: +/// +/// The label string needs to stay valid for the entire lifetime +/// of this object. +struct FunctionCallLabel { + /// Mostly for debuggability. + llvm::StringRef m_pubname; + + lldb::user_id_t m_die_id; + lldb::user_id_t m_module_id; +}; + +/// LLDB attaches this prefix to mangled names of functions that it get called +/// from JITted expressions. +inline constexpr llvm::StringRef FunctionCallLabelPrefix = "$__lldb_func"; + +bool consumeFunctionCallLabelPrefix(llvm::StringRef &name); +bool hasFunctionCallLabelPrefix(llvm::StringRef name); + +/// Returns the components of the specified function call label. +/// +/// The format of \c label is described in \c FunctionCallLabel. +/// The label prefix is not one of the components. +llvm::Expected> +splitFunctionCallLabel(llvm::StringRef label); + +// Decodes the function label into a \c FunctionCallLabel. +llvm::Expected makeFunctionCallLabel(llvm::StringRef label); + } // namespace lldb_private #endif // LLDB_EXPRESSION_EXPRESSION_H diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index e95f95553c17c..70dc20664df20 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -18,6 +18,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SourceModule.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeSystem.h" @@ -328,6 +329,19 @@ class SymbolFile : public PluginInterface { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names); + /// Resolves the function DIE uniquely identified by \c uid within + /// this SymbolFile. + /// + /// \param[in,out] sc_list The resolved functions will be appended to this + /// list. + /// + /// \param[in] uid The UID of the function DIE to resolve. + /// + virtual llvm::Error ResolveFunctionUID(SymbolContextList &sc_list, + lldb::user_id_t uid) { +return llvm::createStringError("Not implemented"); + } + vi