[Lldb-commits] [lldb] edb0efc - [lldb][NFC] Modernize call-function tests
Author: Raphael Isemann Date: 2020-04-01T10:17:42+02:00 New Revision: edb0efca1e73ec5f791d9fe8c28f7c4c85a61c43 URL: https://github.com/llvm/llvm-project/commit/edb0efca1e73ec5f791d9fe8c28f7c4c85a61c43 DIFF: https://github.com/llvm/llvm-project/commit/edb0efca1e73ec5f791d9fe8c28f7c4c85a61c43.diff LOG: [lldb][NFC] Modernize call-function tests Added: Modified: lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py lldb/test/API/commands/expression/call-function/main.cpp Removed: diff --git a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py index 261e702fa59a..f94bcae34cf9 100644 --- a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py +++ b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py @@ -2,26 +2,15 @@ Test calling std::String member functions. """ - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class ExprCommandCallFunctionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -def setUp(self): -# Call super's setUp(). -TestBase.setUp(self) -# Find the line number to break for main.c. -self.line = line_number( -'main.cpp', -'// Please test these expressions while stopped at this line:') - @expectedFailureAll( compiler="icc", bugnumber="llvm.org/pr14437, fails with ICC 13.1") @@ -29,15 +18,7 @@ def setUp(self): def test_with(self): """Test calling std::String member function.""" self.build() -self.runCmd("file " + self.getBuildArtifact("a.out"), -CURRENT_EXECUTABLE_SET) - -# Some versions of GCC encode two locations for the 'return' statement -# in main.cpp -lldbutil.run_break_set_by_file_and_line( -self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) - -self.runCmd("run", RUN_SUCCEEDED) +lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) self.expect("print str", substrs=['Hello world']) diff --git a/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py b/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py index 0f0f1a54e31c..1191176aa706 100644 --- a/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py +++ b/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py @@ -2,13 +2,10 @@ Test calling a function, stopping in the call, continue and gather the result on stop. """ - - import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class ExprCommandCallStopContinueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -17,27 +14,16 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break for main.c. -self.line = line_number( -'main.cpp', -'// Please test these expressions while stopped at this line:') -self.func_line = line_number('main.cpp', '{5, "five"}') def test(self): """Test gathering result from interrupted function call.""" self.build() -self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) - -# Some versions of GCC encode two locations for the 'return' statement -# in main.cpp -lldbutil.run_break_set_by_file_and_line( -self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) - -self.runCmd("run", RUN_SUCCEEDED) +lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", -self.func_line, +line_number('main.cpp', '{5, "five"}'), num_expected_locations=-1, loc_exact=True) diff --git a/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py b/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py index 98cd0f24f36c..edaa76174b47 100644 --- a/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py +++ b/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py @@ -7,36 +7,19 @@ """ - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class
[Lldb-commits] [lldb] 48a5bda - [lldb][NFC] Modernize TestXValuePrinting
Author: Raphael Isemann Date: 2020-04-01T10:20:52+02:00 New Revision: 48a5bdafba5e51244de627a50574d48c87a5249d URL: https://github.com/llvm/llvm-project/commit/48a5bdafba5e51244de627a50574d48c87a5249d DIFF: https://github.com/llvm/llvm-project/commit/48a5bdafba5e51244de627a50574d48c87a5249d.diff LOG: [lldb][NFC] Modernize TestXValuePrinting Added: Modified: lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py Removed: diff --git a/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py b/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py index 3a394d781f0a..f5122b84839a 100644 --- a/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py +++ b/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py @@ -1,36 +1,15 @@ - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class ExprXValuePrintingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -def setUp(self): -# Call super's setUp(). -TestBase.setUp(self) - -self.main_source = "main.cpp" -self.main_source_spec = lldb.SBFileSpec(self.main_source) - -def do_test(self, dictionary=None): -"""Printing an xvalue should work.""" -self.build(dictionary=dictionary) - -(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, - '// Break here', self.main_source_spec) -frame = thread.GetFrameAtIndex(0) - -value = frame.EvaluateExpression("foo().data") -self.assertTrue(value.IsValid()) -self.assertTrue(value.GetError().Success()) -self.assertEqual(value.GetValueAsSigned(), 1234) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test(self): -self.do_test() - +"""Printing an xvalue should work.""" +self.build() +lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp")) +self.expect_expr("foo().data", result_value="1234") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] acb0b99 - [lldb][NFC] Modernize lang/cpp/scope test
Author: Raphael Isemann Date: 2020-04-06T09:36:54+02:00 New Revision: acb0b99c8e4f1dc65a7f1e26da9db77239a67da7 URL: https://github.com/llvm/llvm-project/commit/acb0b99c8e4f1dc65a7f1e26da9db77239a67da7 DIFF: https://github.com/llvm/llvm-project/commit/acb0b99c8e4f1dc65a7f1e26da9db77239a67da7.diff LOG: [lldb][NFC] Modernize lang/cpp/scope test Added: Modified: lldb/test/API/lang/cpp/scope/TestCppScope.py lldb/test/API/lang/cpp/scope/main.cpp Removed: diff --git a/lldb/test/API/lang/cpp/scope/TestCppScope.py b/lldb/test/API/lang/cpp/scope/TestCppScope.py index 213e7fbe9022..1320bd2185f8 100644 --- a/lldb/test/API/lang/cpp/scope/TestCppScope.py +++ b/lldb/test/API/lang/cpp/scope/TestCppScope.py @@ -1,91 +1,27 @@ -""" -Test scopes in C++. -""" import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - -class TestCppScopes(TestBase): +class TestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") -def test_all_but_c(self): -self.do_test(False) - -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") -def test_c(self): -self.do_test(True) - -def do_test(self, test_c): +def test(self): self.build() - -# Get main source file -src_file = os.path.join(self.getSourceDir(), "main.cpp") -src_file_spec = lldb.SBFileSpec(src_file) -self.assertTrue(src_file_spec.IsValid(), "Main source file") - -# Get the path of the executable -exe_path = self.getBuildArtifact("a.out") - -# Load the executable -target = self.dbg.CreateTarget(exe_path) -self.assertTrue(target.IsValid(), VALID_TARGET) - -# Break on main function -main_breakpoint = target.BreakpointCreateBySourceRegex( -"// break here", src_file_spec) -self.assertTrue( -main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, -VALID_BREAKPOINT) - -# Launch the process -args = None -env = None -process = target.LaunchSimple( -args, env, self.get_process_working_directory()) -self.assertTrue(process.IsValid(), PROCESS_IS_VALID) - -# Get the thread of the process -self.assertTrue( -process.GetState() == lldb.eStateStopped, -PROCESS_STOPPED) -thread = lldbutil.get_stopped_thread( -process, lldb.eStopReasonBreakpoint) - -# Get current fream of the thread at the breakpoint -frame = thread.GetSelectedFrame() - -# Test result for scopes of variables - -global_variables = frame.GetVariables(True, True, True, False) -global_variables_assert = { -'A::a': , -'B::a': , -'C::a': , -'::a': , -'a': -} - -self.assertTrue( -global_variables.GetSize() == 4, -"target variable returns all variables") -for variable in global_variables: -name = variable.GetName() -self.assertTrue( -name in global_variables_assert, -"target variable returns wrong variable " + name) - -for name in global_variables_assert: -if name is "C::a" and not test_c: -continue -if name is not "C::a" and test_c: -continue - -value = frame.EvaluateExpression(name) -assert_value = global_variables_assert[name] -self.assertTrue( -value.IsValid() and value.GetValueAsSigned() == assert_value, -name + " = " + str(assert_value)) +lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) + +# Test that global variables contain the right scope operators. +global_vars = self.frame().GetVariables(False, False, True, False) +global_var_names = [v.GetName() for v in global_vars] +expected_var_names = ["A::a", "B::a", "C::a", "::a"] +self.assertEqual(global_var_names, expected_var_names) + +# Test lookup in scopes. +self.expect_expr("A::a", result_value="") +self.expect_expr("B::a", result_value="") +self.expect_expr("C::a", result_value="") +self.expect_expr("::a", result_value="") +# Check that lookup without scope returns the same result. +self.expect_expr("a", result_value="") diff --git a/lldb/test/API/lang/cpp/scope/main.cpp b/lldb/test/API/lang/cpp/scope/main.cpp index da5d7ed529d1..20997a8dd1a7 100644 --- a/lldb/test/API/lang/cpp/scope/main.cpp +++ b/lldb/test/API/lang/cpp/scope/main.cpp @@ -1,17 +1,17 @@ class A { public: -static int a; -
[Lldb-commits] [lldb] 203a8ad - [lldb] Add option to retry Fix-Its multiple times to failed expressions
Author: Raphael Isemann Date: 2020-04-06T11:25:36+02:00 New Revision: 203a8adb65429ec6b8989afdf5956564972b9703 URL: https://github.com/llvm/llvm-project/commit/203a8adb65429ec6b8989afdf5956564972b9703 DIFF: https://github.com/llvm/llvm-project/commit/203a8adb65429ec6b8989afdf5956564972b9703.diff LOG: [lldb] Add option to retry Fix-Its multiple times to failed expressions Summary: Usually when Clang emits an error Fix-It it does two things. It emits the diagnostic and then it fixes the currently generated AST to reflect the applied Fix-It. While emitting the diagnostic is easy to implement, fixing the currently generated AST is often tricky. That causes that some Fix-Its just keep the AST as-is or abort the parsing process entirely. Once the parser stopped, any Fix-Its for the rest of the expression are not detected and when the user manually applies the Fix-It, the next expression will just produce a new Fix-It. This is often occurring with quickly made Fix-Its that are just used to bridge temporary API changes and that often are not worth implementing a proper API fixup in addition to the diagnostic. To still give some kind of reasonable user-experience for users that have these Fix-Its and rely on them to fix their expressions, this patch adds the ability to retry parsing with applied Fix-Its multiple time to give the normal Fix-It experience where things Clang knows how to fix are not causing actual expression error (at least when automatically applying Fix-Its is activated). The way this is implemented is just by having another setting in the expression options that specify how often we should try applying Fix-Its and then reparse the expression. The default setting is still 1 for everyone so this should not affect the speed in which we fail to parse expressions. Reviewers: jingham, JDevlieghere, friss, shafik Reviewed By: shafik Subscribers: shafik, abidh Differential Revision: https://reviews.llvm.org/D77214 Added: Modified: lldb/bindings/interface/SBExpressionOptions.i lldb/include/lldb/API/SBExpressionOptions.h lldb/include/lldb/Target/Target.h lldb/source/API/SBExpressionOptions.cpp lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Expression/UserExpression.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td lldb/test/API/commands/expression/fixits/TestFixIts.py Removed: diff --git a/lldb/bindings/interface/SBExpressionOptions.i b/lldb/bindings/interface/SBExpressionOptions.i index 5dbd7007c01c..33a6ed745a8d 100644 --- a/lldb/bindings/interface/SBExpressionOptions.i +++ b/lldb/bindings/interface/SBExpressionOptions.i @@ -126,6 +126,14 @@ public: bool GetAutoApplyFixIts(); +%feature("docstring", "Sets how often LLDB should retry applying fix-its to an expression.") SetRetriesWithFixIts; +void +SetRetriesWithFixIts(uint64_t retries); + +%feature("docstring", "Gets how often LLDB will retry applying fix-its to an expression.") GetRetriesWithFixIts; +uint64_t +GetRetriesWithFixIts(); + bool GetTopLevel(); diff --git a/lldb/include/lldb/API/SBExpressionOptions.h b/lldb/include/lldb/API/SBExpressionOptions.h index 14b52684ddce..9fc6e9ea957e 100644 --- a/lldb/include/lldb/API/SBExpressionOptions.h +++ b/lldb/include/lldb/API/SBExpressionOptions.h @@ -86,6 +86,10 @@ class LLDB_API SBExpressionOptions { bool GetAutoApplyFixIts(); + void SetRetriesWithFixIts(uint64_t retries); + + uint64_t GetRetriesWithFixIts(); + bool GetTopLevel(); void SetTopLevel(bool b = true); diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index f0a57b8f3827..27997e5ea76d 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -135,6 +135,8 @@ class TargetProperties : public Properties { bool GetEnableAutoApplyFixIts() const; + uint64_t GetNumberOfRetriesWithFixits() const; + bool GetEnableNotifyAboutFixIts() const; bool GetEnableSaveObjects() const; @@ -385,6 +387,12 @@ class EvaluateExpressionOptions { bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; } + void SetRetriesWithFixIts(uint64_t number_of_retries) { +m_retries_with_fixits = number_of_retries; + } + + uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; } + bool IsForUtilityExpr() const { return m_running_utility_expression; } void SetIsForUtilityExpr(bool b) { m_running_utility_expression = b; } @@ -406,6 +414,7 @@ class EvaluateExpressionOptions { bool m_ansi_color_errors = false; bool m_result_is_internal = false; bool m_auto_apply_fixits = true; + uint64_t m_retries_with_fixits = 1; /// True if the executed code should be treated as utility code that is only /// used by LLDB internally. bool m_running_utility_expression = false; diff --git
[Lldb-commits] [lldb] 3c2dc28 - [lldb] Also apply Fix-Its in "note:" diagnostics that belong to an error diagnostic
Author: Raphael Isemann Date: 2020-04-06T10:37:33+02:00 New Revision: 3c2dc28d812c917e01f46b3bcf5b5e0a2a803276 URL: https://github.com/llvm/llvm-project/commit/3c2dc28d812c917e01f46b3bcf5b5e0a2a803276 DIFF: https://github.com/llvm/llvm-project/commit/3c2dc28d812c917e01f46b3bcf5b5e0a2a803276.diff LOG: [lldb] Also apply Fix-Its in "note:" diagnostics that belong to an error diagnostic Summary: LLDB currently applies Fix-Its if they are attached to a Clang diagnostic that has the severity "error". Fix-Its connected to warnings and other severities are supposed to be ignored as LLDB doesn't seem to trust Clang Fix-Its in these situations. However, LLDB also ignores all Fix-Its coming from "note:" diagnostics. These diagnostics are usually emitted alongside other diagnostics (both warnings and errors), either to keep a single diagnostic message shorter or because the Fix-It is in a different source line. As they are technically their own (non-error) diagnostics, we currently are ignoring all Fix-Its associated with them. For example, this is a possible Clang diagnostic with a Fix-It that is currently ignored: ``` error: :2:10: too many arguments provided to function-like macro invocation ToStr(0, {,}) ^ :1:9: macro 'ToStr' defined here #define ToStr(x) #x ^ :2:1: cannot use initializer list at the beginning of a macro argument ToStr(0, {,}) ^ ``` We also don't store "note:" diagnostics at all, as LLDB's abstraction around the whole diagnostic concept doesn't have such a concept. The text of "note:" diagnostics is instead appended to the last non-note diagnostic (which is causing that there is no "note:" text in the diagnostic above, as all the "note:" diagnostics have been appended to the first "error: ..." text). This patch fixes the ignored Fix-Its in note-diagnostics by appending them to the last non-note diagnostic, similar to the way we handle the text in these diagnostics. Reviewers: JDevlieghere, jingham Reviewed By: JDevlieghere Subscribers: abidh Differential Revision: https://reviews.llvm.org/D77055 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/test/API/commands/expression/fixits/TestFixIts.py Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index e5de4b4651df..9996f2608e31 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -147,6 +147,14 @@ class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks { llvm::StringRef getErrorString() { return m_error_stream.GetString(); } }; +static void AddAllFixIts(ClangDiagnostic *diag, const clang::Diagnostic ) { + for (auto _it : Info.getFixItHints()) { +if (fix_it.isNull()) + continue; +diag->AddFixitHint(fix_it); + } +} + class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { public: ClangDiagnosticManagerAdapter(DiagnosticOptions ) { @@ -162,6 +170,17 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { m_manager = manager; } + /// Returns the last ClangDiagnostic message that the DiagnosticManager + /// received or a nullptr if the DiagnosticMangager hasn't seen any + /// Clang diagnostics yet. + ClangDiagnostic *MaybeGetLastClangDiag() const { +if (m_manager->Diagnostics().empty()) + return nullptr; +lldb_private::Diagnostic *diag = m_manager->Diagnostics().back().get(); +ClangDiagnostic *clang_diag = dyn_cast(diag); +return clang_diag; + } + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic ) override { if (!m_manager) { @@ -204,6 +223,23 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { case DiagnosticsEngine::Level::Note: m_manager->AppendMessageToDiagnostic(m_output); make_new_diagnostic = false; + + // 'note:' diagnostics for errors and warnings can also contain Fix-Its. + // We add these Fix-Its to the last error diagnostic to make sure + // that we later have all Fix-Its related to an 'error' diagnostic when + // we apply them to the user expression. + auto *clang_diag = MaybeGetLastClangDiag(); + // If we don't have a previous diagnostic there is nothing to do. + // If the previous diagnostic already has its own Fix-Its, assume that + // the 'note:' Fix-It is just an alternative way to solve the issue and + // ignore these Fix-Its. + if (!clang_diag || clang_diag->HasFixIts()) +break; + // Ignore all Fix-Its that are not associated with an error. + if (clang_diag->GetSeverity() != eDiagnosticSeverityError) +break; +
[Lldb-commits] [lldb] 9beba42 - [lldb][NFC] Modernize TestExprChar
Author: Raphael Isemann Date: 2020-04-01T13:24:21+02:00 New Revision: 9beba4245a77ae75db874146036b77fb76398e4c URL: https://github.com/llvm/llvm-project/commit/9beba4245a77ae75db874146036b77fb76398e4c DIFF: https://github.com/llvm/llvm-project/commit/9beba4245a77ae75db874146036b77fb76398e4c.diff LOG: [lldb][NFC] Modernize TestExprChar Added: Modified: lldb/test/API/commands/expression/char/TestExprsChar.py Removed: diff --git a/lldb/test/API/commands/expression/char/TestExprsChar.py b/lldb/test/API/commands/expression/char/TestExprsChar.py index f1fa78053846..a1a4568aa92e 100644 --- a/lldb/test/API/commands/expression/char/TestExprsChar.py +++ b/lldb/test/API/commands/expression/char/TestExprsChar.py @@ -1,44 +1,21 @@ - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class ExprCharTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -def setUp(self): -# Call super's setUp(). -TestBase.setUp(self) - -self.main_source = "main.cpp" -self.main_source_spec = lldb.SBFileSpec(self.main_source) - def do_test(self, dictionary=None): """These basic expression commands should work as expected.""" self.build(dictionary=dictionary) -(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, - '// Break here', self.main_source_spec) -frame = thread.GetFrameAtIndex(0) - -value = frame.EvaluateExpression("foo(c)") -self.assertTrue(value.IsValid()) -self.assertTrue(value.GetError().Success()) -self.assertEqual(value.GetValueAsSigned(0), 1) - -value = frame.EvaluateExpression("foo(sc)") -self.assertTrue(value.IsValid()) -self.assertTrue(value.GetError().Success()) -self.assertEqual(value.GetValueAsSigned(0), 2) +lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp")) -value = frame.EvaluateExpression("foo(uc)") -self.assertTrue(value.IsValid()) -self.assertTrue(value.GetError().Success()) -self.assertEqual(value.GetValueAsSigned(0), 3) +self.expect_expr("foo(c)", result_value="1") +self.expect_expr("foo(sc)", result_value="2") +self.expect_expr("foo(uc)", result_value="3") def test_default_char(self): self.do_test() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7754b65 - [lldb][NFC] lldb_assert->lldbassert in ClangExpressionParser
Author: Raphael Isemann Date: 2020-03-25T14:10:48+01:00 New Revision: 7754b652b3bf0c4b63cccf6e0d4066503684e94a URL: https://github.com/llvm/llvm-project/commit/7754b652b3bf0c4b63cccf6e0d4066503684e94a DIFF: https://github.com/llvm/llvm-project/commit/7754b652b3bf0c4b63cccf6e0d4066503684e94a.diff LOG: [lldb][NFC] lldb_assert->lldbassert in ClangExpressionParser lldbassert is the macro that takes care of passing along line/file/function to the lldb_assert function. Let's call that instead of manually calling the function. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 3faf6f238b23..698fea4c2d3c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -281,23 +281,22 @@ ClangExpressionParser::ClangExpressionParser( // We can't compile expressions without a target. So if the exe_scope is // null or doesn't have a target, then we just need to get out of here. I'll - // lldb_assert and not make any of the compiler objects since + // lldbassert and not make any of the compiler objects since // I can't return errors directly from the constructor. Further calls will // check if the compiler was made and // bag out if it wasn't. if (!exe_scope) { -lldb_assert(exe_scope, "Can't make an expression parser with a null scope.", -__FUNCTION__, __FILE__, __LINE__); +lldbassert(exe_scope && + "Can't make an expression parser with a null scope."); return; } lldb::TargetSP target_sp; target_sp = exe_scope->CalculateTarget(); if (!target_sp) { -lldb_assert(target_sp.get(), -"Can't make an expression parser with a null target.", -__FUNCTION__, __FILE__, __LINE__); +lldbassert(target_sp.get() && + "Can't make an expression parser with a null target."); return; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 14db82c - [lldb][NFC] Fix typo in TestInvalidArgsLog
Author: Raphael Isemann Date: 2020-03-28T16:16:08+01:00 New Revision: 14db82c929d981833dbd829a3e8e702556aea1d2 URL: https://github.com/llvm/llvm-project/commit/14db82c929d981833dbd829a3e8e702556aea1d2 DIFF: https://github.com/llvm/llvm-project/commit/14db82c929d981833dbd829a3e8e702556aea1d2.diff LOG: [lldb][NFC] Fix typo in TestInvalidArgsLog Added: Modified: lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py Removed: diff --git a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py index 4d3c5733598f..44ddae028ba1 100644 --- a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py +++ b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py @@ -18,5 +18,5 @@ def test_disable_empty(self): @no_debug_info_test def test_timer_empty(self): -self.expect("log timer", error=True, +self.expect("log timers", error=True, substrs=["error: Missing subcommand"]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d30e9ad - Correct the duplicate pragma marks in CommandObjectTarget.cpp
Author: Shivam Mittal Date: 2020-03-31T11:16:40+02:00 New Revision: d30e9ad34519cb0ec17d411bc103af7bb76da77e URL: https://github.com/llvm/llvm-project/commit/d30e9ad34519cb0ec17d411bc103af7bb76da77e DIFF: https://github.com/llvm/llvm-project/commit/d30e9ad34519cb0ec17d411bc103af7bb76da77e.diff LOG: Correct the duplicate pragma marks in CommandObjectTarget.cpp Summary: Resolve the two duplicated pragma marks in lldb/source/Commands/CommandObjectTarget.cpp Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D77096 Added: Modified: lldb/source/Commands/CommandObjectTarget.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 95f81fc6cd54..fb2854d90ba8 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -571,7 +571,7 @@ class CommandObjectTargetSelect : public CommandObjectParsed { } }; -#pragma mark CommandObjectTargetSelect +#pragma mark CommandObjectTargetDelete // "target delete" @@ -2198,7 +2198,7 @@ class CommandObjectTargetModulesDumpSections } }; -#pragma mark CommandObjectTargetModulesDumpSections +#pragma mark CommandObjectTargetModulesDumpClangAST // Clang AST dumping command ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 15f34ff - [lldb] Allow expect_expr without a running target
Author: Raphael Isemann Date: 2020-04-01T09:39:24+02:00 New Revision: 15f34ff2d8976f9211c6112531355ed5e2a92ea0 URL: https://github.com/llvm/llvm-project/commit/15f34ff2d8976f9211c6112531355ed5e2a92ea0 DIFF: https://github.com/llvm/llvm-project/commit/15f34ff2d8976f9211c6112531355ed5e2a92ea0.diff LOG: [lldb] Allow expect_expr without a running target Summary: If we don't have a current frame then we can still run many expressions as long as we have an active target. With this patch `expect_expr` directly calls the target's EvaluateExpression function when there is no current frame. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D77197 Added: Modified: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 966d460ea13d..5058594505f5 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2414,9 +2414,12 @@ def expect_expr( # Set the usual default options for normal expressions. options.SetIgnoreBreakpoints(True) -options.SetLanguage(frame.GuessLanguage()) -eval_result = frame.EvaluateExpression(expr, options) +if self.frame().IsValid(): + options.SetLanguage(frame.GuessLanguage()) + eval_result = self.frame().EvaluateExpression(expr, options) +else: + eval_result = self.target().EvaluateExpression(expr, options) if not eval_result.GetError().Success(): self.assertTrue(eval_result.GetError().Success(), diff --git a/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py b/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py index 31478884ad7d..55ba2717c013 100644 --- a/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py +++ b/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py @@ -17,24 +17,10 @@ class ExprCommandCallBuiltinFunction(TestBase): # Builtins are expanded by Clang, so debug info shouldn't matter. NO_DEBUG_INFO_TESTCASE = True -def setUp(self): -TestBase.setUp(self) -# Find the line number to break for main.c. -self.line = line_number( -'main.cpp', -'// Please test these expressions while stopped at this line:') - def test(self): self.build() -# Set breakpoint in main and run exe -self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) -lldbutil.run_break_set_by_file_and_line( -self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) - -self.runCmd("run", RUN_SUCCEEDED) - -# Test diff erent builtin functions. +target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.expect_expr("__builtin_isinf(0.0f)", result_type="int", result_value="0") self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", result_value="0") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 767a97b - [lldb][NFC] Cleanup Fix-It code
Author: Raphael Isemann Date: 2020-03-30T11:02:44+02:00 New Revision: 767a97b22339350d1d1368ca5548f967e49a4c00 URL: https://github.com/llvm/llvm-project/commit/767a97b22339350d1d1368ca5548f967e49a4c00 DIFF: https://github.com/llvm/llvm-project/commit/767a97b22339350d1d1368ca5548f967e49a4c00.diff LOG: [lldb][NFC] Cleanup Fix-It code Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 698fea4c2d3c..e5de4b4651df 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -219,11 +219,10 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { // FIXME: Should we try to filter out FixIts that apply to our generated // code, and not the user's expression? if (severity == eDiagnosticSeverityError) { -size_t num_fixit_hints = Info.getNumFixItHints(); -for (size_t i = 0; i < num_fixit_hints; i++) { - const clang::FixItHint = Info.getFixItHint(i); - if (!fixit.isNull()) -new_diagnostic->AddFixitHint(fixit); +for (const clang::FixItHint : Info.getFixItHints()) { + if (fixit.isNull()) +continue; + new_diagnostic->AddFixitHint(fixit); } } @@ -1071,6 +1070,28 @@ ClangExpressionParser::GetClangTargetABI(const ArchSpec _arch) { return abi; } +/// Applies the given Fix-It hint to the given commit. +static void ApplyFixIt(const FixItHint , clang::edit::Commit ) { + // This is cobbed from clang::Rewrite::FixItRewriter. + if (fixit.CodeToInsert.empty()) { +if (fixit.InsertFromRange.isValid()) { + commit.insertFromRange(fixit.RemoveRange.getBegin(), + fixit.InsertFromRange, /*afterToken=*/false, + fixit.BeforePreviousInsertions); + return; +} +commit.remove(fixit.RemoveRange); +return; + } + if (fixit.RemoveRange.isTokenRange() || + fixit.RemoveRange.getBegin() != fixit.RemoveRange.getEnd()) { +commit.replace(fixit.RemoveRange, fixit.CodeToInsert); +return; + } + commit.insert(fixit.RemoveRange.getBegin(), fixit.CodeToInsert, +/*afterToken=*/false, fixit.BeforePreviousInsertions); +} + bool ClangExpressionParser::RewriteExpression( DiagnosticManager _manager) { clang::SourceManager _manager = m_compiler->getSourceManager(); @@ -1102,26 +1123,12 @@ bool ClangExpressionParser::RewriteExpression( for (const auto : diagnostic_manager.Diagnostics()) { const auto *diagnostic = llvm::dyn_cast(diag.get()); -if (diagnostic && diagnostic->HasFixIts()) { - for (const FixItHint : diagnostic->FixIts()) { -// This is cobbed from clang::Rewrite::FixItRewriter. -if (fixit.CodeToInsert.empty()) { - if (fixit.InsertFromRange.isValid()) { -commit.insertFromRange(fixit.RemoveRange.getBegin(), - fixit.InsertFromRange, /*afterToken=*/false, - fixit.BeforePreviousInsertions); - } else -commit.remove(fixit.RemoveRange); -} else { - if (fixit.RemoveRange.isTokenRange() || - fixit.RemoveRange.getBegin() != fixit.RemoveRange.getEnd()) -commit.replace(fixit.RemoveRange, fixit.CodeToInsert); - else -commit.insert(fixit.RemoveRange.getBegin(), fixit.CodeToInsert, - /*afterToken=*/false, fixit.BeforePreviousInsertions); -} - } -} +if (!diagnostic) + continue; +if (!diagnostic->HasFixIts()) + continue; +for (const FixItHint : diagnostic->FixIts()) + ApplyFixIt(fixit, commit); } // FIXME - do we want to try to propagate specific errors here? ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 064ab22 - [lldb] Run TestFixIts on non-Darwin platforms
Author: Raphael Isemann Date: 2020-03-30T09:53:51+02:00 New Revision: 064ab22fb29be673fa2ac4ab3b28cc30f9371e9c URL: https://github.com/llvm/llvm-project/commit/064ab22fb29be673fa2ac4ab3b28cc30f9371e9c DIFF: https://github.com/llvm/llvm-project/commit/064ab22fb29be673fa2ac4ab3b28cc30f9371e9c.diff LOG: [lldb] Run TestFixIts on non-Darwin platforms This test also passes on my Linux machine, so this seems too strict. Added: Modified: lldb/test/API/commands/expression/fixits/TestFixIts.py Removed: diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py index 1e8e7dda68c0..273982c0c12f 100644 --- a/lldb/test/API/commands/expression/fixits/TestFixIts.py +++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py @@ -23,7 +23,6 @@ def test_with_dummy_target(self): self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The expression was successful.") self.assertTrue("Fix-it applied" in ret_val.GetError(), "Found the applied FixIt.") -@skipUnlessDarwin def test_with_target(self): """Test calling expressions with errors that can be fixed by the FixIts.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 83c81c0 - [lldb] Make Fix-Its also apply to top-level expressions
Author: Raphael Isemann Date: 2020-03-30T11:50:57+02:00 New Revision: 83c81c0a469482888482983c302c09c02680ae7c URL: https://github.com/llvm/llvm-project/commit/83c81c0a469482888482983c302c09c02680ae7c DIFF: https://github.com/llvm/llvm-project/commit/83c81c0a469482888482983c302c09c02680ae7c.diff LOG: [lldb] Make Fix-Its also apply to top-level expressions Summary: Currently top-level expressions won't automatically get Fix-Its applied. The reason for that is that we only set the `m_fixed_text` member if we have a wrapping source code (I.e. `m_source_code` is not zero and is wrapping some expressions). This patch just always sets `m_fixed_text` to get this working. Reviewers: labath, jingham Reviewed By: labath Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D77042 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/test/API/commands/expression/fixits/TestFixIts.py Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index b246fc374d1c..2b75c4f75c63 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -616,15 +616,14 @@ bool ClangUserExpression::Parse(DiagnosticManager _manager, if (parser.RewriteExpression(diagnostic_manager)) { size_t fixed_start; size_t fixed_end; -const std::string _expression = -diagnostic_manager.GetFixedExpression(); +m_fixed_text = diagnostic_manager.GetFixedExpression(); // Retrieve the original expression in case we don't have a top level // expression (which has no surrounding source code). if (m_source_code && -m_source_code->GetOriginalBodyBounds(fixed_expression, m_expr_lang, +m_source_code->GetOriginalBodyBounds(m_fixed_text, m_expr_lang, fixed_start, fixed_end)) m_fixed_text = - fixed_expression.substr(fixed_start, fixed_end - fixed_start); + m_fixed_text.substr(fixed_start, fixed_end - fixed_start); } } return false; diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py index 273982c0c12f..eb1dd97aa9a9 100644 --- a/lldb/test/API/commands/expression/fixits/TestFixIts.py +++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py @@ -33,6 +33,10 @@ def test_with_target(self): options = lldb.SBExpressionOptions() options.SetAutoApplyFixIts(True) +top_level_options = lldb.SBExpressionOptions() +top_level_options.SetAutoApplyFixIts(True) +top_level_options.SetTopLevel(True) + frame = self.thread.GetFrameAtIndex(0) # Try with one error: @@ -41,6 +45,15 @@ def test_with_target(self): self.assertTrue(value.GetError().Success()) self.assertEquals(value.GetValueAsUnsigned(), 10) +# Try with one error in a top-level expression. +# The Fix-It changes "ptr.m" to "ptr->m". +expr = "struct X { int m; }; X x; X *ptr = int m = ptr.m;" +value = frame.EvaluateExpression(expr, top_level_options) +# A successfully parsed top-level expression will yield an error +# that there is 'no value'. If a parsing error would have happened we +# would get a diff erent error kind, so let's check the error kind here. +self.assertEquals(value.GetError().GetCString(), "error: No value") + # Try with two errors: two_error_expression = "my_pointer.second->a" value = frame.EvaluateExpression(two_error_expression, options) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 53e7c8f - [lldb][NFC] Cleanup TestFixIts.py
Author: Raphael Isemann Date: 2020-03-30T09:40:03+02:00 New Revision: 53e7c8fdfaaa1172f7658aa5bb61a3282fb09a84 URL: https://github.com/llvm/llvm-project/commit/53e7c8fdfaaa1172f7658aa5bb61a3282fb09a84 DIFF: https://github.com/llvm/llvm-project/commit/53e7c8fdfaaa1172f7658aa5bb61a3282fb09a84.diff LOG: [lldb][NFC] Cleanup TestFixIts.py Added: Modified: lldb/test/API/commands/expression/fixits/TestFixIts.py Removed: diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py index 7aca1c5aa863..1e8e7dda68c0 100644 --- a/lldb/test/API/commands/expression/fixits/TestFixIts.py +++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py @@ -2,8 +2,6 @@ Test calling an expression with errors that a FixIt can fix. """ - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -14,19 +12,6 @@ class ExprCommandWithFixits(TestBase): mydir = TestBase.compute_mydir(__file__) -def setUp(self): -# Call super's setUp(). -TestBase.setUp(self) - -self.main_source = "main.cpp" -self.main_source_spec = lldb.SBFileSpec(self.main_source) - -@skipUnlessDarwin -def test_with_target(self): -"""Test calling expressions with errors that can be fixed by the FixIts.""" -self.build() -self.try_expressions() - def test_with_dummy_target(self): """Test calling expressions in the dummy target with errors that can be fixed by the FixIts.""" @@ -38,10 +23,13 @@ def test_with_dummy_target(self): self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The expression was successful.") self.assertTrue("Fix-it applied" in ret_val.GetError(), "Found the applied FixIt.") -def try_expressions(self): +@skipUnlessDarwin +def test_with_target(self): """Test calling expressions with errors that can be fixed by the FixIts.""" +self.build() (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self, -'Stop here to evaluate expressions', self.main_source_spec) +'Stop here to evaluate expressions', + lldb.SBFileSpec("main.cpp")) options = lldb.SBExpressionOptions() options.SetAutoApplyFixIts(True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 502a06f - [lldb] Make TestExprDiagnostics.py pass again after enabling Fix-Its in test
Author: Raphael Isemann Date: 2020-03-30T13:52:09+02:00 New Revision: 502a06fcdafa637a9890da16c2734bc1a36010f6 URL: https://github.com/llvm/llvm-project/commit/502a06fcdafa637a9890da16c2734bc1a36010f6 DIFF: https://github.com/llvm/llvm-project/commit/502a06fcdafa637a9890da16c2734bc1a36010f6.diff LOG: [lldb] Make TestExprDiagnostics.py pass again after enabling Fix-Its in test Commit 83c81c0a469482888482983c302c09c02680ae7c enabled Fix-Its for top-level expressions which change the error message of this test here as Clang comes up with a strange Fix-It for this expression. This patch just changes the test to declare a void variable so that Clang doesn't see a way to recover with a Fix-It and change the error message. Added: Modified: lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py Removed: diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py index da29d7b2c1af..b5eb552badb5 100644 --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -60,10 +60,10 @@ def test_source_and_caret_printing(self): self.assertIn(":1:10", value.GetError().GetCString()) # Multiline top-level expressions. -value = frame.EvaluateExpression("void x() {}\nvoid foo(unknown_type x) {}", top_level_opts) +value = frame.EvaluateExpression("void x() {}\nvoid foo;", top_level_opts) self.assertFalse(value.GetError().Success()) -self.assertIn("\nvoid foo(unknown_type x) {}\n ^\n", value.GetError().GetCString()) -self.assertIn(":2:10", value.GetError().GetCString()) +self.assertIn("\nvoid foo;\n ^", value.GetError().GetCString()) +self.assertIn(":2:6", value.GetError().GetCString()) # Test that we render Clang's 'notes' correctly. value = frame.EvaluateExpression("struct SFoo{}; struct SFoo { int x; };", top_level_opts) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 11a5cae - [lldb][NFC] Refactor Fix-It filter for warnings
Author: Raphael Isemann Date: 2020-03-30T14:01:16+02:00 New Revision: 11a5caee2aeae2546213366e7fc54095bb8163b9 URL: https://github.com/llvm/llvm-project/commit/11a5caee2aeae2546213366e7fc54095bb8163b9 DIFF: https://github.com/llvm/llvm-project/commit/11a5caee2aeae2546213366e7fc54095bb8163b9.diff LOG: [lldb][NFC] Refactor Fix-It filter for warnings LLDB only automatically applies Fix-Its from errors, but not from warnings. Currently we only store Fix-Its from errors and then later apply all Fix-Its we stored. This moves the filter to the application phase, so that we now store *all* Fix-Its but only apply Fix-Its from errors later on. This is NFC preparation for an upcoming patch. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index e5de4b4651df..b3880ce03b08 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -214,16 +214,12 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { auto new_diagnostic = std::make_unique( stripped_output, severity, Info.getID()); - // Don't store away warning fixits, since the compiler doesn't have - // enough context in an expression for the warning to be useful. // FIXME: Should we try to filter out FixIts that apply to our generated // code, and not the user's expression? - if (severity == eDiagnosticSeverityError) { -for (const clang::FixItHint : Info.getFixItHints()) { - if (fixit.isNull()) -continue; - new_diagnostic->AddFixitHint(fixit); -} + for (const clang::FixItHint : Info.getFixItHints()) { +if (fixit.isNull()) + continue; +new_diagnostic->AddFixitHint(fixit); } m_manager->AddDiagnostic(std::move(new_diagnostic)); @@ -1127,6 +1123,10 @@ bool ClangExpressionParser::RewriteExpression( continue; if (!diagnostic->HasFixIts()) continue; +// Don't apply warning Fix-Its, since the compiler doesn't have enough +// context in an expression for the warning to be useful. +if (diagnostic->GetSeverity() != eDiagnosticSeverityError) + continue; for (const FixItHint : diagnostic->FixIts()) ApplyFixIt(fixit, commit); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 51b3874 - Convert for loops to entry-based iteration
Author: Shivam Mittal Date: 2020-04-02T18:56:29+02:00 New Revision: 51b38746295fc18664f766fe6cb7974b862c28eb URL: https://github.com/llvm/llvm-project/commit/51b38746295fc18664f766fe6cb7974b862c28eb DIFF: https://github.com/llvm/llvm-project/commit/51b38746295fc18664f766fe6cb7974b862c28eb.diff LOG: Convert for loops to entry-based iteration Summary: Convert index-based loops marked TODO in CommandObjectSettings and CommandObjectTarget to entry-based. Reviewers: labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76729 Added: Modified: lldb/source/Commands/CommandObjectSettings.cpp lldb/source/Commands/CommandObjectTarget.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index cc1080c8cc0c..87e0352636e1 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -531,10 +531,8 @@ class CommandObjectSettingsList : public CommandObjectParsed { if (argc > 0) { const bool dump_qualified_name = true; - // TODO: Convert to StringRef based enumeration. Requires converting - // GetPropertyAtPath first. - for (size_t i = 0; i < argc; ++i) { -const char *property_path = args.GetArgumentAtIndex(i); + for (const Args::ArgEntry : args) { +const char *property_path = arg.c_str(); const Property *property = GetDebugger().GetValueProperties()->GetPropertyAtPath( diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index fb2854d90ba8..decdd9c53de2 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -876,21 +876,18 @@ class CommandObjectTargetVariable : public CommandObjectParsed { Stream = result.GetOutputStream(); if (argc > 0) { - - // TODO: Convert to entry-based iteration. Requires converting - // DumpValueObject. - for (size_t idx = 0; idx < argc; ++idx) { + for (const Args::ArgEntry : args) { VariableList variable_list; ValueObjectList valobj_list; -const char *arg = args.GetArgumentAtIndex(idx); size_t matches = 0; bool use_var_name = false; if (m_option_variable.use_regex) { - RegularExpression regex(llvm::StringRef::withNullAsEmpty(arg)); + RegularExpression regex( + llvm::StringRef::withNullAsEmpty(arg.c_str())); if (!regex.IsValid()) { result.GetErrorStream().Printf( -"error: invalid regular expression: '%s'\n", arg); +"error: invalid regular expression: '%s'\n", arg.c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -900,14 +897,14 @@ class CommandObjectTargetVariable : public CommandObjectParsed { matches = variable_list.GetSize(); } else { Status error(Variable::GetValuesForVariableExpressionPath( - arg, m_exe_ctx.GetBestExecutionContextScope(), + arg.c_str(), m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, target, variable_list, valobj_list)); matches = variable_list.GetSize(); } if (matches == 0) { result.GetErrorStream().Printf( - "error: can't find global variable '%s'\n", arg); + "error: can't find global variable '%s'\n", arg.c_str()); result.SetStatus(eReturnStatusFailed); return false; } else { @@ -923,7 +920,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed { if (valobj_sp) DumpValueObject(s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() - : arg); + : arg.c_str()); } } } @@ -3058,17 +3055,14 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { module_list_ptr = >GetImages(); } } else { -// TODO: Convert to entry based iteration. Requires converting -// FindModulesByName. -for (size_t i = 0; i < argc; ++i) { +for (const Args::ArgEntry : command) { // Dump specified images (by basename or fullpath) - const char *arg_cstr = command.GetArgumentAtIndex(i); const size_t num_matches = FindModulesByName( - target, arg_cstr, module_list, use_global_module_list); + target, arg.c_str(), module_list, use_global_module_list); if (num_matches == 0) { if (argc == 1) { result.AppendErrorWithFormat("no modules found that
[Lldb-commits] [lldb] daed98e - Convert CommandObjectCommands functions to return StringRefs
Author: Shivam Mittal Date: 2020-03-26T11:20:38+01:00 New Revision: daed98e5b5d1b4a2ab29b3f757b53519ed070439 URL: https://github.com/llvm/llvm-project/commit/daed98e5b5d1b4a2ab29b3f757b53519ed070439 DIFF: https://github.com/llvm/llvm-project/commit/daed98e5b5d1b4a2ab29b3f757b53519ed070439.diff LOG: Convert CommandObjectCommands functions to return StringRefs Reviewers: jingham, aprantl, labath, jankratochvil Reviewed By: labath, jankratochvil Subscribers: labath, jankratochvil, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76569 Added: Modified: lldb/source/Commands/CommandObjectCommands.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index cf5125dc9306..b12377d71512 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -527,14 +527,13 @@ rather than using a positional placeholder:" m_option_group.NotifyOptionParsingStarting(_ctx); OptionsWithRaw args_with_suffix(raw_command_line); -const char *remainder = args_with_suffix.GetRawPart().c_str(); if (args_with_suffix.HasArgs()) if (!ParseOptionsAndNotify(args_with_suffix.GetArgs(), result, m_option_group, exe_ctx)) return false; -llvm::StringRef raw_command_string(remainder); +llvm::StringRef raw_command_string = args_with_suffix.GetRawPart(); Args args(raw_command_string); if (args.GetArgumentCount() < 2) { @@ -1171,14 +1170,9 @@ a number follows 'f':" return llvm::makeArrayRef(g_regex_options); } -// TODO: Convert these functions to return StringRefs. -const char *GetHelp() { - return (m_help.empty() ? nullptr : m_help.c_str()); -} +llvm::StringRef GetHelp() { return m_help; } -const char *GetSyntax() { - return (m_syntax.empty() ? nullptr : m_syntax.c_str()); -} +llvm::StringRef GetSyntax() { return m_syntax; } protected: // Instance variables to hold the values for command options. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b58af8d - [lldb] Improve error message when --func-regex parameter for the breakpoint command is invalid
Author: Raphael Isemann Date: 2020-04-27T09:55:06+02:00 New Revision: b58af8d254ee1b1a7d2806b1fdfe295df925748a URL: https://github.com/llvm/llvm-project/commit/b58af8d254ee1b1a7d2806b1fdfe295df925748a DIFF: https://github.com/llvm/llvm-project/commit/b58af8d254ee1b1a7d2806b1fdfe295df925748a.diff LOG: [lldb] Improve error message when --func-regex parameter for the breakpoint command is invalid Summary: Currently the breakpoint command is prompting the user to file a bug report if the provided regex is invalid: ``` (lldb) rbreak *foo error: Function name regular expression could not be compiled: "Inconvertible error value. An error has occurred that could not be converted to a known std::error_code. Please file a bug. repetition-operator operand invalid" ``` The reason is simply that we are using the wrong StringError constructor (the one with the error code as the first parameter is also printing the string version of the error code, and the inconvertible error code is just an invalid place holder code with that description). Switching the StringError constructor parameters will only print the error message we get from the regex engine when we convert the error into a string. I checked the rest of the code base and I couldn't find the same issue anywhere else. Fixes rdar://62233561 Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D78808 Added: lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py Modified: lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Utility/RegularExpression.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 3c5d8f087a27..661ebc790354 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -620,7 +620,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { RegularExpression regexp(m_options.m_func_regexp); if (llvm::Error err = regexp.GetError()) { result.AppendErrorWithFormat( -"Function name regular expression could not be compiled: \"%s\"", +"Function name regular expression could not be compiled: %s", llvm::toString(std::move(err)).c_str()); result.SetStatus(eReturnStatusFailed); return false; diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp index 3736a25ef2ac..20bebbfe15f2 100644 --- a/lldb/source/Utility/RegularExpression.cpp +++ b/lldb/source/Utility/RegularExpression.cpp @@ -35,7 +35,7 @@ llvm::StringRef RegularExpression::GetText() const { return m_regex_text; } llvm::Error RegularExpression::GetError() const { std::string error; if (!m_regex.isValid(error)) -return llvm::make_error(llvm::inconvertibleErrorCode(), - error); +return llvm::make_error(error, + llvm::inconvertibleErrorCode()); return llvm::Error::success(); } diff --git a/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py new file mode 100644 index ..a8cfcf2d1d87 --- /dev/null +++ b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py @@ -0,0 +1,14 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test +def test_error(self): +self.expect("breakpoint set --func-regex (", error=True, +substrs=["error: Function name regular expression could " + + "not be compiled: parentheses not balanced"]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d00eaa0 - [lldb] Adjust TestExec code to be closer to real world code
Author: Raphael Isemann Date: 2020-04-27T14:57:12+02:00 New Revision: d00eaa082b7cd6ada106ed01751abce65abd6dd8 URL: https://github.com/llvm/llvm-project/commit/d00eaa082b7cd6ada106ed01751abce65abd6dd8 DIFF: https://github.com/llvm/llvm-project/commit/d00eaa082b7cd6ada106ed01751abce65abd6dd8.diff LOG: [lldb] Adjust TestExec code to be closer to real world code Summary: For some reason the TestExec test on the macOS bots randomly fails with this error: ``` output: * thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x108e66000) * frame #0: 0x000108e66000 [...] File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 25, in test_hitting_exec self.do_test(False) File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 113, in do_test "Stopped at breakpoint in exec'ed process.") AssertionError: False is not True : Stopped at breakpoint in exec'ed process. Config=x86_64-/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-11 ``` I don't know why the test program is failing and I couldn't reproduce this problem on my own. This patch is a stab in the dark that just tries to make the test code more similar to code which we would expect in a user program to make whatever part of macOS happy that is currently not liking our code. The actual changes are: * We pass in argv[0] that is describing otherprog path instead of the current argv[0]. * We pass in a non-null envp (which anyway doesn't seem to be allowed on macOS man page). Reviewers: labath, JDevlieghere Reviewed By: labath Subscribers: abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D75241 Added: Modified: lldb/test/API/functionalities/exec/main.cpp Removed: diff --git a/lldb/test/API/functionalities/exec/main.cpp b/lldb/test/API/functionalities/exec/main.cpp index bec470fd13ef..51c67d5f232d 100644 --- a/lldb/test/API/functionalities/exec/main.cpp +++ b/lldb/test/API/functionalities/exec/main.cpp @@ -12,7 +12,8 @@ int main(int argc, char const **argv) { std::string directory_name(::dirname(buf)); std::string other_program = directory_name + "/secondprog"; - execve(other_program.c_str(), const_cast(argv), nullptr); + argv[0] = other_program.c_str(); + execv(argv[0], const_cast(argv)); perror("execve"); abort(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ff5264f - [lldb][cmake] Move the remove_module_flags call to the right place in debugserver's CMakeLists
Author: Raphael Isemann Date: 2020-04-27T16:04:19+02:00 New Revision: ff5264f0c6f026b25e2d91d0f5d5377a156c1f40 URL: https://github.com/llvm/llvm-project/commit/ff5264f0c6f026b25e2d91d0f5d5377a156c1f40 DIFF: https://github.com/llvm/llvm-project/commit/ff5264f0c6f026b25e2d91d0f5d5377a156c1f40.diff LOG: [lldb][cmake] Move the remove_module_flags call to the right place in debugserver's CMakeLists This code should always be executed, not just when building the debugserver on its own. Fixes the modules build when building LLVM+LLDB together. Added: Modified: lldb/tools/debugserver/CMakeLists.txt Removed: diff --git a/lldb/tools/debugserver/CMakeLists.txt b/lldb/tools/debugserver/CMakeLists.txt index 8bd0ecc7d1ff..fc23cf3c7e20 100644 --- a/lldb/tools/debugserver/CMakeLists.txt +++ b/lldb/tools/debugserver/CMakeLists.txt @@ -13,13 +13,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) include(debugserverConfig) include(AddLLDB) - # debugserver contains ObjC++ code, so let's disable Clang modules - # in this subdirectory to avoid building ObjC++ modules (which often - # doesn't properly work). - remove_module_flags() - set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../") include_directories(${LLDB_SOURCE_DIR}/include) endif() +# debugserver contains ObjC++ code, so let's disable Clang modules +# in this subdirectory to avoid building ObjC++ modules (which often +# doesn't properly work). +remove_module_flags() + add_subdirectory(source) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a53874b - [lldb] Fix modules build by adding missing include
Author: Raphael Isemann Date: 2020-04-22T09:14:09+02:00 New Revision: a53874b7e4c82416b8eb48bbd45b5cb93f1e09d3 URL: https://github.com/llvm/llvm-project/commit/a53874b7e4c82416b8eb48bbd45b5cb93f1e09d3 DIFF: https://github.com/llvm/llvm-project/commit/a53874b7e4c82416b8eb48bbd45b5cb93f1e09d3.diff LOG: [lldb] Fix modules build by adding missing include This header is using FileSpec so we should at least include the forward header. Added: Modified: lldb/include/lldb/Utility/XcodeSDK.h Removed: diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h index b186ab4a7091..552c51c36844 100644 --- a/lldb/include/lldb/Utility/XcodeSDK.h +++ b/lldb/include/lldb/Utility/XcodeSDK.h @@ -9,6 +9,7 @@ #ifndef LLDB_UTILITY_SDK_H #define LLDB_UTILITY_SDK_H +#include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/VersionTuple.h" #include ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e327ea4 - [lldb] Fix typo in breakpoint set -r description
Author: Raphael Isemann Date: 2020-04-23T12:06:27+02:00 New Revision: e327ea4a82874f535b6ea93e39ea58643aef88bd URL: https://github.com/llvm/llvm-project/commit/e327ea4a82874f535b6ea93e39ea58643aef88bd DIFF: https://github.com/llvm/llvm-project/commit/e327ea4a82874f535b6ea93e39ea58643aef88bd.diff LOG: [lldb] Fix typo in breakpoint set -r description Added: Modified: lldb/source/Commands/Options.td Removed: diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index b0cf97e067cc..05c7b3213e2a 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -157,7 +157,7 @@ let Command = "breakpoint set" in { "multiple times tomake one breakpoint for multiple methods.">; def breakpoint_set_func_regex : Option<"func-regex", "r">, Group<7>, Arg<"RegularExpression">, Required, Desc<"Set the breakpoint by function " -"name, evaluating a regular-expression to findthe function name(s).">; +"name, evaluating a regular-expression to find the function name(s).">; def breakpoint_set_basename : Option<"basename", "b">, Group<8>, Arg<"FunctionName">, Required, Completion<"Symbol">, Desc<"Set the breakpoint by function basename (C++ namespaces and arguments" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c2fec2f - [lldb] Make RNBSocketTest compile again after socket modernization
Author: Raphael Isemann Date: 2020-04-23T17:00:02+02:00 New Revision: c2fec2fb17787c14e7860a57ef4f03e085cd3a7b URL: https://github.com/llvm/llvm-project/commit/c2fec2fb17787c14e7860a57ef4f03e085cd3a7b DIFF: https://github.com/llvm/llvm-project/commit/c2fec2fb17787c14e7860a57ef4f03e085cd3a7b.diff LOG: [lldb] Make RNBSocketTest compile again after socket modernization Commit c9e6b7010c6998b6 changed the API but didn't update this macOS-specific test. Added: Modified: lldb/unittests/debugserver/CMakeLists.txt lldb/unittests/debugserver/RNBSocketTest.cpp Removed: diff --git a/lldb/unittests/debugserver/CMakeLists.txt b/lldb/unittests/debugserver/CMakeLists.txt index 66c4c639fc89..c216eecd7d8a 100644 --- a/lldb/unittests/debugserver/CMakeLists.txt +++ b/lldb/unittests/debugserver/CMakeLists.txt @@ -15,6 +15,7 @@ add_lldb_unittest(debugserverTests LINK_LIBS lldbDebugserverCommon lldbHost +LLVMTestingSupport LINK_COMPONENTS Support ) diff --git a/lldb/unittests/debugserver/RNBSocketTest.cpp b/lldb/unittests/debugserver/RNBSocketTest.cpp index b5a6896f3ba1..7840c48f82b4 100644 --- a/lldb/unittests/debugserver/RNBSocketTest.cpp +++ b/lldb/unittests/debugserver/RNBSocketTest.cpp @@ -17,6 +17,7 @@ #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" #include "lldb/Host/common/TCPSocket.h" +#include "llvm/Testing/Support/Error.h" using namespace lldb_private; @@ -26,15 +27,16 @@ std::string goodbye = "Goodbye!"; static void ServerCallbackv4(const void *baton, in_port_t port) { auto child_pid = fork(); if (child_pid == 0) { -Socket *client_socket; char addr_buffer[256]; sprintf(addr_buffer, "%s:%d", baton, port); -Status err = Socket::TcpConnect(addr_buffer, false, client_socket); -if (err.Fail()) - abort(); +llvm::Expected> socket_or_err = +Socket::TcpConnect(addr_buffer, false); +ASSERT_THAT_EXPECTED(socket_or_err, llvm::Succeeded()); +Socket *client_socket = socket_or_err->get(); + char buffer[32]; size_t read_size = 32; -err = client_socket->Read((void *)[0], read_size); +Status err = client_socket->Read((void *)[0], read_size); if (err.Fail()) abort(); std::string Recv([0], read_size); @@ -102,9 +104,10 @@ void TestSocketConnect(const char *addr) { Socket *server_socket; Predicate port_predicate; port_predicate.SetValue(0, eBroadcastNever); - Status err = - Socket::TcpListen(addr_wrap, false, server_socket, _predicate); - ASSERT_FALSE(err.Fail()); + llvm::Expected> socket_or_err = + Socket::TcpListen(addr_wrap, false, _predicate); + ASSERT_THAT_EXPECTED(socket_or_err, llvm::Succeeded()); + server_socket = socket_or_err->get(); auto port = ((TCPSocket *)server_socket)->GetLocalPortNumber(); auto child_pid = fork(); @@ -120,7 +123,7 @@ void TestSocketConnect(const char *addr) { ASSERT_EQ(bye, goodbye); } else { Socket *connected_socket; -err = server_socket->Accept(connected_socket); +Status err = server_socket->Accept(connected_socket); if (err.Fail()) { llvm::errs() << err.AsCString(); abort(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8e9fb84 - [lldb] Also set owning module for template specializations
Author: Raphael Isemann Date: 2020-04-30T20:40:13+02:00 New Revision: 8e9fb845fcc42648ffa8c0c5f331f9f2f298bc89 URL: https://github.com/llvm/llvm-project/commit/8e9fb845fcc42648ffa8c0c5f331f9f2f298bc89 DIFF: https://github.com/llvm/llvm-project/commit/8e9fb845fcc42648ffa8c0c5f331f9f2f298bc89.diff LOG: [lldb] Also set owning module for template specializations Summary: This was originally commented out as it broke the data-formatter-stl/libcxx/ tests. However this was fixed by commit ef423a3ba57045f80b0fcafce72121449a8b54d4 (Add Objective-C property accessors loaded from Clang module DWARF to lookup) which sets the HasExternalVisibleStorage flag for the template specializations. Reviewers: aprantl Reviewed By: aprantl Subscribers: abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D79168 Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 7acdad2924fb..de1ce9d36b04 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1563,15 +1563,7 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl( ast.getTypeDeclType(class_template_specialization_decl, nullptr); class_template_specialization_decl->setDeclName( class_template_decl->getDeclName()); - // FIXME: Turning this on breaks the libcxx data formatter tests. - // SetOwningModule marks the Decl as external, which prevents a - // LookupPtr from being built. Template instantiations can also not - // be found by ExternalASTSource::FindExternalVisibleDeclsByName(), - // nor can we lazily build a LookupPtr later, because template - // specializations are supposed to be hidden so - // makeDeclVisibleInContextWithFlags() is a noop, as well. - // - // SetOwningModule(class_template_specialization_decl, owning_module); + SetOwningModule(class_template_specialization_decl, owning_module); decl_ctx->addDecl(class_template_specialization_decl); class_template_specialization_decl->setSpecializationKind( diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm index b83797f503cd..f675c3aa8204 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -52,10 +52,10 @@ @implementation SomeClass { // Template specializations are not yet supported, so they lack the ownership info: Template t2; -// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} struct Template +// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct Template Namespace::InNamespace t3; -// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} struct InNamespace +// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct InNamespace Namespace::AlsoInNamespace t4; -// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} struct AlsoInNamespace +// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A.B struct AlsoInNamespace ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b3180d6 - [lldb] Re-add deleted RUN line in module-ownership.mm
Author: Raphael Isemann Date: 2020-04-30T19:29:50+02:00 New Revision: b3180d6a1ad24e890dfe7d97407edc1b3e74b755 URL: https://github.com/llvm/llvm-project/commit/b3180d6a1ad24e890dfe7d97407edc1b3e74b755 DIFF: https://github.com/llvm/llvm-project/commit/b3180d6a1ad24e890dfe7d97407edc1b3e74b755.diff LOG: [lldb] Re-add deleted RUN line in module-ownership.mm This was deleted in 681466f5e6412350a0b066791450e72325c2c074 by accident. Added: Modified: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm index f6522e1a808c..b83797f503cd 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -1,6 +1,7 @@ // RUN: %clang --target=x86_64-apple-macosx -g -gmodules \ // RUN:-fmodules -fmodules-cache-path=%t.cache \ // RUN:-c -o %t.o %s -I%S/Inputs +// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck %s // Verify that the owning module information from DWARF is preserved in the AST. @import A; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0e50b9a - Complete breakpoint enable/disable/delete/modify with a list of breakpoint IDs
Author: Gongyu Deng Date: 2020-05-11T15:21:51+02:00 New Revision: 0e50b9a43bf65714cc6669203aeb1c175878a7da URL: https://github.com/llvm/llvm-project/commit/0e50b9a43bf65714cc6669203aeb1c175878a7da DIFF: https://github.com/llvm/llvm-project/commit/0e50b9a43bf65714cc6669203aeb1c175878a7da.diff LOG: Complete breakpoint enable/disable/delete/modify with a list of breakpoint IDs Summary: 1. A new common completion `CommandCompletions::Breakpoints` to provide a list of the breakpoints of the current context; 2. Apply the completion above to the commands breakpoint enable/disable/delete/modify; 3. Unit test. Reviewers: teemperor, JDevlieghere Reviewed By: teemperor Tags: #lldb Differential Revision: https://reviews.llvm.org/D79666 Added: Modified: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index a6e025e72baf..dc2bf841620d 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -35,10 +35,11 @@ class CommandCompletions { eArchitectureCompletion = (1u << 7), eVariablePathCompletion = (1u << 8), eRegisterCompletion = (1u << 9), +eBreakpointCompletion = (1u << 10), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 10) +eCustomCompletion = (1u << 11) }; static bool InvokeCommonCompletionCallbacks( @@ -85,6 +86,9 @@ class CommandCompletions { static void Registers(CommandInterpreter , CompletionRequest , SearchFilter *searcher); + + static void Breakpoints(CommandInterpreter , + CompletionRequest , SearchFilter *searcher); }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 1e903157c511..d4e4f6a5ebb5 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -57,6 +57,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, {eVariablePathCompletion, CommandCompletions::VariablePath}, {eRegisterCompletion, CommandCompletions::Registers}, + {eBreakpointCompletion, CommandCompletions::Breakpoints}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -549,4 +550,35 @@ void CommandCompletions::Registers(CommandInterpreter , request.TryCompleteCurrentArg(reg_prefix + reg_info->name, reg_info->alt_name); } -} \ No newline at end of file +} + +void CommandCompletions::Breakpoints(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher) { + lldb::TargetSP target = interpreter.GetDebugger().GetSelectedTarget(); + if (!target) +return; + + const BreakpointList = target->GetBreakpointList(); + + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + + size_t num_breakpoints = breakpoints.GetSize(); + if (num_breakpoints == 0) +return; + + for (size_t i = 0; i < num_breakpoints; ++i) { +lldb::BreakpointSP bp = breakpoints.GetBreakpointAtIndex(i); + +StreamString s; +bp->GetDescription(, lldb::eDescriptionLevelBrief); +llvm::StringRef bp_info = s.GetString(); + +const size_t colon_pos = bp_info.find_first_of(':'); +if (colon_pos != llvm::StringRef::npos) + bp_info = bp_info.drop_front(colon_pos + 2); + +request.TryCompleteCurrentArg(std::to_string(bp->GetID()), bp_info); + } +} diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index e62a1154797e..11cded687913 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -819,6 +819,14 @@ class CommandObjectBreakpointModify : public CommandObjectParsed { ~CommandObjectBreakpointModify() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion, +request, nullptr); + } + Options *GetOptions() override { return _options; } protected: @@ -885,6 +893,14 @@ class
[Lldb-commits] [lldb] 710fa2c - [lldb] Make module-ownership.mm test more robust against AST node ordering
Author: Raphael Isemann Date: 2020-05-08T13:44:13+02:00 New Revision: 710fa2c4ee346e1ec2db66ac5fdf6909e79d9a8c URL: https://github.com/llvm/llvm-project/commit/710fa2c4ee346e1ec2db66ac5fdf6909e79d9a8c DIFF: https://github.com/llvm/llvm-project/commit/710fa2c4ee346e1ec2db66ac5fdf6909e79d9a8c.diff LOG: [lldb] Make module-ownership.mm test more robust against AST node ordering The current test is checking both the anonymous structs and the template specializations in one FileCheck run, but the anonymous struct line can partially match the AST dump of a template specialization, causing that FileCheck won't match that same line later against the template specialization check and incorrectly fails on that check. This only happens when the template specialization node somehow ends up before the anonymous struct node. This patch just puts the checks for the anonymous structs in their own FileCheck run to prevent them from partially matching any other record decl. Fixes rdar://62997926 Added: Modified: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm index f675c3aa8204..72f2c8865f97 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -1,6 +1,8 @@ // RUN: %clang --target=x86_64-apple-macosx -g -gmodules \ // RUN:-fmodules -fmodules-cache-path=%t.cache \ // RUN:-c -o %t.o %s -I%S/Inputs +// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck --check-prefix CHECK-ANON-S1 %s +// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck --check-prefix CHECK-ANON-S2 %s // RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck %s // Verify that the owning module information from DWARF is preserved in the AST. @@ -20,11 +22,11 @@ // CHECK-TOPLEVELSTRUCT: -FieldDecl {{.*}} in A a 'int' Struct s2; -// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct +// CHECK-ANON-S1: CXXRecordDecl {{.*}} imported in A struct StructB s3; -// CHECK-DAG: CXXRecordDecl {{.*}} imported in A.B struct -// CHECK-DAG: -FieldDecl {{.*}} in A.B b 'int' +// CHECK-ANON-S2: CXXRecordDecl {{.*}} imported in A.B struct +// CHECK-ANON-S2: -FieldDecl {{.*}} in A.B b 'int' Nested s4; // CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct Nested ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7283ec0 - [lldb] Fix RecordDecl match string in module-ownership.mm to get the test running again
Author: Raphael Isemann Date: 2020-05-08T15:05:19+02:00 New Revision: 7283ec017049862423934187e35d69123774bbdc URL: https://github.com/llvm/llvm-project/commit/7283ec017049862423934187e35d69123774bbdc DIFF: https://github.com/llvm/llvm-project/commit/7283ec017049862423934187e35d69123774bbdc.diff LOG: [lldb] Fix RecordDecl match string in module-ownership.mm to get the test running again The relevant output FileCheck is scanning in this test is as follows: CXXRecordDecl 0x7f96cf8239c8 <> imported in A.B struct definition <> `-FieldDecl 0x7f96cf823b90 <> imported in A.B anon_field_b 'int' (anonymous struct) CXXRecordDecl 0x7f96cf823be8 <> imported in A.B struct Before 710fa2c4ee346e1ec2db66ac5fdf6909e79d9a8c this test was passing by accident as it had a -DAG suffix in the checks changed by this patch, causing FileCheck to first match the last line of the output above (instead of the first one), and then finding the FieldDecl above. When I removed the -DAG suffix, FileCheck actually enforced the ordering and started failing as the FieldDecl comes before the CXXRecordDecl match we get. This patch fixes the CXXRecordDecl check to find the first line of the output above which caused FileCheck to also find the FieldDecl that follows. Also gives the FieldDecl a more unique name to make name collisions less likely. Added: Modified: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h b/lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h index 23d8347a2322..384d59b7b80a 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h @@ -1,5 +1,5 @@ typedef struct { - int b; + int anon_field_b; } StructB; namespace Namespace { diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm index 36bd1bfe37e6..b20e08024b9b 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -25,8 +25,8 @@ // CHECK-ANON-S1: CXXRecordDecl {{.*}} imported in A struct StructB s3; -// CHECK-ANON-S2: CXXRecordDecl {{.*}} imported in A.B struct -// CHECK-ANON-S2: -FieldDecl {{.*}} in A.B b 'int' +// CHECK-ANON-S2: CXXRecordDecl {{.*}} imported in A.B {{.*}} struct +// CHECK-ANON-S2: -FieldDecl {{.*}} in A.B anon_field_b 'int' Nested s4; // CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct Nested ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 13a1b3c - [lldb] Prevent objc-root-class warning when compiling module-ownership.mm test
Author: Raphael Isemann Date: 2020-05-08T14:41:01+02:00 New Revision: 13a1b3c1e6f40ec8459280eaae82fd3b0ed7b3a7 URL: https://github.com/llvm/llvm-project/commit/13a1b3c1e6f40ec8459280eaae82fd3b0ed7b3a7 DIFF: https://github.com/llvm/llvm-project/commit/13a1b3c1e6f40ec8459280eaae82fd3b0ed7b3a7.diff LOG: [lldb] Prevent objc-root-class warning when compiling module-ownership.mm test This test was generating the following false-positive warning when being compiled: warning: class 'SomeClass' defined without specifying a base class [-Wobjc-root-class] Added: Modified: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm index 72f2c8865f97..36bd1bfe37e6 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -1,4 +1,4 @@ -// RUN: %clang --target=x86_64-apple-macosx -g -gmodules \ +// RUN: %clang --target=x86_64-apple-macosx -g -gmodules -Wno-objc-root-class \ // RUN:-fmodules -fmodules-cache-path=%t.cache \ // RUN:-c -o %t.o %s -I%S/Inputs // RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck --check-prefix CHECK-ANON-S1 %s ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f8af9f5 - [lldb] Add missing nullptr checks to AppleObjCRuntime::GetBacktraceThreadFromException
Author: Raphael Isemann Date: 2020-05-11T16:02:51+02:00 New Revision: f8af9f5fca7dac5479a43837daa3e2bd897b00b7 URL: https://github.com/llvm/llvm-project/commit/f8af9f5fca7dac5479a43837daa3e2bd897b00b7 DIFF: https://github.com/llvm/llvm-project/commit/f8af9f5fca7dac5479a43837daa3e2bd897b00b7.diff LOG: [lldb] Add missing nullptr checks to AppleObjCRuntime::GetBacktraceThreadFromException Summary: We got a few crash reports where LLDB crashes while derefencing the `frames_value` shared_ptr in the AppleObjCRuntime::GetBacktraceThreadFromException. `GetChildMemberWithName` returns a nullptr when an error occurs, so this seems to be just a missing nullptr check. This patch adds that nullptr check and the other ones in the similar code directly below. Fixes rdar://62174039 Reviewers: jingham, kubamracek Reviewed By: jingham Subscribers: abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D78798 Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Removed: diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 0fe0d9217e6a..e00ce9d019df 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -501,19 +501,32 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread( return ValueObjectSP(); } +/// Utility method for error handling in GetBacktraceThreadFromException. +/// \param msg The message to add to the log. +/// \return An invalid ThreadSP to be returned from +/// GetBacktraceThreadFromException. +LLVM_NODISCARD +static ThreadSP FailExceptionParsing(llvm::StringRef msg) { + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); + LLDB_LOG(log, "Failed getting backtrace from exception: {0}", msg); + return ThreadSP(); +} + ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( lldb::ValueObjectSP exception_sp) { ValueObjectSP reserved_dict = exception_sp->GetChildMemberWithName(ConstString("reserved"), true); - if (!reserved_dict) return ThreadSP(); + if (!reserved_dict) +return FailExceptionParsing("Failed to get 'reserved' member."); reserved_dict = reserved_dict->GetSyntheticValue(); - if (!reserved_dict) return ThreadSP(); + if (!reserved_dict) +return FailExceptionParsing("Failed to get synthetic value."); TypeSystemClang *clang_ast_context = TypeSystemClang::GetScratch(*exception_sp->GetTargetSP()); if (!clang_ast_context) -return ThreadSP(); +return FailExceptionParsing("Failed to get scratch AST."); CompilerType objc_id = clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID); ValueObjectSP return_addresses; @@ -554,15 +567,22 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( } } - if (!return_addresses) return ThreadSP(); + if (!return_addresses) +return FailExceptionParsing("Failed to get return addresses."); auto frames_value = return_addresses->GetChildMemberWithName(ConstString("_frames"), true); + if (!frames_value) +return FailExceptionParsing("Failed to get frames_value."); addr_t frames_addr = frames_value->GetValueAsUnsigned(0); auto count_value = return_addresses->GetChildMemberWithName(ConstString("_cnt"), true); + if (!count_value) +return FailExceptionParsing("Failed to get count_value."); size_t count = count_value->GetValueAsUnsigned(0); auto ignore_value = return_addresses->GetChildMemberWithName(ConstString("_ignore"), true); + if (!ignore_value) +return FailExceptionParsing("Failed to get ignore_value."); size_t ignore = ignore_value->GetValueAsUnsigned(0); size_t ptr_size = m_process->GetAddressByteSize(); @@ -574,7 +594,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( pcs.push_back(pc); } - if (pcs.empty()) return ThreadSP(); + if (pcs.empty()) +return FailExceptionParsing("Failed to get PC list."); ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs)); m_process->GetExtendedThreadList().AddThread(new_thread_sp); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e87362e - Tab completion for breakpoint write and breakpoint name add/delete
Author: Gongyu Deng Date: 2020-05-11T15:55:11+02:00 New Revision: e87362e6894e052456c645129ac570f6bc23e8d1 URL: https://github.com/llvm/llvm-project/commit/e87362e6894e052456c645129ac570f6bc23e8d1 DIFF: https://github.com/llvm/llvm-project/commit/e87362e6894e052456c645129ac570f6bc23e8d1.diff LOG: Tab completion for breakpoint write and breakpoint name add/delete Summary: Apply the common completion created in [[ https://reviews.llvm.org/D75418 | Revision D75418 ]] to the commands `breakpoint write` and `breakpoint name add/delete`. Reviewers: teemperor, JDevlieghere Reviewed By: teemperor Tags: #lldb Differential Revision: https://reviews.llvm.org/D79686 Added: Modified: lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 11cded687913..fbd96c2c5ef5 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -1770,6 +1770,14 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed { ~CommandObjectBreakpointNameAdd() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion, +request, nullptr); + } + Options *GetOptions() override { return _option_group; } protected: @@ -1849,6 +1857,14 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed { ~CommandObjectBreakpointNameDelete() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion, +request, nullptr); + } + Options *GetOptions() override { return _option_group; } protected: @@ -2147,6 +2163,14 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed { ~CommandObjectBreakpointWrite() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion, +request, nullptr); + } + Options *GetOptions() override { return _options; } class CommandOptions : public Options { diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 3a9c30a3e62a..a53ade542f46 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -478,10 +478,10 @@ def test_register_read_and_write_on_x86(self): self.complete_from_to('register write rbx ', []) -def test_breakpoint_enable_disable_delete_modify_with_ids(self): -"""These four breakpoint subcommands should be completed with a list of breakpoint ids""" +def test_complete_breakpoint_with_ids(self): +"""These breakpoint subcommands should be completed with a list of breakpoint ids""" -subcommands = ['enable', 'disable', 'delete', 'modify'] +subcommands = ['enable', 'disable', 'delete', 'modify', 'name add', 'name delete', 'write'] # The tab completion here is unavailable without a target for subcommand in subcommands: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7c89297 - Correct the argument list of command `breakpoint read`
Author: Gongyu Deng Date: 2020-05-15T09:00:05+02:00 New Revision: 7c89297cf7eecd52327915de587df8183793afac URL: https://github.com/llvm/llvm-project/commit/7c89297cf7eecd52327915de587df8183793afac DIFF: https://github.com/llvm/llvm-project/commit/7c89297cf7eecd52327915de587df8183793afac.diff LOG: Correct the argument list of command `breakpoint read` Summary: Command `breakpoint read` should not accept breakpoint ids as arguments, and in fact, it is not implemented to deal with breakpoint id arguments either. So this patch is to correct the argument list of this command so that the help text won't misguide users. Reviewers: teemperor, JDevlieghere, jingham Reviewed By: teemperor, JDevlieghere Tags: #lldb Differential Revision: https://reviews.llvm.org/D79722 Added: Modified: lldb/source/Commands/CommandObjectBreakpoint.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index fbd96c2c5ef5..be7ef8a1b60b 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -2034,14 +2034,7 @@ class CommandObjectBreakpointRead : public CommandObjectParsed { "Read and set the breakpoints previously saved to " "a file with \"breakpoint write\". ", nullptr), -m_options() { -CommandArgumentEntry arg; -CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, - eArgTypeBreakpointIDRange); -// Add the entry for the first argument for this command to the object's -// arguments vector. -m_arguments.push_back(arg); - } +m_options() {} ~CommandObjectBreakpointRead() override = default; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5f7a5e3 - [lldb][NFC] Early-exit in SetupDeclVendor
Author: Raphael Isemann Date: 2020-05-13T16:54:38+02:00 New Revision: 5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8 URL: https://github.com/llvm/llvm-project/commit/5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8 DIFF: https://github.com/llvm/llvm-project/commit/5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8.diff LOG: [lldb][NFC] Early-exit in SetupDeclVendor Also removed the unnecessary element-by-element copy of the std::vector hand_imported_modules to modules_for_macros. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 2b75c4f75c63..b2c6cba3bd58 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -348,37 +348,37 @@ bool ClangUserExpression::SetupPersistentState(DiagnosticManager _man } static void SetupDeclVendor(ExecutionContext _ctx, Target *target) { - if (ClangModulesDeclVendor *decl_vendor = - target->GetClangModulesDeclVendor()) { -auto *persistent_state = llvm::cast( -target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)); -if (!persistent_state) - return; -const ClangModulesDeclVendor::ModuleVector _imported_modules = -persistent_state->GetHandLoadedClangModules(); -ClangModulesDeclVendor::ModuleVector modules_for_macros; + ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor(); + if (!decl_vendor) +return; -for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) { - modules_for_macros.push_back(module); -} + if (!target->GetEnableAutoImportClangModules()) +return; + + auto *persistent_state = llvm::cast( + target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)); + if (!persistent_state) +return; -if (target->GetEnableAutoImportClangModules()) { - if (StackFrame *frame = exe_ctx.GetFramePtr()) { -if (Block *block = frame->GetFrameBlock()) { - SymbolContext sc; + StackFrame *frame = exe_ctx.GetFramePtr(); + if (!frame) +return; + + Block *block = frame->GetFrameBlock(); + if (!block) +return; + SymbolContext sc; - block->CalculateSymbolContext(); + block->CalculateSymbolContext(); - if (sc.comp_unit) { -StreamString error_stream; + if (!sc.comp_unit) +return; + StreamString error_stream; -decl_vendor->AddModulesForCompileUnit( -*sc.comp_unit, modules_for_macros, error_stream); - } -} - } -} - } + ClangModulesDeclVendor::ModuleVector modules_for_macros = + persistent_state->GetHandLoadedClangModules(); + decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros, +error_stream); } void ClangUserExpression::UpdateLanguageForExpr() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2fe6672 - [lldb][NFC] Don't specify a default argument when creating a TextDiagnosticPrinter
Author: Raphael Isemann Date: 2020-05-13T15:55:51+02:00 New Revision: 2fe6672498d60074fd34e2770659d5526e53e093 URL: https://github.com/llvm/llvm-project/commit/2fe6672498d60074fd34e2770659d5526e53e093 DIFF: https://github.com/llvm/llvm-project/commit/2fe6672498d60074fd34e2770659d5526e53e093.diff LOG: [lldb][NFC] Don't specify a default argument when creating a TextDiagnosticPrinter Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index e7afbe5c3031..8885cbc85b2c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -162,8 +162,7 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { m_options->ShowPresumedLoc = true; m_options->ShowLevel = false; m_os.reset(new llvm::raw_string_ostream(m_output)); -m_passthrough.reset( -new clang::TextDiagnosticPrinter(*m_os, m_options, false)); +m_passthrough.reset(new clang::TextDiagnosticPrinter(*m_os, m_options)); } void ResetManager(DiagnosticManager *manager = nullptr) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7cf4ab1 - [lldb][modules] Disable Clang Modules in source/Host directory on macOS
Author: Raphael Isemann Date: 2020-05-08T18:13:58+02:00 New Revision: 7cf4ab13af8aa3183e551b3319399cddd9384948 URL: https://github.com/llvm/llvm-project/commit/7cf4ab13af8aa3183e551b3319399cddd9384948 DIFF: https://github.com/llvm/llvm-project/commit/7cf4ab13af8aa3183e551b3319399cddd9384948.diff LOG: [lldb][modules] Disable Clang Modules in source/Host directory on macOS Summary: The arpa/inet.h header in macOS is providing an incorrect htonl function with enabled local submodule visibility while building LLDB. This caused several networking tests to fail as the IP addresses are now flipped in LLDB. This patch disables building with modules when local submodule visibility is active and the current system is macOS for the source/Host directory (which is the *only directory that includes arpa/inet.h). * debugserver also includes arpa/inet.h but there we already disabled modules. Reviewers: aprantl Reviewed By: aprantl Subscribers: mgorny, JDevlieghere Differential Revision: https://reviews.llvm.org/D79632 Added: Modified: lldb/source/Host/CMakeLists.txt Removed: diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index 2837c0c5e3a1..a5e4e352d036 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -1,3 +1,11 @@ +if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) + # The arpa/inet.h header used in the files here is providing a miscompiled + # htonl function on macOS <= 10.15 when local submodule visibility is active. + # Disabling modules in this directory until this is is fixed. + # See rdar://problem/62886385 + remove_module_flags() +endif() + macro(add_host_subdirectory group) list(APPEND HOST_SOURCES ${ARGN}) source_group(${group} FILES ${ARGN}) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] aaf68cd - [lldb] Warn the user about starting the --func-regex parameter with an asterisk
Author: Raphael Isemann Date: 2020-05-06T12:37:52+02:00 New Revision: aaf68cd9ce2fda224e02fd0f860e6372b4b00e47 URL: https://github.com/llvm/llvm-project/commit/aaf68cd9ce2fda224e02fd0f860e6372b4b00e47 DIFF: https://github.com/llvm/llvm-project/commit/aaf68cd9ce2fda224e02fd0f860e6372b4b00e47.diff LOG: [lldb] Warn the user about starting the --func-regex parameter with an asterisk Summary: Sometimes users think that setting a function regex for all function that contain the word 'needle' in their name looks like this: `*needle*`. However, LLDB only searches the function name and doesn't fully match it against the regex, so the leading and trailing '*' operators don't do anything and actually just cause the regex engine to reject the regular expression with "repetition-operator operand invalid". This patch makes this a bit more obvious to the user by printing a warning that a leading '*' before this regular expression here doesn't have any purpose (and will cause an error). This doesn't attempt to detect a case where there is only a trailing '*' as that would involve parsing the regex and it seems the most common way to end up in this situation is by doing `rbreak *needle*`. Reviewers: JDevlieghere Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D78809 Added: Modified: lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py Removed: diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 661ebc790354..e62a1154797e 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -622,6 +622,14 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { result.AppendErrorWithFormat( "Function name regular expression could not be compiled: %s", llvm::toString(std::move(err)).c_str()); +// Check if the incorrect regex looks like a globbing expression and +// warn the user about it. +if (!m_options.m_func_regexp.empty()) { + if (m_options.m_func_regexp[0] == '*' || + m_options.m_func_regexp[0] == '?') +result.AppendWarning( +"Function name regex does not accept glob patterns."); +} result.SetStatus(eReturnStatusFailed); return false; } diff --git a/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py index a8cfcf2d1d87..1eedb266c5b4 100644 --- a/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py +++ b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py @@ -12,3 +12,19 @@ def test_error(self): self.expect("breakpoint set --func-regex (", error=True, substrs=["error: Function name regular expression could " + "not be compiled: parentheses not balanced"]) + +# Point out if looks like the user provided a globbing expression. +self.expect("breakpoint set --func-regex *a", error=True, +substrs=["error: Function name regular expression could " + + "not be compiled: repetition-operator operand invalid", + "warning: Function name regex does not accept glob patterns."]) +self.expect("breakpoint set --func-regex ?a", error=True, +substrs=["error: Function name regular expression could " + + "not be compiled: repetition-operator operand invalid", + "warning: Function name regex does not accept glob patterns."]) +# Make sure that warning is only shown for invalid regular expressions +# that look like a globbing expression (i.e., they have a leading * or ?). +self.expect("breakpoint set --func-regex a*+", error=True, matching=False, +substrs=["warning: Function name regex does not accept glob patterns."]) +self.expect("breakpoint set --func-regex a?+", error=True, matching=False, +substrs=["warning: Function name regex does not accept glob patterns."]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 939ca45 - [lldb] Fix string summary of an empty NSPathStore2
Author: Raphael Isemann Date: 2020-03-19T12:20:35+01:00 New Revision: 939ca455e72e822450013eff37c9ea7746850350 URL: https://github.com/llvm/llvm-project/commit/939ca455e72e822450013eff37c9ea7746850350 DIFF: https://github.com/llvm/llvm-project/commit/939ca455e72e822450013eff37c9ea7746850350.diff LOG: [lldb] Fix string summary of an empty NSPathStore2 Summary: Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888). It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings. This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly was the original purpose of this magic value). Reviewers: aprantl, JDevlieghere, shafik Reviewed By: aprantl Subscribers: christof, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68010 Added: Modified: lldb/include/lldb/DataFormatters/StringPrinter.h lldb/source/DataFormatters/StringPrinter.cpp lldb/source/Plugins/Language/ObjC/NSString.cpp lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m Removed: diff --git a/lldb/include/lldb/DataFormatters/StringPrinter.h b/lldb/include/lldb/DataFormatters/StringPrinter.h index 6f8869cc2a1e..5842cde893d8 100644 --- a/lldb/include/lldb/DataFormatters/StringPrinter.h +++ b/lldb/include/lldb/DataFormatters/StringPrinter.h @@ -115,9 +115,15 @@ class StringPrinter { lldb::ProcessSP GetProcessSP() const { return m_process_sp; } +void SetHasSourceSize(bool e) { m_has_source_size = e; } + +bool HasSourceSize() const { return m_has_source_size; } + private: uint64_t m_location = 0; lldb::ProcessSP m_process_sp; +/// True iff we know the source size of the string. +bool m_has_source_size = false; }; class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions { diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 92dd71d17b8c..4515b67b2adf 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -525,27 +525,33 @@ static bool ReadUTFBufferAndDumpToStream( if (!options.GetStream()) return false; - uint32_t sourceSize = options.GetSourceSize(); + uint32_t sourceSize; bool needs_zero_terminator = options.GetNeedsZeroTermination(); bool is_truncated = false; const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); - if (!sourceSize) { + if (options.HasSourceSize()) { +sourceSize = options.GetSourceSize(); +if (!options.GetIgnoreMaxLength()) { + if (sourceSize > max_size) { +sourceSize = max_size; +is_truncated = true; + } +} + } else { sourceSize = max_size; needs_zero_terminator = true; - } else if (!options.GetIgnoreMaxLength()) { -if (sourceSize > max_size) { - sourceSize = max_size; - is_truncated = true; -} } const int bufferSPSize = sourceSize * type_width; lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0)); - if (!buffer_sp->GetBytes()) + // Check if we got bytes. We never get any bytes if we have an empty + // string, but we still continue so that we end up actually printing + // an empty string (""). + if (sourceSize != 0 && !buffer_sp->GetBytes()) return false; Status error; diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index 65256dc7acbd..7c4afb36b588 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -170,6 +170,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetStream(); options.SetQuote('"'); options.SetSourceSize(explicit_length); + options.SetHasSourceSize(has_explicit_length); options.SetNeedsZeroTermination(false); options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped); @@ -182,6 +183,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetProcessSP(process_sp); options.SetStream(); options.SetSourceSize(explicit_length); + options.SetHasSourceSize(has_explicit_length); options.SetNeedsZeroTermination(false); options.SetIgnoreMaxLength(summary_options.GetCapping() ==
[Lldb-commits] [lldb] 718d941 - Revert "[lldb] Fix string summary of an empty NSPathStore2"
Author: Raphael Isemann Date: 2020-03-19T13:08:39+01:00 New Revision: 718d94187dbb2388dbc84deb5d49004fd552817c URL: https://github.com/llvm/llvm-project/commit/718d94187dbb2388dbc84deb5d49004fd552817c DIFF: https://github.com/llvm/llvm-project/commit/718d94187dbb2388dbc84deb5d49004fd552817c.diff LOG: Revert "[lldb] Fix string summary of an empty NSPathStore2" This reverts commit 939ca455e72e822450013eff37c9ea7746850350. This failed on the debian bot for some reason: File "/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py", line 67, in test_with_run_command "s summary wrong") AssertionError: 'L"hello world! מזל טוב!\\0!\\0\\0\\0A\\0\\Ufffd\\Ufffd\\Ufffd\\ [truncated]... != 'L"hello world! מזל טוב!"' Diff is 2156 characters long. Set self.maxDiff to None to see it. : s summary wrong Added: Modified: lldb/include/lldb/DataFormatters/StringPrinter.h lldb/source/DataFormatters/StringPrinter.cpp lldb/source/Plugins/Language/ObjC/NSString.cpp lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m Removed: diff --git a/lldb/include/lldb/DataFormatters/StringPrinter.h b/lldb/include/lldb/DataFormatters/StringPrinter.h index 5842cde893d8..6f8869cc2a1e 100644 --- a/lldb/include/lldb/DataFormatters/StringPrinter.h +++ b/lldb/include/lldb/DataFormatters/StringPrinter.h @@ -115,15 +115,9 @@ class StringPrinter { lldb::ProcessSP GetProcessSP() const { return m_process_sp; } -void SetHasSourceSize(bool e) { m_has_source_size = e; } - -bool HasSourceSize() const { return m_has_source_size; } - private: uint64_t m_location = 0; lldb::ProcessSP m_process_sp; -/// True iff we know the source size of the string. -bool m_has_source_size = false; }; class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions { diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 4515b67b2adf..92dd71d17b8c 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -525,33 +525,27 @@ static bool ReadUTFBufferAndDumpToStream( if (!options.GetStream()) return false; - uint32_t sourceSize; + uint32_t sourceSize = options.GetSourceSize(); bool needs_zero_terminator = options.GetNeedsZeroTermination(); bool is_truncated = false; const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); - if (options.HasSourceSize()) { -sourceSize = options.GetSourceSize(); -if (!options.GetIgnoreMaxLength()) { - if (sourceSize > max_size) { -sourceSize = max_size; -is_truncated = true; - } -} - } else { + if (!sourceSize) { sourceSize = max_size; needs_zero_terminator = true; + } else if (!options.GetIgnoreMaxLength()) { +if (sourceSize > max_size) { + sourceSize = max_size; + is_truncated = true; +} } const int bufferSPSize = sourceSize * type_width; lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0)); - // Check if we got bytes. We never get any bytes if we have an empty - // string, but we still continue so that we end up actually printing - // an empty string (""). - if (sourceSize != 0 && !buffer_sp->GetBytes()) + if (!buffer_sp->GetBytes()) return false; Status error; diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index 7c4afb36b588..65256dc7acbd 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -170,7 +170,6 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetStream(); options.SetQuote('"'); options.SetSourceSize(explicit_length); - options.SetHasSourceSize(has_explicit_length); options.SetNeedsZeroTermination(false); options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped); @@ -183,7 +182,6 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetProcessSP(process_sp); options.SetStream(); options.SetSourceSize(explicit_length); - options.SetHasSourceSize(has_explicit_length); options.SetNeedsZeroTermination(false); options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped); @@ -201,7 +199,6 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetStream(); options.SetQuote('"'); options.SetSourceSize(explicit_length);
[Lldb-commits] [lldb] 50f1985 - [lldb][NFC] Delete the original UserExpression before trying to reparse it with FixIts.
Author: Raphael Isemann Date: 2020-03-19T18:10:57+01:00 New Revision: 50f198535363c6882b02c3dde7bec31e723c4762 URL: https://github.com/llvm/llvm-project/commit/50f198535363c6882b02c3dde7bec31e723c4762 DIFF: https://github.com/llvm/llvm-project/commit/50f198535363c6882b02c3dde7bec31e723c4762.diff LOG: [lldb][NFC] Delete the original UserExpression before trying to reparse it with FixIts. Currently when an expression fails to parse and we have a FixIt, we keep the failed UserExpression around while trying to parse the expression with applied fixits. This means that we have this rather confusing control flow: 1. Original expression created and parsing attempted. 2. Expression with applied FixIts is created and parsing attempted. 3. Original expression is destroyed and parser deconstructed. 4. Expression with applied FixIts is destroyed and parser deconstructed. This patch just deletes the original expression so that step 2 and 3 are swapped and the whole process looks more like just sequentially parsing two expressions (which is what we actually do here). Doesn't fix anything just makes the code less fragile. Added: Modified: lldb/source/Expression/UserExpression.cpp Removed: diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp index 0243cc0c3750..5bd2321e48dd 100644 --- a/lldb/source/Expression/UserExpression.cpp +++ b/lldb/source/Expression/UserExpression.cpp @@ -259,6 +259,10 @@ UserExpression::Evaluate(ExecutionContext _ctx, // If there is a fixed expression, try to parse it: if (!parse_success) { +// Delete the expression that failed to parse before attempting to parse +// the next expression. +user_expression_sp.reset(); + execution_results = lldb::eExpressionParseError; if (fixed_expression && !fixed_expression->empty() && options.GetAutoApplyFixIts()) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7b24425 - Reland [lldb] Fix string summary of an empty NSPathStore2
Author: Raphael Isemann Date: 2020-03-19T18:50:26+01:00 New Revision: 7b2442584e40f97693c38c0d79b83f770d557039 URL: https://github.com/llvm/llvm-project/commit/7b2442584e40f97693c38c0d79b83f770d557039 DIFF: https://github.com/llvm/llvm-project/commit/7b2442584e40f97693c38c0d79b83f770d557039.diff LOG: Reland [lldb] Fix string summary of an empty NSPathStore2 (This is D68010 but I also set the new parameter in LibStdcpp.cpp to fix the Debian tests). Summary: Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888). It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings. This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly was the original purpose of this magic value). Reviewers: aprantl, JDevlieghere, shafik Reviewed By: aprantl Subscribers: christof, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68010 Added: Modified: lldb/include/lldb/DataFormatters/StringPrinter.h lldb/source/DataFormatters/StringPrinter.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp lldb/source/Plugins/Language/ObjC/NSString.cpp lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m Removed: diff --git a/lldb/include/lldb/DataFormatters/StringPrinter.h b/lldb/include/lldb/DataFormatters/StringPrinter.h index 6f8869cc2a1e..5842cde893d8 100644 --- a/lldb/include/lldb/DataFormatters/StringPrinter.h +++ b/lldb/include/lldb/DataFormatters/StringPrinter.h @@ -115,9 +115,15 @@ class StringPrinter { lldb::ProcessSP GetProcessSP() const { return m_process_sp; } +void SetHasSourceSize(bool e) { m_has_source_size = e; } + +bool HasSourceSize() const { return m_has_source_size; } + private: uint64_t m_location = 0; lldb::ProcessSP m_process_sp; +/// True iff we know the source size of the string. +bool m_has_source_size = false; }; class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions { diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 92dd71d17b8c..4515b67b2adf 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -525,27 +525,33 @@ static bool ReadUTFBufferAndDumpToStream( if (!options.GetStream()) return false; - uint32_t sourceSize = options.GetSourceSize(); + uint32_t sourceSize; bool needs_zero_terminator = options.GetNeedsZeroTermination(); bool is_truncated = false; const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); - if (!sourceSize) { + if (options.HasSourceSize()) { +sourceSize = options.GetSourceSize(); +if (!options.GetIgnoreMaxLength()) { + if (sourceSize > max_size) { +sourceSize = max_size; +is_truncated = true; + } +} + } else { sourceSize = max_size; needs_zero_terminator = true; - } else if (!options.GetIgnoreMaxLength()) { -if (sourceSize > max_size) { - sourceSize = max_size; - is_truncated = true; -} } const int bufferSPSize = sourceSize * type_width; lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0)); - if (!buffer_sp->GetBytes()) + // Check if we got bytes. We never get any bytes if we have an empty + // string, but we still continue so that we end up actually printing + // an empty string (""). + if (sourceSize != 0 && !buffer_sp->GetBytes()) return false; Status error; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 78f58754cc31..b4af67ecee0d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -259,6 +259,7 @@ bool lldb_private::formatters::LibStdcppStringSummaryProvider( if (error.Fail()) return false; options.SetSourceSize(size_of_data); + options.SetHasSourceSize(true); if (!StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF8>(options)) { @@ -319,6 +320,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider( if (error.Fail()) return false; options.SetSourceSize(size_of_data); + options.SetHasSourceSize(true); options.SetPrefixToken("L"); switch (wchar_size) {
[Lldb-commits] [lldb] f955418 - [lldb] Tighten checks in TestStats.py
Author: Raphael Isemann Date: 2020-03-17T14:12:13+01:00 New Revision: f95541839cb25c883dc530928232105af87c75dc URL: https://github.com/llvm/llvm-project/commit/f95541839cb25c883dc530928232105af87c75dc DIFF: https://github.com/llvm/llvm-project/commit/f95541839cb25c883dc530928232105af87c75dc.diff LOG: [lldb] Tighten checks in TestStats.py Just adding trailing newlines that "...: 1" doesn't match "...: 10". Added: Modified: lldb/test/API/commands/statistics/basic/TestStats.py Removed: diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py index 4809adf9060f..76bc22433848 100644 --- a/lldb/test/API/commands/statistics/basic/TestStats.py +++ b/lldb/test/API/commands/statistics/basic/TestStats.py @@ -18,8 +18,8 @@ def test(self): self.expect("statistics enable", substrs=['already enabled'], error=True) self.expect("expr patatino", substrs=['27']) self.expect("statistics disable") -self.expect("statistics dump", substrs=['expr evaluation successes : 1', -'expr evaluation failures : 0']) +self.expect("statistics dump", substrs=['expr evaluation successes : 1\n', +'expr evaluation failures : 0\n']) # 'frame var' with disabled statistics shouldn't change stats. self.expect("frame var", substrs=['27']) @@ -28,5 +28,5 @@ def test(self): # 'frame var' with enabled statistics will change stats. self.expect("frame var", substrs=['27']) self.expect("statistics disable") -self.expect("statistics dump", substrs=['frame var successes : 1', -'frame var failures : 0']) +self.expect("statistics dump", substrs=['frame var successes : 1\n', +'frame var failures : 0\n']) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7c6e52a - [lldb] Ptrs->refs in CommandObjectExpression::EvaluateExpression parameters
Author: Raphael Isemann Date: 2020-03-17T13:23:16+01:00 New Revision: 7c6e52ac0ce5a6879331bc3c322dd20bfec3bf14 URL: https://github.com/llvm/llvm-project/commit/7c6e52ac0ce5a6879331bc3c322dd20bfec3bf14 DIFF: https://github.com/llvm/llvm-project/commit/7c6e52ac0ce5a6879331bc3c322dd20bfec3bf14.diff LOG: [lldb] Ptrs->refs in CommandObjectExpression::EvaluateExpression parameters The error_stream and result parameter were inconsistently checked for being null, so we might as well make them references instead of crashing in case someone passes a nullptr and hits one of the code paths that are currently not doing a nullptr check on those parameters. Also change output_stream for consistency. Added: Modified: lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Commands/CommandObjectExpression.h Removed: diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 388f9f0af66a..7d8de573df0e 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -403,9 +403,9 @@ CommandObjectExpression::GetEvalOptions(const Target ) { } bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, - Stream *output_stream, - Stream *error_stream, - CommandReturnObject *result) { + Stream _stream, + Stream _stream, + CommandReturnObject ) { // Don't use m_exe_ctx as this might be called asynchronously after the // command object DoExecute has finished when doing multi-line expression // that use an input reader... @@ -425,11 +425,10 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, // We only tell you about the FixIt if we applied it. The compiler errors // will suggest the FixIt if it parsed. - if (error_stream && !m_fixed_expression.empty() && - target->GetEnableNotifyAboutFixIts()) { + if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) { if (success == eExpressionCompleted) - error_stream->Printf(" Fix-it applied, fixed expression was: \n %s\n", - m_fixed_expression.c_str()); + error_stream.Printf(" Fix-it applied, fixed expression was: \n%s\n", + m_fixed_expression.c_str()); } if (result_valobj_sp) { @@ -443,10 +442,10 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, if (m_varobj_options.elem_count > 0) { Status error(CanBeUsedForElementCountPrinting(*result_valobj_sp)); if (error.Fail()) { -result->AppendErrorWithFormat( +result.AppendErrorWithFormat( "expression cannot be used with --element-count %s\n", error.AsCString("")); -result->SetStatus(eReturnStatusFailed); +result.SetStatus(eReturnStatusFailed); return false; } } @@ -456,36 +455,33 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, options.SetVariableFormatDisplayLanguage( result_valobj_sp->GetPreferredDisplayLanguage()); -result_valobj_sp->Dump(*output_stream, options); +result_valobj_sp->Dump(output_stream, options); -if (result) - result->SetStatus(eReturnStatusSuccessFinishResult); +result.SetStatus(eReturnStatusSuccessFinishResult); } } else { if (result_valobj_sp->GetError().GetError() == UserExpression::kNoResult) { if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) { - error_stream->PutCString("(void)\n"); + error_stream.PutCString("(void)\n"); } -if (result) - result->SetStatus(eReturnStatusSuccessFinishResult); +result.SetStatus(eReturnStatusSuccessFinishResult); } else { const char *error_cstr = result_valobj_sp->GetError().AsCString(); if (error_cstr && error_cstr[0]) { const size_t error_cstr_len = strlen(error_cstr); const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n'; if (strstr(error_cstr, "error:") != error_cstr) -error_stream->PutCString("error: "); - error_stream->Write(error_cstr, error_cstr_len); +error_stream.PutCString("error: "); + error_stream.Write(error_cstr, error_cstr_len); if (!ends_with_newline) -error_stream->EOL(); +error_stream.EOL(); } else { - error_stream->PutCString("error: unknown error\n"); +
[Lldb-commits] [lldb] f5e0f8b - [lldb] Add test for importing ObjC modules in a non-ObjC target
Author: Raphael Isemann Date: 2020-03-17T12:49:48+01:00 New Revision: f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8 URL: https://github.com/llvm/llvm-project/commit/f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8 DIFF: https://github.com/llvm/llvm-project/commit/f5e0f8b10ab95e94b5ffb32e380f95d21415c3e8.diff LOG: [lldb] Add test for importing ObjC modules in a non-ObjC target This was previously crashing due to a missing nullptr check (see e2d8aa6bf774ef29e134c40f886c7bb5f970 ). This just adds a test that should make sure this doesn't crash in case a user ends up in this strange setup. Added: lldb/test/API/lang/objc/modules-non-objc-target/Makefile lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py lldb/test/API/lang/objc/modules-non-objc-target/main.c Modified: Removed: diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/Makefile b/lldb/test/API/lang/objc/modules-non-objc-target/Makefile new file mode 100644 index ..10495940055b --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py new file mode 100644 index ..18283f6d2b33 --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py @@ -0,0 +1,26 @@ +""" +Tests that importing ObjC modules in a non-ObjC target doesn't crash LLDB. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@skipUnlessDarwin +def test(self): +self.build() +lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.c")) + +# Import foundation to get some ObjC types. +self.expect("expr --lang objc -- @import Foundation") +# Do something with NSString (which requires special handling when +# preparing to run in the target). The expression most likely can't +# be prepared to run in the target but it should at least not crash LLDB. +self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 1];', +error=True, +substrs=["error: The expression could not be prepared to run in the target"]) diff --git a/lldb/test/API/lang/objc/modules-non-objc-target/main.c b/lldb/test/API/lang/objc/modules-non-objc-target/main.c new file mode 100644 index ..ba45ee316cd4 --- /dev/null +++ b/lldb/test/API/lang/objc/modules-non-objc-target/main.c @@ -0,0 +1,3 @@ +int main() { + return 0; // break here +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 467c490 - [lldb] Enable now passing part of TestDataFormatterStdString.py
Author: Raphael Isemann Date: 2020-03-20T11:35:15+01:00 New Revision: 467c4902a10999f792bea653147641ac8b89cca5 URL: https://github.com/llvm/llvm-project/commit/467c4902a10999f792bea653147641ac8b89cca5 DIFF: https://github.com/llvm/llvm-project/commit/467c4902a10999f792bea653147641ac8b89cca5.diff LOG: [lldb] Enable now passing part of TestDataFormatterStdString.py This was fixed by 7b2442584e40f97693c38c0d79b83f770d557039 . Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py index fa0e4d123984..44d8ff26078a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -60,8 +60,7 @@ def cleanup(): var_Q = self.frame().FindVariable('Q') var_uchar = self.frame().FindVariable('uchar') -# TODO: This is currently broken -# self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary wrong") +self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary wrong") self.assertEqual( var_s.GetSummary(), 'L"hello world! מזל טוב!"', "s summary wrong") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6a4905a - [lldb] Mark expressions that couldn't be parsed or executed as failed expressions
Author: Raphael Isemann Date: 2020-03-23T15:28:17+01:00 New Revision: 6a4905ae2d65a2883112bf8cbf83c35c0c03f410 URL: https://github.com/llvm/llvm-project/commit/6a4905ae2d65a2883112bf8cbf83c35c0c03f410 DIFF: https://github.com/llvm/llvm-project/commit/6a4905ae2d65a2883112bf8cbf83c35c0c03f410.diff LOG: [lldb] Mark expressions that couldn't be parsed or executed as failed expressions Summary: LLDB keeps statistics of how many expression evaluations are 'successful' and 'failed' which are updated after each expression evaluation (assuming statistics are enabled). >From what I understand the idea is that this could be used to define how well >LLDB's expression evaluator is working. Currently all expressions are considered successful unless the user passes an explicit positive element counting to the expression command (with the `-Z` flag) and then passes an expression that successfully evaluates to a type that doesn't support element counting. Expressions that fail to parse, execute or any other outcome are considered successful at the moment which means we nearly always have a 100% expression evaluation success rate. This patch makes that expressions that fail to parse or execute to count as failed expressions. We can't know whether the expression failed because of an user error of because LLDB couldn't correctly parse/compile it, but I would argue that this is still an improvement. Assuming that the percentage of valid user expressions stays mostly constant over time (which seems like a reasonable assumption), then this way we can still see if we are doing relatively better/worse from release to release. Reviewers: davide, aprantl, JDevlieghere Reviewed By: aprantl Subscribers: abidh Differential Revision: https://reviews.llvm.org/D76280 Added: Modified: lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Commands/CommandObjectExpression.h lldb/test/API/commands/statistics/basic/TestStats.py Removed: diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 7d8de573df0e..9a314c251475 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -486,7 +486,8 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, } } - return true; + return (success != eExpressionSetupError && + success != eExpressionParseError); } void CommandObjectExpression::IOHandlerInputComplete(IOHandler _handler, diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index ddee9c36924d..1e59cbc14528 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -71,6 +71,16 @@ class CommandObjectExpression : public CommandObjectRaw, /// expression in the given target. EvaluateExpressionOptions GetEvalOptions(const Target ); + /// Evaluates the given expression. + /// \param output_stream The stream to which the evaluation result will be + /// printed. + /// \param error_stream Contains error messages that should be displayed to + /// the user in case the evaluation fails. + /// \param result A CommandReturnObject which status will be set to the + /// appropriate value depending on evaluation success and + /// whether the expression produced any result. + /// \return Returns true iff the expression was successfully evaluated, + /// executed and the result could be printed to the output stream. bool EvaluateExpression(llvm::StringRef expr, Stream _stream, Stream _stream, CommandReturnObject ); diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py index 76bc22433848..be028199fade 100644 --- a/lldb/test/API/commands/statistics/basic/TestStats.py +++ b/lldb/test/API/commands/statistics/basic/TestStats.py @@ -21,6 +21,20 @@ def test(self): self.expect("statistics dump", substrs=['expr evaluation successes : 1\n', 'expr evaluation failures : 0\n']) +self.expect("statistics enable") +# Doesn't parse. +self.expect("expr doesnt_exist", error=True, +substrs=["undeclared identifier 'doesnt_exist'"]) +# Doesn't successfully execute. +self.expect("expr int *i = nullptr; *i", error=True) +# Interpret an integer as an array with 3 elements is also a failure. +self.expect("expr -Z 3 -- 1", error=True, +substrs=["expression cannot be used with --element-count"]) +self.expect("statistics disable") +# We should have gotten 3 new failures and the previous success. +
[Lldb-commits] [lldb] 68687e7 - [lldb][NFC] Mark GetNextPersistentVariableName as overriden to silence warning
Author: Raphael Isemann Date: 2020-03-24T12:30:03+01:00 New Revision: 68687e75e7cb494796439f127a93ea03f2710551 URL: https://github.com/llvm/llvm-project/commit/68687e75e7cb494796439f127a93ea03f2710551 DIFF: https://github.com/llvm/llvm-project/commit/68687e75e7cb494796439f127a93ea03f2710551.diff LOG: [lldb][NFC] Mark GetNextPersistentVariableName as overriden to silence warning This was triggering -Winconsistent-missing-override warnings. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h index f6298911dd6c..f888b2d56e68 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h @@ -51,7 +51,7 @@ class ClangPersistentVariables : public PersistentExpressionState { void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override; - virtual ConstString GetNextPersistentVariableName(bool is_error = false); + ConstString GetNextPersistentVariableName(bool is_error = false) override; /// Returns the next file name that should be used for user expressions. std::string GetNextExprFileName() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 177dd63 - Data formatters: fix detection of C strings
Author: Jaroslav Sevcik Date: 2020-03-24T14:25:59+01:00 New Revision: 177dd63c8d742250dac6ea365e7c30f0fbab3257 URL: https://github.com/llvm/llvm-project/commit/177dd63c8d742250dac6ea365e7c30f0fbab3257 DIFF: https://github.com/llvm/llvm-project/commit/177dd63c8d742250dac6ea365e7c30f0fbab3257.diff LOG: Data formatters: fix detection of C strings Summary: Detection of C strings does not work well for pointers. If the value object holding a (char*) pointer does not have an address (e.g., if it is a temp), the value is not considered a C string and its formatting is left to DumpDataExtractor rather than the special handling in ValueObject::DumpPrintableRepresentation. This leads to inconsistent outputs, e.g., in escaping non-ASCII characters. See the test for an example; the second test expectation is not met (without this patch). With this patch, the C string detection only insists that the pointer value is valid. The patch makes the code consistent with how the pointer is obtained in ValueObject::ReadPointedString. Reviewers: teemperor Reviewed By: teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76650 Added: lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp Modified: lldb/source/Core/ValueObject.cpp Removed: diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 4c9c44ea15f4..9e20ba76dccb 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -764,7 +764,7 @@ bool ValueObject::IsCStringContainer(bool check_pointer) { return true; addr_t cstr_address = LLDB_INVALID_ADDRESS; AddressType cstr_address_type = eAddressTypeInvalid; - cstr_address = GetAddressOf(true, _address_type); + cstr_address = GetPointerValue(_address_type); return (cstr_address != LLDB_INVALID_ADDRESS); } diff --git a/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile new file mode 100644 index ..8b20bcb0 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py new file mode 100644 index ..c05e9e9b06ba --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py @@ -0,0 +1,18 @@ +# coding=utf8 + +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class CstringUnicodeTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) +NO_DEBUG_INFO_TESTCASE = True + +def test_cstring_unicode(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "// break here", +lldb.SBFileSpec("main.cpp", False)) +self.expect_expr("s", result_summary='""') +self.expect_expr("(const char*)s", result_summary='""') diff --git a/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp new file mode 100644 index ..c1e8bcf242f4 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp @@ -0,0 +1,4 @@ +int main() { + const char *s = u8""; + return 0; // break here +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b8dab9b - [lldb] Remove some debugging printfs from ITSession code
Author: Raphael Isemann Date: 2020-03-24T18:09:27+01:00 New Revision: b8dab9b3d5b9b75f5ec9b8fed3e1c0586a82e3bf URL: https://github.com/llvm/llvm-project/commit/b8dab9b3d5b9b75f5ec9b8fed3e1c0586a82e3bf DIFF: https://github.com/llvm/llvm-project/commit/b8dab9b3d5b9b75f5ec9b8fed3e1c0586a82e3bf.diff LOG: [lldb] Remove some debugging printfs from ITSession code Summary: This seems only useful for debugging and it's just plainly printf'ing to the console instead of some log, so let's remove this. Reviewers: #lldb, JDevlieghere Reviewed By: JDevlieghere Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D76699 Added: Modified: lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Removed: diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index aa99db418283..34f88d2b4443 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -605,9 +605,6 @@ static uint32_t CountITSize(uint32_t ITMask) { // First count the trailing zeros of the IT mask. uint32_t TZ = llvm::countTrailingZeros(ITMask); if (TZ > 3) { -#ifdef LLDB_CONFIGURATION_DEBUG -printf("Encoding error: IT Mask ''\n"); -#endif return 0; } return (4 - TZ); @@ -622,15 +619,9 @@ bool ITSession::InitIT(uint32_t bits7_0) { // A8.6.50 IT unsigned short FirstCond = Bits32(bits7_0, 7, 4); if (FirstCond == 0xF) { -#ifdef LLDB_CONFIGURATION_DEBUG -printf("Encoding error: IT FirstCond ''\n"); -#endif return false; } if (FirstCond == 0xE && ITCounter != 1) { -#ifdef LLDB_CONFIGURATION_DEBUG -printf("Encoding error: IT FirstCond '1110' && Mask != '1000'\n"); -#endif return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6b6a779 - [lldb][NFC] Always update m_cache_{hits/misses} in FormatCache
Author: Raphael Isemann Date: 2020-03-24T20:16:43+01:00 New Revision: 6b6a779ca8ce4025ed0a38fbcfcb6c07334ace57 URL: https://github.com/llvm/llvm-project/commit/6b6a779ca8ce4025ed0a38fbcfcb6c07334ace57 DIFF: https://github.com/llvm/llvm-project/commit/6b6a779ca8ce4025ed0a38fbcfcb6c07334ace57.diff LOG: [lldb][NFC] Always update m_cache_{hits/misses} in FormatCache Summary: These two variables are only incremented under LLDB_CONFIGURATION_DEBUG but their value is always logged when verbose lldb formatter logging is enabled, which causes that our cache hit/miss log looks like this in non-Debug builds: ``` Cache hits: 0 - Cache Misses: 0 ... Cache hits: 0 - Cache Misses: 0 ... Cache hits: 0 - Cache Misses: 0 ``` This just always increments those two counters independent of build mode. Reviewers: JDevlieghere Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D76687 Added: Modified: lldb/include/lldb/DataFormatters/FormatCache.h lldb/source/DataFormatters/FormatCache.cpp Removed: diff --git a/lldb/include/lldb/DataFormatters/FormatCache.h b/lldb/include/lldb/DataFormatters/FormatCache.h index 581744c04f79..e75aaee1a7bb 100644 --- a/lldb/include/lldb/DataFormatters/FormatCache.h +++ b/lldb/include/lldb/DataFormatters/FormatCache.h @@ -49,13 +49,13 @@ class FormatCache { CacheMap m_map; std::recursive_mutex m_mutex; - uint64_t m_cache_hits; - uint64_t m_cache_misses; + uint64_t m_cache_hits = 0; + uint64_t m_cache_misses = 0; Entry (ConstString type); public: - FormatCache(); + FormatCache() = default; template bool Get(ConstString type, ImplSP _impl_sp); void Set(ConstString type, lldb::TypeFormatImplSP _sp); diff --git a/lldb/source/DataFormatters/FormatCache.cpp b/lldb/source/DataFormatters/FormatCache.cpp index f7e5c72f7781..5e0965fcdae4 100644 --- a/lldb/source/DataFormatters/FormatCache.cpp +++ b/lldb/source/DataFormatters/FormatCache.cpp @@ -51,15 +51,6 @@ void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) { m_synthetic_sp = synthetic_sp; } -FormatCache::FormatCache() -: m_map(), m_mutex() -#ifdef LLDB_CONFIGURATION_DEBUG - , - m_cache_hits(0), m_cache_misses(0) -#endif -{ -} - FormatCache::Entry ::GetEntry(ConstString type) { auto i = m_map.find(type), e = m_map.end(); if (i != e) @@ -87,15 +78,11 @@ bool FormatCache::Get(ConstString type, ImplSP _impl_sp) { std::lock_guard guard(m_mutex); auto entry = GetEntry(type); if (entry.IsCached()) { -#ifdef LLDB_CONFIGURATION_DEBUG m_cache_hits++; -#endif entry.Get(format_impl_sp); return true; } -#ifdef LLDB_CONFIGURATION_DEBUG m_cache_misses++; -#endif format_impl_sp.reset(); return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] aef982e - [lldb] Don't dump the frame in SBTarget::EvaluateExpression in LLDB_CONFIGURATION_DEBUG
Author: Raphael Isemann Date: 2020-03-24T20:16:09+01:00 New Revision: aef982e35acd2a0c4f6064308601658745e78cfc URL: https://github.com/llvm/llvm-project/commit/aef982e35acd2a0c4f6064308601658745e78cfc DIFF: https://github.com/llvm/llvm-project/commit/aef982e35acd2a0c4f6064308601658745e78cfc.diff LOG: [lldb] Don't dump the frame in SBTarget::EvaluateExpression in LLDB_CONFIGURATION_DEBUG Summary: Dumping the frame using the user-set format could cause that a debug LLDB doesn't behave as a release LLDB, which could potentially break replaying a reproducer. Also it's kinda strange that the frame format set by the user is used in the internal log output. Reviewers: JDevlieghere Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D76685 Added: Modified: lldb/source/API/SBTarget.cpp Removed: diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index a75104a12583..ca75e91bd906 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -2340,16 +2340,6 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, Target *target = exe_ctx.GetTargetPtr(); if (target) { -#ifdef LLDB_CONFIGURATION_DEBUG - StreamString frame_description; - if (frame) -frame->DumpUsingSettingsFormat(_description); - llvm::PrettyStackTraceFormat stack_trace( - "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " - "%u) %s", - expr, options.GetFetchDynamicValue(), - frame_description.GetString().str().c_str()); -#endif target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0ccc4de - [lldb] Always log if acquiring packet sequence mutex fails
Author: Raphael Isemann Date: 2020-03-24T20:24:50+01:00 New Revision: 0ccc4de42eae92d5a7a1b67b29d7921c7f144b8d URL: https://github.com/llvm/llvm-project/commit/0ccc4de42eae92d5a7a1b67b29d7921c7f144b8d DIFF: https://github.com/llvm/llvm-project/commit/0ccc4de42eae92d5a7a1b67b29d7921c7f144b8d.diff LOG: [lldb] Always log if acquiring packet sequence mutex fails Summary: Currently we only log in debug builds but I don't see why we would do this as this is neither expensive and seems useful. I looked into the git history of this code and it seems originally there was also an assert here and the logging here was the #else branch branch for non-Debug builds. Reviewers: #lldb, labath Reviewed By: labath Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D76698 Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Removed: diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index edbd408622f1..fdf1397d7a69 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2797,12 +2797,10 @@ size_t GDBRemoteCommunicationClient::GetCurrentThreadIDs( thread_ids.push_back(1); } } else { -#if !defined(LLDB_CONFIGURATION_DEBUG) Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); -LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending " - "packet 'qfThreadInfo'"); -#endif +LLDB_LOG(log, "error: failed to get packet sequence mutex, not sending " + "packet 'qfThreadInfo'"); sequence_mutex_unavailable = true; } return thread_ids.size(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] dee4cbc - [lldb][NFC] Remove some redundant comment containing just the file name
Author: Raphael Isemann Date: 2020-05-06T13:58:25+02:00 New Revision: dee4cbcd479f075ae33a8d3841fedde388c45782 URL: https://github.com/llvm/llvm-project/commit/dee4cbcd479f075ae33a8d3841fedde388c45782 DIFF: https://github.com/llvm/llvm-project/commit/dee4cbcd479f075ae33a8d3841fedde388c45782.diff LOG: [lldb][NFC] Remove some redundant comment containing just the file name Added: Modified: lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py Removed: diff --git a/lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py b/lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py index 23b26772554d..5346b9904ce5 100644 --- a/lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py +++ b/lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py @@ -1,4 +1,3 @@ -# TestMacABImacOSFramework.py import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a14f4a7 - tab completion for register read/write
Author: Gongyu Deng Date: 2020-05-07T18:14:27+02:00 New Revision: a14f4a7531f083a4820b5452808a1d003f1e88cc URL: https://github.com/llvm/llvm-project/commit/a14f4a7531f083a4820b5452808a1d003f1e88cc DIFF: https://github.com/llvm/llvm-project/commit/a14f4a7531f083a4820b5452808a1d003f1e88cc.diff LOG: tab completion for register read/write Summary: 1. Created a new common completion for the registers of the current context; 2. Apply this new common completion to the commands register read/write; 3. Unit test. Reviewers: teemperor, JDevlieghere Reviewed By: teemperor Tags: #lldb Differential Revision: https://reviews.llvm.org/D79490 Added: Modified: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectRegister.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 51f5a2e5705e..a6e025e72baf 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -34,10 +34,11 @@ class CommandCompletions { ePlatformPluginCompletion = (1u << 6), eArchitectureCompletion = (1u << 7), eVariablePathCompletion = (1u << 8), +eRegisterCompletion = (1u << 9), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 9) +eCustomCompletion = (1u << 10) }; static bool InvokeCommonCompletionCallbacks( @@ -81,6 +82,9 @@ class CommandCompletions { static void VariablePath(CommandInterpreter , CompletionRequest , SearchFilter *searcher); + + static void Registers(CommandInterpreter , +CompletionRequest , SearchFilter *searcher); }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index bc3a2ec4bd9e..1e903157c511 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -18,6 +18,7 @@ #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Variable.h" +#include "lldb/Target/RegisterContext.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/TildeExpressionResolver.h" @@ -55,6 +56,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames}, {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, {eVariablePathCompletion, CommandCompletions::VariablePath}, + {eRegisterCompletion, CommandCompletions::Registers}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -531,3 +533,20 @@ void CommandCompletions::VariablePath(CommandInterpreter , SearchFilter *searcher) { Variable::AutoComplete(interpreter.GetExecutionContext(), request); } + +void CommandCompletions::Registers(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher) { + std::string reg_prefix = ""; + if (request.GetCursorArgumentPrefix().startswith("$")) +reg_prefix = "$"; + + RegisterContext *reg_ctx = + interpreter.GetExecutionContext().GetRegisterContext(); + const size_t reg_num = reg_ctx->GetRegisterCount(); + for (size_t reg_idx = 0; reg_idx < reg_num; ++reg_idx) { +const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx); +request.TryCompleteCurrentArg(reg_prefix + reg_info->name, + reg_info->alt_name); + } +} \ No newline at end of file diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 2c5457396eca..56e8c3fb4b84 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -70,6 +70,17 @@ class CommandObjectRegisterRead : public CommandObjectParsed { ~CommandObjectRegisterRead() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +if (!m_exe_ctx.HasProcessScope()) + return; + +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eRegisterCompletion, +request, nullptr); + } + Options *GetOptions() override { return _option_group; } bool DumpRegister(const ExecutionContext _ctx, Stream , @@ -323,6 +334,17 @@
[Lldb-commits] [lldb] d7c2c2e - [lldb][NFC] Also initialize language_flags in ValueObject::Dereference
Author: Raphael Isemann Date: 2020-05-07T17:52:12+02:00 New Revision: d7c2c2ed79abd5446f8b485fe8249e1d3b78488d URL: https://github.com/llvm/llvm-project/commit/d7c2c2ed79abd5446f8b485fe8249e1d3b78488d DIFF: https://github.com/llvm/llvm-project/commit/d7c2c2ed79abd5446f8b485fe8249e1d3b78488d.diff LOG: [lldb][NFC] Also initialize language_flags in ValueObject::Dereference We currently rely on the TypeSystem implementation to initialize this value with 0 in the GetChildCompilerTypeAtIndex call below. Let's just initialize this variable like the rest. Added: Modified: lldb/source/Core/ValueObject.cpp Removed: diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 9e20ba76dccb..f80e86fc195b 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -2810,7 +2810,7 @@ ValueObjectSP ValueObject::Dereference(Status ) { const bool transparent_pointers = false; CompilerType compiler_type = GetCompilerType(); CompilerType child_compiler_type; -uint64_t language_flags; +uint64_t language_flags = 0; ExecutionContext exe_ctx(GetExecutionContextRef()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7b1f1cf - [lldb] Remove 'use_synthetic' parameters in ValueObject code
Author: Raphael Isemann Date: 2020-05-08T21:17:32+02:00 New Revision: 7b1f1cf1cf71ed143673a981074da642cfcde56e URL: https://github.com/llvm/llvm-project/commit/7b1f1cf1cf71ed143673a981074da642cfcde56e DIFF: https://github.com/llvm/llvm-project/commit/7b1f1cf1cf71ed143673a981074da642cfcde56e.diff LOG: [lldb] Remove 'use_synthetic' parameters in ValueObject code Summary: `CalculateSyntheticValue` and `GetSyntheticValue` have a `use_synthetic` parameter that makes the function do nothing when it's false. We obviously always pass true to the function (or check that the value we pass is true), because there really isn't any point calling with function with a `false`. This just removes all of this. Reviewers: labath, JDevlieghere, davide Reviewed By: davide Subscribers: davide Differential Revision: https://reviews.llvm.org/D79568 Added: Modified: lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/source/API/SBValue.cpp lldb/source/Core/ValueObject.cpp Removed: diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 35574f1a7647..1dd399ae7813 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -575,7 +575,7 @@ class ValueObject : public UserID { virtual lldb::ValueObjectSP GetNonSyntheticValue(); - lldb::ValueObjectSP GetSyntheticValue(bool use_synthetic = true); + lldb::ValueObjectSP GetSyntheticValue(); virtual bool HasSyntheticValue(); @@ -926,7 +926,7 @@ class ValueObject : public UserID { virtual bool HasDynamicValueTypeInfo() { return false; } - virtual void CalculateSyntheticValue(bool use_synthetic = true); + virtual void CalculateSyntheticValue(); // Should only be called by ValueObject::GetChildAtIndex() Returns a // ValueObject managed by this ValueObject's manager. diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index 8ff7f5052117..406586fb24f6 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -66,7 +66,7 @@ class ValueObjectSynthetic : public ValueObject { bool IsSynthetic() override { return true; } - void CalculateSyntheticValue(bool use_synthetic) override {} + void CalculateSyntheticValue() override {} bool IsDynamic() override { return ((m_parent != nullptr) ? m_parent->IsDynamic() : false); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 65a2a5046c58..7485b0ee1838 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -137,7 +137,7 @@ class ValueImpl { } if (m_use_synthetic) { - ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic); + ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(); if (synthetic_sp) value_sp = synthetic_sp; } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index f80e86fc195b..59bd0c0209b6 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1933,10 +1933,7 @@ ValueObject::GetSyntheticExpressionPathChild(const char *expression, return synthetic_child_sp; } -void ValueObject::CalculateSyntheticValue(bool use_synthetic) { - if (!use_synthetic) -return; - +void ValueObject::CalculateSyntheticValue() { TargetSP target_sp(GetTargetSP()); if (target_sp && !target_sp->GetEnableSyntheticValue()) { m_synthetic_value = nullptr; @@ -1988,11 +1985,8 @@ ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); } lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); } -ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) { - if (!use_synthetic) -return ValueObjectSP(); - - CalculateSyntheticValue(use_synthetic); +ValueObjectSP ValueObject::GetSyntheticValue() { + CalculateSyntheticValue(); if (m_synthetic_value) return m_synthetic_value->GetSP(); @@ -2006,7 +2000,7 @@ bool ValueObject::HasSyntheticValue() { if (m_synthetic_children_sp.get() == nullptr) return false; - CalculateSyntheticValue(true); + CalculateSyntheticValue(); return m_synthetic_value != nullptr; } @@ -3341,7 +3335,7 @@ lldb::ValueObjectSP ValueObjectManager::GetSP() { } if (m_use_synthetic) { -lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue(m_use_synthetic); +lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue(); if (synthetic_sp) m_user_valobj_sp = synthetic_sp; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] aa04ce7 - [lldb][NFC] Minor NamespaceMap refactor
Author: Raphael Isemann Date: 2020-05-20T15:29:20+02:00 New Revision: aa04ce761793bfff6de398091125823476a6e924 URL: https://github.com/llvm/llvm-project/commit/aa04ce761793bfff6de398091125823476a6e924 DIFF: https://github.com/llvm/llvm-project/commit/aa04ce761793bfff6de398091125823476a6e924.diff LOG: [lldb][NFC] Minor NamespaceMap refactor Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h index 8cdc1a817a08..ed32eac2b4af 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h @@ -102,8 +102,8 @@ class ClangASTImporter { // Namespace maps // - typedef std::vector> - NamespaceMap; + typedef std::pair NamespaceMapItem; + typedef std::vector NamespaceMap; typedef std::shared_ptr NamespaceMapSP; void RegisterNamespaceMap(const clang::NamespaceDecl *decl, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 7d66cc0c29f4..7d40cd0e8a0e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -676,13 +676,11 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)", namespace_map.get(), namespace_map->size()); -for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), - e = namespace_map->end(); - i != e; ++i) { +for (ClangASTImporter::NamespaceMapItem : *namespace_map) { LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}", - i->second.GetName(), i->first->GetFileSpec().GetFilename()); + n.second.GetName(), n.first->GetFileSpec().GetFilename()); - FindExternalVisibleDecls(context, i->first, i->second); + FindExternalVisibleDecls(context, n.first, n.second); } } else if (isa(context.m_decl_context)) { CompilerDeclContext namespace_decl; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bca378f - [lldb][NFC] Overload raw_ostream operator << for ConstString
Author: Raphael Isemann Date: 2020-05-22T11:24:48+02:00 New Revision: bca378f68a7d21f9da7d2f86a54fdbb5604b4d05 URL: https://github.com/llvm/llvm-project/commit/bca378f68a7d21f9da7d2f86a54fdbb5604b4d05 DIFF: https://github.com/llvm/llvm-project/commit/bca378f68a7d21f9da7d2f86a54fdbb5604b4d05.diff LOG: [lldb][NFC] Overload raw_ostream operator << for ConstString Summary: We are not doing this very often, but sometimes it's convenient when I can just << ConstStrings into llvm::errs() during testing. Reviewers: labath, JDevlieghere Reviewed By: labath, JDevlieghere Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D80310 Added: Modified: lldb/include/lldb/Utility/ConstString.h lldb/source/Core/Section.cpp lldb/source/Symbol/Function.cpp Removed: diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h index c2419407f2f6..1e55b2ebb957 100644 --- a/lldb/include/lldb/Utility/ConstString.h +++ b/lldb/include/lldb/Utility/ConstString.h @@ -490,6 +490,11 @@ template <> struct ScalarTraits { static QuotingType mustQuote(StringRef S) { return QuotingType::Double; } }; } // namespace yaml + +inline raw_ostream <<(raw_ostream , lldb_private::ConstString s) { + os << s.GetStringRef(); + return os; +} } // namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ConstString) diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index ce4715721ee7..9bf1c62c5ab8 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -337,7 +337,7 @@ void Section::DumpName(llvm::raw_ostream ) const { if (name && name[0]) s << name << '.'; } - s << m_name.GetStringRef(); + s << m_name; } bool Section::IsDescendant(const Section *section) { diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 0b1f6a8c3a3d..953c77632e01 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -374,9 +374,9 @@ void Function::GetDescription(Stream *s, lldb::DescriptionLevel level, *s << "id = " << (const UserID &)*this; if (name) -*s << ", name = \"" << name.GetCString() << '"'; +s->AsRawOstream() << ", name = \"" << name << '"'; if (mangled) -*s << ", mangled = \"" << mangled.GetCString() << '"'; +s->AsRawOstream() << ", mangled = \"" << mangled << '"'; *s << ", range = "; Address::DumpStyle fallback_style; if (level == eDescriptionLevelVerbose) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5f88f39 - [lldb] Enable C++14 when evaluating expressions in a C++14 frame
Author: Raphael Isemann Date: 2020-05-22T11:42:44+02:00 New Revision: 5f88f39ab8154682c3b1eb9d7050a9412a55d9e7 URL: https://github.com/llvm/llvm-project/commit/5f88f39ab8154682c3b1eb9d7050a9412a55d9e7 DIFF: https://github.com/llvm/llvm-project/commit/5f88f39ab8154682c3b1eb9d7050a9412a55d9e7.diff LOG: [lldb] Enable C++14 when evaluating expressions in a C++14 frame Summary: Currently we never enable C++14 in the expression evaluator. This enables it when the language of the program is C++14. It seems C++17 and so on isn't yet in any of the language enums (and the DWARF standard it seems), so C++17 support will be a follow up patch. Reviewers: labath, JDevlieghere Reviewed By: labath, JDevlieghere Subscribers: aprantl Differential Revision: https://reviews.llvm.org/D80308 Added: lldb/test/API/lang/cpp/standards/cpp11/Makefile lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py lldb/test/API/lang/cpp/standards/cpp11/main.cpp lldb/test/API/lang/cpp/standards/cpp14/Makefile lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py lldb/test/API/lang/cpp/standards/cpp14/main.cpp Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 8885cbc85b2c..877d75cfec30 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -491,9 +491,11 @@ ClangExpressionParser::ClangExpressionParser( // be re-evaluated in the future. lang_opts.CPlusPlus11 = true; break; + case lldb::eLanguageTypeC_plus_plus_14: +lang_opts.CPlusPlus14 = true; +LLVM_FALLTHROUGH; case lldb::eLanguageTypeC_plus_plus: case lldb::eLanguageTypeC_plus_plus_11: - case lldb::eLanguageTypeC_plus_plus_14: lang_opts.CPlusPlus11 = true; m_compiler->getHeaderSearchOpts().UseLibcxx = true; LLVM_FALLTHROUGH; diff --git a/lldb/test/API/lang/cpp/standards/cpp11/Makefile b/lldb/test/API/lang/cpp/standards/cpp11/Makefile new file mode 100644 index ..e78030cbf752 --- /dev/null +++ b/lldb/test/API/lang/cpp/standards/cpp11/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp +CXXFLAGS_EXTRAS := -std=c++11 + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py b/lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py new file mode 100644 index ..e4162c09758f --- /dev/null +++ b/lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py @@ -0,0 +1,19 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def test(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) + +# Run an expression that is valid in C++11 (as it uses nullptr). +self.expect_expr("nullptr == nullptr", result_type="bool", result_value="true") + +# Run a expression that is not valid in C++11 (as it uses polymorphic +# lambdas from C++14). +self.expect("expr [](auto x) { return x; }(1)", error=True, substrs=["'auto' not allowed in lambda parameter"]) diff --git a/lldb/test/API/lang/cpp/standards/cpp11/main.cpp b/lldb/test/API/lang/cpp/standards/cpp11/main.cpp new file mode 100644 index ..ba45ee316cd4 --- /dev/null +++ b/lldb/test/API/lang/cpp/standards/cpp11/main.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; // break here +} diff --git a/lldb/test/API/lang/cpp/standards/cpp14/Makefile b/lldb/test/API/lang/cpp/standards/cpp14/Makefile new file mode 100644 index ..a27336ffd9ac --- /dev/null +++ b/lldb/test/API/lang/cpp/standards/cpp14/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp +CXXFLAGS_EXTRAS := -std=c++14 + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py b/lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py new file mode 100644 index ..3422cf19b3d7 --- /dev/null +++ b/lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py @@ -0,0 +1,19 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def test(self): +self.build() +lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) + +# Run an expression that is valid in C++11 (as it uses nullptr). +self.expect_expr("nullptr == nullptr", result_type="bool", result_value="true") + +# Run a expression
[Lldb-commits] [lldb] bdc4c0b - Revert "[lldb] avoid assert in threadsanitizer tests on linux"
Author: Raphael Isemann Date: 2020-09-04T09:30:56+02:00 New Revision: bdc4c0bc5c5e522aa770363fa6f50a3d5a5eadc2 URL: https://github.com/llvm/llvm-project/commit/bdc4c0bc5c5e522aa770363fa6f50a3d5a5eadc2 DIFF: https://github.com/llvm/llvm-project/commit/bdc4c0bc5c5e522aa770363fa6f50a3d5a5eadc2.diff LOG: Revert "[lldb] avoid assert in threadsanitizer tests on linux" This reverts commit f369d51896e1c0f61df253b116c42771479549df. The bug this fixes was already fixed by 1c5a0cb1c3bffdae0d73acf8a23e31646b35c596 with the same approach and this commit is now just giving the variable a second fallback value. Added: Modified: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp Removed: diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp index 68e732538158..a2954f556b10 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -855,8 +855,6 @@ bool InstrumentationRuntimeTSan::NotifyBreakpointHit( }); report->GetAsDictionary()->AddBooleanItem("all_addresses_are_same", all_addresses_are_same); - } else { -stop_reason_description = "unknown ThreadSanitizer stop reason"; } // Make sure this is the right process ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7c80f2d - Revert "[lldb] Add reproducer verifier"
Author: Raphael Isemann Date: 2020-09-01T12:21:44+02:00 New Revision: 7c80f2da812e45bbdfa3c8f9ab24440f8ef3362a URL: https://github.com/llvm/llvm-project/commit/7c80f2da812e45bbdfa3c8f9ab24440f8ef3362a DIFF: https://github.com/llvm/llvm-project/commit/7c80f2da812e45bbdfa3c8f9ab24440f8ef3362a.diff LOG: Revert "[lldb] Add reproducer verifier" This reverts commit 297f69afac58fc9dc13897857a5e70131c5adc85. It broke the Fedora 33 x86-64 bot. See the review for more info. Added: Modified: lldb/include/lldb/API/SBReproducer.h lldb/include/lldb/Utility/Reproducer.h lldb/source/API/SBReproducer.cpp lldb/source/Commands/CommandObjectReproducer.cpp lldb/source/Commands/Options.td lldb/source/Utility/Reproducer.cpp lldb/source/Utility/ReproducerProvider.cpp lldb/test/Shell/Reproducer/TestDebugSymbols.test lldb/tools/driver/Driver.cpp lldb/tools/driver/Options.td llvm/include/llvm/Support/VirtualFileSystem.h llvm/lib/Support/VirtualFileSystem.cpp Removed: lldb/test/Shell/Reproducer/TestVerify.test diff --git a/lldb/include/lldb/API/SBReproducer.h b/lldb/include/lldb/API/SBReproducer.h index 5578162412c8..78044e9acbc3 100644 --- a/lldb/include/lldb/API/SBReproducer.h +++ b/lldb/include/lldb/API/SBReproducer.h @@ -11,32 +11,8 @@ #include "lldb/API/SBDefines.h" -namespace lldb_private { -namespace repro { -struct ReplayOptions; -} -} // namespace lldb_private - namespace lldb { -class LLDB_API SBReplayOptions { -public: - SBReplayOptions(); - SBReplayOptions(const SBReplayOptions ); - ~SBReplayOptions(); - - SBReplayOptions =(const SBReplayOptions ); - - void SetVerify(bool verify); - bool GetVerify() const; - - void SetCheckVersion(bool check); - bool GetCheckVersion() const; - -private: - std::unique_ptr m_opaque_up; -}; - /// The SBReproducer class is special because it bootstraps the capture and /// replay of SB API calls. As a result we cannot rely on any other SB objects /// in the interface or implementation of this class. @@ -46,7 +22,6 @@ class LLDB_API SBReproducer { static const char *Capture(const char *path); static const char *Replay(const char *path); static const char *Replay(const char *path, bool skip_version_check); - static const char *Replay(const char *path, const SBReplayOptions ); static const char *PassiveReplay(const char *path); static const char *GetPath(); static bool SetAutoGenerate(bool b); diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h index 7e5591493d71..d6cde4485090 100644 --- a/lldb/include/lldb/Utility/Reproducer.h +++ b/lldb/include/lldb/Utility/Reproducer.h @@ -227,22 +227,6 @@ class Reproducer { mutable std::mutex m_mutex; }; -class Verifier { -public: - Verifier(Loader *loader) : m_loader(loader) {} - void Verify(llvm::function_ref error_callback, - llvm::function_ref warning_callback, - llvm::function_ref note_callback) const; - -private: - Loader *m_loader; -}; - -struct ReplayOptions { - bool verify = true; - bool check_version = true; -}; - } // namespace repro } // namespace lldb_private diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index 233e0b5b..7d08a88fe9e3 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -30,33 +30,6 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::repro; -SBReplayOptions::SBReplayOptions() -: m_opaque_up(std::make_unique()){}; - -SBReplayOptions::SBReplayOptions(const SBReplayOptions ) -: m_opaque_up(std::make_unique(*rhs.m_opaque_up)) {} - -SBReplayOptions::~SBReplayOptions() = default; - -SBReplayOptions ::operator=(const SBReplayOptions ) { - if (this == ) -return *this; - *m_opaque_up = *rhs.m_opaque_up; - return *this; -} - -void SBReplayOptions::SetVerify(bool verify) { m_opaque_up->verify = verify; } - -bool SBReplayOptions::GetVerify() const { return m_opaque_up->verify; } - -void SBReplayOptions::SetCheckVersion(bool check) { - m_opaque_up->check_version = check; -} - -bool SBReplayOptions::GetCheckVersion() const { - return m_opaque_up->check_version; -} - SBRegistry::SBRegistry() { Registry = *this; @@ -190,18 +163,10 @@ const char *SBReproducer::PassiveReplay(const char *path) { } const char *SBReproducer::Replay(const char *path) { - SBReplayOptions options; - return SBReproducer::Replay(path, options); + return SBReproducer::Replay(path, false); } const char *SBReproducer::Replay(const char *path, bool skip_version_check) { - SBReplayOptions options; - options.SetCheckVersion(!skip_version_check); - return SBReproducer::Replay(path, options); -} - -const char *SBReproducer::Replay(const char *path, - const SBReplayOptions ) { static std::string error; if (auto e =
[Lldb-commits] [lldb] 1c5a0cb - [lldb] Don't crash when LLDB can't extract the tsan report
Author: Raphael Isemann Date: 2020-08-31T11:13:11+02:00 New Revision: 1c5a0cb1c3bffdae0d73acf8a23e31646b35c596 URL: https://github.com/llvm/llvm-project/commit/1c5a0cb1c3bffdae0d73acf8a23e31646b35c596 DIFF: https://github.com/llvm/llvm-project/commit/1c5a0cb1c3bffdae0d73acf8a23e31646b35c596.diff LOG: [lldb] Don't crash when LLDB can't extract the tsan report Right now all tsan tests are crashing on Linux. The tests were already marked as expected failures, but since commit 20ce8affce85d added an assert that every StopInfo needs a non-empty stop description the tests actually started crash (which is even with an expectedFailure a failed test). The reason for that is that we never had any stop description when hitting tsan errors on Linux. Before the assert that just made the test fail, but now the empty description is hitting the assert. This patch just adds a generic stop description mentioning tsan to prevent that we hit that assert on platforms where we don't support extracting the tsan report. Reviewed By: friss Differential Revision: https://reviews.llvm.org/D86593 Added: Modified: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp Removed: diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp index 50f0faefa0f4..a2954f556b10 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -809,7 +809,9 @@ bool InstrumentationRuntimeTSan::NotifyBreakpointHit( StructuredData::ObjectSP report = instance->RetrieveReportData(context->exe_ctx_ref); - std::string stop_reason_description; + std::string stop_reason_description = + "unknown thread sanitizer fault (unable to extract thread sanitizer " + "report)"; if (report) { std::string issue_description = instance->FormatDescription(report); report->GetAsDictionary()->AddStringItem("description", issue_description); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] da0d43d - [lldb][NFC] Remove trailing whitespace in TestCompletion
Author: Raphael Isemann Date: 2020-08-31T12:24:25+02:00 New Revision: da0d43d90a4f931466ecdd9bc27c47fa45cc6c21 URL: https://github.com/llvm/llvm-project/commit/da0d43d90a4f931466ecdd9bc27c47fa45cc6c21 DIFF: https://github.com/llvm/llvm-project/commit/da0d43d90a4f931466ecdd9bc27c47fa45cc6c21.diff LOG: [lldb][NFC] Remove trailing whitespace in TestCompletion Added: Modified: lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index f4d361593e48..befa1dbc2b58 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -44,9 +44,9 @@ def test_frame_variable(self): (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec) self.assertEquals(process.GetState(), lldb.eStateStopped) - -# Since CommandInterpreter has been corrected to update the current execution -# context at the beginning of HandleCompletion, we're here explicitly testing + +# Since CommandInterpreter has been corrected to update the current execution +# context at the beginning of HandleCompletion, we're here explicitly testing # the scenario where "frame var" is completed without any preceding commands. self.complete_from_to('frame variable fo', @@ -133,7 +133,7 @@ def completions_contain_str(self, input, needle): @skipIfRemote def test_common_completion_process_pid_and_name(self): # The LLDB process itself and the process already attached to are both -# ignored by the process discovery mechanism, thus we need a process known +# ignored by the process discovery mechanism, thus we need a process known # to us here. self.build() server = self.spawnSubprocess( @@ -562,7 +562,7 @@ def test_common_completion_frame_index(self): self.complete_from_to('frame select ', ['0']) self.complete_from_to('thread backtrace -s ', ['0']) - + def test_frame_recognizer_delete(self): self.runCmd("frame recognizer add -l py_class -s module_name -n recognizer_name") self.check_completion_with_desc('frame recognizer delete ', [['0', 'py_class, module module_name, symbol recognizer_name']]) @@ -693,7 +693,7 @@ def test_complete_breakpoint_with_ids(self): for subcommand in subcommands: self.complete_from_to('breakpoint ' + subcommand + ' ', ['1']) - + bp2 = target.BreakpointCreateByName('Bar', 'a.out') self.assertTrue(bp2) self.assertEqual(bp2.GetNumLocations(), 1) @@ -702,7 +702,7 @@ def test_complete_breakpoint_with_ids(self): self.complete_from_to('breakpoint ' + subcommand + ' ', ['1', '2']) - + for subcommand in subcommands: self.complete_from_to('breakpoint ' + subcommand + ' 1 ', ['1', ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b51321c - [lldb] Fix TestCompletion's pid completion failing randomly
Author: Raphael Isemann Date: 2020-08-31T12:22:41+02:00 New Revision: b51321ccc894f6ed512c27cb43b1f04883d5ed0e URL: https://github.com/llvm/llvm-project/commit/b51321ccc894f6ed512c27cb43b1f04883d5ed0e DIFF: https://github.com/llvm/llvm-project/commit/b51321ccc894f6ed512c27cb43b1f04883d5ed0e.diff LOG: [lldb] Fix TestCompletion's pid completion failing randomly TestCompletion is randomly failing on some bots. The error message however states that the computed completions actually do contain the expected pid we're looking for, so there shouldn't be any test failure. The reason for that turns out to be that complete_from_to is actually used for testing two different features. It can be used for testing what the common prefix for the list of completions is and *also* for checking all the possible completions that are returned for a command. Which one of the two things should be checked can't be defined by a parameter to the function, but is instead guessed by the test method instead based on the results that were returned. If there is a common prefix in all completions, then that prefix is searched and otherwise all completions are searched. For TestCompletion's pid test this behaviour leads to the strange test failures. If all the pid's that our test LLDB can see have a common prefix (e.g., it can only see pids [123, 122, 10004, 1] -> common prefix '1'), then complete_from_to check that the common prefix contains our pid, which is always fails ('1' doesn't contain '123' or any other valid pid). If there isn't a common prefix (e.g., pids are [123, 122, 10004, 777]) then complete_from_to will check the list of completions instead which works correctly. This patch is fixing this by adding a simple check method that doesn't have this behaviour and is simply searching the returned list of completions. This should get the bots green while I'm working on a proper fix that fixes complete_from_to. Added: Modified: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 112b19abab39..dacd5ed734b5 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2296,6 +2296,17 @@ def completions_match(self, command, completions): self.assertItemsEqual(completions, list(match_strings)[1:], "List of returned completion is wrong") +def completions_contain(self, command, completions): +"""Checks that the completions for the given command contain the given +list of completions.""" +interp = self.dbg.GetCommandInterpreter() +match_strings = lldb.SBStringList() +interp.HandleCompletion(command, len(command), 0, -1, match_strings) +for completion in completions: +# match_strings is a 1-indexed list, so we have to slice... +self.assertIn(completion, list(match_strings)[1:], + "Couldn't find expected completion") + def filecheck( self, command, diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index b80594b7568b..f4d361593e48 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -143,9 +143,9 @@ def test_common_completion_process_pid_and_name(self): self.assertIsNotNone(server) pid = server.pid -self.complete_from_to('process attach -p ', [str(pid)]) -self.complete_from_to('platform process attach -p ', [str(pid)]) -self.complete_from_to('platform process info ', [str(pid)]) +self.completions_contain('process attach -p ', [str(pid)]) +self.completions_contain('platform process attach -p ', [str(pid)]) +self.completions_contain('platform process info ', [str(pid)]) self.completions_contain_str('process attach -n ', "a.out") self.completions_contain_str('platform process attach -n ', "a.out") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1cd99fe - [lldb] tab completion for class `CommandObjectTypeFormatterDelete`
Author: Gongyu Deng Date: 2020-08-31T14:18:07+02:00 New Revision: 1cd99fe9d4166bbe72b0b935b40bbb41cdc0a6c8 URL: https://github.com/llvm/llvm-project/commit/1cd99fe9d4166bbe72b0b935b40bbb41cdc0a6c8 DIFF: https://github.com/llvm/llvm-project/commit/1cd99fe9d4166bbe72b0b935b40bbb41cdc0a6c8.diff LOG: [lldb] tab completion for class `CommandObjectTypeFormatterDelete` 1. Added a dedicated completion to class `CommandObjectTypeFormatterDelete` which can be used by these commands: `type filter/format/summary/synthetic delete`; 2. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D84142 Added: Modified: lldb/include/lldb/DataFormatters/FormattersContainer.h lldb/source/Commands/CommandObjectType.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index aebccbe413cc..2f56218c43a7 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -202,6 +202,13 @@ template class FormattersContainer { return m_map.size(); } + void AutoComplete(CompletionRequest ) { +ForEach([](const TypeMatcher , const ValueSP ) { + request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef()); + return true; +}); + } + protected: FormattersContainer(const FormattersContainer &) = delete; const FormattersContainer =(const FormattersContainer &) = delete; diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index d820e7abd21f..004c066b57aa 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -37,6 +37,9 @@ #include #include +#define CHECK_FORMATTER_KIND_MASK(VAL) \ + ((m_formatter_kind_mask & (VAL)) == (VAL)) + using namespace lldb; using namespace lldb_private; @@ -777,6 +780,39 @@ class CommandObjectTypeFormatterDelete : public CommandObjectParsed { ~CommandObjectTypeFormatterDelete() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +if (request.GetCursorIndex()) + return; + +DataVisualization::Categories::ForEach( +[this, ](const lldb::TypeCategoryImplSP _sp) { + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemValue)) +category_sp->GetTypeFormatsContainer()->AutoComplete(request); + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexValue)) +category_sp->GetRegexTypeFormatsContainer()->AutoComplete(request); + + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSummary)) +category_sp->GetTypeSummariesContainer()->AutoComplete(request); + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexSummary)) +category_sp->GetRegexTypeSummariesContainer()->AutoComplete( +request); + + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemFilter)) +category_sp->GetTypeFiltersContainer()->AutoComplete(request); + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexFilter)) +category_sp->GetRegexTypeFiltersContainer()->AutoComplete(request); + + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSynth)) +category_sp->GetTypeSyntheticsContainer()->AutoComplete(request); + if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexSynth)) +category_sp->GetRegexTypeSyntheticsContainer()->AutoComplete( +request); + return true; +}); + } + protected: virtual bool FormatterSpecificDeletion(ConstString typeCS) { return false; } diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index befa1dbc2b58..4e78b6e23730 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -581,6 +581,27 @@ def test_symbol_name(self): # (anonymous namespace)::Quux(). self.complete_from_to('breakpoint set -n Qu', '') +def test_completion_type_formatter_delete(self): +self.runCmd('type filter add --child a Aoo') +self.complete_from_to('type filter delete ', ['Aoo']) +self.runCmd('type filter add --child b -x Boo') +self.complete_from_to('type filter delete ', ['Boo']) + +self.runCmd('type format add -f hex Coo') +self.complete_from_to('type format delete ', ['Coo']) +self.runCmd('type format add -f hex -x Doo') +self.complete_from_to('type format delete ', ['Doo']) + +self.runCmd('type summary add
[Lldb-commits] [lldb] f9ad112 - [lldb] Speed up TestValueObjectRecursion by making it a no_debug_info_test
Author: Raphael Isemann Date: 2020-09-04T11:25:43+02:00 New Revision: f9ad112770ece2e3612ddcdd6a4157bc0b0faf31 URL: https://github.com/llvm/llvm-project/commit/f9ad112770ece2e3612ddcdd6a4157bc0b0faf31 DIFF: https://github.com/llvm/llvm-project/commit/f9ad112770ece2e3612ddcdd6a4157bc0b0faf31.diff LOG: [lldb] Speed up TestValueObjectRecursion by making it a no_debug_info_test This is one of the most expensive tests and runs for nearly half a minute on my machine. Beside this test just doing a lot of work by iterating 15k times on one ValueObject (which seems to be the point), it also runs this for every debug info variant which doesn't seem relevant to just iterating ValueObject. This marks it as no_debug_info_test to only run one debug info variation and cut down the runtime to around 7 seconds on my machine. Added: Modified: lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py Removed: diff --git a/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py b/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py index e949f1a1a07e..1653fe36af7b 100644 --- a/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py +++ b/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py @@ -6,6 +6,7 @@ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -20,6 +21,7 @@ def setUp(self): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') +@no_debug_info_test def test_with_run_command(self): """Test that deeply nested ValueObjects still work.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 101f37a - [lldb][NFC] Rewrite CPP11EnumTypes test to make it faster
Author: Raphael Isemann Date: 2020-09-04T13:45:42+02:00 New Revision: 101f37a1b330e3f0ae57762db47bba28f72cf50d URL: https://github.com/llvm/llvm-project/commit/101f37a1b330e3f0ae57762db47bba28f72cf50d DIFF: https://github.com/llvm/llvm-project/commit/101f37a1b330e3f0ae57762db47bba28f72cf50d.diff LOG: [lldb][NFC] Rewrite CPP11EnumTypes test to make it faster TestCPP11EnumTypes is one of the most expensive tests on my system and takes around 35 seconds to run. A relatively large amount of that time is actually doing CPU intensive work it seems (and not waiting on timeouts like other slow tests). The main issue is that this test repeatedly compiles the same source files with different compiler defines. The test is also including standard library headers, so it will also build all system modules with the gmodules debug info variant. This leads to the problem that this test ends up compiling all system Clang modules 8 times (one for each subtest with a unique define). As the system modules are quite large, this causes that this test spends most of its runtime just recompiling all system modules on macOS. There is also the small issue that this test is starting and start-stopping the test process a few hundred times. This rewrites the test to instead just use a macro to instantiate all the enum types in a single source and uses global variables to test the values (which means there is no more need to continue/stop or even start a process). I kept running all the debug info variants (event though it doesn't seem really relevant) to keep this as NFC as possible. This reduced the test runtime by around 1.5 seconds on my system (or in relative numbers, the runtime of this test decreases by 95%). Added: Modified: lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py lldb/test/API/lang/cpp/enum_types/main.cpp Removed: diff --git a/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py b/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py index c58f700039eb..d40eee0cb1b0 100644 --- a/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -1,7 +1,5 @@ """Look up enum type information and check for correct display.""" - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -12,145 +10,45 @@ class CPP11EnumTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_int8_t(self): -"""Test C++11 enumeration class types as int8_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int8_t"'}) -self.image_lookup_for_enum_type(True) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_int16_t(self): -"""Test C++11 enumeration class types as int16_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int16_t"'}) -self.image_lookup_for_enum_type(True) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_int32_t(self): -"""Test C++11 enumeration class types as int32_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int32_t"'}) -self.image_lookup_for_enum_type(True) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_int64_t(self): -"""Test C++11 enumeration class types as int64_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int64_t"'}) -self.image_lookup_for_enum_type(True) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_uint8_t(self): -"""Test C++11 enumeration class types as uint8_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint8_t"'}) -self.image_lookup_for_enum_type(False) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_uint16_t(self): -"""Test C++11 enumeration class types as uint16_t types.""" -self.build( -dictionary={ -'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint16_t"'}) -self.image_lookup_for_enum_type(False) - -@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') -@skipIf(dwarf_version=['<', '4']) -def test_uint32_t(self): -"""Test C++11
[Lldb-commits] [lldb] f0699d9 - [debugserver] Fix that debugserver's stop reply packets always return signal code 0
Author: Raphael Isemann Date: 2020-09-03T09:47:03+02:00 New Revision: f0699d9109143754088c26604c58f5ab3e9d4678 URL: https://github.com/llvm/llvm-project/commit/f0699d9109143754088c26604c58f5ab3e9d4678 DIFF: https://github.com/llvm/llvm-project/commit/f0699d9109143754088c26604c58f5ab3e9d4678.diff LOG: [debugserver] Fix that debugserver's stop reply packets always return signal code 0 If our process terminates due to an unhandled signal, we are supposed to get the signal code via WTERMSIG. However, we instead try to get the exit status via WEXITSTATUS which just ends up always calculating signal code 0 (at least on the macOS implementation where it just shifts the signal code bits away and we're left with only 0 bits). The exit status calculation on the LLDB side also seems a bit off as it claims an exit status that is just the signal code (instead of for example 128 + signal code), but that will be another patch. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D86336 Added: lldb/test/Shell/Process/Inputs/abort.c lldb/test/Shell/Process/TestAbortExitCode.test Modified: lldb/tools/debugserver/source/RNBRemote.cpp Removed: diff --git a/lldb/test/Shell/Process/Inputs/abort.c b/lldb/test/Shell/Process/Inputs/abort.c new file mode 100644 index ..9edc9336dc3e --- /dev/null +++ b/lldb/test/Shell/Process/Inputs/abort.c @@ -0,0 +1,3 @@ +#include + +int main(int argc, char **argv) { abort(); } diff --git a/lldb/test/Shell/Process/TestAbortExitCode.test b/lldb/test/Shell/Process/TestAbortExitCode.test new file mode 100644 index ..a61c09505112 --- /dev/null +++ b/lldb/test/Shell/Process/TestAbortExitCode.test @@ -0,0 +1,6 @@ +UNSUPPORTED: system-windows + +RUN: %clang_host %p/Inputs/abort.c -o %t +RUN: %lldb %t -o run -o continue | FileCheck %s + +CHECK: status = 6 (0x0006) Terminated due to signal 6 diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 5e2512731f39..b66cc8f583e8 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -3066,7 +3066,7 @@ rnb_err_t RNBRemote::HandlePacket_last_signal(const char *unused) { WEXITSTATUS(pid_status)); else if (WIFSIGNALED(pid_status)) snprintf(pid_exited_packet, sizeof(pid_exited_packet), "X%02x", - WEXITSTATUS(pid_status)); + WTERMSIG(pid_status)); else if (WIFSTOPPED(pid_status)) snprintf(pid_exited_packet, sizeof(pid_exited_packet), "S%02x", WSTOPSIG(pid_status)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e123959 - [lldb] Remove debugserver specific string from TestAbortExitCode check
Author: Raphael Isemann Date: 2020-09-03T10:03:02+02:00 New Revision: e123959e94716ef6b5942060ac5934f696eaa3d3 URL: https://github.com/llvm/llvm-project/commit/e123959e94716ef6b5942060ac5934f696eaa3d3 DIFF: https://github.com/llvm/llvm-project/commit/e123959e94716ef6b5942060ac5934f696eaa3d3.diff LOG: [lldb] Remove debugserver specific string from TestAbortExitCode check The test only checks the exit code that the debug server sends back, but not the following explanation which is different for debugserver and lldb-server. Added: Modified: lldb/test/Shell/Process/TestAbortExitCode.test Removed: diff --git a/lldb/test/Shell/Process/TestAbortExitCode.test b/lldb/test/Shell/Process/TestAbortExitCode.test index a61c09505112..5be0a15ab172 100644 --- a/lldb/test/Shell/Process/TestAbortExitCode.test +++ b/lldb/test/Shell/Process/TestAbortExitCode.test @@ -3,4 +3,4 @@ UNSUPPORTED: system-windows RUN: %clang_host %p/Inputs/abort.c -o %t RUN: %lldb %t -o run -o continue | FileCheck %s -CHECK: status = 6 (0x0006) Terminated due to signal 6 +CHECK: status = 6 (0x0006) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5b354d2 - [lldb] Make symbol list output from `image dump symtab` not depend on internal ordering of DenseMap
Author: Raphael Isemann Date: 2020-09-03T10:27:19+02:00 New Revision: 5b354d204d0952a6dd39e41fb41b51414bff5f0b URL: https://github.com/llvm/llvm-project/commit/5b354d204d0952a6dd39e41fb41b51414bff5f0b DIFF: https://github.com/llvm/llvm-project/commit/5b354d204d0952a6dd39e41fb41b51414bff5f0b.diff LOG: [lldb] Make symbol list output from `image dump symtab` not depend on internal ordering of DenseMap `image dump symtab` seems to output the symbols in whatever order they appear in the DenseMap that is used to filter out symbols with non-unique addresses. As DenseMap is a hash map this order can change at any time so the output of this command is pretty unstable. This also causes the `Breakpad/symtab.test` to fail with enabled reverse iteration (which reverses the DenseMap order to find issues like this). This patch makes the DenseMap a std::vector and uses a separate DenseSet to do the address filtering. The output order is now dependent on the order in which the symbols are read (which should be deterministic). It might also avoid a bit of work as all the work for creating the Symbol constructor parameters is only done when we can actually emplace a new Symbol. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D87036 Added: Modified: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp lldb/test/Shell/SymbolFile/Breakpad/symtab.test Removed: diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index eeec7296747e..07e5b284eab8 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -326,7 +326,8 @@ void SymbolFileBreakpad::AddSymbols(Symtab ) { } const SectionList = *module.GetSectionList(); - llvm::DenseMap symbols; + llvm::DenseSet found_symbol_addresses; + std::vector symbols; auto add_symbol = [&](addr_t address, llvm::Optional size, llvm::StringRef name) { address += base; @@ -338,8 +339,12 @@ void SymbolFileBreakpad::AddSymbols(Symtab ) { name, address); return; } -symbols.try_emplace( -address, /*symID*/ 0, Mangled(name), eSymbolTypeCode, +// Keep track of what addresses were already added so far and only add +// the symbol with the first address. +if (!found_symbol_addresses.insert(address).second) + return; +symbols.emplace_back( +/*symID*/ 0, Mangled(name), eSymbolTypeCode, /*is_global*/ true, /*is_debug*/ false, /*is_trampoline*/ false, /*is_artificial*/ false, AddressRange(section_sp, address - section_sp->GetFileAddress(), @@ -359,8 +364,8 @@ void SymbolFileBreakpad::AddSymbols(Symtab ) { LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line); } - for (auto : symbols) -symtab.AddSymbol(std::move(KV.second)); + for (Symbol : symbols) +symtab.AddSymbol(std::move(symbol)); symtab.CalculateSymbolSizes(); } diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test index a02d94c30aa3..1eb03fa43deb 100644 --- a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test @@ -6,10 +6,10 @@ # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5: # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name # CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out -# CHECK: [1] 0 X Code0x004000c0 0x0010 0x f2 -# CHECK: [2] 0 X Code0x004000d0 0x0022 0x _start -# CHECK: [3] 0 X Code0x004000a0 0x000d 0x func_only -# CHECK: [4] 0 X Code0x004000b0 0x000c 0x f1_func +# CHECK: [1] 0 X Code0x004000b0 0x000c 0x f1_func +# CHECK: [2] 0 X Code0x004000a0 0x000d 0x func_only +# CHECK: [3] 0 X Code0x004000c0 0x0010 0x f2 +# CHECK: [4] 0 X Code0x004000d0 0x0022 0x _start # CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v # CHECK: Address: symtab.out[0x004000b0] (symtab.out.PT_LOAD[0]..text2 + 0) ___ lldb-commits mailing list
[Lldb-commits] [lldb] 4e4a3fe - [lldb][doc] Mention python3-dev instead of python2.7-dev in build docs
Author: Raphael Isemann Date: 2020-09-09T09:31:27+02:00 New Revision: 4e4a3feecdb6bd56483b9c6ba9116609c20588aa URL: https://github.com/llvm/llvm-project/commit/4e4a3feecdb6bd56483b9c6ba9116609c20588aa DIFF: https://github.com/llvm/llvm-project/commit/4e4a3feecdb6bd56483b9c6ba9116609c20588aa.diff LOG: [lldb][doc] Mention python3-dev instead of python2.7-dev in build docs Added: Modified: lldb/docs/resources/build.rst Removed: diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst index c1cb6ec1a934..b5c1fb8cb001 100644 --- a/lldb/docs/resources/build.rst +++ b/lldb/docs/resources/build.rst @@ -71,7 +71,7 @@ commands below. :: > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig - > sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev + > sudo apt-get install build-essential subversion swig python3-dev libedit-dev libncurses5-dev > pkg install swig python > pkgin install swig python27 cmake ninja-build > brew install swig cmake ninja ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 32c8da4 - [lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType when trying to complete a forward decl
Author: Raphael Isemann Date: 2020-09-09T10:05:57+02:00 New Revision: 32c8da41dc0cb99651823a1a21130c2cbdf688e1 URL: https://github.com/llvm/llvm-project/commit/32c8da41dc0cb99651823a1a21130c2cbdf688e1 DIFF: https://github.com/llvm/llvm-project/commit/32c8da41dc0cb99651823a1a21130c2cbdf688e1.diff LOG: [lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType when trying to complete a forward decl SemaSourceWithPriorities is a special SemaSource that wraps our normal LLDB ExternalASTSource and the ASTReader (which is used for the C++ module loading). It's only active when the `import-std-module` setting is turned on. The `CompleteType` function there in `SemaSourceWithPriorities` is looping over all ExternalASTSources and asks each to complete the type. However, that loop is in another loop that keeps doing that until the type is complete. If that function is ever called on a type that is a forward decl then that causes LLDB to go into an infinite loop. I remember I added that second loop and the comment because I thought I saw a similar pattern in some other Clang code, but after some grepping I can't find that code anywhere and it seems the rest of the code base only calls CompleteType once (It would also be kinda silly to have calling it multiple times). So it seems that's just a silly mistake. The is implicitly tested by importing `std::pair`, but I also added a simpler dedicated test that creates a dummy libc++ module with some forward declarations and then imports them into the scratch AST context. At some point the ASTImporter will check if one of the forward decls could be completed by the ExternalASTSource, which will cause the `SemaSourceWithPriorities` to go into an infinite loop once it receives the `CompleteType` call. Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D87289 Added: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/main.cpp lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/module.modulemap lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/vector lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/libc_header.h Modified: lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h index 769b18d54ced..b70ec223df4d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h @@ -359,15 +359,12 @@ class SemaSourceWithPriorities : public clang::ExternalSemaSource { } void CompleteType(clang::TagDecl *Tag) override { -while (!Tag->isCompleteDefinition()) - for (size_t i = 0; i < Sources.size(); ++i) { -// FIXME: We are technically supposed to loop here too until -// Tag->isCompleteDefinition() is true, but if our low quality source -// is failing to complete the tag this code will deadlock. -Sources[i]->CompleteType(Tag); -if (Tag->isCompleteDefinition()) - break; - } +for (clang::ExternalSemaSource *S : Sources) { + S->CompleteType(Tag); + // Stop after the first source completed the type. + if (Tag->isCompleteDefinition()) +break; +} } void CompleteType(clang::ObjCInterfaceDecl *Class) override { diff --git a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile new file mode 100644 index ..4915cdae8764 --- /dev/null +++ b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile @@ -0,0 +1,9 @@ +# We don't have any standard include directories, so we can't +# parse the test_common.h header we usually inject as it includes +# system headers. +NO_TEST_COMMON_H := 1 + +CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py new file mode 100644 index ..48459abb9266 --- /dev/null +++ b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py @@ -0,0 +1,39 @@ +""" +Tests forward declarations coming
[Lldb-commits] [lldb] 7866b91 - [lldb] Fix a crash when the ASTImporter is giving us two Imported callbacks for the same target decl
Author: Raphael Isemann Date: 2020-09-09T10:31:39+02:00 New Revision: 7866b91405693df5b4cf6ba770b3a92d48b0c508 URL: https://github.com/llvm/llvm-project/commit/7866b91405693df5b4cf6ba770b3a92d48b0c508 DIFF: https://github.com/llvm/llvm-project/commit/7866b91405693df5b4cf6ba770b3a92d48b0c508.diff LOG: [lldb] Fix a crash when the ASTImporter is giving us two Imported callbacks for the same target decl The ASTImporter has an `Imported(From, To)` callback that notifies subclasses that a declaration has been imported in some way. LLDB uses this in the `CompleteTagDeclsScope` to see which records have been imported into the scratch context. If the record was declared inside the expression, then the `CompleteTagDeclsScope` will forcibly import the full definition of that record to the scratch context so that the expression AST can safely be disposed later (otherwise we might end up going back to the deleted AST to complete the minimally imported record). The way this is implemented is that there is a list of decls that need to be imported (`m_decls_to_complete`) and we keep completing the declarations inside that list until the list is empty. Every `To` Decl we get via the `Imported` callback will be added to the list of Decls to be completed. There are some situations where the ASTImporter will actually give us two `Imported` calls with the same `To` Decl. One way where this happens is if the ASTImporter decides to merge an imported definition into an already imported one. Another way is that the ASTImporter just happens to get two calls to `ASTImporter::Import` for the same Decl. This for example happens when importing the DeclContext of a Decl requires importing the Decl itself, such as when importing a RecordDecl that was declared inside a function. The bug addressed in this patch is that when we end up getting two `Imported` calls for the same `To` Decl, then we would crash in the `CompleteTagDeclsScope`. That's because the first time we complete the Decl we remove the Origin tracking information (that maps the Decl back to from where it came from). The next time we try to complete the same `To` Decl the Origin tracking information is gone and we hit the `to_context_md->getOrigin(decl).ctx == m_src_ctx` assert (`getOrigin(decl).ctx` is a nullptr the second time as the Origin was deleted). This is actually a regression coming from D72495. Before D72495 `m_decls_to_complete` was actually a set so every declaration in there could only be queued once to be completed. The set was changed to a vector to make the iteration over it deterministic, but that also causes that we now potentially end up trying to complete a Decl twice. This patch essentially just reverts D72495 and makes the `CompleteTagDeclsScope` use a SetVector for the list of declarations to be completed. The SetVector should filter out the duplicates (as the original `set` did) and also ensure that the completion order is deterministic. I actually couldn't find any way to cause LLDB to reproduce this bug by merging declarations (this would require that we for example declare two namespaces in a non-top-level expression which isn't possible). But the bug reproduces very easily by just declaring a class in an expression, so that's what the test is doing. Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D85648 Added: lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 73042c205a5a..e2601a059bb7 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -216,7 +216,12 @@ namespace { /// imported while completing the original Decls). class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener { ClangASTImporter::ImporterDelegateSP m_delegate; - llvm::SmallVector m_decls_to_complete; + /// List of declarations in the target context that need to be completed. + /// Every declaration should only be completed once and therefore should only + /// be once in this list. + llvm::SetVector m_decls_to_complete; + /// Set of declarations that already were successfully completed (not just + /// added to m_decls_to_complete). llvm::SmallPtrSet m_decls_already_completed; clang::ASTContext *m_dst_ctx; clang::ASTContext *m_src_ctx; @@ -244,6 +249,9 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener { NamedDecl *decl = m_decls_to_complete.pop_back_val(); m_decls_already_completed.insert(decl); + // The decl that should be completed has to be imported into the target + // context from some other context. +
[Lldb-commits] [lldb] ef733d9 - [lldb] Add targets for running test suite against Watch/TV/iPhone simulators
Author: Raphael Isemann Date: 2020-10-13T17:07:46+02:00 New Revision: ef733d9df486884aa33de9f5a9f6bade4e70f187 URL: https://github.com/llvm/llvm-project/commit/ef733d9df486884aa33de9f5a9f6bade4e70f187 DIFF: https://github.com/llvm/llvm-project/commit/ef733d9df486884aa33de9f5a9f6bade4e70f187.diff LOG: [lldb] Add targets for running test suite against Watch/TV/iPhone simulators This patch adds several build system targets that run the normal test suite but against the Watch/TV/iPhone simulators. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D89224 Added: Modified: lldb/test/API/lit.cfg.py lldb/test/CMakeLists.txt Removed: diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index a4d4d83fd366..4bc31206c9f2 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -146,6 +146,20 @@ def delete_module_cache(path): elif lldb_repro_mode == 'replay': config.available_features.add('lldb-repro-replay') +lldb_use_simulator = lit_config.params.get('lldb-run-with-simulator', None) +if lldb_use_simulator: + if lldb_use_simulator == "ios": +lit_config.note("Running API tests on iOS simulator") +config.available_features.add('lldb-simulator-ios') + elif lldb_use_simulator == "watchos": +lit_config.note("Running API tests on watchOS simulator") +config.available_features.add('lldb-simulator-watchos') + elif lldb_use_simulator == "tvos": +lit_config.note("Running API tests on tvOS simulator") +config.available_features.add('lldb-simulator-tvos') + else: +lit_config.error("Unknown simulator id '{}'".format(lldb_use_simulator)) + # Set a default per-test timeout of 10 minutes. Setting a timeout per test # requires that killProcessAndChildren() is supported on the platform and # lit complains if the value is set but it is not supported. @@ -216,6 +230,16 @@ def delete_module_cache(path): 'lldb-repro-replay' in config.available_features: dotest_cmd += ['--skip-category=lldb-vscode', '--skip-category=std-module'] +if 'lldb-simulator-ios' in config.available_features: + dotest_cmd += ['--apple-sdk', 'iphonesimulator', + '--platform-name', 'ios-simulator'] +elif 'lldb-simulator-watchos' in config.available_features: + dotest_cmd += ['--apple-sdk', 'watchsimulator', + '--platform-name', 'watchos-simulator'] +elif 'lldb-simulator-tvos' in config.available_features: + dotest_cmd += ['--apple-sdk', 'appletvsimulator', + '--platform-name', 'tvos-simulator'] + if is_configured('enabled_plugins'): for plugin in config.enabled_plugins: dotest_cmd += ['--enable-plugin', plugin] diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 21d8c61f11ed..91665e7b 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -214,6 +214,29 @@ add_lit_testsuite(check-lldb-reproducers DEPENDS lldb-test-deps) add_dependencies(check-lldb-reproducers check-lldb-reproducers-capture) +# Targets for running the test suite on the diff erent Apple simulators. +add_lit_testsuite(check-lldb-simulator-ios + "Running lldb test suite on the iOS simulator" + ${CMAKE_CURRENT_BINARY_DIR}/API + PARAMS "lldb-run-with-simulator=ios" + EXCLUDE_FROM_CHECK_ALL + DEPENDS lldb-test-deps) + +add_lit_testsuite(check-lldb-simulator-watchos + "Running lldb test suite on the watchOS simulator" + ${CMAKE_CURRENT_BINARY_DIR}/API + PARAMS "lldb-run-with-simulator=watchos" + EXCLUDE_FROM_CHECK_ALL + DEPENDS lldb-test-deps) + +add_lit_testsuite(check-lldb-simulator-tvos + "Running lldb test suite on the tvOS simulator" + ${CMAKE_CURRENT_BINARY_DIR}/API + PARAMS "lldb-run-with-simulator=tvos" + EXCLUDE_FROM_CHECK_ALL + DEPENDS lldb-test-deps) + + if(LLDB_BUILT_STANDALONE) # This has to happen *AFTER* add_lit_testsuite. if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6733b25 - [lldb][cmake] Remove custom logic for finding VCS file to fix LLDB's VCSVersion.inc generation
Author: Raphael Isemann Date: 2020-10-13T17:14:43+02:00 New Revision: 6733b2544794f2703f19f07aa7c6806408e36160 URL: https://github.com/llvm/llvm-project/commit/6733b2544794f2703f19f07aa7c6806408e36160 DIFF: https://github.com/llvm/llvm-project/commit/6733b2544794f2703f19f07aa7c6806408e36160.diff LOG: [lldb][cmake] Remove custom logic for finding VCS file to fix LLDB's VCSVersion.inc generation We are still implementing our own logic for this that looks for a VCS file in the place where it was before the monorepo migration. This removes this logic and just uses the CMake function that LLVM/Clang are using. Reviewed By: JDevlieghere, kastiglione Differential Revision: https://reviews.llvm.org/D88950 Added: Modified: lldb/source/CMakeLists.txt Removed: diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt index b196147e68e7..6dbdec5ec008 100644 --- a/lldb/source/CMakeLists.txt +++ b/lldb/source/CMakeLists.txt @@ -4,16 +4,8 @@ set(lldbBase_SOURCES lldb.cpp ) -foreach(file -"${LLDB_SOURCE_DIR}/.git/logs/HEAD" # Git -"${LLDB_SOURCE_DIR}/.svn/wc.db" # SVN 1.7 -"${LLDB_SOURCE_DIR}/.svn/entries" # SVN 1.6 -) - if(EXISTS "${file}") -set(lldb_vc "${file}") -break() - endif() -endforeach() + +find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc) set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc") set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 02114e1 - [lldb] Allow limiting the number of error diagnostics when parsing an expression
Author: Raphael Isemann Date: 2020-10-13T17:12:43+02:00 New Revision: 02114e15daad7f02e65289412d37334618386ce5 URL: https://github.com/llvm/llvm-project/commit/02114e15daad7f02e65289412d37334618386ce5 DIFF: https://github.com/llvm/llvm-project/commit/02114e15daad7f02e65289412d37334618386ce5.diff LOG: [lldb] Allow limiting the number of error diagnostics when parsing an expression While debugging another bug I found out that we currently don't set any limit for the number of diagnostics Clang emits. If a user does something that generates a lot of errors (like including some long header file from within the expression function), then we currently spam the LLDB output with potentially thousands of Clang error diagnostics. Clang sets a default limit of 20 errors, but given that LLDB is often used interactively for small expressions I would say a limit of 5 is enough. The limit is implemented as a setting, so if a user cares about seeing having a million errors printed to their terminal then they can just increase the settings value. Reviewed By: shafik, mib Differential Revision: https://reviews.llvm.org/D9 Added: lldb/test/API/commands/expression/error-limit/Makefile lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py lldb/test/API/commands/expression/error-limit/main.cpp Modified: lldb/include/lldb/Target/Target.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Removed: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index f371c4fd6956..0a27147cb61d 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -173,6 +173,8 @@ class TargetProperties : public Properties { llvm::StringRef GetExpressionPrefixContents(); + uint64_t GetExprErrorLimit() const; + bool GetUseHexImmediates() const; bool GetUseFastStepping() const; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 202eb87cca3d..8ad39ecd2707 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -454,6 +454,10 @@ ClangExpressionParser::ClangExpressionParser( // 4. Create and install the target on the compiler. m_compiler->createDiagnostics(); + // Limit the number of error diagnostics we emit. + // A value of 0 means no limit for both LLDB and Clang. + m_compiler->getDiagnostics().setErrorLimit(target_sp->GetExprErrorLimit()); + auto target_info = TargetInfo::CreateTargetInfo( m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts); if (log) { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 6ce613697825..5cbdb4995c75 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4026,6 +4026,12 @@ llvm::StringRef TargetProperties::GetExpressionPrefixContents() { return ""; } +uint64_t TargetProperties::GetExprErrorLimit() const { + const uint32_t idx = ePropertyExprErrorLimit; + return m_collection_sp->GetPropertyAtIndexAsUInt64( + nullptr, idx, g_target_properties[idx].default_uint_value); +} + bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() { const uint32_t idx = ePropertyBreakpointUseAvoidList; return m_collection_sp->GetPropertyAtIndexAsBoolean( diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td index 7fb9b105ceef..c624bc35d16e 100644 --- a/lldb/source/Target/TargetProperties.td +++ b/lldb/source/Target/TargetProperties.td @@ -20,6 +20,10 @@ let Definition = "target" in { def ExprPrefix: Property<"expr-prefix", "FileSpec">, DefaultStringValue<"">, Desc<"Path to a file containing expressions to be prepended to all expressions.">; + def ExprErrorLimit: Property<"expr-error-limit", "UInt64">, +DefaultUnsignedValue<5>, +Desc<"The maximum amount of errors to emit while parsing an expression. " + "A value of 0 means to always continue parsing if possible.">; def PreferDynamic: Property<"prefer-dynamic-value", "Enum">, DefaultEnumValue<"eDynamicDontRunTarget">, EnumValues<"OptionEnumValues(g_dynamic_value_types)">, diff --git a/lldb/test/API/commands/expression/error-limit/Makefile b/lldb/test/API/commands/expression/error-limit/Makefile new file mode 100644 index ..8b20bcb0 --- /dev/null +++ b/lldb/test/API/commands/expression/error-limit/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py b/lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py new file mode 100644
[Lldb-commits] [lldb] 4cd873c - [lldb][NFC] Remove property predicate matcher
Author: Raphael Isemann Date: 2020-10-13T17:09:27+02:00 New Revision: 4cd873c4bd7ff66d4af2bf5e57c27e6924bfc92a URL: https://github.com/llvm/llvm-project/commit/4cd873c4bd7ff66d4af2bf5e57c27e6924bfc92a DIFF: https://github.com/llvm/llvm-project/commit/4cd873c4bd7ff66d4af2bf5e57c27e6924bfc92a.diff LOG: [lldb][NFC] Remove property predicate matcher That's supposed to be used to implement things such as `settings set target.run-args{basename==test&==x86_64} arg1` but it's not actually fully implemented or tested anywhere. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D88910 Added: Modified: lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Interpreter/OptionValueProperties.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index bd944b6a5adf..d60afdeb46fb 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -104,11 +104,6 @@ class OptionValueProperties Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override; - virtual bool PredicateMatches(const ExecutionContext *exe_ctx, -llvm::StringRef predicate) const { -return false; - } - OptionValueArch * GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx, uint32_t idx) const; diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index 5b82008ca571..6c4e77f614f9 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -147,38 +147,6 @@ OptionValueProperties::GetSubValue(const ExecutionContext *exe_ctx, } return return_val_sp; } - case '{': -// Predicate matching for predicates like -// "{}" -// strings are parsed by the current OptionValueProperties subclass to mean -// whatever they want to. For instance a subclass of OptionValueProperties -// for a lldb_private::Target might implement: "target.run- -// args{arch==i386}" -- only set run args if the arch is i386 "target -// .run-args{path=/tmp/a/b/c/a.out}" -- only set run args if the path -// matches "target.run-args{basename==test&==x86_64}" -- only set run -// args if executable basename is "test" and arch is "x86_64" -if (sub_name[1]) { - llvm::StringRef predicate_start = sub_name.drop_front(); - size_t pos = predicate_start.find('}'); - if (pos != llvm::StringRef::npos) { -auto predicate = predicate_start.take_front(pos); -auto rest = predicate_start.drop_front(pos); -if (PredicateMatches(exe_ctx, predicate)) { - if (!rest.empty()) { -// Still more subvalue string to evaluate -return value_sp->GetSubValue(exe_ctx, rest, - will_modify, error); - } else { -// We have a match! -break; - } -} - } -} -// Predicate didn't match or wasn't correctly formed -value_sp.reset(); -break; - case '[': // Array or dictionary access for subvalues like: "[12]" -- access // 12th array element "['hello']" -- dictionary access of key named hello ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 24e0757 - [lldb] Remove all the RegisterInfo name constification code
Author: Raphael Isemann Date: 2020-10-13T17:10:29+02:00 New Revision: 24e07570cc928b75e894b81639cabe96c660ccef URL: https://github.com/llvm/llvm-project/commit/24e07570cc928b75e894b81639cabe96c660ccef DIFF: https://github.com/llvm/llvm-project/commit/24e07570cc928b75e894b81639cabe96c660ccef.diff LOG: [lldb] Remove all the RegisterInfo name constification code RegisterInfo's `reg_name`/`reg_alt_name` fields are C-Strings and are supposed to only be generated from a ConstString. The reason for that is that `DynamicRegisterInfo::GetRegisterInfo` and `RegInfoBasedABI::GetRegisterInfoByName` try to optimise finding registers by name by only comparing the C string pointer values instead of the underlying strings. This only works if both C strings involved in the comparison come from a ConstString. If one of the two C strings doesn't come from a ConstString the comparison won't work (and most likely will silently fail). I added an assert in b0060c3a7868ef026d95d0cf8a076791ef74f474 which checks that both strings come from a ConstString. Apparently not all ABI plugins are generating their register names via ConstString, so this code is now not just silently failing but also asserting. In D88375 we did a shady fix for the MIPS plugins by just copying the ConstString setup code to that plugin, but we still need to fix ABISysV_arc, ABISysV_ppc and ABISysV_ppc64 plugins. I would say we just fix the remaining plugins by removing the whole requirement to have the register names coming from ConstStrings. I really doubt that we actually save any time with the whole ConstString search trick (searching ~50 strings that have <4 characters doesn't sound more expensive than calling the really expensive ConstString constructor + comparing the same amount of pointer values). Also whatever small percentage of LLDB's runtime is actually spend in this function is anyway not worth the complexity of this approach. This patch just removes all this and just does a normal string comparison. Reviewed By: JDevlieghere, labath Differential Revision: https://reviews.llvm.org/D88490 Added: Modified: lldb/include/lldb/Target/ABI.h lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h lldb/source/Target/ABI.cpp Removed: diff --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h index b252e4b54f03..131b2eaff765 100644 --- a/lldb/include/lldb/Target/ABI.h +++ b/lldb/include/lldb/Target/ABI.h @@ -159,7 +159,7 @@ class RegInfoBasedABI : public ABI { protected: using ABI::ABI; - bool GetRegisterInfoByName(ConstString name, RegisterInfo ); + bool GetRegisterInfoByName(llvm::StringRef name, RegisterInfo ); virtual const RegisterInfo *GetRegisterInfoArray(uint32_t ) = 0; }; diff --git a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp index ef500cb198a8..06c4590b7740 100644 --- a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp @@ -34,7 +34,7 @@ using namespace lldb; using namespace lldb_private; -static RegisterInfo g_register_infos[] = { +static const RegisterInfo g_register_infos[] = { // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME // DWARF GENERIC PROCESS PLUGIN // LLDB NATIVE @@ -1292,24 +1292,9 @@ static RegisterInfo g_register_infos[] = { static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); -static bool g_register_info_names_constified = false; const lldb_private::RegisterInfo * ABIMacOSX_arm::GetRegisterInfoArray(uint32_t ) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. - if (!g_register_info_names_constified) { -g_register_info_names_constified = true; -for (uint32_t i = 0; i < k_num_register_infos; ++i) { - if (g_register_infos[i].name) -g_register_infos[i].name = -ConstString(g_register_infos[i].name).GetCString(); - if (g_register_infos[i].alt_name) -g_register_infos[i].alt_name = -ConstString(g_register_infos[i].alt_name).GetCString(); -} - } count = k_num_register_infos; return g_register_infos; } diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp index c63c569f875a..26b3152bed16 100644 ---
[Lldb-commits] [lldb] 82ed186 - [lldb] Explicitly test the template argument SB API
Author: Raphael Isemann Date: 2020-10-15T11:17:43+02:00 New Revision: 82ed18601dbc816e1f64407a926602f95bbeda32 URL: https://github.com/llvm/llvm-project/commit/82ed18601dbc816e1f64407a926602f95bbeda32 DIFF: https://github.com/llvm/llvm-project/commit/82ed18601dbc816e1f64407a926602f95bbeda32.diff LOG: [lldb] Explicitly test the template argument SB API Added: lldb/test/API/lang/cpp/template-arguments/Makefile lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py lldb/test/API/lang/cpp/template-arguments/main.cpp Modified: Removed: diff --git a/lldb/test/API/lang/cpp/template-arguments/Makefile b/lldb/test/API/lang/cpp/template-arguments/Makefile new file mode 100644 index ..8b20bcb0 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-arguments/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py b/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py new file mode 100644 index ..3ba86bc44e25 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py @@ -0,0 +1,30 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test +def test(self): +self.build() +self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + +value = self.expect_expr("temp1", result_type="C") +template_type = value.GetType() +self.assertEqual(template_type.GetNumberOfTemplateArguments(), 2) + +# Check a type argument. +self.assertEqual(template_type.GetTemplateArgumentKind(0), lldb.eTemplateArgumentKindType) +self.assertEqual(template_type.GetTemplateArgumentType(0).GetName(), "int") + +# Check a integral argument. +self.assertEqual(template_type.GetTemplateArgumentKind(1), lldb.eTemplateArgumentKindIntegral) +self.assertEqual(template_type.GetTemplateArgumentType(1).GetName(), "unsigned int") +#FIXME: There is no way to get the actual value of the parameter. + +# Try to get an invalid template argument. +self.assertEqual(template_type.GetTemplateArgumentKind(2), lldb.eTemplateArgumentKindNull) +self.assertEqual(template_type.GetTemplateArgumentType(2).GetName(), "") diff --git a/lldb/test/API/lang/cpp/template-arguments/main.cpp b/lldb/test/API/lang/cpp/template-arguments/main.cpp new file mode 100644 index ..728bd400c258 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-arguments/main.cpp @@ -0,0 +1,8 @@ +template +struct C { + T member = value; +}; + +C temp1; + +int main() {} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cb81e66 - [lldb] Reject redefinitions of persistent variables
Author: Raphael Isemann Date: 2020-10-14T10:24:35+02:00 New Revision: cb81e662a58908913f342520e4c010564a68126a URL: https://github.com/llvm/llvm-project/commit/cb81e662a58908913f342520e4c010564a68126a DIFF: https://github.com/llvm/llvm-project/commit/cb81e662a58908913f342520e4c010564a68126a.diff LOG: [lldb] Reject redefinitions of persistent variables Currently one can redefine a persistent variable and LLDB will just silently ignore the second definition: ``` (lldb) expr int $i = 1 (lldb) expr int $i = 2 (lldb) expr $i (int) $i = 1 ``` This patch makes this an error and rejects the expression with the second definition. A nice follow up would be to refactor LLDB's persistent variables to not just be a pair of type and name, but also contain some way to obtain the original declaration and source code that declared the variable. That way we could actually make a full diagnostic as we would get from redefining a variable twice in the same expression. Reviewed By: labath, shafik, JDevlieghere Differential Revision: https://reviews.llvm.org/D89310 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 8c49898e1d6c..7d8cd85500ae 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -19,6 +19,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/Materializer.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/CompilerDecl.h" @@ -125,6 +126,12 @@ void ClangExpressionDeclMap::InstallCodeGenerator( m_parser_vars->m_code_gen = code_gen; } +void ClangExpressionDeclMap::InstallDiagnosticManager( +DiagnosticManager _manager) { + assert(m_parser_vars); + m_parser_vars->m_diagnostics = _manager; +} + void ClangExpressionDeclMap::DidParse() { if (m_parser_vars && m_parser_vars->m_persistent_vars) { for (size_t entity_index = 0, num_entities = m_found_entities.GetSize(); @@ -196,6 +203,17 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl, if (ast == nullptr) return false; + // Check if we already declared a persistent variable with the same name. + if (lldb::ExpressionVariableSP conflicting_var = + m_parser_vars->m_persistent_vars->GetVariable(name)) { +std::string msg = llvm::formatv("redefinition of persistent variable '{0}'", +name).str(); +m_parser_vars->m_diagnostics->AddDiagnostic( +msg, DiagnosticSeverity::eDiagnosticSeverityError, +DiagnosticOrigin::eDiagnosticOriginLLDB); +return false; + } + if (m_parser_vars->m_materializer && is_result) { Status err; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index 6974535a8993..0c81d46c6c52 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -102,6 +102,8 @@ class ClangExpressionDeclMap : public ClangASTSource { void InstallCodeGenerator(clang::ASTConsumer *code_gen); + void InstallDiagnosticManager(DiagnosticManager _manager); + /// Disable the state needed for parsing and IR transformation. void DidParse(); @@ -330,6 +332,8 @@ class ClangExpressionDeclMap : public ClangASTSource { clang::ASTConsumer *m_code_gen = nullptr; ///< If non-NULL, a code generator ///that receives new top-level ///functions. +DiagnosticManager *m_diagnostics = nullptr; + private: ParserVars(const ParserVars &) = delete; const ParserVars =(const ParserVars &) = delete; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 8ad39ecd2707..bd0d831f0ca7 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1078,6 +1078,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager _manager, ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap(); if (decl_map) {
[Lldb-commits] [lldb] ce4d15f - [lldb] Symlink the Clang resource directory to the LLDB build directory in standalone builds
Author: Raphael Isemann Date: 2020-10-06T09:28:39+02:00 New Revision: ce4d15fe142eb0e0ed7c998a73b13e7bee45d99e URL: https://github.com/llvm/llvm-project/commit/ce4d15fe142eb0e0ed7c998a73b13e7bee45d99e DIFF: https://github.com/llvm/llvm-project/commit/ce4d15fe142eb0e0ed7c998a73b13e7bee45d99e.diff LOG: [lldb] Symlink the Clang resource directory to the LLDB build directory in standalone builds When doing a standalone build (i.e., building just LLDB against an existing LLVM/Clang installation), LLDB is currently unable to find any Clang resource directory that contains all the builtin headers we need to parse real source code. This causes several tests that actually parse source code on disk within the expression parser to fail (most notably nearly all the import-std-module tests). The reason why LLDB can't find the resource directory is that we search based on the path of the LLDB shared library path. We assumed that the Clang resource directory is in the same prefix and has the same relative path to the LLDB shared library (e.g., `../clang/10.0.0/include`). However for a standalone build where the existing Clang can be anywhere on the disk, so we can't just rely on the hardcoded relative paths to the LLDB shared library. It seems we can either solve this by copying the resource directory to the LLDB installation, symlinking it there or we pass the path to the Clang installation to the code that is trying to find the resource directory. When building the LLDB framework we currently copy the resource directory over to the framework folder (this is why the import-std-module are not failing on the Green Dragon standalone bot). This patch symlinks the resource directory of Clang into the LLDB build directory. The reason for that is simply that this is only needed when running LLDB from the build directory. Once LLDB and Clang/LLVM are installed the already existing logic can find the Clang resource directory by searching relative to the LLDB shared library. Reviewed By: kastiglione, JDevlieghere Differential Revision: https://reviews.llvm.org/D88581 Added: Modified: lldb/cmake/modules/LLDBConfig.cmake lldb/cmake/modules/LLDBFramework.cmake lldb/source/API/CMakeLists.txt Removed: diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index af94e6e223d9..5fbc89892c73 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -250,6 +250,30 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) endif() endif() + +# If LLDB is building against a prebuilt Clang, then the Clang resource +# directory that LLDB is using for its embedded Clang instance needs to point +# to the resource directory of the used Clang installation. +if (NOT TARGET clang-resource-headers) + set(LLDB_CLANG_RESOURCE_DIR_NAME "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") + # Iterate over the possible places where the external resource directory + # could be and pick the first that exists. + foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}" +"${LLVM_BUILD_LIBRARY_DIR}" +"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") +# Build the resource directory path by appending 'clang/'. +set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}") +if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}") + set(LLDB_EXTERNAL_CLANG_RESOURCE_DIR "${CANDIDATE_RESOURCE_DIR}") + break() +endif() + endforeach() + + if (NOT LLDB_EXTERNAL_CLANG_RESOURCE_DIR) +message(FATAL_ERROR "Expected directory for clang-resource headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}") + endif() +endif() + # Find Apple-specific libraries or frameworks that may be needed. if (APPLE) if(NOT APPLE_EMBEDDED) diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 43af71b78f24..2fb059ac458b 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -110,20 +110,7 @@ if(NOT APPLE_EMBEDDED) add_dependencies(liblldb clang-resource-headers) set(clang_resource_headers_dir $) else() -# In standalone builds try the best possible guess -if(Clang_DIR) - set(clang_lib_dir ${Clang_DIR}/../..) -elseif(LLVM_DIR) - set(clang_lib_dir ${LLVM_DIR}/../..) -elseif(LLVM_LIBRARY_DIRS) - set(clang_lib_dir ${LLVM_LIBRARY_DIRS}) -elseif(LLVM_BUILD_LIBRARY_DIR) - set(clang_lib_dir ${LLVM_BUILD_LIBRARY_DIR}) -elseif(LLVM_BINARY_DIR) - set(clang_lib_dir ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) -endif() -set(clang_version ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}) -set(clang_resource_headers_dir ${clang_lib_dir}/clang/${clang_version}/include) +set(clang_resource_headers_dir
[Lldb-commits] [lldb] dfc7243 - [lldb] Don't add no-sandbox entitlement when running tests on simulator
Author: Raphael Isemann Date: 2020-10-13T15:08:46+02:00 New Revision: dfc72439529c49e8bfeab9d604b1aa1cac7d89e8 URL: https://github.com/llvm/llvm-project/commit/dfc72439529c49e8bfeab9d604b1aa1cac7d89e8 DIFF: https://github.com/llvm/llvm-project/commit/dfc72439529c49e8bfeab9d604b1aa1cac7d89e8.diff LOG: [lldb] Don't add no-sandbox entitlement when running tests on simulator It seems that if codesigning the test executables with the `com.apple.private.security.no-sandbox` entitlement then the simulator refuses to launch them and every test fails with `Process launch failed: process exited with status -1 (no such process.)`. This patch checks if we're trying to run the test suite on the simulator and then avoids signing the executable with `no-sandbox`. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D89052 Added: lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist Modified: lldb/packages/Python/lldbsuite/test/builders/darwin.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py b/lldb/packages/Python/lldbsuite/test/builders/darwin.py index 236e4fac1368..fd25c0c2f115 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py +++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py @@ -65,11 +65,15 @@ def getExtraMakeArgs(self): if configuration.dsymutil: args['DSYMUTIL'] = configuration.dsymutil -operating_system, _ = get_os_and_env() +operating_system, env = get_os_and_env() if operating_system and operating_system != "macosx": builder_dir = os.path.dirname(os.path.abspath(__file__)) test_dir = os.path.dirname(builder_dir) -entitlements = os.path.join(test_dir, 'make', 'entitlements.plist') +if env == "simulator": + entitlements_file = 'entitlements-simulator.plist' +else: + entitlements_file = 'entitlements.plist' +entitlements = os.path.join(test_dir, 'make', entitlements_file) args['CODESIGN'] = 'codesign --entitlements {}'.format( entitlements) diff --git a/lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist b/lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist new file mode 100644 index ..9acd12816c91 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist @@ -0,0 +1,8 @@ + +http://www.apple.com/DTDs/PropertyList-1.0.dtd;> + + +com.apple.security.get-task-allow + + + ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f4f4d54 - [lldb] Fill Watch/AppleTV simulator gaps in PlatformDarwin
Author: Raphael Isemann Date: 2020-10-13T15:06:41+02:00 New Revision: f4f4d54ae0d8971e67fd64e10d700804105b720c URL: https://github.com/llvm/llvm-project/commit/f4f4d54ae0d8971e67fd64e10d700804105b720c DIFF: https://github.com/llvm/llvm-project/commit/f4f4d54ae0d8971e67fd64e10d700804105b720c.diff LOG: [lldb] Fill Watch/AppleTV simulator gaps in PlatformDarwin When running the test suite against the Watch/AppleTV simulator we currently hitting the unimplemented parts of PlatformDarwin for the respective simulator platforms. This just adds the respective switch cases. This whole code path depends on having a valid Target, so can't just unittest this code without refactoring it. So instead this is tested by just running the testsuite against the respective simulators (which is how I found this). Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D89106 Added: Modified: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Removed: diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 4e2df72ee3a8..6f25128caf24 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1325,6 +1325,12 @@ FileSpec PlatformDarwin::GetSDKDirectoryForModules(XcodeSDK::Type sdk_type) { case XcodeSDK::Type::iPhoneOS: sdks_spec.AppendPathComponent("iPhoneOS.platform"); break; + case XcodeSDK::Type::WatchSimulator: +sdks_spec.AppendPathComponent("WatchSimulator.platform"); +break; + case XcodeSDK::Type::AppleTVSimulator: +sdks_spec.AppendPathComponent("AppleTVSimulator.platform"); +break; default: llvm_unreachable("unsupported sdk"); } @@ -1567,6 +1573,14 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( minimum_version_option.PutCString("-mmacosx-version-min="); minimum_version_option.PutCString(version.getAsString()); break; +case XcodeSDK::Type::WatchSimulator: + minimum_version_option.PutCString("-mwatchos-simulator-version-min="); + minimum_version_option.PutCString(version.getAsString()); + break; +case XcodeSDK::Type::AppleTVSimulator: + minimum_version_option.PutCString("-mtvos-version-min="); + minimum_version_option.PutCString(version.getAsString()); + break; default: llvm_unreachable("unsupported sdk"); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 480c440 - [lldb] Don't let dotest silently fall back to default SDK if the specified one can't be found
Author: Raphael Isemann Date: 2020-10-13T15:07:45+02:00 New Revision: 480c440f9a3cf3434355f24217cfa430dc1cabda URL: https://github.com/llvm/llvm-project/commit/480c440f9a3cf3434355f24217cfa430dc1cabda DIFF: https://github.com/llvm/llvm-project/commit/480c440f9a3cf3434355f24217cfa430dc1cabda.diff LOG: [lldb] Don't let dotest silently fall back to default SDK if the specified one can't be found If the SDK name passed to dotest can't be found by `xcrun` we silently fall back to the default SDK. This leads to rather cryptic errors being reported later on when linking the actual test executables. Instead just directly log and abort when this situation is encountered and inform the user about the invalid argument. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D89053 Added: Modified: lldb/packages/Python/lldbsuite/test/dotest.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 0da60f11a609..a98965e50c19 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -302,6 +302,11 @@ def parseOptionsAndInitTestdirs(): configuration.sdkroot = seven.get_command_output( 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)) +if not configuration.sdkroot: +logging.error( +'No SDK found with the name %s; aborting...', +args.apple_sdk) +sys.exit(-1) if args.arch: configuration.arch = args.arch ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7518006 - [lldb] XFAIL TestMemoryHistory on Linux
Author: Raphael Isemann Date: 2020-08-26T10:24:13+02:00 New Revision: 7518006d75accd21325747430d6bced66b2c5ada URL: https://github.com/llvm/llvm-project/commit/7518006d75accd21325747430d6bced66b2c5ada DIFF: https://github.com/llvm/llvm-project/commit/7518006d75accd21325747430d6bced66b2c5ada.diff LOG: [lldb] XFAIL TestMemoryHistory on Linux This test appears to have never worked on Linux but it seems none of the current bots ever ran this test as it required enabling compiler-rt (otherwise it would have just been skipped). This just copies over the XFAIL decorator that are already on all other sanitizer tests. Added: Modified: lldb/test/API/functionalities/asan/TestMemoryHistory.py Removed: diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py b/lldb/test/API/functionalities/asan/TestMemoryHistory.py index 37c34984f43b..0b8dc20f27c5 100644 --- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py +++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py @@ -15,6 +15,9 @@ class AsanTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) +@expectedFailureAll( +oslist=["linux"], +bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @expectedFailureNetBSD @skipUnlessAddressSanitizer ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2501e91 - [lldb] Don't depend on psutil in TestCompletion.py
Author: Raphael Isemann Date: 2020-08-25T08:30:33+02:00 New Revision: 2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3 URL: https://github.com/llvm/llvm-project/commit/2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3 DIFF: https://github.com/llvm/llvm-project/commit/2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3.diff LOG: [lldb] Don't depend on psutil in TestCompletion.py psutil isn't reall a dependency of the test suite so this shouldn't be unconditionally be imported here. Instead just check for the process name by looking for the "a.out" string to get the bots green again. Added: Modified: lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index e2b003219a00..b80594b7568b 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -6,7 +6,6 @@ import os from multiprocessing import Process -import psutil import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -119,6 +118,18 @@ def test_process_plugin_completion(self): self.complete_from_to('process ' + subcommand + ' mac', 'process ' + subcommand + ' mach-o-core') +def completions_contain_str(self, input, needle): +interp = self.dbg.GetCommandInterpreter() +match_strings = lldb.SBStringList() +num_matches = interp.HandleCompletion(input, len(input), 0, -1, match_strings) +found_needle = False +for match in match_strings: + if needle in match: +found_needle = True +break +self.assertTrue(found_needle, "Returned completions: " + "\n".join(match_strings)) + + @skipIfRemote def test_common_completion_process_pid_and_name(self): # The LLDB process itself and the process already attached to are both @@ -136,9 +147,8 @@ def test_common_completion_process_pid_and_name(self): self.complete_from_to('platform process attach -p ', [str(pid)]) self.complete_from_to('platform process info ', [str(pid)]) -pname = psutil.Process(pid).name() # FIXME: psutil doesn't work for remote -self.complete_from_to('process attach -n ', [str(pname)]) -self.complete_from_to('platform process attach -n ', [str(pname)]) +self.completions_contain_str('process attach -n ', "a.out") +self.completions_contain_str('platform process attach -n ', "a.out") def test_process_signal(self): # The tab completion for "process signal" won't work without a running process. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7de7fe5 - [lldb] Don't ask for QOS_CLASS_UNSPECIFIED queue in TestQueues
Author: Raphael Isemann Date: 2020-08-25T20:13:33+02:00 New Revision: 7de7fe5d0e3f7f4d28e1dde42df4a7defa564f11 URL: https://github.com/llvm/llvm-project/commit/7de7fe5d0e3f7f4d28e1dde42df4a7defa564f11 DIFF: https://github.com/llvm/llvm-project/commit/7de7fe5d0e3f7f4d28e1dde42df4a7defa564f11.diff LOG: [lldb] Don't ask for QOS_CLASS_UNSPECIFIED queue in TestQueues TestQueues is curiously failing for me as my queue for QOS_CLASS_UNSPECIFIED is named "Utility" and not "User Initiated" or "Default". While debugging, this I noticed that this test isn't actually using this API right from what I understand. The API documentation for `dispatch_get_global_queue` specifies for the parameter: "You may specify the value QOS_CLASS_USER_INTERACTIVE, QOS_CLASS_USER_INITIATED, QOS_CLASS_UTILITY, or QOS_CLASS_BACKGROUND." QOS_CLASS_UNSPECIFIED isn't listed as one of the supported values. swift-corelibs-libdispatch even checks for this value and returns a DISPATCH_BAD_INPUT. The libdispatch shipped on macOS seems to also check for QOS_CLASS_UNSPECIFIED and seems to instead cause a "client crash", but somehow this doesn't trigger in this test and instead we just get whatever queue This patch just removes that part of the test as it appears the code is just incorrect. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D86211 Added: Modified: lldb/test/API/macosx/queues/TestQueues.py lldb/test/API/macosx/queues/main.c Removed: diff --git a/lldb/test/API/macosx/queues/TestQueues.py b/lldb/test/API/macosx/queues/TestQueues.py index e177daa54fa3..711c99a7d400 100644 --- a/lldb/test/API/macosx/queues/TestQueues.py +++ b/lldb/test/API/macosx/queues/TestQueues.py @@ -192,7 +192,6 @@ def queues(self): user_initiated_thread = lldb.SBThread() user_interactive_thread = lldb.SBThread() utility_thread = lldb.SBThread() -unspecified_thread = lldb.SBThread() background_thread = lldb.SBThread() for th in process.threads: if th.GetName() == "user initiated QoS": @@ -201,8 +200,6 @@ def queues(self): user_interactive_thread = th if th.GetName() == "utility QoS": utility_thread = th -if th.GetName() == "unspecified QoS": -unspecified_thread = th if th.GetName() == "background QoS": background_thread = th @@ -213,9 +210,6 @@ def queues(self): user_interactive_thread.IsValid(), "Found user interactive QoS thread") self.assertTrue(utility_thread.IsValid(), "Found utility QoS thread") -self.assertTrue( -unspecified_thread.IsValid(), -"Found unspecified QoS thread") self.assertTrue( background_thread.IsValid(), "Found background QoS thread") @@ -248,16 +242,6 @@ def queues(self): stream.GetData(), "Utility", "utility QoS thread name is valid") stream.Clear() -self.assertTrue( -unspecified_thread.GetInfoItemByPathAsString( -"requested_qos.printable_name", -stream), -"Get QoS printable string for unspecified QoS thread") -qosName = stream.GetData() -self.assertTrue( -qosName == "User Initiated" or qosName == "Default", -"unspecified QoS thread name is valid: " + str(qosName)) -stream.Clear() self.assertTrue( background_thread.GetInfoItemByPathAsString( "requested_qos.printable_name", diff --git a/lldb/test/API/macosx/queues/main.c b/lldb/test/API/macosx/queues/main.c index 3978b92bff1a..2bf390b1330a 100644 --- a/lldb/test/API/macosx/queues/main.c +++ b/lldb/test/API/macosx/queues/main.c @@ -136,15 +136,9 @@ int main (int argc, const char **argv) while (1) sleep (10); }); -dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{ -pthread_setname_np ("unspecified QoS"); -atomic_fetch_add(_count, 1); -while (1) -sleep (10); - }); // Unfortunately there is no pthread_barrier on darwin. -while ((atomic_load(_count) < 13) || (finished_enqueueing_work == 0)) +while ((atomic_load(_count) < 12) || (finished_enqueueing_work == 0)) sleep (1); stopper (); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ef76686 - [lldb] Initialize reproducers in LocateSymbolFileTest
Author: Raphael Isemann Date: 2020-08-25T20:26:43+02:00 New Revision: ef76686916d40f20c782ed3967130bd2e0105b31 URL: https://github.com/llvm/llvm-project/commit/ef76686916d40f20c782ed3967130bd2e0105b31 DIFF: https://github.com/llvm/llvm-project/commit/ef76686916d40f20c782ed3967130bd2e0105b31.diff LOG: [lldb] Initialize reproducers in LocateSymbolFileTest Since a842950b62b6d029a392c3c312c6495d6368c2a4 this test started using the reproducer subsystem but we never initialized it in the test. The Subsystem takes an argument, so we can't use the usual SubsystemRAII at the moment to do this for us. This just adds the initialize/terminate calls to get the test passing again. Added: Modified: lldb/unittests/Symbol/LocateSymbolFileTest.cpp Removed: diff --git a/lldb/unittests/Symbol/LocateSymbolFileTest.cpp b/lldb/unittests/Symbol/LocateSymbolFileTest.cpp index 268faeaf1dbb..a2f9be56635d 100644 --- a/lldb/unittests/Symbol/LocateSymbolFileTest.cpp +++ b/lldb/unittests/Symbol/LocateSymbolFileTest.cpp @@ -14,6 +14,7 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/LocateSymbolFile.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Reproducer.h" using namespace lldb_private; @@ -27,15 +28,22 @@ class SymbolsTest : public ::testing::Test { TEST_F( SymbolsTest, TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) { + EXPECT_THAT_ERROR( + repro::Reproducer::Initialize(repro::ReproducerMode::Off, llvm::None), + llvm::Succeeded()); ModuleSpec module_spec; FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths(); FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec, search_paths); EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty()); + repro::Reproducer::Terminate(); } TEST_F(SymbolsTest, LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) { + EXPECT_THAT_ERROR( + repro::Reproducer::Initialize(repro::ReproducerMode::Off, llvm::None), + llvm::Succeeded()); ModuleSpec module_spec; // using a GUID here because the symbol file shouldn't actually exist on disk module_spec.GetSymbolFileSpec().SetFile( @@ -44,4 +52,5 @@ TEST_F(SymbolsTest, FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec, search_paths); EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty()); + repro::Reproducer::Terminate(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c1b1868 - [lldb] Make error messages in TestQueues more helpfull
Author: Raphael Isemann Date: 2020-08-19T13:30:31+02:00 New Revision: c1b1868f35bbb4d6e63515c00eb74d5aeac1aecc URL: https://github.com/llvm/llvm-project/commit/c1b1868f35bbb4d6e63515c00eb74d5aeac1aecc DIFF: https://github.com/llvm/llvm-project/commit/c1b1868f35bbb4d6e63515c00eb74d5aeac1aecc.diff LOG: [lldb] Make error messages in TestQueues more helpfull Added: Modified: lldb/test/API/macosx/queues/TestQueues.py Removed: diff --git a/lldb/test/API/macosx/queues/TestQueues.py b/lldb/test/API/macosx/queues/TestQueues.py index 805ad21a4137..e177daa54fa3 100644 --- a/lldb/test/API/macosx/queues/TestQueues.py +++ b/lldb/test/API/macosx/queues/TestQueues.py @@ -226,8 +226,8 @@ def queues(self): "requested_qos.printable_name", stream), "Get QoS printable string for user initiated QoS thread") -self.assertTrue( -stream.GetData() == "User Initiated", +self.assertEqual( +stream.GetData(), "User Initiated", "user initiated QoS thread name is valid") stream.Clear() self.assertTrue( @@ -235,8 +235,8 @@ def queues(self): "requested_qos.printable_name", stream), "Get QoS printable string for user interactive QoS thread") -self.assertTrue( -stream.GetData() == "User Interactive", +self.assertEqual( +stream.GetData(), "User Interactive", "user interactive QoS thread name is valid") stream.Clear() self.assertTrue( @@ -244,8 +244,8 @@ def queues(self): "requested_qos.printable_name", stream), "Get QoS printable string for utility QoS thread") -self.assertTrue( -stream.GetData() == "Utility", +self.assertEqual( +stream.GetData(), "Utility", "utility QoS thread name is valid") stream.Clear() self.assertTrue( @@ -256,15 +256,15 @@ def queues(self): qosName = stream.GetData() self.assertTrue( qosName == "User Initiated" or qosName == "Default", -"unspecified QoS thread name is valid") +"unspecified QoS thread name is valid: " + str(qosName)) stream.Clear() self.assertTrue( background_thread.GetInfoItemByPathAsString( "requested_qos.printable_name", stream), "Get QoS printable string for background QoS thread") -self.assertTrue( -stream.GetData() == "Background", +self.assertEqual( +stream.GetData(), "Background", "background QoS thread name is valid") @skipIfDarwin # rdar://50379398 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e1cd7ca - [lldb] Tab completion for process load/unload
Author: Gongyu Deng Date: 2020-08-21T10:36:39+02:00 New Revision: e1cd7cac8a36608616d515b64d12f2e86643970d URL: https://github.com/llvm/llvm-project/commit/e1cd7cac8a36608616d515b64d12f2e86643970d DIFF: https://github.com/llvm/llvm-project/commit/e1cd7cac8a36608616d515b64d12f2e86643970d.diff LOG: [lldb] Tab completion for process load/unload 1. Complete `process load` with the common disk file completion, so there is not test provided for it; 2. Complete `process unload` with the tokens of valid loaded images. Thanks for Raphael's help on the test for `process unload`. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D79887 Added: lldb/test/API/functionalities/completion/shared.cpp Modified: lldb/include/lldb/Target/Process.h lldb/source/Commands/CommandObjectProcess.cpp lldb/test/API/functionalities/completion/Makefile lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 42f10082b981..90172f39412d 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -739,6 +739,12 @@ class Process : public std::enable_shared_from_this, void SetShouldDetach(bool b) { m_should_detach = b; } + /// Get the image vector for the current process. + /// + /// \return + /// The constant reference to the member m_image_tokens. + const std::vector& GetImageTokens() { return m_image_tokens; } + /// Get the image information address for the current process. /// /// Some runtimes have system functions that can help dynamic loaders locate diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index a5df62f23345..25fe2e4b8b1a 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -923,6 +923,17 @@ class CommandObjectProcessLoad : public CommandObjectParsed { ~CommandObjectProcessLoad() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { +if (!m_exe_ctx.HasProcessScope()) + return; + +CommandCompletions::InvokeCommonCompletionCallbacks( +GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, +request, nullptr); + } + Options *GetOptions() override { return _options; } protected: @@ -988,6 +999,24 @@ class CommandObjectProcessUnload : public CommandObjectParsed { ~CommandObjectProcessUnload() override = default; + void + HandleArgumentCompletion(CompletionRequest , + OptionElementVector _element_vector) override { + +if (request.GetCursorIndex() || !m_exe_ctx.HasProcessScope()) + return; + +Process *process = m_exe_ctx.GetProcessPtr(); + +const std::vector = process->GetImageTokens(); +const size_t token_num = tokens.size(); +for (size_t i = 0; i < token_num; ++i) { + if (tokens[i] == LLDB_INVALID_IMAGE_TOKEN) +continue; + request.TryCompleteCurrentArg(std::to_string(i)); +} + } + protected: bool DoExecute(Args , CommandReturnObject ) override { Process *process = m_exe_ctx.GetProcessPtr(); diff --git a/lldb/test/API/functionalities/completion/Makefile b/lldb/test/API/functionalities/completion/Makefile index 8b20bcb0..f46742243bd9 100644 --- a/lldb/test/API/functionalities/completion/Makefile +++ b/lldb/test/API/functionalities/completion/Makefile @@ -1,3 +1,10 @@ CXX_SOURCES := main.cpp +USE_LIBDL := 1 + +a.out: lib_shared + +lib_shared: + $(MAKE) -f $(MAKEFILE_RULES) \ + DYLIB_ONLY=YES DYLIB_CXX_SOURCES=shared.cpp DYLIB_NAME=shared include Makefile.rules diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 4922cca7b722..4c81288b3836 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -85,6 +85,31 @@ def test_process_launch_arch(self): ['mips', 'arm64']) +def test_process_load(self): +self.build() +lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp")) +self.complete_from_to('process load Makef', 'process load Makefile') + +@skipUnlessPlatform(["linux"]) +def test_process_unload(self): +"""Test the completion for "process unload " """ +# This tab completion should not work without a running process. +self.complete_from_to('process unload ', + 'process unload ') + +self.build() +lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp")) +
[Lldb-commits] [lldb] 22e63cb - [lldb] tab completion for breakpoint names
Author: Gongyu Deng Date: 2020-08-20T20:56:34+02:00 New Revision: 22e63cba17e5e6266b9251e3fb7032b793143d09 URL: https://github.com/llvm/llvm-project/commit/22e63cba17e5e6266b9251e3fb7032b793143d09 DIFF: https://github.com/llvm/llvm-project/commit/22e63cba17e5e6266b9251e3fb7032b793143d09.diff LOG: [lldb] tab completion for breakpoint names 1. created a common completion for breakpoint names; 2. bound the breakpoint name common completion with eArgTypeBreakpointName; 3. implemented the dedicated completion for breakpoint read -N. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D80693 Added: lldb/test/API/functionalities/completion/breakpoints.json lldb/test/API/functionalities/completion/breakpoints_invalid.json Modified: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index a744b3fd849d..1d8972e0ca03 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -44,10 +44,11 @@ class CommandCompletions { eStopHookIDCompletion = (1u << 16), eThreadIndexCompletion = (1u << 17), eWatchPointIDCompletion = (1u << 18), +eBreakpointNameCompletion = (1u << 19), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 19) +eCustomCompletion = (1u << 20) }; static bool InvokeCommonCompletionCallbacks( @@ -101,6 +102,10 @@ class CommandCompletions { static void Breakpoints(CommandInterpreter , CompletionRequest , SearchFilter *searcher); + static void BreakpointNames(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher); + static void ProcessPluginNames(CommandInterpreter , CompletionRequest , SearchFilter *searcher); diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 4ed11e14b84f..109613e223c7 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -70,6 +70,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eStopHookIDCompletion, CommandCompletions::StopHookIDs}, {eThreadIndexCompletion, CommandCompletions::ThreadIndexes}, {eWatchPointIDCompletion, CommandCompletions::WatchPointIDs}, + {eBreakpointNameCompletion, CommandCompletions::BreakpointNames}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -617,13 +618,26 @@ void CommandCompletions::Breakpoints(CommandInterpreter , } } +void CommandCompletions::BreakpointNames(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher) { + lldb::TargetSP target = interpreter.GetDebugger().GetSelectedTarget(); + if (!target) +return; + + std::vector name_list; + target->GetBreakpointNames(name_list); + + for (const std::string : name_list) +request.TryCompleteCurrentArg(name); +} + void CommandCompletions::ProcessPluginNames(CommandInterpreter , CompletionRequest , SearchFilter *searcher) { PluginManager::AutoCompleteProcessName(request.GetCursorArgumentPrefix(), request); } - void CommandCompletions::DisassemblyFlavors(CommandInterpreter , CompletionRequest , SearchFilter *searcher) { diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index b62fe6c93cd8..023ba208176a 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -2097,7 +2097,79 @@ class CommandObjectBreakpointRead : public CommandObjectParsed { return llvm::makeArrayRef(g_breakpoint_read_options); } -// Instance variables to hold the values for command options. +void HandleOptionArgumentCompletion( +CompletionRequest , OptionElementVector _element_vector, +int opt_element_index, CommandInterpreter ) override { + int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; +
[Lldb-commits] [lldb] 4a15f51 - [lldb][NFC] Simplify string literal in GDBRemoteCommunicationClient
Author: Raphael Isemann Date: 2020-08-26T16:25:11+02:00 New Revision: 4a15f51a4f7726e12c327fa30e76d90a2b90430b URL: https://github.com/llvm/llvm-project/commit/4a15f51a4f7726e12c327fa30e76d90a2b90430b DIFF: https://github.com/llvm/llvm-project/commit/4a15f51a4f7726e12c327fa30e76d90a2b90430b.diff LOG: [lldb][NFC] Simplify string literal in GDBRemoteCommunicationClient Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Removed: diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 2e6d174e4674..0949b9918523 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1701,14 +1701,9 @@ Status GDBRemoteCommunicationClient::GetWatchpointSupportInfo(uint32_t ) { // Set num to 0 first. num = 0; if (m_supports_watchpoint_support_info != eLazyBoolNo) { -char packet[64]; -const int packet_len = -::snprintf(packet, sizeof(packet), "qWatchpointSupportInfo:"); -assert(packet_len < (int)sizeof(packet)); -UNUSED_IF_ASSERT_DISABLED(packet_len); StringExtractorGDBRemote response; -if (SendPacketAndWaitForResponse(packet, response, false) == -PacketResult::Success) { +if (SendPacketAndWaitForResponse("qWatchpointSupportInfo:", response, + false) == PacketResult::Success) { m_supports_watchpoint_support_info = eLazyBoolYes; llvm::StringRef name; llvm::StringRef value; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 188f1ac - [lldb] type category name common completion
Author: Gongyu Deng Date: 2020-08-24T19:54:23+02:00 New Revision: 188f1ac301c5c6da6d2f5697952510fc39cbdd43 URL: https://github.com/llvm/llvm-project/commit/188f1ac301c5c6da6d2f5697952510fc39cbdd43 DIFF: https://github.com/llvm/llvm-project/commit/188f1ac301c5c6da6d2f5697952510fc39cbdd43.diff LOG: [lldb] type category name common completion 1. Added a new common completion TypeCategoryNames to provide a list of category names for completion; 2. Applied the completion to these commands: type category delete/enable/disable/list/define; 3. Added a related test case; 4. Bound the completion to the arguments of the type 'eArgTypeName'. Reviewed By: teemperor, JDevlieghere Differential Revision: https://reviews.llvm.org/D84124 Added: Modified: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index b90e81cb95a8..c80bde0e719b 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -49,6 +49,7 @@ class CommandCompletions { eProcessNameCompletion = (1u << 21), eRemoteDiskFileCompletion = (1u << 22), eRemoteDiskDirectoryCompletion = (1u << 23), +eTypeCategoryNameCompletion = (1u << 24), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. @@ -146,6 +147,10 @@ class CommandCompletions { static void WatchPointIDs(CommandInterpreter , CompletionRequest , SearchFilter *searcher); + + static void TypeCategoryNames(CommandInterpreter , +CompletionRequest , +SearchFilter *searcher); }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 9221830b6460..0ea6d4288169 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -74,7 +75,9 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eProcessIDCompletion, CommandCompletions::ProcessIDs}, {eProcessNameCompletion, CommandCompletions::ProcessNames}, {eRemoteDiskFileCompletion, CommandCompletions::RemoteDiskFiles}, - {eRemoteDiskDirectoryCompletion, CommandCompletions::RemoteDiskDirectories}, + {eRemoteDiskDirectoryCompletion, + CommandCompletions::RemoteDiskDirectories}, + {eTypeCategoryNameCompletion, CommandCompletions::TypeCategoryNames}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -780,3 +783,14 @@ void CommandCompletions::WatchPointIDs(CommandInterpreter , strm.GetString()); } } + +void CommandCompletions::TypeCategoryNames(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher) { + DataVisualization::Categories::ForEach( + [](const lldb::TypeCategoryImplSP _sp) { +request.TryCompleteCurrentArg(category_sp->GetName(), + category_sp->GetDescription()); +return true; + }); +} diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 3cd4ad88afc7..b6af481090d7 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -4725,8 +4725,6 @@ class CommandObjectTargetStopHookDelete : public CommandObjectParsed { void HandleArgumentCompletion(CompletionRequest , OptionElementVector _element_vector) override { -if (request.GetCursorIndex()) - return; CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion, request, nullptr); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index b23f91de0ce6..d820e7abd21f 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@
[Lldb-commits] [lldb] 3cd8d7b - [lldb] Remote disk file/directory completion for platform commands
Author: Gongyu Deng Date: 2020-08-24T17:55:54+02:00 New Revision: 3cd8d7b1727f06a701f41764c1109e5d321284b3 URL: https://github.com/llvm/llvm-project/commit/3cd8d7b1727f06a701f41764c1109e5d321284b3 DIFF: https://github.com/llvm/llvm-project/commit/3cd8d7b1727f06a701f41764c1109e5d321284b3.diff LOG: [lldb] Remote disk file/directory completion for platform commands 1. Extended the gdb-remote communication related classes with disk file/directory completion functions; 2. Added two common completion functions RemoteDiskFiles and RemoteDiskDirectories based on the functions above; 3. Added completion for these commands: A. platform get-file ; B. platform put-file ; C. platform get-size ; D. platform settings -w ; E. platform open file . 4. Added related tests for client and server; 5. Updated docs/lldb-platform-packets.txt. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D85284 Added: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py Modified: lldb/docs/lldb-platform-packets.txt lldb/include/lldb/Interpreter/CommandCompletions.h lldb/include/lldb/Target/Platform.h lldb/include/lldb/Utility/StringExtractorGDBRemote.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectPlatform.cpp lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h lldb/source/Utility/StringExtractorGDBRemote.cpp lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py Removed: diff --git a/lldb/docs/lldb-platform-packets.txt b/lldb/docs/lldb-platform-packets.txt index 23d1cacc5f7e..8d3fed7ab341 100644 --- a/lldb/docs/lldb-platform-packets.txt +++ b/lldb/docs/lldb-platform-packets.txt @@ -237,6 +237,27 @@ incompatible with the flags that gdb specifies. // Continues to return the results of the qfProcessInfo. Once all matches // have been sent, Exx is returned to indicate end of matches. +//-- +// qPathComplete +// +// BRIEF +// Get a list of matched disk files/directories by passing a boolean flag +// and a partial path. +// +// EXAMPLE +// +// receive: qPathComplete:0,6d61696e +// send:M6d61696e2e637070 +// receive: qPathComplete:1,746573 +// send:M746573742f,74657374732f +// +// If the first argument is zero, the result should contain all +// files (including directories) starting with the given path. If the +// argument is one, the result should contain only directories. +// +// The result should be a comma-separated list of hex-encoded paths. +// Paths denoting a directory should end with a directory separator ('/' or '\'). + //-- // vFile:size: // diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 0392eaed62c5..b90e81cb95a8 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -47,10 +47,12 @@ class CommandCompletions { eBreakpointNameCompletion = (1u << 19), eProcessIDCompletion = (1u << 20), eProcessNameCompletion = (1u << 21), +eRemoteDiskFileCompletion = (1u << 22), +eRemoteDiskDirectoryCompletion = (1u << 23), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 22) +eCustomCompletion = (1u << 24) }; static bool InvokeCommonCompletionCallbacks( @@ -72,6 +74,14 @@ class CommandCompletions { StringList , TildeExpressionResolver ); + static void RemoteDiskFiles(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher); + + static void RemoteDiskDirectories(CommandInterpreter , +CompletionRequest , +SearchFilter *searcher); + static void SourceFiles(CommandInterpreter , CompletionRequest , SearchFilter *searcher); diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 6234b8244b3f..9335f73b37df
[Lldb-commits] [lldb] 19311f5 - [lldb] common completion for process pids and process names
Author: Gongyu Deng Date: 2020-08-24T17:30:43+02:00 New Revision: 19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa URL: https://github.com/llvm/llvm-project/commit/19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa DIFF: https://github.com/llvm/llvm-project/commit/19311f5c3e9ada9d445e49feb7a2ae00ddaee2fa.diff LOG: [lldb] common completion for process pids and process names 1. Added two common completions: `ProcessIDs` and `ProcessNames`, which are refactored from their original dedicated option completions; 2. Removed the dedicated option completion functions of `process attach` and `platform process attach`, so that they can use arg-type-bound common completions instead; 3. Bound `eArgTypePid` to the pid completion, `eArgTypeProcessName` to the process name completion in `CommandObject.cpp`; 4. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D80700 Added: Modified: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectPlatform.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py lldb/test/API/functionalities/completion/main.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 1d8972e0ca03..0392eaed62c5 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -45,10 +45,12 @@ class CommandCompletions { eThreadIndexCompletion = (1u << 17), eWatchPointIDCompletion = (1u << 18), eBreakpointNameCompletion = (1u << 19), +eProcessIDCompletion = (1u << 20), +eProcessNameCompletion = (1u << 21), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 20) +eCustomCompletion = (1u << 22) }; static bool InvokeCommonCompletionCallbacks( @@ -110,6 +112,12 @@ class CommandCompletions { CompletionRequest , SearchFilter *searcher); + static void ProcessIDs(CommandInterpreter , + CompletionRequest , SearchFilter *searcher); + + static void ProcessNames(CommandInterpreter , + CompletionRequest , SearchFilter *searcher); + static void DisassemblyFlavors(CommandInterpreter , CompletionRequest , SearchFilter *searcher); diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 109613e223c7..9e74d8ad26cd 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -71,6 +71,8 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eThreadIndexCompletion, CommandCompletions::ThreadIndexes}, {eWatchPointIDCompletion, CommandCompletions::WatchPointIDs}, {eBreakpointNameCompletion, CommandCompletions::BreakpointNames}, + {eProcessIDCompletion, CommandCompletions::ProcessIDs}, + {eProcessNameCompletion, CommandCompletions::ProcessNames}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -649,6 +651,33 @@ void CommandCompletions::DisassemblyFlavors(CommandInterpreter , } } +void CommandCompletions::ProcessIDs(CommandInterpreter , +CompletionRequest , +SearchFilter *searcher) { + lldb::PlatformSP platform_sp(interpreter.GetPlatform(true)); + if (!platform_sp) +return; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; + platform_sp->FindProcesses(match_info, process_infos); + for (const ProcessInstanceInfo : process_infos) +request.TryCompleteCurrentArg(std::to_string(info.GetProcessID()), + info.GetNameAsStringRef()); +} + +void CommandCompletions::ProcessNames(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher) { + lldb::PlatformSP platform_sp(interpreter.GetPlatform(true)); + if (!platform_sp) +return; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; + platform_sp->FindProcesses(match_info, process_infos); + for (const ProcessInstanceInfo : process_infos) +request.TryCompleteCurrentArg(info.GetNameAsStringRef()); +} + void CommandCompletions::TypeLanguages(CommandInterpreter , CompletionRequest ,
[Lldb-commits] [lldb] c57ea1b - [lldb] Get lldb-server platform's --socket-file working again
Author: Raphael Isemann Date: 2020-08-17T10:29:06+02:00 New Revision: c57ea1b48f26caf7922bf434187e1c277f412550 URL: https://github.com/llvm/llvm-project/commit/c57ea1b48f26caf7922bf434187e1c277f412550 DIFF: https://github.com/llvm/llvm-project/commit/c57ea1b48f26caf7922bf434187e1c277f412550.diff LOG: [lldb] Get lldb-server platform's --socket-file working again `lldb-server platform --socket-file /any/path` currently always fails to create the socket file. This stopped working after D67424 which changed the input variables of `writeFileAtomically` slightly. We're expected to pass in a temporary path template (`/tmp/foo-%`) and the final path we want to write. Instead we currently pass in the never set `temp_file_path` as the temporary path (which will make this function always fail) and pass in the temp_file_spec's path as the final path (which is actually the template path such as `/tmp/foo-%`) instead of the actual path we want to write (e.g. `/tmp/foo`). Reviewed By: labath Differential Revision: https://reviews.llvm.org/D85890 Added: Modified: lldb/tools/lldb-server/lldb-platform.cpp Removed: diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp index 33f918ffc2a1..ba3b6c59185c 100644 --- a/lldb/tools/lldb-server/lldb-platform.cpp +++ b/lldb/tools/lldb-server/lldb-platform.cpp @@ -104,11 +104,12 @@ static Status save_socket_id_to_file(const std::string _id, llvm::SmallString<64> temp_file_path; temp_file_spec.AppendPathComponent("port-file.%%"); + temp_file_path = temp_file_spec.GetPath(); Status status; if (auto Err = handleErrors(llvm::writeFileAtomically( - temp_file_path, temp_file_spec.GetPath(), socket_id), + temp_file_path, file_spec.GetPath(), socket_id), [, _spec](const AtomicFileWriteError ) { std::string ErrorMsgBuffer; llvm::raw_string_ostream S(ErrorMsgBuffer); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5913f25 - [lldb][NFC] Remove stride parameter from GetArrayElementType
Author: Raphael Isemann Date: 2020-08-17T10:19:51+02:00 New Revision: 5913f2591c45dc84e872a62343f81462372ccbdb URL: https://github.com/llvm/llvm-project/commit/5913f2591c45dc84e872a62343f81462372ccbdb DIFF: https://github.com/llvm/llvm-project/commit/5913f2591c45dc84e872a62343f81462372ccbdb.diff LOG: [lldb][NFC] Remove stride parameter from GetArrayElementType This parameter isn't used anywhere in LLDB nor the Swift downstream branch. It also doesn't really fit into the TypeSystem APIs that usually don't return additional related functionality via some output parameters. Also the implementations already states that the calculated value there is wrong. Let's remove it. If we need this functionality at some point then Swift's much nicer `GetByteStride` function seems like the way to go. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D84299 Added: Modified: lldb/include/lldb/Symbol/CompilerType.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/source/Symbol/CompilerType.cpp Removed: diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 7d5d71cbc55c..c5e19773d51c 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -177,8 +177,7 @@ class CompilerType { /// Creating related types. /// \{ - CompilerType GetArrayElementType(ExecutionContextScope *exe_scope, - uint64_t *stride = nullptr) const; + CompilerType GetArrayElementType(ExecutionContextScope *exe_scope) const; CompilerType GetArrayType(uint64_t size) const; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 4b851fea6e02..31cd447ed29a 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -218,7 +218,7 @@ class TypeSystem : public PluginInterface { // Creating related types virtual CompilerType - GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride, + GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) = 0; virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type, diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 7f5fdb5b0d91..69c829d21fda 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -4090,7 +4090,6 @@ unsigned TypeSystemClang::GetTypeQualifiers(lldb::opaque_compiler_type_t type) { CompilerType TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride, ExecutionContextScope *exe_scope) { if (type) { clang::QualType qual_type(GetQualType(type)); @@ -4101,14 +4100,7 @@ TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type, if (!array_eletype) return CompilerType(); -CompilerType element_type = GetType(clang::QualType(array_eletype, 0)); - -// TODO: the real stride will be >= this value.. find the real one! -if (stride) - if (Optional size = element_type.GetByteSize(exe_scope)) -*stride = *size; - -return element_type; +return GetType(clang::QualType(array_eletype, 0)); } return CompilerType(); } diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 78c45ae32d3b..399743a72f76 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -689,7 +689,6 @@ class TypeSystemClang : public TypeSystem { uint32_t opaque_payload); CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride, ExecutionContextScope *exe_scope) override; CompilerType GetArrayType(lldb::opaque_compiler_type_t type, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index c27bba26a208..2d2d8c3463c4 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -317,10 +317,10 @@ unsigned CompilerType::GetTypeQualifiers() const { // Creating related types -CompilerType CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope, - uint64_t *stride) const { +CompilerType +CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope) const { if (IsValid()) { -return m_type_system->GetArrayElementType(m_type, stride,
[Lldb-commits] [lldb] 24fc317 - [lldb] Print the exception traceback when hitting cleanup errors
Author: Raphael Isemann Date: 2020-08-17T09:53:52+02:00 New Revision: 24fc3177c1767535aeb494511a13dabf9f6de647 URL: https://github.com/llvm/llvm-project/commit/24fc3177c1767535aeb494511a13dabf9f6de647 DIFF: https://github.com/llvm/llvm-project/commit/24fc3177c1767535aeb494511a13dabf9f6de647.diff LOG: [lldb] Print the exception traceback when hitting cleanup errors Right now if the test suite encounters a cleanup error it just prints "CLEANUP ERROR:" but not any additional information. This patch just prints the exception that caused the cleanup error. This should make debugging the failing tests for D83865 easier (and seems in general nice to have). Reviewed By: labath Differential Revision: https://reviews.llvm.org/D83874 Added: Modified: lldb/packages/Python/lldbsuite/test/test_result.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 54affca86057..cab446d95e6d 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -9,6 +9,7 @@ # System modules import os +import traceback # Third-party modules import unittest2 @@ -228,8 +229,8 @@ def addCleanupError(self, test, err): if method: method() self.stream.write( -"CLEANUP ERROR: LLDB (%s) :: %s\n" % -(self._config_string(test), str(test))) +"CLEANUP ERROR: LLDB (%s) :: %s\n%s\n" % +(self._config_string(test), str(test), traceback.format_exc())) def addFailure(self, test, err): if (self.checkExclusion( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7208cb1 - [lldb] Remove XFAIL from now passing TestPtrRefs/TestPtreRefsObjC
Author: Raphael Isemann Date: 2020-08-15T08:14:44+02:00 New Revision: 7208cb1ac43e4be806bcb91c622fc1f8641e010b URL: https://github.com/llvm/llvm-project/commit/7208cb1ac43e4be806bcb91c622fc1f8641e010b DIFF: https://github.com/llvm/llvm-project/commit/7208cb1ac43e4be806bcb91c622fc1f8641e010b.diff LOG: [lldb] Remove XFAIL from now passing TestPtrRefs/TestPtreRefsObjC 8fcfe2862fd4fde4793e232cfeebe6c5540c80a5 and 0cceb54366b406649fdfe7bb11b133ab96f3cd70 fixed those tests. Added: Modified: lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py Removed: diff --git a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py index 6a392a0a756e..96073ea7fa6b 100644 --- a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py +++ b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py @@ -15,7 +15,6 @@ class TestPtrRefs(TestBase): @skipIfAsan # The output looks diff erent under ASAN. @skipUnlessDarwin -@expectedFailureAll(oslist=["macosx"], debug_info=["dwarf", "gmodules"], bugnumber="llvm.org/pr45112") def test_ptr_refs(self): """Test format string functionality.""" self.build() diff --git a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py index ca543eb91967..7767f7b45720 100644 --- a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py +++ b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py @@ -15,7 +15,6 @@ class TestPtrRefsObjC(TestBase): @skipIfAsan # The output looks diff erent under ASAN. @skipUnlessDarwin -@expectedFailureAll(oslist=["macosx"], debug_info=["dwarf", "gmodules"], bugnumber="llvm.org/pr45112") def test_ptr_refs(self): """Test the ptr_refs tool on Darwin with Objective-C""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 24c74f5 - [lldb] Don't delete orphaned shared modules in SBDebugger::DeleteTarget
Author: Raphael Isemann Date: 2020-08-17T11:30:56+02:00 New Revision: 24c74f5e8c2cf263dd84292ca5d33ee0890b48dd URL: https://github.com/llvm/llvm-project/commit/24c74f5e8c2cf263dd84292ca5d33ee0890b48dd DIFF: https://github.com/llvm/llvm-project/commit/24c74f5e8c2cf263dd84292ca5d33ee0890b48dd.diff LOG: [lldb] Don't delete orphaned shared modules in SBDebugger::DeleteTarget In D83876 the consensus seems that LLDB should never deleted orphaned modules implicitly. However, SBDebugger::DeleteTarget is currently doing exactly that. This code was added in 753406221b55b95141c8c1239660dc4db4e35ea5 but I don't see any explanation in the commit, so I think we should delete it. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D83933 Added: Modified: lldb/source/API/SBDebugger.cpp Removed: diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 5f62987f37da..b39481c70972 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -879,8 +879,6 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget ) { result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp); target_sp->Destroy(); target.Clear(); - const bool mandatory = true; - ModuleList::RemoveOrphanSharedModules(mandatory); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits