[Lldb-commits] [lldb] 0495301 - [lldb-vscode] Report supportsModulesRequest=true
Author: Andy Yankovsky Date: 2021-12-03T16:07:48+01:00 New Revision: 049530129326f9b0bfa9ce6a762c6cb180974ac5 URL: https://github.com/llvm/llvm-project/commit/049530129326f9b0bfa9ce6a762c6cb180974ac5 DIFF: https://github.com/llvm/llvm-project/commit/049530129326f9b0bfa9ce6a762c6cb180974ac5.diff LOG: [lldb-vscode] Report supportsModulesRequest=true The adapter does support `Modules` request, implemented in 39239f9. Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D115033 Added: Modified: lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp index 445a06c9da702..97ec4b578cf7c 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1505,7 +1505,7 @@ void request_initialize(const llvm::json::Object &request) { // is the behavior of LLDB CLI, that expects a TAB. body.try_emplace("supportsCompletionsRequest", false); // The debug adapter supports the modules request. - body.try_emplace("supportsModulesRequest", false); + body.try_emplace("supportsModulesRequest", true); // The set of additional module information exposed by the debug adapter. // body.try_emplace("additionalModuleColumns"] = ColumnDescriptor // Checksum algorithms supported by the debug adapter. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b2e2eec - [lldb][NFC] clang-format some files as preparation for https://reviews.llvm.org/D114627
Author: Lasse Folger Date: 2021-12-09T12:38:00+01:00 New Revision: b2e2eece9aa8db4bcc47c7fed0a9b999a3d96baf URL: https://github.com/llvm/llvm-project/commit/b2e2eece9aa8db4bcc47c7fed0a9b999a3d96baf DIFF: https://github.com/llvm/llvm-project/commit/b2e2eece9aa8db4bcc47c7fed0a9b999a3d96baf.diff LOG: [lldb][NFC] clang-format some files as preparation for https://reviews.llvm.org/D114627 Reviewed By: werat Differential Revision: https://reviews.llvm.org/D115110 Added: Modified: lldb/include/lldb/Core/Module.h lldb/include/lldb/Symbol/SymbolFile.h lldb/source/Core/Module.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Symbol/SymbolFile.cpp Removed: diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index b80f4fd9b85a7..acc11c777dbf3 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -21,8 +21,8 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/XcodeSDK.h" #include "lldb/Utility/UUID.h" +#include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" @@ -128,7 +128,7 @@ class Module : public std::enable_shared_from_this, Module(const ModuleSpec &module_spec); template - static lldb::ModuleSP CreateModuleFromObjectFile(Args &&... args) { + static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args) { // Must create a module and place it into a shared pointer before we can // create an object file since it has a std::weak_ptr back to the module, // so we need to control the creation carefully in this static function @@ -255,8 +255,7 @@ class Module : public std::enable_shared_from_this, /// Returns a valid symbol pointer if a symbol was found, /// nullptr otherwise. const Symbol *FindFirstSymbolWithNameAndType( - ConstString name, - lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); + ConstString name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, @@ -439,12 +438,13 @@ class Module : public std::enable_shared_from_this, /// /// \param searched_symbol_files /// Prevents one file from being visited multiple times. - void FindTypes(llvm::ArrayRef pattern, LanguageSet languages, - llvm::DenseSet &searched_symbol_files, - TypeMap &types); + void + FindTypes(llvm::ArrayRef pattern, LanguageSet languages, +llvm::DenseSet &searched_symbol_files, +TypeMap &types); - lldb::TypeSP FindFirstType(const SymbolContext &sc, - ConstString type_name, bool exact_match); + lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, + bool exact_match); /// Find types by name that are in a namespace. This function is used by the /// expression parser when searches need to happen in an exact namespace @@ -788,8 +788,7 @@ class Module : public std::enable_shared_from_this, const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - void SetFileSpecAndObjectName(const FileSpec &file, -ConstString object_name); + void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name); bool GetIsDynamicLinkEditor(); @@ -876,7 +875,7 @@ class Module : public std::enable_shared_from_this, /// The value is returned as a reference to allow it to be updated by the /// ElapsedTime RAII object. StatsDuration &GetSymtabParseTime() { return m_symtab_parse_time; } - + /// Accessor for the symbol table index time metric. /// /// The value is returned as a reference to allow it to be updated by the @@ -949,27 +948,27 @@ class Module : public std::enable_shared_from_this, protected: // Member Variables mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy -///in multi-threaded environments. +/// in multi-threaded environments. /// The modification time for this module when it was created. llvm::sys::TimePoint<> m_mod_time; - ArchSpec m_arch; ///< The architecture for this module. + ArchSpec m_arch; ///< The architecture for this module. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help - ///match it up to debug symbols. + /// match it up to debug symbols. FileSpec m_file; ///< The file representation on disk for this module (if -
[Lldb-commits] [lldb] afb446e - [lldb] Constant-resolve operands to `getelementptr`
Author: Andy Yankovsky Date: 2022-02-09T17:38:38+01:00 New Revision: afb446e8a61de4a41504a71f61a4b1d93ce22716 URL: https://github.com/llvm/llvm-project/commit/afb446e8a61de4a41504a71f61a4b1d93ce22716 DIFF: https://github.com/llvm/llvm-project/commit/afb446e8a61de4a41504a71f61a4b1d93ce22716.diff LOG: [lldb] Constant-resolve operands to `getelementptr` Operands to `getelementptr` can be constants or constant expressions. Check that all operands can be constant-resolved and resolve them during the evaluation. If some operands can't be resolved as constants -- the expression evaluation will fallback to JIT. Fixes: https://bugs.llvm.org/show_bug.cgi?id=52449 Reviewed By: #lldb, shafik Differential Revision: https://reviews.llvm.org/D113498 Added: Modified: lldb/source/Expression/IRInterpreter.cpp lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py Removed: diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 21348be1578ff..2ad51d0e84027 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -285,9 +285,11 @@ class InterpreterStackFrame { return true; // no offset to apply! SmallVector indices(op_cursor, op_end); - Type *src_elem_ty = cast(constant_expr)->getSourceElementType(); + + // DataLayout::getIndexedOffsetInType assumes the indices are + // instances of ConstantInt. uint64_t offset = m_target_data.getIndexedOffsetInType(src_elem_ty, indices); @@ -466,12 +468,20 @@ static bool CanResolveConstant(llvm::Constant *constant) { case Instruction::BitCast: return CanResolveConstant(constant_expr->getOperand(0)); case Instruction::GetElementPtr: { +// Check that the base can be constant-resolved. ConstantExpr::const_op_iterator op_cursor = constant_expr->op_begin(); Constant *base = dyn_cast(*op_cursor); -if (!base) +if (!base || !CanResolveConstant(base)) return false; -return CanResolveConstant(base); +// Check that all other operands are just ConstantInt. +for (Value *op : make_range(constant_expr->op_begin() + 1, +constant_expr->op_end())) { + ConstantInt *constant_int = dyn_cast(op); + if (!constant_int) +return false; +} +return true; } } } else { diff --git a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py index 07ec5c52ea4c7..503e0d1341566 100644 --- a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py @@ -41,3 +41,31 @@ def test_access_without_scope(self): self.createTestTarget() self.expect("expression s_c", error=True, startstr="error: use of undeclared identifier 's_d'") + +def test_no_crash_in_IR_arithmetic(self): +""" +Test that LLDB doesn't crash on evaluating specific expression involving +pointer arithmetic and taking the address of a static class member. +See https://bugs.llvm.org/show_bug.cgi?id=52449 +""" +self.build() +lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp")) + +# This expression contains the following IR code: +# ... i64 ptrtoint (i32* @_ZN1A3s_cE to i64)) ... +expr = "(int*)100 + (long long)(&A::s_c)" + +# The IR interpreter doesn't support non-const operands to the +# `GetElementPtr` IR instruction, so verify that it correctly fails to +# evaluate expression. +opts = lldb.SBExpressionOptions() +opts.SetAllowJIT(False) +value = self.target().EvaluateExpression(expr, opts) +self.assertTrue(value.GetError().Fail()) +self.assertIn( +"Can't evaluate the expression without a running target", +value.GetError().GetCString()) + +# Evaluating the expression via JIT should work fine. +value = self.target().EvaluateExpression(expr) +self.assertSuccess(value.GetError()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e0f2375 - [lldb] Disable failing test on Windows
Author: Andy Yankovsky Date: 2022-02-09T20:40:50+01:00 New Revision: e0f2375b5262d0dd778ecaf0628f905d241da733 URL: https://github.com/llvm/llvm-project/commit/e0f2375b5262d0dd778ecaf0628f905d241da733 DIFF: https://github.com/llvm/llvm-project/commit/e0f2375b5262d0dd778ecaf0628f905d241da733.diff LOG: [lldb] Disable failing test on Windows Test was introduced in https://reviews.llvm.org/D113498. Added: Modified: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py Removed: diff --git a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py index 503e0d1341566..7cb4c51b02b30 100644 --- a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py @@ -42,6 +42,8 @@ def test_access_without_scope(self): self.expect("expression s_c", error=True, startstr="error: use of undeclared identifier 's_d'") +# We fail to lookup static members on Windows. +@expectedFailureAll(oslist=["windows"]) def test_no_crash_in_IR_arithmetic(self): """ Test that LLDB doesn't crash on evaluating specific expression involving ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2e0ef17 - [lldb] Add a positive test for `getelementptr` constant args
Author: Andy Yankovsky Date: 2022-02-14T18:04:37Z New Revision: 2e0ef179d8838de06bf694ae6ca43c2b24847a8c URL: https://github.com/llvm/llvm-project/commit/2e0ef179d8838de06bf694ae6ca43c2b24847a8c DIFF: https://github.com/llvm/llvm-project/commit/2e0ef179d8838de06bf694ae6ca43c2b24847a8c.diff LOG: [lldb] Add a positive test for `getelementptr` constant args The IR interpreter supports const operands to the `GetElementPtr` IR instruction, so it should be able to evaluate expression without JIT. Follow up to https://reviews.llvm.org/D113498 Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D119734 Added: Modified: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py lldb/test/API/lang/cpp/static_members/main.cpp Removed: diff --git a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py index 7cb4c51b02b3..85ebd5fe6853 100644 --- a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py @@ -71,3 +71,20 @@ def test_no_crash_in_IR_arithmetic(self): # Evaluating the expression via JIT should work fine. value = self.target().EvaluateExpression(expr) self.assertSuccess(value.GetError()) + +# We fail to lookup static members on Windows. +@expectedFailureAll(oslist=["windows"]) +def test_IR_interpreter_can_handle_getelementptr_constants_args(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp")) + +# This expression contains the following IR code: +# ... getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0 +expr = "arr[0]" + +# The IR interpreter supports const operands to the `GetElementPtr` IR +# instruction, so it should be able to evaluate expression without JIT. +opts = lldb.SBExpressionOptions() +opts.SetAllowJIT(False) +value = self.target().EvaluateExpression(expr, opts) +self.assertSuccess(value.GetError()) diff --git a/lldb/test/API/lang/cpp/static_members/main.cpp b/lldb/test/API/lang/cpp/static_members/main.cpp index 87ea6aa87747..df11c4c5cf7e 100644 --- a/lldb/test/API/lang/cpp/static_members/main.cpp +++ b/lldb/test/API/lang/cpp/static_members/main.cpp @@ -15,6 +15,8 @@ int main() { A my_a; my_a.m_a = 1; + int arr[2]{0}; + my_a.access(); // stop in main return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7ec32da - [lldb] Enable test for `getelementptr` const args for Windows
Author: Andy Yankovsky Date: 2022-02-14T18:48:51Z New Revision: 7ec32dad2b01ffcd47b7f99f5ebba9130ab9e00b URL: https://github.com/llvm/llvm-project/commit/7ec32dad2b01ffcd47b7f99f5ebba9130ab9e00b DIFF: https://github.com/llvm/llvm-project/commit/7ec32dad2b01ffcd47b7f99f5ebba9130ab9e00b.diff LOG: [lldb] Enable test for `getelementptr` const args for Windows The test actually passes fine on Windows, since it doesn't use any static members. Follow-up to https://reviews.llvm.org/D113498 Added: Modified: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py Removed: diff --git a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py index 85ebd5fe68531..35e29cc97090c 100644 --- a/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py @@ -72,8 +72,6 @@ def test_no_crash_in_IR_arithmetic(self): value = self.target().EvaluateExpression(expr) self.assertSuccess(value.GetError()) -# We fail to lookup static members on Windows. -@expectedFailureAll(oslist=["windows"]) def test_IR_interpreter_can_handle_getelementptr_constants_args(self): self.build() lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp")) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4867872 - [lldb] Add support for using integral const static data members in the expression evaluator
Author: Andy Yankovsky Date: 2022-07-14T15:15:11Z New Revision: 486787210df5ce5eabadc90a7de353ae81101feb URL: https://github.com/llvm/llvm-project/commit/486787210df5ce5eabadc90a7de353ae81101feb DIFF: https://github.com/llvm/llvm-project/commit/486787210df5ce5eabadc90a7de353ae81101feb.diff LOG: [lldb] Add support for using integral const static data members in the expression evaluator This adds support for using const static integral data members as described by C++11 [class.static.data]p3 to LLDB's expression evaluator. So far LLDB treated these data members are normal static variables. They already work as intended when they are declared in the class definition and then defined in a namespace scope. However, if they are declared and initialised in the class definition but never defined in a namespace scope, all LLDB expressions that use them will fail to link when LLDB can't find the respective symbol for the variable. The reason for this is that the data members which are only declared in the class are not emitted into any object file so LLDB can never resolve them. Expressions that use these variables are expected to directly use their constant value if possible. Clang can do this for us during codegen, but it requires that we add the constant value to the VarDecl we generate for these data members. This patch implements this by: * parsing the constant values from the debug info and adding it to variable declarations we encounter. * ensuring that LLDB doesn't implicitly try to take the address of expressions that might be an lvalue that points to such a special data member. The second change is caused by LLDB's way of storing lvalues in the expression parser. When LLDB parses an expression, it tries to keep the result around via two mechanisms: 1. For lvalues, LLDB generates a static pointer variable and stores the address of the last expression in it: `T *$__lldb_expr_result_ptr = &LastExpression` 2. For everything else, LLDB generates a static variable of the same type as the last expression and then direct initialises that variable: `T $__lldb_expr_result(LastExpression)` If we try to print a special const static data member via something like `expr Class::Member`, then LLDB will try to take the address of this expression as it's an lvalue. This means LLDB will try to take the address of the variable which causes that Clang can't replace the use with the constant value. There isn't any good way to detect this case (as there a lot of different expressions that could yield an lvalue that points to such a data member), so this patch also changes that we only use the first way of capturing the result if the last expression does not have a type that could potentially indicate it's coming from such a special data member. This change shouldn't break most workflows for users. The only observable side effect I could find is that the implicit persistent result variables for const int's now have their own memory address: Before this change: ``` (lldb) p i (const int) $0 = 123 (lldb) p &$0 (const int *) $1 = 0x7ffeefbff8e8 (lldb) p &i (const int *) $2 = 0x7ffeefbff8e8 ``` After this change we capture `i` by value so it has its own value. ``` (lldb) p i (const int) $0 = 123 (lldb) p &$0 (const int *) $1 = 0x000100155320 (lldb) p &i (const int *) $2 = 0x7ffeefbff8e8 ``` Reviewed By: Michael137 Differential Revision: https://reviews.llvm.org/D81471 Added: lldb/test/API/lang/cpp/const_static_integral_member/Makefile lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py lldb/test/API/lang/cpp/const_static_integral_member/main.cpp lldb/test/API/lang/cpp/const_static_integral_member_int128/Makefile lldb/test/API/lang/cpp/const_static_integral_member_int128/TestConstStaticIntegralMemberInt128.py lldb/test/API/lang/cpp/const_static_integral_member_int128/main.cpp Modified: lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/unittests/SymbolFile/DWARF/CMakeLists.txt lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 7a1ac78705474..799ae29e2841c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -197,6 +197,27 @@ bool ASTResultSynthesizer::SynthesizeObjCMethodResult( return ret; } +/// Returns true if LLDB can take the address of the given lvalue for the sake +/// of capturing the expression result. Returns false if LLDB should instead +/// store the expression result
[Lldb-commits] [lldb] 7d297de - Reland "[lldb] Add support for using integral const static data members in the expression evaluator"
Author: Andy Yankovsky Date: 2022-07-15T10:52:35Z New Revision: 7d297de95117e783bbfaecbba1f72fc55de05a30 URL: https://github.com/llvm/llvm-project/commit/7d297de95117e783bbfaecbba1f72fc55de05a30 DIFF: https://github.com/llvm/llvm-project/commit/7d297de95117e783bbfaecbba1f72fc55de05a30.diff LOG: Reland "[lldb] Add support for using integral const static data members in the expression evaluator" Reland 486787210d which broke tests on Arm and Windows. * Windows -- on Windows const static data members with no out-of-class definition do have valid addresses, in constract to other platforms (Linux, macos) where they don't. Adjusted the test to expect success on Windows and failure on other platforms. * Arm -- `int128` is not available on 32-bit ARM, so disable the test for this architecture. Added: lldb/test/API/lang/cpp/const_static_integral_member/Makefile lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py lldb/test/API/lang/cpp/const_static_integral_member/main.cpp lldb/test/API/lang/cpp/const_static_integral_member_int128/Makefile lldb/test/API/lang/cpp/const_static_integral_member_int128/TestConstStaticIntegralMemberInt128.py lldb/test/API/lang/cpp/const_static_integral_member_int128/main.cpp Modified: lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/unittests/SymbolFile/DWARF/CMakeLists.txt lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 7a1ac78705474..799ae29e2841c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -197,6 +197,27 @@ bool ASTResultSynthesizer::SynthesizeObjCMethodResult( return ret; } +/// Returns true if LLDB can take the address of the given lvalue for the sake +/// of capturing the expression result. Returns false if LLDB should instead +/// store the expression result in a result variable. +static bool CanTakeAddressOfLValue(const Expr *lvalue_expr) { + assert(lvalue_expr->getValueKind() == VK_LValue && + "lvalue_expr not a lvalue"); + + QualType qt = lvalue_expr->getType(); + // If the lvalue has const-qualified non-volatile integral or enum type, then + // the underlying value might come from a const static data member as + // described in C++11 [class.static.data]p3. If that's the case, then the + // value might not have an address if the user didn't also define the member + // in a namespace scope. Taking the address would cause that LLDB later fails + // to link the expression, so those lvalues should be stored in a result + // variable. + if (qt->isIntegralOrEnumerationType() && qt.isConstQualified() && + !qt.isVolatileQualified()) +return false; + return true; +} + bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body, DeclContext *DC) { Log *log = GetLog(LLDBLog::Expressions); @@ -265,6 +286,10 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body, // - During dematerialization, $0 is marked up as a load address with value // equal to the contents of the structure entry. // + // - Note: if we cannot take an address of the resulting Lvalue (e.g. it's + // a static const member without an out-of-class definition), then we + // follow the Rvalue route. + // // For Rvalues // // - In AST result synthesis the expression E is transformed into an @@ -304,7 +329,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body, clang::VarDecl *result_decl = nullptr; - if (is_lvalue) { + if (is_lvalue && CanTakeAddressOfLValue(last_expr)) { IdentifierInfo *result_ptr_id; if (expr_type->isFunctionType()) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4b9354371bda3..10dc8d1fb7c39 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2390,6 +2390,7 @@ struct MemberAttributes { uint64_t data_bit_offset = UINT64_MAX; AccessType accessibility = eAccessNone; llvm::Optional byte_size; + llvm::Optional const_value_form; DWARFFormValue encoding_form; /// Indicates the byte offset of the word from the base address of the /// structure. @@ -2436,6 +2437,9 @@ MemberAttributes::MemberAttributes(const DWARFDIE &die, case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
[Lldb-commits] [lldb] 5c39c31 - [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra
Author: Andy Yankovsky Date: 2022-07-22T09:22:40Z New Revision: 5c39c31a99525630dfe684fed48292a50fd0c3c9 URL: https://github.com/llvm/llvm-project/commit/5c39c31a99525630dfe684fed48292a50fd0c3c9 DIFF: https://github.com/llvm/llvm-project/commit/5c39c31a99525630dfe684fed48292a50fd0c3c9.diff LOG: [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra DW_OP_skip/DW_OP_bra can move offset to the end of the data, which means that this was the last instruction to execute and the interpreter should terminate. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D130285 Added: Modified: lldb/source/Expression/DWARFExpression.cpp lldb/unittests/Expression/DWARFExpressionTest.cpp Removed: diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 9e6b21fc25ea3..25f6a46d805b7 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -1655,11 +1655,16 @@ bool DWARFExpression::Evaluate( case DW_OP_skip: { int16_t skip_offset = (int16_t)opcodes.GetU16(&offset); lldb::offset_t new_offset = offset + skip_offset; - if (opcodes.ValidOffset(new_offset)) + // New offset can point at the end of the data, in this case we should + // terminate the DWARF expression evaluation (will happen in the loop + // condition). + if (new_offset <= opcodes.GetByteSize()) offset = new_offset; else { if (error_ptr) - error_ptr->SetErrorString("Invalid opcode offset in DW_OP_skip."); + error_ptr->SetErrorStringWithFormatv( + "Invalid opcode offset in DW_OP_skip: {0}+({1}) > {2}", offset, + skip_offset, opcodes.GetByteSize()); return false; } } break; @@ -1684,11 +1689,16 @@ bool DWARFExpression::Evaluate( Scalar zero(0); if (tmp.ResolveValue(exe_ctx) != zero) { lldb::offset_t new_offset = offset + bra_offset; - if (opcodes.ValidOffset(new_offset)) + // New offset can point at the end of the data, in this case we should + // terminate the DWARF expression evaluation (will happen in the loop + // condition). + if (new_offset <= opcodes.GetByteSize()) offset = new_offset; else { if (error_ptr) - error_ptr->SetErrorString("Invalid opcode offset in DW_OP_bra."); + error_ptr->SetErrorStringWithFormatv( + "Invalid opcode offset in DW_OP_bra: {0}+({1}) > {2}", offset, + bra_offset, opcodes.GetByteSize()); return false; } } diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp index 5169e5f9a33ec..06f79186bad76 100644 --- a/lldb/unittests/Expression/DWARFExpressionTest.cpp +++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -131,6 +131,25 @@ TEST(DWARFExpression, DW_OP_const) { llvm::HasValue(0x010101010101)); } +TEST(DWARFExpression, DW_OP_skip) { + EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x42, DW_OP_skip, 0x02, 0x00, + DW_OP_const1u, 0xff}), + llvm::HasValue(0x42)); +} + +TEST(DWARFExpression, DW_OP_bra) { + EXPECT_THAT_EXPECTED( + // clang-format off + Evaluate({ +DW_OP_const1u, 0x42, // push 0x42 +DW_OP_const1u, 0x1, // push 0x1 +DW_OP_bra, 0x02, 0x00, // if 0x1 > 0, then skip 0x0002 opcodes +DW_OP_const1u, 0xff, // push 0xff + }), + // clang-format on + llvm::HasValue(0x42)); +} + TEST(DWARFExpression, DW_OP_convert) { /// Auxiliary debug info. const char *yamldata = R"( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ee691fb - [lldb][NFC] clang format change
Author: Lasse Folger Date: 2021-10-18T12:00:32+02:00 New Revision: ee691fbc3de36ca0c720e1699565be34f192e058 URL: https://github.com/llvm/llvm-project/commit/ee691fbc3de36ca0c720e1699565be34f192e058 DIFF: https://github.com/llvm/llvm-project/commit/ee691fbc3de36ca0c720e1699565be34f192e058.diff LOG: [lldb][NFC] clang format change clang format on some demangling files Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D111934 Added: Modified: lldb/source/Core/Mangled.cpp llvm/include/llvm/Demangle/Demangle.h Removed: diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index b2ceb6312be06..35b1082c3025d 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -260,7 +260,8 @@ ConstString Mangled::GetDemangledName() const { if (m_mangled && m_demangled.IsNull()) { // Don't bother running anything that isn't mangled const char *mangled_name = m_mangled.GetCString(); -ManglingScheme mangling_scheme = GetManglingScheme(m_mangled.GetStringRef()); +ManglingScheme mangling_scheme = +GetManglingScheme(m_mangled.GetStringRef()); if (mangling_scheme != eManglingSchemeNone && !m_mangled.GetMangledCounterpart(m_demangled)) { // We didn't already mangle this name, demangle it and if all goes well @@ -296,8 +297,7 @@ ConstString Mangled::GetDemangledName() const { return m_demangled; } -ConstString -Mangled::GetDisplayDemangledName() const { +ConstString Mangled::GetDisplayDemangledName() const { return GetDemangledName(); } diff --git a/llvm/include/llvm/Demangle/Demangle.h b/llvm/include/llvm/Demangle/Demangle.h index d9c407034ac9d..8d61fa1c17f2f 100644 --- a/llvm/include/llvm/Demangle/Demangle.h +++ b/llvm/include/llvm/Demangle/Demangle.h @@ -31,7 +31,6 @@ enum : int { char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status); - enum MSDemangleFlags { MSDF_None = 0, MSDF_DumpBackrefs = 1 << 0, @@ -53,9 +52,9 @@ enum MSDemangleFlags { /// receives the size of the demangled string on output if n_buf is not nullptr. /// status receives one of the demangle_ enum entries above if it's not nullptr. /// Flags controls various details of the demangled representation. -char *microsoftDemangle(const char *mangled_name, size_t *n_read, -char *buf, size_t *n_buf, -int *status, MSDemangleFlags Flags = MSDF_None); +char *microsoftDemangle(const char *mangled_name, size_t *n_read, char *buf, +size_t *n_buf, int *status, +MSDemangleFlags Flags = MSDF_None); // Demangles a Rust v0 mangled symbol. The API follows that of __cxa_demangle. char *rustDemangle(const char *MangledName, char *Buf, size_t *N, int *Status); @@ -120,6 +119,7 @@ struct ItaniumPartialDemangler { bool isSpecialName() const; ~ItaniumPartialDemangler(); + private: void *RootNode; void *Context; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 134e181 - [lldb] change name demangling to be consistent between windows and linx
Author: Lasse Folger Date: 2021-10-19T12:04:37+02:00 New Revision: 134e1817f62c08cde1ed1f7e94e51425536085ac URL: https://github.com/llvm/llvm-project/commit/134e1817f62c08cde1ed1f7e94e51425536085ac DIFF: https://github.com/llvm/llvm-project/commit/134e1817f62c08cde1ed1f7e94e51425536085ac.diff LOG: [lldb] change name demangling to be consistent between windows and linx When printing names in lldb on windows these names contain the full type information while on linux only the name is contained. This change introduces a flag in the Microsoft demangler to control if the type information should be included. With the flag enabled demangled name contains only the qualified name, e.g: without flag -> with flag int (*array2d)[10] -> array2d int (*abc::array2d)[10] -> abc::array2d const int *x -> x For globals there is a second inconsistency which is not yet addressed by this change. On linux globals (in global namespace) are prefixed with :: while on windows they are not. Reviewed By: teemperor, rnk Differential Revision: https://reviews.llvm.org/D111715 Added: Modified: lldb/source/Core/Mangled.cpp llvm/include/llvm/Demangle/Demangle.h llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h llvm/lib/Demangle/MicrosoftDemangle.cpp llvm/lib/Demangle/MicrosoftDemangleNodes.cpp llvm/test/Demangle/ms-options.test llvm/tools/llvm-undname/llvm-undname.cpp Removed: diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 35b1082c3025d..e36d412896a93 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -131,9 +131,9 @@ void Mangled::SetValue(ConstString name) { static char *GetMSVCDemangledStr(const char *M) { char *demangled_cstr = llvm::microsoftDemangle( M, nullptr, nullptr, nullptr, nullptr, - llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier | -llvm::MSDF_NoCallingConvention | -llvm::MSDF_NoMemberType)); + llvm::MSDemangleFlags( + llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention | + llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType)); if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) { if (demangled_cstr && demangled_cstr[0]) diff --git a/llvm/include/llvm/Demangle/Demangle.h b/llvm/include/llvm/Demangle/Demangle.h index 8d61fa1c17f2f..521795f7a1f81 100644 --- a/llvm/include/llvm/Demangle/Demangle.h +++ b/llvm/include/llvm/Demangle/Demangle.h @@ -38,6 +38,7 @@ enum MSDemangleFlags { MSDF_NoCallingConvention = 1 << 2, MSDF_NoReturnType = 1 << 3, MSDF_NoMemberType = 1 << 4, + MSDF_NoVariableType = 1 << 5, }; /// Demangles the Microsoft symbol pointed at by mangled_name and returns it. diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h index 77446e9b0f079..7f3ee5a1d487f 100644 --- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h +++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h @@ -80,6 +80,7 @@ enum OutputFlags { OF_NoAccessSpecifier = 4, OF_NoMemberType = 8, OF_NoReturnType = 16, + OF_NoVariableType = 32, }; // Types diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 303207176be71..15d7056b29cb1 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -2361,6 +2361,8 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, OF = OutputFlags(OF | OF_NoReturnType); if (Flags & MSDF_NoMemberType) OF = OutputFlags(OF | OF_NoMemberType); + if (Flags & MSDF_NoVariableType) +OF = OutputFlags(OF | OF_NoVariableType); int InternalStatus = demangle_success; if (D.Error) diff --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp index 9fe157bf0d2aa..56a07377c92ad 100644 --- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp @@ -613,12 +613,12 @@ void VariableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const { if (!(Flags & OF_NoMemberType) && IsStatic) OS << "static "; - if (Type) { + if (!(Flags & OF_NoVariableType) && Type) { Type->outputPre(OS, Flags); outputSpaceIfNecessary(OS); } Name->output(OS, Flags); - if (Type) + if (!(Flags & OF_NoVariableType) && Type) Type->outputPost(OS, Flags); } diff --git a/llvm/test/Demangle/ms-options.test b/llvm/test/Demangle/ms-options.test index 1699ad6f558a5..94663a5f9fc46 100644 --- a/llvm/test/Demangle/ms-options.test +++ b/llvm/test/Demangle/ms-options.test @@ -1,14 +1,43 @@ -; RUN: llvm-undname < %s | FileCheck %s -; RUN: llvm-undname --no-calling-convention < %s | FileCheck %s --check-prefix=CHECK-NO-CALLING-CONV -; RUN: llvm-undname --no-return-type < %
[Lldb-commits] [lldb] dc8f003 - [lldb-vscode] Add presentation hints for scopes
Author: Andy Yankovsky Date: 2021-11-09T17:50:46+01:00 New Revision: dc8f0035ca990fc5587bd508fed609f995e7c842 URL: https://github.com/llvm/llvm-project/commit/dc8f0035ca990fc5587bd508fed609f995e7c842 DIFF: https://github.com/llvm/llvm-project/commit/dc8f0035ca990fc5587bd508fed609f995e7c842.diff LOG: [lldb-vscode] Add presentation hints for scopes Scopes can have an optional hint for how to present this scope in the UI: https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope The IDEs can use the hint to present the data accordingly. For example, Visual Studio has a separate Registers window, which is populated with the data from the scope with `presentationHint: "registers"`. Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D113400 Added: Modified: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py lldb/tools/lldb-vscode/JSONUtils.cpp Removed: diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py index 30a85ec5eb28e..9a4a5de40e718 100644 --- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py +++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py @@ -394,3 +394,17 @@ def test_scopes_and_evaluate_expansion(self): self.verify_variables( expandable_expression["children"], response["body"]["variables"] ) + +# Test that frame scopes have corresponding presentation hints. +frame_id = self.vscode.get_stackFrame()["id"] +scopes = self.vscode.request_scopes(frame_id)["body"]["scopes"] + +scope_names = [scope["name"] for scope in scopes] +self.assertIn("Locals", scope_names) +self.assertIn("Registers", scope_names) + +for scope in scopes: +if scope["name"] == "Locals": +self.assertEquals(scope.get("presentationHint"), "locals") +if scope["name"] == "Registers": +self.assertEquals(scope.get("presentationHint"), "registers") diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp index 0e6227f3b15d4..58a08796e738d 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.cpp +++ b/lldb/tools/lldb-vscode/JSONUtils.cpp @@ -175,6 +175,13 @@ void FillResponse(const llvm::json::Object &request, // "type": "string", // "description": "Name of the scope such as 'Arguments', 'Locals'." // }, +// "presentationHint": { +// "type": "string", +// "description": "An optional hint for how to present this scope in the +// UI. If this attribute is missing, the scope is shown +// with a generic UI.", +// "_enum": [ "arguments", "locals", "registers" ], +// }, // "variablesReference": { // "type": "integer", // "description": "The variables of this scope can be retrieved by @@ -229,6 +236,15 @@ llvm::json::Value CreateScope(const llvm::StringRef name, int64_t namedVariables, bool expensive) { llvm::json::Object object; EmplaceSafeString(object, "name", name.str()); + + // TODO: Support "arguments" scope. At the moment lldb-vscode includes the + // arguments into the "locals" scope. + if (variablesReference == VARREF_LOCALS) { +object.try_emplace("presentationHint", "locals"); + } else if (variablesReference == VARREF_REGS) { +object.try_emplace("presentationHint", "registers"); + } + object.try_emplace("variablesReference", variablesReference); object.try_emplace("expensive", expensive); object.try_emplace("namedVariables", namedVariables); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 95102b7 - [lldb] Unwrap the type when dereferencing the value
Author: Andy Yankovsky Date: 2021-11-15T14:48:19+01:00 New Revision: 95102b7dc3c1b5b3f1b688221d9aa28cb1e17974 URL: https://github.com/llvm/llvm-project/commit/95102b7dc3c1b5b3f1b688221d9aa28cb1e17974 DIFF: https://github.com/llvm/llvm-project/commit/95102b7dc3c1b5b3f1b688221d9aa28cb1e17974.diff LOG: [lldb] Unwrap the type when dereferencing the value The value type can be a typedef of a reference (e.g. `typedef int& myint`). In this case `GetQualType(type)` will return `clang::Typedef`, which cannot be casted to `clang::ReferenceType`. Fix a regression introduced in https://reviews.llvm.org/D103532. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D113673 Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py lldb/test/API/lang/cpp/dereferencing_references/main.cpp Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 077104b8fe85..b20ae32a08ac 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6492,7 +6492,8 @@ CompilerType TypeSystemClang::GetChildCompilerTypeAtIndex( case clang::Type::RValueReference: if (idx_is_valid) { const clang::ReferenceType *reference_type = - llvm::cast(GetQualType(type).getTypePtr()); + llvm::cast( + RemoveWrappingTypes(GetQualType(type)).getTypePtr()); CompilerType pointee_clang_type = GetType(reference_type->getPointeeType()); if (transparent_pointers && pointee_clang_type.IsAggregateType()) { diff --git a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py index 994e26f0e91e..741fc6ed85e0 100644 --- a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py +++ b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py @@ -21,3 +21,7 @@ def test(self): # Same as above for rvalue references. rref_val = self.expect_var_path("r_ref", type="TTT &&") self.assertEqual(rref_val.Dereference().GetType().GetName(), "TTT") + +# Typedef to a reference should dereference to the underlying type. +td_val = self.expect_var_path("td_to_ref_type", type="td_int_ref") +self.assertEqual(td_val.Dereference().GetType().GetName(), "int") diff --git a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp index 8228dc411320..b64978a9029f 100644 --- a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp +++ b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp @@ -1,8 +1,13 @@ typedef int TTT; +typedef int &td_int_ref; int main() { int i = 0; + // references to typedefs TTT &l_ref = i; TTT &&r_ref = static_cast(i); + // typedef of a reference + td_int_ref td_to_ref_type = i; + return l_ref; // break here } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f66b69a - [lldb] Fix lookup for global constants in namespaces
Author: Tonko Sabolčec Date: 2021-11-23T12:53:03+01:00 New Revision: f66b69a3925c547b1ee8ea93800f4bf7e31f407b URL: https://github.com/llvm/llvm-project/commit/f66b69a3925c547b1ee8ea93800f4bf7e31f407b DIFF: https://github.com/llvm/llvm-project/commit/f66b69a3925c547b1ee8ea93800f4bf7e31f407b.diff LOG: [lldb] Fix lookup for global constants in namespaces LLDB uses mangled name to construct a fully qualified name for global variables. Sometimes DW_TAG_linkage_name attribute is missing from debug info, so LLDB has to rely on parent entries to construct the fully qualified name. Currently, the fallback is handled when the parent DW_TAG is either DW_TAG_compiled_unit or DW_TAG_partial_unit, which may not work well for global constants in namespaces. For example: namespace ns { const int x = 10; } may produce the following debug info: <1><2a>: Abbrev Number: 2 (DW_TAG_namespace) <2b> DW_AT_name: (indirect string, offset: 0x5e): ns <2><2f>: Abbrev Number: 3 (DW_TAG_variable) <30> DW_AT_name: (indirect string, offset: 0x61): x <34> DW_AT_type: <0x3c> <38> DW_AT_decl_file : 1 <39> DW_AT_decl_line : 2 <3a> DW_AT_const_value : 10 Since the fallback didn't handle the case when parent tag is DW_TAG_namespace, LLDB wasn't able to match the variable by its fully qualified name "ns::x". This change fixes this by additional check if the parent is a DW_TAG_namespace. Reviewed By: werat, clayborg Differential Revision: https://reviews.llvm.org/D112147 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py lldb/test/API/lang/cpp/global_variables/main.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 2dd7ae60b231c..0a75310c3bde5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3271,15 +3271,14 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, } const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die); - const dw_tag_t parent_tag = die.GetParent().Tag(); + const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); + const dw_tag_t parent_tag = sc_parent_die.Tag(); bool is_static_member = (parent_tag == DW_TAG_compile_unit || parent_tag == DW_TAG_partial_unit) && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type); ValueType scope = eValueTypeInvalid; - - const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); SymbolContextScope *symbol_context_scope = nullptr; bool has_explicit_mangled = mangled != nullptr; diff --git a/lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py b/lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py index 045c083cd5528..dbce44f340197 100644 --- a/lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py +++ b/lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py @@ -15,12 +15,11 @@ def setUp(self): TestBase.setUp(self) self.source = lldb.SBFileSpec('main.cpp') -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test(self): self.build() (target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", self.source) - + # Check that we can access g_file_global_int by its name self.expect("target variable g_file_global_int", VARIABLES_DISPLAYED_CORRECTLY, substrs=['42']) @@ -29,6 +28,30 @@ def test(self): self.expect("target variable xyz::g_file_global_int", VARIABLES_DISPLAYED_CORRECTLY, error=True, substrs=['can\'t find global variable']) +# Check that we can access g_file_global_const_int by its name +self.expect("target variable g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['1337']) +self.expect("target variable abc::g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['1337']) +self.expect("target variable xyz::g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +error=True, substrs=['can\'t find global variable']) + +# Try accessing a global variable in anonymous namespace. +self.expect("target variable g_anon_namespace_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['100']) +self.expect("target variable abc::g_anon_namespace_const_int", VARIABLES_DISPLAYED_CORRECTLY, +error=True, substrs=['can\
[Lldb-commits] [lldb] 6f5d109 - [lldb] Add SBBreakpointLocation::SetCallback
Author: Laura Chaparro-Gutierrez Date: 2022-09-12T17:44:02Z New Revision: 6f5d109fca23056dd74d673d2e3439ece22c80b4 URL: https://github.com/llvm/llvm-project/commit/6f5d109fca23056dd74d673d2e3439ece22c80b4 DIFF: https://github.com/llvm/llvm-project/commit/6f5d109fca23056dd74d673d2e3439ece22c80b4.diff LOG: [lldb] Add SBBreakpointLocation::SetCallback * Include SetCallback in SBBreakpointLocation, similar as in SBBreakpoint. * Add test_breakpoint_location_callback test as part of TestMultithreaded. Reviewed By: werat, JDevlieghere Differential Revision: https://reviews.llvm.org/D133689 Co-authored-by: Andy Yankovsky Added: lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template Modified: lldb/include/lldb/API/SBBreakpointLocation.h lldb/source/API/SBBreakpointLocation.cpp lldb/test/API/api/multithreaded/TestMultithreaded.py Removed: diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h index a906727f938a3..ca29696065eab 100644 --- a/lldb/include/lldb/API/SBBreakpointLocation.h +++ b/lldb/include/lldb/API/SBBreakpointLocation.h @@ -48,11 +48,13 @@ class LLDB_API SBBreakpointLocation { void SetCondition(const char *condition); const char *GetCondition(); - + void SetAutoContinue(bool auto_continue); bool GetAutoContinue(); + void SetCallback(SBBreakpointHitCallback callback, void *baton); + void SetScriptCallbackFunction(const char *callback_function_name); SBError SetScriptCallbackFunction(const char *callback_function_name, diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 6c03aba15447f..a253530f5718b 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -28,6 +28,8 @@ #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" +#include "SBBreakpointOptionCommon.h" + using namespace lldb; using namespace lldb_private; @@ -198,6 +200,21 @@ bool SBBreakpointLocation::GetAutoContinue() { return false; } +void SBBreakpointLocation::SetCallback(SBBreakpointHitCallback callback, + void *baton) { + LLDB_INSTRUMENT_VA(this, callback, baton); + + BreakpointLocationSP loc_sp = GetSP(); + + if (loc_sp) { +std::lock_guard guard( +loc_sp->GetTarget().GetAPIMutex()); +BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton)); + loc_sp->SetCallback(SBBreakpointCallbackBaton::PrivateBreakpointHitCallback, +baton_sp, false); + } +} + void SBBreakpointLocation::SetScriptCallbackFunction( const char *callback_function_name) { LLDB_INSTRUMENT_VA(this, callback_function_name); diff --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py b/lldb/test/API/api/multithreaded/TestMultithreaded.py index 231eb9ffefc42..33759906243a4 100644 --- a/lldb/test/API/api/multithreaded/TestMultithreaded.py +++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py @@ -18,6 +18,7 @@ def setUp(self): self.generateSource('driver.cpp') self.generateSource('listener_test.cpp') self.generateSource('test_breakpoint_callback.cpp') +self.generateSource('test_breakpoint_location_callback.cpp') self.generateSource('test_listener_event_description.cpp') self.generateSource('test_listener_event_process_state.cpp') self.generateSource('test_listener_resume.cpp') @@ -41,6 +42,15 @@ def test_breakpoint_callback(self): self.build_and_test('driver.cpp test_breakpoint_callback.cpp', 'test_breakpoint_callback') +@skipIfRemote +@skipIfNoSBHeaders +# clang-cl does not support throw or catch (llvm.org/pr24538) +@skipIfWindows +def test_breakpoint_location_callback(self): +"""Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit. """ +self.build_and_test('driver.cpp test_breakpoint_location_callback.cpp', +'test_breakpoint_location_callback') + @skipIfRemote @skipIfNoSBHeaders # clang-cl does not support throw or catch (llvm.org/pr24538) diff --git a/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template new file mode 100644 index 0..0b0dc5652e850 --- /dev/null +++ b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template @@ -0,0 +1,52 @@ + +// LLDB C++ API Test: verify that the function registered with +// SBBreakpoint.SetCallback() is invoked when a breakpoint is hit. + +#include +#include +#include +#include + +%include_SB_APIs% + +#include "common.h" + +using namespace std; +using namespace lldb; + +mutex g_mutex; +condition_variable g_condition; +int g_breakpoint_hit
[Lldb-commits] [lldb] 14642dc - [lldb] Fix member access in GetExpressionPath
Author: Tonko Sabolčec Date: 2022-09-30T11:25:07Z New Revision: 14642dc7405ebd93a46dda1f2dba616395660715 URL: https://github.com/llvm/llvm-project/commit/14642dc7405ebd93a46dda1f2dba616395660715 DIFF: https://github.com/llvm/llvm-project/commit/14642dc7405ebd93a46dda1f2dba616395660715.diff LOG: [lldb] Fix member access in GetExpressionPath This change fixes two issues in ValueObject::GetExpressionPath method: 1. Accessing members of struct references used to produce expression paths such as "str.&str.member" (instead of the expected "str.member"). This is fixed by assigning the flag tha the child value is a dereference when calling Dereference() on references and adjusting logic in expression path creation. 2. If the parent of member access is dereference, the produced expression path was "*(ptr).member". This is incorrect, since it dereferences the member instead of the pointer. This is fixed by wrapping dereference expression into parenthesis, resulting with "(*(ptr)).member". Reviewed By: werat, clayborg Differential Revision: https://reviews.llvm.org/D132734 Added: lldb/test/API/python_api/expression_path/Makefile lldb/test/API/python_api/expression_path/TestExpressionPath.py lldb/test/API/python_api/expression_path/main.cpp Modified: lldb/source/Core/ValueObject.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Removed: diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 19d86bee40e1f..ece787bdbe4c0 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -273,8 +273,6 @@ CompilerType ValueObject::MaybeCalculateCompleteType() { return compiler_type; } - - DataExtractor &ValueObject::GetDataExtractor() { UpdateValueIfNeeded(false); return m_data; @@ -409,8 +407,9 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs, return root; } -lldb::ValueObjectSP ValueObject::GetChildAtIndexPath( - llvm::ArrayRef> idxs, size_t *index_of_error) { +lldb::ValueObjectSP +ValueObject::GetChildAtIndexPath(llvm::ArrayRef> idxs, + size_t *index_of_error) { if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); @@ -1185,9 +1184,10 @@ bool ValueObject::DumpPrintableRepresentation( { Status error; lldb::WritableDataBufferSP buffer_sp; -std::pair read_string = ReadPointedString( -buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) || - (custom_format == eFormatCharArray)); +std::pair read_string = +ReadPointedString(buffer_sp, error, 0, + (custom_format == eFormatVectorOfChar) || + (custom_format == eFormatCharArray)); lldb_private::formatters::StringPrinter:: ReadBufferAndDumpToStreamOptions options(*this); options.SetData(DataExtractor( @@ -1552,8 +1552,7 @@ bool ValueObject::GetDeclaration(Declaration &decl) { return false; } -void ValueObject::AddSyntheticChild(ConstString key, -ValueObject *valobj) { +void ValueObject::AddSyntheticChild(ConstString key, ValueObject *valobj) { m_synthetic_children[key] = valobj; } @@ -1924,64 +1923,96 @@ void ValueObject::GetExpressionPath(Stream &s, return; } - const bool is_deref_of_parent = IsDereferenceOfParent(); + // Checks whether a value is dereference of a non-reference parent. + // This is used to determine whether to print a dereference operation (*). + auto is_deref_of_non_reference = [](ValueObject *value) { +if (value == nullptr) + return false; +ValueObject *value_parent = value->GetParent(); +if (value_parent) { + CompilerType parent_compiler_type = value_parent->GetCompilerType(); + if (parent_compiler_type) { +const uint32_t parent_type_info = parent_compiler_type.GetTypeInfo(); +if (parent_type_info & eTypeIsReference) + return false; + } +} +return value->IsDereferenceOfParent(); + }; + + ValueObject *parent = GetParent(); - if (is_deref_of_parent && + if (is_deref_of_non_reference(this) && epformat == eGetExpressionPathFormatDereferencePointers) { // this is the original format of GetExpressionPath() producing code like // *(a_ptr).memberName, which is entirely fine, until you put this into // StackFrame::GetValueForVariableExpressionPath() which prefers to see -// a_ptr->memberName. the eHonorPointers mode is meant to produce strings -// in this latter format +// a_ptr->memberName. The eHonorPointers mode is meant to produce strings +// in this latter format. s.PutCString("*("); +if (parent) + parent->GetExpressionPath(s, epformat); +s.PutChar(')'); +return; } - V
[Lldb-commits] [lldb] fb30324 - Revert "[lldb] Fix member access in GetExpressionPath"
Author: Andy Yankovsky Date: 2022-09-30T15:26:09Z New Revision: fb30324a5d535b911b41aa09b1429ca3a88c7fee URL: https://github.com/llvm/llvm-project/commit/fb30324a5d535b911b41aa09b1429ca3a88c7fee DIFF: https://github.com/llvm/llvm-project/commit/fb30324a5d535b911b41aa09b1429ca3a88c7fee.diff LOG: Revert "[lldb] Fix member access in GetExpressionPath" This reverts commit 14642dc74 Broke the tests on macOS -- https://reviews.llvm.org/D132734#3827245 Added: Modified: lldb/source/Core/ValueObject.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Removed: lldb/test/API/python_api/expression_path/Makefile lldb/test/API/python_api/expression_path/TestExpressionPath.py lldb/test/API/python_api/expression_path/main.cpp diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ece787bdbe4c0..19d86bee40e1f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -273,6 +273,8 @@ CompilerType ValueObject::MaybeCalculateCompleteType() { return compiler_type; } + + DataExtractor &ValueObject::GetDataExtractor() { UpdateValueIfNeeded(false); return m_data; @@ -407,9 +409,8 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs, return root; } -lldb::ValueObjectSP -ValueObject::GetChildAtIndexPath(llvm::ArrayRef> idxs, - size_t *index_of_error) { +lldb::ValueObjectSP ValueObject::GetChildAtIndexPath( + llvm::ArrayRef> idxs, size_t *index_of_error) { if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); @@ -1184,10 +1185,9 @@ bool ValueObject::DumpPrintableRepresentation( { Status error; lldb::WritableDataBufferSP buffer_sp; -std::pair read_string = -ReadPointedString(buffer_sp, error, 0, - (custom_format == eFormatVectorOfChar) || - (custom_format == eFormatCharArray)); +std::pair read_string = ReadPointedString( +buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) || + (custom_format == eFormatCharArray)); lldb_private::formatters::StringPrinter:: ReadBufferAndDumpToStreamOptions options(*this); options.SetData(DataExtractor( @@ -1552,7 +1552,8 @@ bool ValueObject::GetDeclaration(Declaration &decl) { return false; } -void ValueObject::AddSyntheticChild(ConstString key, ValueObject *valobj) { +void ValueObject::AddSyntheticChild(ConstString key, +ValueObject *valobj) { m_synthetic_children[key] = valobj; } @@ -1923,96 +1924,64 @@ void ValueObject::GetExpressionPath(Stream &s, return; } - // Checks whether a value is dereference of a non-reference parent. - // This is used to determine whether to print a dereference operation (*). - auto is_deref_of_non_reference = [](ValueObject *value) { -if (value == nullptr) - return false; -ValueObject *value_parent = value->GetParent(); -if (value_parent) { - CompilerType parent_compiler_type = value_parent->GetCompilerType(); - if (parent_compiler_type) { -const uint32_t parent_type_info = parent_compiler_type.GetTypeInfo(); -if (parent_type_info & eTypeIsReference) - return false; - } -} -return value->IsDereferenceOfParent(); - }; - - ValueObject *parent = GetParent(); + const bool is_deref_of_parent = IsDereferenceOfParent(); - if (is_deref_of_non_reference(this) && + if (is_deref_of_parent && epformat == eGetExpressionPathFormatDereferencePointers) { // this is the original format of GetExpressionPath() producing code like // *(a_ptr).memberName, which is entirely fine, until you put this into // StackFrame::GetValueForVariableExpressionPath() which prefers to see -// a_ptr->memberName. The eHonorPointers mode is meant to produce strings -// in this latter format. +// a_ptr->memberName. the eHonorPointers mode is meant to produce strings +// in this latter format s.PutCString("*("); -if (parent) - parent->GetExpressionPath(s, epformat); -s.PutChar(')'); -return; } - const bool is_deref_of_parent = IsDereferenceOfParent(); - bool is_parent_deref_of_non_reference = false; - bool print_obj_access = false; - bool print_ptr_access = false; - - if (!IsBaseClass() && !is_deref_of_parent) { -ValueObject *non_base_class_parent = GetNonBaseClassParent(); -if (non_base_class_parent && !non_base_class_parent->GetName().IsEmpty()) { - CompilerType non_base_class_parent_compiler_type = - non_base_class_parent->GetCompilerType(); - if (non_base_class_parent_compiler_type) { -if (parent && parent->IsDereferenceOfParent() && -epformat == eGetExpressionPathFormatHonorPointers) { -
[Lldb-commits] [lldb] 0205aa4 - [lldb] Fix member access in GetExpressionPath
Author: Tonko Sabolčec Date: 2022-10-12T12:08:57Z New Revision: 0205aa4a02570dfeda5807f66756ebdbb102744b URL: https://github.com/llvm/llvm-project/commit/0205aa4a02570dfeda5807f66756ebdbb102744b DIFF: https://github.com/llvm/llvm-project/commit/0205aa4a02570dfeda5807f66756ebdbb102744b.diff LOG: [lldb] Fix member access in GetExpressionPath This change fixes two issues in ValueObject::GetExpressionPath method: 1. Accessing members of struct references used to produce expression paths such as "str.&str.member" (instead of the expected "str.member"). This is fixed by assigning the flag tha the child value is a dereference when calling Dereference() on references and adjusting logic in expression path creation. 2. If the parent of member access is dereference, the produced expression path was "*(ptr).member". This is incorrect, since it dereferences the member instead of the pointer. This is fixed by wrapping dereference expression into parenthesis, resulting with "(*ptr).member". Reviewed By: werat, clayborg Differential Revision: https://reviews.llvm.org/D132734 Added: lldb/test/API/python_api/expression_path/Makefile lldb/test/API/python_api/expression_path/TestExpressionPath.py lldb/test/API/python_api/expression_path/main.cpp Modified: lldb/source/Core/ValueObject.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Removed: diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 19d86bee40e1f..226a2c3f690f2 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -273,8 +273,6 @@ CompilerType ValueObject::MaybeCalculateCompleteType() { return compiler_type; } - - DataExtractor &ValueObject::GetDataExtractor() { UpdateValueIfNeeded(false); return m_data; @@ -409,8 +407,9 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs, return root; } -lldb::ValueObjectSP ValueObject::GetChildAtIndexPath( - llvm::ArrayRef> idxs, size_t *index_of_error) { +lldb::ValueObjectSP +ValueObject::GetChildAtIndexPath(llvm::ArrayRef> idxs, + size_t *index_of_error) { if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); @@ -1185,9 +1184,10 @@ bool ValueObject::DumpPrintableRepresentation( { Status error; lldb::WritableDataBufferSP buffer_sp; -std::pair read_string = ReadPointedString( -buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) || - (custom_format == eFormatCharArray)); +std::pair read_string = +ReadPointedString(buffer_sp, error, 0, + (custom_format == eFormatVectorOfChar) || + (custom_format == eFormatCharArray)); lldb_private::formatters::StringPrinter:: ReadBufferAndDumpToStreamOptions options(*this); options.SetData(DataExtractor( @@ -1552,8 +1552,7 @@ bool ValueObject::GetDeclaration(Declaration &decl) { return false; } -void ValueObject::AddSyntheticChild(ConstString key, -ValueObject *valobj) { +void ValueObject::AddSyntheticChild(ConstString key, ValueObject *valobj) { m_synthetic_children[key] = valobj; } @@ -1924,64 +1923,96 @@ void ValueObject::GetExpressionPath(Stream &s, return; } - const bool is_deref_of_parent = IsDereferenceOfParent(); + // Checks whether a value is dereference of a non-reference parent. + // This is used to determine whether to print a dereference operation (*). + auto is_deref_of_non_reference = [](ValueObject *value) { +if (value == nullptr) + return false; +ValueObject *value_parent = value->GetParent(); +if (value_parent) { + CompilerType parent_compiler_type = value_parent->GetCompilerType(); + if (parent_compiler_type) { +const uint32_t parent_type_info = parent_compiler_type.GetTypeInfo(); +if (parent_type_info & eTypeIsReference) + return false; + } +} +return value->IsDereferenceOfParent(); + }; + + ValueObject *parent = GetParent(); - if (is_deref_of_parent && + if (is_deref_of_non_reference(this) && epformat == eGetExpressionPathFormatDereferencePointers) { // this is the original format of GetExpressionPath() producing code like // *(a_ptr).memberName, which is entirely fine, until you put this into // StackFrame::GetValueForVariableExpressionPath() which prefers to see -// a_ptr->memberName. the eHonorPointers mode is meant to produce strings -// in this latter format -s.PutCString("*("); +// a_ptr->memberName. The eHonorPointers mode is meant to produce strings +// in this latter format. +s.PutChar
Re: [Lldb-commits] Prevent type canonization when dereferencing
I think the problem is specific to references, at least that's the case I ran into in lldb-eval -- https://github.com/google/lldb-eval/blob/master/docs/lldb-bugs.md#dereferencing-a-value-canonizes-the-type On Wed, 2 Jun 2021 at 17:26, Raphael “Teemperor” Isemann < teempe...@gmail.com> wrote: > I assume your bug is for dereferencing references? In your test taking the > ref variable and then dereferencing it via the SB API reproduces that I > think you're running into: > > >>> lldb.frame.FindVariable("p_ref").GetType().GetName() > 'TPair &' > >>> lldb.frame.FindVariable("p_ref").Dereference().GetType().GetName() > 'TTuple' > > (I made `p_ref` a local to avoid the expression evaluation machinery) > > Cheers, > - Raphael > > > On 2 Jun 2021, at 15:27, Lasse Folger wrote: > > > > Hi Raphael, > > > > I have a very similar test for a tool that integrates with lldb which > failed without the patch. > > I thought the test in the patch would behave the same which is > apparently not the case. > > Thanks for pointing that out. I will need to take another look and will > get back to you once I figure out what's wrong. > > Sorry for the inconvenience. > > > > kind regards, > > Lasse > > > > > > On Wed, Jun 2, 2021 at 1:15 PM Raphael “Teemperor” Isemann < > teempe...@gmail.com> wrote: > > Hi Lasse, > > > > the test from the patch passes for me even without your non-test > changes. Not sure if you attached the wrong diff or it needs to be applied > on a specific commit that is not ToT? Can you maybe try pushing your code > to some git repo? > > > > Your change to TypeSystemClang (which I assume removes the > canonicalization of parent_qual_type) is from what I can see not actually > changing the result value of `GetChildCompilerTypeAtIndex`. It looks like > the return value for pointer types is computed independently from > `parent_qual_type` without any canonicalization. > > > > Cheers, > > - Raphael > > > >> On 2 Jun 2021, at 11:39, Lasse Folger via lldb-commits < > lldb-commits@lists.llvm.org> wrote: > >> > >> <0001-lldb-prevent-canonization-of-type-when-dereferencing.patch> > > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] aafa05e - [lldb] Add minidump save-core functionality to ELF object files
Author: Andrej Korman Date: 2021-08-31T13:04:38+02:00 New Revision: aafa05e03d629cc6605718c54575256d9d683659 URL: https://github.com/llvm/llvm-project/commit/aafa05e03d629cc6605718c54575256d9d683659 DIFF: https://github.com/llvm/llvm-project/commit/aafa05e03d629cc6605718c54575256d9d683659.diff LOG: [lldb] Add minidump save-core functionality to ELF object files This change adds save-core functionality into the ObjectFileELF that enables saving minidump of a stopped process. This change is mainly targeting Linux running on x86_64 machines. Minidump should contain basic information needed to examine state of threads, local variables and stack traces. Full support for other platforms is not so far implemented. API tests are using LLDB's MinidumpParser. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D108233 Added: lldb/source/Plugins/ObjectFile/Minidump/CMakeLists.txt lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h lldb/test/API/functionalities/process_save_core_minidump/Makefile lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py lldb/test/API/functionalities/process_save_core_minidump/main.cpp Modified: lldb/include/lldb/Core/PluginManager.h lldb/source/API/SBProcess.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Commands/Options.td lldb/source/Core/PluginManager.cpp lldb/source/Plugins/ObjectFile/CMakeLists.txt Removed: diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index be91929c62e1..2bee2edea636 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -192,7 +192,8 @@ class PluginManager { static Status SaveCore(const lldb::ProcessSP &process_sp, const FileSpec &outfile, - lldb::SaveCoreStyle &core_style); + lldb::SaveCoreStyle &core_style, + const ConstString plugin_name); // ObjectContainer static bool diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 47c35a23b078..a965814be1b9 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1228,7 +1228,8 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { FileSpec core_file(file_name); SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; - error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style); + error.ref() = + PluginManager::SaveCore(process_sp, core_file, core_style, ConstString()); return LLDB_RECORD_RESULT(error); } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index bb6220a53d4e..b3e2f6a1a02b 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1180,12 +1180,13 @@ static constexpr OptionEnumValues SaveCoreStyles() { class CommandObjectProcessSaveCore : public CommandObjectParsed { public: CommandObjectProcessSaveCore(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "process save-core", -"Save the current process as a core file using an " -"appropriate file type.", -"process save-core [-s corefile-style] FILE", -eCommandRequiresProcess | eCommandTryTargetAPILock | -eCommandProcessMustBeLaunched) {} + : CommandObjectParsed( +interpreter, "process save-core", +"Save the current process as a core file using an " +"appropriate file type.", +"process save-core [-s corefile-style -p plugin-name] FILE", +eCommandRequiresProcess | eCommandTryTargetAPILock | +eCommandProcessMustBeLaunched) {} ~CommandObjectProcessSaveCore() override = default; @@ -1208,6 +1209,9 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { Status error; switch (short_option) { + case 'p': +m_requested_plugin_name.SetString(option_arg); +break; case 's': m_requested_save_core_style = (lldb::SaveCoreStyle)OptionArgParser::ToOptionEnum( @@ -1223,10 +1227,12 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { void OptionParsingStarting(ExecutionContext *execution_context) override { m_requested_save_core_style = eSaveCoreUnspecified; + m_requested_plugin_name.Clear(); } // Instance variables to hold the values for command options. SaveCore
[Lldb-commits] [lldb] 1f986f6 - Revert "[lldb] Add minidump save-core functionality to ELF object files"
Author: Andy Yankovsky Date: 2021-08-31T13:36:53+02:00 New Revision: 1f986f60573c6f4355c2d8a5c7ddcb2d32dfd43c URL: https://github.com/llvm/llvm-project/commit/1f986f60573c6f4355c2d8a5c7ddcb2d32dfd43c DIFF: https://github.com/llvm/llvm-project/commit/1f986f60573c6f4355c2d8a5c7ddcb2d32dfd43c.diff LOG: Revert "[lldb] Add minidump save-core functionality to ELF object files" This reverts commit aafa05e03d629cc6605718c54575256d9d683659. Broke builder on aarch64 -- https://lab.llvm.org/buildbot/#/builders/96/builds/10926 Added: Modified: lldb/include/lldb/Core/PluginManager.h lldb/source/API/SBProcess.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Commands/Options.td lldb/source/Core/PluginManager.cpp lldb/source/Plugins/ObjectFile/CMakeLists.txt Removed: lldb/source/Plugins/ObjectFile/Minidump/CMakeLists.txt lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h lldb/test/API/functionalities/process_save_core_minidump/Makefile lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py lldb/test/API/functionalities/process_save_core_minidump/main.cpp diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index 2bee2edea6360..be91929c62e13 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -192,8 +192,7 @@ class PluginManager { static Status SaveCore(const lldb::ProcessSP &process_sp, const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, - const ConstString plugin_name); + lldb::SaveCoreStyle &core_style); // ObjectContainer static bool diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index a965814be1b98..47c35a23b0781 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1228,8 +1228,7 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { FileSpec core_file(file_name); SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; - error.ref() = - PluginManager::SaveCore(process_sp, core_file, core_style, ConstString()); + error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style); return LLDB_RECORD_RESULT(error); } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index b3e2f6a1a02b7..bb6220a53d4e8 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1180,13 +1180,12 @@ static constexpr OptionEnumValues SaveCoreStyles() { class CommandObjectProcessSaveCore : public CommandObjectParsed { public: CommandObjectProcessSaveCore(CommandInterpreter &interpreter) - : CommandObjectParsed( -interpreter, "process save-core", -"Save the current process as a core file using an " -"appropriate file type.", -"process save-core [-s corefile-style -p plugin-name] FILE", -eCommandRequiresProcess | eCommandTryTargetAPILock | -eCommandProcessMustBeLaunched) {} + : CommandObjectParsed(interpreter, "process save-core", +"Save the current process as a core file using an " +"appropriate file type.", +"process save-core [-s corefile-style] FILE", +eCommandRequiresProcess | eCommandTryTargetAPILock | +eCommandProcessMustBeLaunched) {} ~CommandObjectProcessSaveCore() override = default; @@ -1209,9 +1208,6 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { Status error; switch (short_option) { - case 'p': -m_requested_plugin_name.SetString(option_arg); -break; case 's': m_requested_save_core_style = (lldb::SaveCoreStyle)OptionArgParser::ToOptionEnum( @@ -1227,12 +1223,10 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { void OptionParsingStarting(ExecutionContext *execution_context) override { m_requested_save_core_style = eSaveCoreUnspecified; - m_requested_plugin_name.Clear(); } // Instance variables to hold the values for command options. SaveCoreStyle m_requested_save_core_style; -ConstString m_requested_plugin_name; }; protected: @@ -1243,8 +1237,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { FileSpec output_file(command.GetArgumentAtIndex(0)); SaveCoreStyle corefile_style = m_options.m_requested_sa
[Lldb-commits] [lldb] eee687a - [lldb] Add minidump save-core functionality to ELF object files
Author: Andrej Korman Date: 2021-09-01T15:14:29+02:00 New Revision: eee687a66d76bf0b6e3746f7b8d09b0d871bff27 URL: https://github.com/llvm/llvm-project/commit/eee687a66d76bf0b6e3746f7b8d09b0d871bff27 DIFF: https://github.com/llvm/llvm-project/commit/eee687a66d76bf0b6e3746f7b8d09b0d871bff27.diff LOG: [lldb] Add minidump save-core functionality to ELF object files This change adds save-core functionality into the ObjectFileELF that enables saving minidump of a stopped process. This change is mainly targeting Linux running on x86_64 machines. Minidump should contain basic information needed to examine state of threads, local variables and stack traces. Full support for other platforms is not so far implemented. API tests are using LLDB's MinidumpParser. This relands commit aafa05e, reverted in 1f986f6. Failed tests were fixed. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D108233 Added: lldb/source/Plugins/ObjectFile/Minidump/CMakeLists.txt lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h lldb/test/API/functionalities/process_save_core_minidump/Makefile lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py lldb/test/API/functionalities/process_save_core_minidump/main.cpp Modified: lldb/include/lldb/Core/PluginManager.h lldb/source/API/SBProcess.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Commands/Options.td lldb/source/Core/PluginManager.cpp lldb/source/Plugins/ObjectFile/CMakeLists.txt Removed: diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index be91929c62e13..2bee2edea6360 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -192,7 +192,8 @@ class PluginManager { static Status SaveCore(const lldb::ProcessSP &process_sp, const FileSpec &outfile, - lldb::SaveCoreStyle &core_style); + lldb::SaveCoreStyle &core_style, + const ConstString plugin_name); // ObjectContainer static bool diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 47c35a23b0781..a965814be1b98 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1228,7 +1228,8 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { FileSpec core_file(file_name); SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; - error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style); + error.ref() = + PluginManager::SaveCore(process_sp, core_file, core_style, ConstString()); return LLDB_RECORD_RESULT(error); } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index bb6220a53d4e8..b3e2f6a1a02b7 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1180,12 +1180,13 @@ static constexpr OptionEnumValues SaveCoreStyles() { class CommandObjectProcessSaveCore : public CommandObjectParsed { public: CommandObjectProcessSaveCore(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "process save-core", -"Save the current process as a core file using an " -"appropriate file type.", -"process save-core [-s corefile-style] FILE", -eCommandRequiresProcess | eCommandTryTargetAPILock | -eCommandProcessMustBeLaunched) {} + : CommandObjectParsed( +interpreter, "process save-core", +"Save the current process as a core file using an " +"appropriate file type.", +"process save-core [-s corefile-style -p plugin-name] FILE", +eCommandRequiresProcess | eCommandTryTargetAPILock | +eCommandProcessMustBeLaunched) {} ~CommandObjectProcessSaveCore() override = default; @@ -1208,6 +1209,9 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { Status error; switch (short_option) { + case 'p': +m_requested_plugin_name.SetString(option_arg); +break; case 's': m_requested_save_core_style = (lldb::SaveCoreStyle)OptionArgParser::ToOptionEnum( @@ -1223,10 +1227,12 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { void OptionParsingStarting(ExecutionContext *execution_context) override { m_requested_save_core_style = eSaveCoreUnspecified; + m_requested_plugin_name.Clear(); }
Re: [Lldb-commits] [lldb] eee687a - [lldb] Add minidump save-core functionality to ELF object files
Thanks for flagging this! Adding the author of the change. Does it fail somewhere on the llvm builders? Is there an easy way to reproduce this locally? On Thu, 2 Sept 2021 at 01:53, Richard Smith wrote: > The new test fails under MSan: > > Uninitialized bytes in __interceptor_write at offset 2 inside > [0x7fb1f42ed000, 18438530) > ==3871==WARNING: MemorySanitizer: use-of-uninitialized-value > #0 0x55f5706515d9 in RetryAfterSignal unsigned long), int, const void *, unsigned long> > llvm-project/llvm/include/llvm/Support/Errno.h:38:11 > #1 0x55f5706515d9 in lldb_private::NativeFile::Write(void const*, > unsigned long&) llvm-project/lldb/source/Host/common/File.cpp:585:9 > #2 0x55f570badbf5 in > MinidumpFileBuilder::Dump(std::__msan::unique_ptr std::__msan::default_delete >&) const > llvm-project/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp:739:22 > #3 0x55f570bb075c in > ObjectFileMinidump::SaveCore(std::__msan::shared_ptr > const&, lldb_private::FileSpec const&, lldb::SaveCoreStyle&, > lldb_private::Status&) > llvm-project/lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp:114:19 > #4 0x55f57048960b in > lldb_private::PluginManager::SaveCore(std::__msan::shared_ptr > const&, lldb_private::FileSpec const&, lldb::SaveCoreStyle&, > lldb_private::ConstString) > llvm-project/lldb/source/Core/PluginManager.cpp:696:9 > > Please can you take a look? > > On Wed, 1 Sept 2021 at 06:19, Andy Yankovsky via lldb-commits < > lldb-commits@lists.llvm.org> wrote: > >> >> Author: Andrej Korman >> Date: 2021-09-01T15:14:29+02:00 >> New Revision: eee687a66d76bf0b6e3746f7b8d09b0d871bff27 >> >> URL: >> https://github.com/llvm/llvm-project/commit/eee687a66d76bf0b6e3746f7b8d09b0d871bff27 >> DIFF: >> https://github.com/llvm/llvm-project/commit/eee687a66d76bf0b6e3746f7b8d09b0d871bff27.diff >> >> LOG: [lldb] Add minidump save-core functionality to ELF object files >> >> This change adds save-core functionality into the ObjectFileELF that >> enables >> saving minidump of a stopped process. This change is mainly targeting >> Linux >> running on x86_64 machines. Minidump should contain basic information >> needed >> to examine state of threads, local variables and stack traces. Full >> support >> for other platforms is not so far implemented. API tests are using LLDB's >> MinidumpParser. >> >> This relands commit aafa05e, reverted in 1f986f6. >> Failed tests were fixed. >> >> Reviewed By: clayborg >> >> Differential Revision: https://reviews.llvm.org/D108233 >> >> Added: >> lldb/source/Plugins/ObjectFile/Minidump/CMakeLists.txt >> lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp >> lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h >> lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp >> lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h >> lldb/test/API/functionalities/process_save_core_minidump/Makefile >> >> lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py >> lldb/test/API/functionalities/process_save_core_minidump/main.cpp >> >> Modified: >> lldb/include/lldb/Core/PluginManager.h >> lldb/source/API/SBProcess.cpp >> lldb/source/Commands/CommandObjectProcess.cpp >> lldb/source/Commands/Options.td >> lldb/source/Core/PluginManager.cpp >> lldb/source/Plugins/ObjectFile/CMakeLists.txt >> >> Removed: >> >> >> >> >> >> diff --git a/lldb/include/lldb/Core/PluginManager.h >> b/lldb/include/lldb/Core/PluginManager.h >> index be91929c62e13..2bee2edea6360 100644 >> --- a/lldb/include/lldb/Core/PluginManager.h >> +++ b/lldb/include/lldb/Core/PluginManager.h >> @@ -192,7 +192,8 @@ class PluginManager { >> >>static Status SaveCore(const lldb::ProcessSP &process_sp, >> const FileSpec &outfile, >> - lldb::SaveCoreStyle &core_style); >> + lldb::SaveCoreStyle &core_style, >> + const ConstString plugin_name); >> >>// ObjectContainer >>static bool >> >> diff --git a/lldb/source/API/SBProcess.cpp >> b/lldb/source/API/SBProcess.cpp >> index 47c35a23b0781..a965814be1b98 100644 >> --- a/lldb/source/API/SBProcess.cpp >> +++ b/lldb/source/API/SBProcess.cpp >> @@
[Lldb-commits] [lldb] 7ec7876 - [lldb] Fix handling of `DW_AT_decl_file` according to D91014
Author: Andy Yankovsky Date: 2021-03-01T16:01:11+01:00 New Revision: 7ec7876feda412b6edad0d83565395ef2fd5a004 URL: https://github.com/llvm/llvm-project/commit/7ec7876feda412b6edad0d83565395ef2fd5a004 DIFF: https://github.com/llvm/llvm-project/commit/7ec7876feda412b6edad0d83565395ef2fd5a004.diff LOG: [lldb] Fix handling of `DW_AT_decl_file` according to D91014 Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed. Differential Revision: https://reviews.llvm.org/D96778 Added: lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s lldb/test/Shell/SymbolFile/DWARF/Inputs/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu2.s Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 188a667ca564..af01a8f53518 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2201,7 +2201,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( case DW_AT_description: default: case DW_AT_decl_file: - decl.SetFile(die.GetCU()->GetFile(form_value.Unsigned())); + decl.SetFile(attributes.CompileUnitAtIndex(i)->GetFile( + form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7d273cb7df1b..587550961ec9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3126,8 +3126,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, continue; switch (attr) { case DW_AT_decl_file: - decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( - form_value.Unsigned())); + decl.SetFile( + attributes.CompileUnitAtIndex(i)->GetFile(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s new file mode 100644 index ..c0998a1711aa --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s @@ -0,0 +1,170 @@ +# Check that DW_AT_decl_file of DW_AT_variable which is inherited by +# DW_AT_abstract_origin from a diff erent DW_TAG_compile_unit is using the +# DW_TAG_compile_unit->DW_AT_stmt_list where the DW_AT_decl_file is located (and +# not where the DW_AT_abstract_origin is located). +# DW_TAG_variable in CU 1 is using DW_AT_decl_file 3. +# CU 1 has files: +# file_names[ 1]: name: "inlinevarother.h" +# file_names[ 2]: name: "inlinevar1.c" +# file_names[ 3]: name: "inlinevar.h" +# CU 2 has files: +# file_names[ 1]: name: "inlinevar2.c" +# file_names[ 2]: name: "inlinevar.h" + +# REQUIRES: x86 + +// RUN: %clang -o %t --target=x86_64-pc-linux %s \ +// RUN: %S/Inputs/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu2.s + +# RUN: %lldb %t \ +# RUN: -o 'b other' -o r -o disas -o 'frame variable --show-declaration' \ +# RUN: -o exit | FileCheck %s + +# CHECK: inlinevar.h:2: (int) var = {{.*}} +# Unfixed LLDB did show only: (int) var = {{.*}} + + .text + .file "inlinevar1.c" + .file 1 "" "./inlinevarother.h" + .globl main# -- Begin function main + .type main,@function +main: # @main +.Lfunc_begin1: + .file 2 "" "inlinevar1.c" + .loc2 4 0 # inlinevar1.c:4:0 +.Ltmp2: + .file 3 "" "./inlinevar.h" + .loc3 2 16 prologue_end # ./inlinevar.h:2:16 + movl$42, %eax + pushq %rax + .loc3 3 10 # ./inlinevar.h:3:10 +.Ltmp3: + .loc2 5 20 # inlinevar1.c:5:20 + callq other + popq%rcx + .loc2 5 19 # inlinevar1.c:5:19 + addl%ecx, %eax + .loc2 5 3 # inlinevar1.c:5:3 + retq +.Ltmp4: +.Lfunc_end1: + .size main, .Lfunc_end1-main +# -- End function + .section.debug_abbrev,"",@progbits + .byte 1
[Lldb-commits] [lldb] 3b47bd3 - [lldb] Fix handling of `DW_AT_decl_file` according to D91014 (attempt #2)
Author: Andy Yankovsky Date: 2021-03-03T10:27:35+01:00 New Revision: 3b47bd32f9df4a57db98db5f35e680c7bd9fde3e URL: https://github.com/llvm/llvm-project/commit/3b47bd32f9df4a57db98db5f35e680c7bd9fde3e DIFF: https://github.com/llvm/llvm-project/commit/3b47bd32f9df4a57db98db5f35e680c7bd9fde3e.diff LOG: [lldb] Fix handling of `DW_AT_decl_file` according to D91014 (attempt #2) Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed. Test case is provided by @jankratochvil. The test is marked to run only on x64 and exclude Windows and Darwin, because the assembly is not OS-independent. (First attempt https://reviews.llvm.org/D96778 broke the build bots) Reviewed By: jankratochvil Differential Revision: https://reviews.llvm.org/D97765 Added: lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s lldb/test/Shell/SymbolFile/DWARF/Inputs/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu2.s Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 188a667ca564..af01a8f53518 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2201,7 +2201,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( case DW_AT_description: default: case DW_AT_decl_file: - decl.SetFile(die.GetCU()->GetFile(form_value.Unsigned())); + decl.SetFile(attributes.CompileUnitAtIndex(i)->GetFile( + form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7d273cb7df1b..587550961ec9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3126,8 +3126,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, continue; switch (attr) { case DW_AT_decl_file: - decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( - form_value.Unsigned())); + decl.SetFile( + attributes.CompileUnitAtIndex(i)->GetFile(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s new file mode 100644 index ..ef1481bbf800 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s @@ -0,0 +1,171 @@ +# Check that DW_AT_decl_file of DW_AT_variable which is inherited by +# DW_AT_abstract_origin from a diff erent DW_TAG_compile_unit is using the +# DW_TAG_compile_unit->DW_AT_stmt_list where the DW_AT_decl_file is located (and +# not where the DW_AT_abstract_origin is located). +# DW_TAG_variable in CU 1 is using DW_AT_decl_file 3. +# CU 1 has files: +# file_names[ 1]: name: "inlinevarother.h" +# file_names[ 2]: name: "inlinevar1.c" +# file_names[ 3]: name: "inlinevar.h" +# CU 2 has files: +# file_names[ 1]: name: "inlinevar2.c" +# file_names[ 2]: name: "inlinevar.h" + +# UNSUPPORTED: system-darwin, system-windows +# REQUIRES: target-x86_64 + +# RUN: %clang_host -o %t %s \ +# RUN: %S/Inputs/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu2.s + +# RUN: %lldb %t \ +# RUN: -o 'b other' -o r -o disas -o 'frame variable --show-declaration' \ +# RUN: -o exit | FileCheck %s + +# CHECK: inlinevar.h:2: (int) var = {{.*}} +# Unfixed LLDB did show only: (int) var = {{.*}} + + .text + .file "inlinevar1.c" + .file 1 "" "./inlinevarother.h" + .globl main# -- Begin function main + .type main,@function +main: # @main +.Lfunc_begin1: + .file 2 "" "inlinevar1.c" + .loc2 4 0 # inlinevar1.c:4:0 +.Ltmp2: + .file 3 "" "./inlinevar.h" + .loc3 2 16 prologue_end # ./inlinevar.h:2:16 + movl$42, %eax + pushq %rax + .loc3 3 10 # ./inlinevar.h:3:10 +.Ltmp3: + .loc2 5 20 # inlinevar1.c:5:20 + callq other + popq%rcx + .loc2 5 19 # inlinevar1.c:5:19 + addl%ec
[Lldb-commits] [lldb] 1b7e5d4 - [lldb] Fix error message in IRInterpreter
Author: Andy Yankovsky Date: 2021-03-08T16:46:38+01:00 New Revision: 1b7e5d461aee80cd3031b4854ab71f6721b71e31 URL: https://github.com/llvm/llvm-project/commit/1b7e5d461aee80cd3031b4854ab71f6721b71e31 DIFF: https://github.com/llvm/llvm-project/commit/1b7e5d461aee80cd3031b4854ab71f6721b71e31.diff LOG: [lldb] Fix error message in IRInterpreter `memory_read_error` -> `memory_write_error` Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D98170 Added: Modified: lldb/source/Expression/IRInterpreter.cpp Removed: diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index b87a759aadc5..81d8a8d5070d 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -1241,7 +1241,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, if (!write_error.Success()) { LLDB_LOGF(log, "Couldn't write to a region on behalf of a LoadInst"); error.SetErrorToGenericError(); -error.SetErrorString(memory_read_error); +error.SetErrorString(memory_write_error); return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0bab7b2 - [lldb] Encode `bool` as unsigned int
Author: Andy Yankovsky Date: 2021-05-19T15:32:17+02:00 New Revision: 0bab7b26f4d9dc4cb8f6c2877ad4a2c388c41c65 URL: https://github.com/llvm/llvm-project/commit/0bab7b26f4d9dc4cb8f6c2877ad4a2c388c41c65 DIFF: https://github.com/llvm/llvm-project/commit/0bab7b26f4d9dc4cb8f6c2877ad4a2c388c41c65.diff LOG: [lldb] Encode `bool` as unsigned int `bool` is considered to be unsigned according to `std::is_unsigned::value` (and `Type::GetTypeInfo`). Encoding it as signed int works fine for normal variables and fields, but breaks when reading the values of boolean bitfields. If the field is declared as `bool b : 1` and has a value of `0b1`, the call to `SBValue::GetValueAsSigned()` will return `-1`. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D102685 Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py lldb/test/API/lang/cpp/bitfields/main.cpp Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 7e037a1589f16..51e53f0bab561 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -4698,7 +4698,6 @@ lldb::Encoding TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type, case clang::BuiltinType::Void: break; -case clang::BuiltinType::Bool: case clang::BuiltinType::Char_S: case clang::BuiltinType::SChar: case clang::BuiltinType::WChar_S: @@ -4709,6 +4708,7 @@ lldb::Encoding TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type, case clang::BuiltinType::Int128: return lldb::eEncodingSint; +case clang::BuiltinType::Bool: case clang::BuiltinType::Char_U: case clang::BuiltinType::UChar: case clang::BuiltinType::WChar_U: diff --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py index 0585cf60951b6..bf457d33a0bd1 100644 --- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -120,3 +120,36 @@ def test_and_run_command(self): '(uint32_t) b_a = 2', '(uint32_t:1) d_a = 1', ]) + +self.expect( +"frame variable --show-types bb", +VARIABLES_DISPLAYED_CORRECTLY, +substrs=[ +'(bool:1) a = true', +'(bool:1) b = false', +'(bool:2) c = true', +'(bool:2) d = true', +]) + +bb = self.frame().FindVariable('bb') +self.assertTrue(bb.IsValid()) + +bb_a = bb.GetChildAtIndex(0) +self.assertTrue(bb_a.IsValid()) +self.assertEqual(bb_a.GetValueAsUnsigned(), 1) +self.assertEqual(bb_a.GetValueAsSigned(), 1) + +bb_b = bb.GetChildAtIndex(1) +self.assertTrue(bb_b.IsValid()) +self.assertEqual(bb_b.GetValueAsUnsigned(), 0) +self.assertEqual(bb_b.GetValueAsSigned(), 0) + +bb_c = bb.GetChildAtIndex(2) +self.assertTrue(bb_c.IsValid()) +self.assertEqual(bb_c.GetValueAsUnsigned(), 1) +self.assertEqual(bb_c.GetValueAsSigned(), 1) + +bb_d = bb.GetChildAtIndex(3) +self.assertTrue(bb_d.IsValid()) +self.assertEqual(bb_d.GetValueAsUnsigned(), 1) +self.assertEqual(bb_d.GetValueAsSigned(), 1) diff --git a/lldb/test/API/lang/cpp/bitfields/main.cpp b/lldb/test/API/lang/cpp/bitfields/main.cpp index f9015b758c724..a9887b5e826e9 100644 --- a/lldb/test/API/lang/cpp/bitfields/main.cpp +++ b/lldb/test/API/lang/cpp/bitfields/main.cpp @@ -104,5 +104,17 @@ int main(int argc, char const *argv[]) { uwbf.x = 0x; uwubf.x = 0x; + struct BoolBits { +bool a : 1; +bool b : 1; +bool c : 2; +bool d : 2; + } bb; + + bb.a = 0b1; + bb.b = 0b0; + bb.c = 0b11; + bb.d = 0b01; + return 0; // Set break point at this line. } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6c83d4a - [lldb] Enable TestCppBitfields on Windows
Author: Andy Yankovsky Date: 2021-05-19T17:04:19+02:00 New Revision: 6c83d4a60b7d243f0674f4381ec72b7c8ec4f2be URL: https://github.com/llvm/llvm-project/commit/6c83d4a60b7d243f0674f4381ec72b7c8ec4f2be DIFF: https://github.com/llvm/llvm-project/commit/6c83d4a60b7d243f0674f4381ec72b7c8ec4f2be.diff LOG: [lldb] Enable TestCppBitfields on Windows The test works correctly on Windows, the linked bug has been resolved. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D102769 Added: Modified: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py Removed: diff --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py index bf457d33a0bd..480b680e792e 100644 --- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -16,9 +16,6 @@ def setUp(self): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') -# BitFields exhibit crashes in record layout on Windows -# (http://llvm.org/pr21800) -@skipIfWindows def test_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits