[Lldb-commits] [PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3684
+  return ToAttrOrErr.takeError();
+#if 0
+RecordType *FromRT =

It is still not working. The testcase either PASSes despite this `#if 0` or it 
FAILs even if it is `#if 1`. Sure the goal is to reproduce the LLDB testcase 
behavior - PASS with `#if 1` and FAIL with `#if 0`.
With libstdc++11 and this form of patch it fails on:
```
  lldb-api :: 
commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  lldb-api :: 
commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
  lldb-api :: 
commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
```
It also fails for this one but there are reasons not interesting for this patch:
```
  lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
```
These two are too complex to debug IMO:
```
  lldb-api :: 
commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
```
I tried to reproduce the first two, this one has [[ 
https://people.redhat.com/jkratoch/lldbbt1.txt | such backtrace ]]:
```
  lldb-api :: 
commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
```



Comment at: clang/unittests/AST/ASTImporterTest.cpp:6441
+  findFromTU(FromB)->Importer->Imported(FromB, ToB);
+  llvm::Error Err = findFromTU(FromB)->Importer->ImportDefinition(FromB);
+  EXPECT_FALSE((bool)Err);

This code is trying to mimic the LLDB behavior from the backtrace of LLDB 
testcase: https://people.redhat.com/jkratoch/lldbbt1.txt



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101236/new/

https://reviews.llvm.org/D101236

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102942: Remove or use variables which are unused but set.

2021-05-24 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.

`ABISysV_ppc.cpp` feels a bit like this should be used to calculate some 
offset, but I don't think that's for this review to figure out what is wrong 
there. The other LLDB changes LGTM.




Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:3104
   bool wants_raw_input = false;
-  size_t actual_cmd_name_len = 0;
   std::string next_word;

Was already checked in unused and I don't see what we would need that for, LGTM.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp:342
 
-uint32_t isa_count = 0;
-

This code was apparently rendered obsolete by 
89870cebcb0c9996f49336a21e72b80511f37341 so LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102942/new/

https://reviews.llvm.org/D102942

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 42a9c0c - [lldb] Reland "Fix UB in half2float" to fix the ubsan bot.

2021-05-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-24T15:23:32+02:00
New Revision: 42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55

URL: 
https://github.com/llvm/llvm-project/commit/42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55
DIFF: 
https://github.com/llvm/llvm-project/commit/42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55.diff

LOG: [lldb] Reland "Fix UB in half2float" to fix the ubsan bot.

This relands part of the UB fix in 4b074b49be206306330076b9fa40632ef1960823.
The original commit also added some additional tests that uncovered some
other issues (see D102845). I landed all the passing tests in
48780527dd6820698f3537f5ebf76499030ee349 and this patch is now just fixing
the UB in half2float. See D102846 for a proposed rewrite of the function.

Original commit message:

  The added DumpDataExtractorTest uncovered that this is lshifting a negative
  integer which upsets ubsan and breaks the sanitizer bot. This patch just
  changes the variable we shift to be unsigned.

Added: 


Modified: 
lldb/source/Core/DumpDataExtractor.cpp

Removed: 




diff  --git a/lldb/source/Core/DumpDataExtractor.cpp 
b/lldb/source/Core/DumpDataExtractor.cpp
index ec44e3481c1e5..34c9353c9feaa 100644
--- a/lldb/source/Core/DumpDataExtractor.cpp
+++ b/lldb/source/Core/DumpDataExtractor.cpp
@@ -52,7 +52,9 @@ static float half2float(uint16_t half) {
 float f;
 uint32_t u;
   } u;
-  int32_t v = (int16_t)half;
+  // Sign extend to 4 byte.
+  int32_t sign_extended = static_cast(half);
+  uint32_t v = static_cast(sign_extended);
 
   if (0 == (v & 0x7c00)) {
 u.u = v & 0x80007FFFU;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103020: [lldb] Add missing mutex guards to TargetList::CreateTarget

2021-05-24 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: LLDB.
teemperor added a project: LLDB.
Herald added a subscriber: JDevlieghere.
teemperor requested review of this revision.

TestMultipleTargets is randomly failing on the bots. The reason for that is 
that the
test is calling `SBDebugger::CreateTarget` from multiple threads.
`TargetList::CreateTarget` is curiously missing the guard that all of its
other member functions have, so all the threads in the test end up changing the
internal TargetList state at the same time and end up corrupting it.


https://reviews.llvm.org/D103020

Files:
  lldb/source/Target/TargetList.cpp


Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,6 +48,7 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, triple_str, load_dependent_files,
   platform_options, target_sp);
@@ -62,6 +63,7 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, specified_arch, load_dependent_files,
   platform_sp, target_sp);


Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,6 +48,7 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, triple_str, load_dependent_files,
   platform_options, target_sp);
@@ -62,6 +63,7 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, specified_arch, load_dependent_files,
   platform_sp, target_sp);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 54c2687 - [lldb] Introduce createTestTarget for creating a valid target in API tests

2021-05-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-24T16:18:44+02:00
New Revision: 54c2687292da54a2d7964a47b0e334155385f084

URL: 
https://github.com/llvm/llvm-project/commit/54c2687292da54a2d7964a47b0e334155385f084
DIFF: 
https://github.com/llvm/llvm-project/commit/54c2687292da54a2d7964a47b0e334155385f084.diff

LOG: [lldb] Introduce createTestTarget for creating a valid target in API tests

At the moment nearly every test calls something similar to
`self.dbg.CreateTarget(self.getBuildArtifact("a.out"))` and them sometimes
checks if the created target is actually valid with something like
`self.assertTrue(target.IsValid(), "some useless text")`.

Beside being really verbose the error messages generated by this pattern are
always just indicating that the target failed to be created but now why.

This patch introduces a helper function `createTestTarget` to our Test class
that creates the target with the much more verbose `CreateTarget` overload that
gives us back an SBError (with a fancy error). If the target couldn't be created
the function prints out the SBError that LLDB returned and asserts for us. It
also defaults to the "a.out" build artifact path that nearly all tests are using
to avoid to hardcode "a.out" in every test.

I converted a bunch of tests to the new function but I'll do the rest of the
test suite as follow ups.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D102771

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/android/platform/TestDefaultCacheLineSize.py
lldb/test/API/api/listeners/TestListener.py
lldb/test/API/assert_messages_test/TestAssertMessages.py
lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py

lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
lldb/test/API/commands/expression/completion/TestExprCompletion.py
lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py
lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py
lldb/test/API/commands/expression/test/TestExprs.py
lldb/test/API/commands/frame/language/TestGuessLanguage.py
lldb/test/API/commands/frame/var/TestFrameVar.py

lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
lldb/test/API/commands/process/launch/TestProcessLaunch.py
lldb/test/API/commands/register/register/register_command/TestRegisters.py

lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
lldb/test/API/functionalities/asan/TestMemoryHistory.py
lldb/test/API/functionalities/asan/TestReportData.py

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py

lldb/test/API/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py

lldb/test/API/functionalities/breakpoint/breakpoint_by_file_colon_line/TestBreakpointByFileColonLine.py

lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py

lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py

lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py

lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
lldb/test/API/sample_test/TestSampleTest.py
lldb/test/API/sample_test/main.c

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 77b1eb3a1567a..7c0f01add8f07 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2654,6 +2654,31 @@ def assertSuccess(self, obj, msg=None):
 self.fail(self._formatMessage(msg,
 "'{}' is not success".format(error)))
 
+def createTestTarget(self, file_path=None, msg=None):
+"""
+Creates a target from the file found at the given file path.
+Asserts that the resulting target is valid.
+:param file_path: The file path that should be used to create the 
target.
+  The default argument opens the curren

[Lldb-commits] [PATCH] D102771: [lldb] Introduce createTestTarget for creating a valid target in API tests

2021-05-24 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54c2687292da: [lldb] Introduce createTestTarget for creating 
a valid target in API tests (authored by teemperor).
Herald added subscribers: lldb-commits, wenlei.

Changed prior to commit:
  https://reviews.llvm.org/D102771?vs=346444&id=347384#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102771/new/

https://reviews.llvm.org/D102771

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/android/platform/TestDefaultCacheLineSize.py
  lldb/test/API/api/listeners/TestListener.py
  lldb/test/API/assert_messages_test/TestAssertMessages.py
  lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
  lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
  
lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
  lldb/test/API/commands/expression/completion/TestExprCompletion.py
  lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
  lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py
  lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py
  lldb/test/API/commands/expression/test/TestExprs.py
  lldb/test/API/commands/frame/language/TestGuessLanguage.py
  lldb/test/API/commands/frame/var/TestFrameVar.py
  
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
  lldb/test/API/commands/process/launch/TestProcessLaunch.py
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  
lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
  lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  lldb/test/API/functionalities/asan/TestMemoryHistory.py
  lldb/test/API/functionalities/asan/TestReportData.py
  
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_by_file_colon_line/TestBreakpointByFileColonLine.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
  lldb/test/API/sample_test/TestSampleTest.py
  lldb/test/API/sample_test/main.c

Index: lldb/test/API/sample_test/main.c
===
--- lldb/test/API/sample_test/main.c
+++ lldb/test/API/sample_test/main.c
@@ -1,9 +1,10 @@
 #include 
 
+int test_var = 10;
+
 int
 main()
 {
-  int test_var = 10;
   printf ("Set a breakpoint here: %d.\n", test_var);
   //% test_var = self.frame().FindVariable("test_var")
   //% test_value = test_var.GetValueAsUnsigned()
Index: lldb/test/API/sample_test/TestSampleTest.py
===
--- lldb/test/API/sample_test/TestSampleTest.py
+++ lldb/test/API/sample_test/TestSampleTest.py
@@ -46,3 +46,8 @@
 test_value = test_var.GetValueAsUnsigned()
 self.assertEqual(test_value, 10, "Got the right value for test_var")
 
+def sample_test_no_launch(self):
+""" Same as above but doesn't launch a process."""
+
+target = self.createTestTarget()
+self.expect_expr("test_var", result_value="10")
Index: lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
@@ -99,11 +99,7 @@
 
 def breakpoint_ignore_count_python(self):
 """Use Python APIs to set breakpoint ignore count."""
-exe = self.getBuildArtifact("a.out")
-
-# Create a target by the debugger.
-target = self.dbg.CreateTarget(exe)
-self.assertTrue(target, VALID_TARGET)
+target = self.createTestTarget()
 
 # Now create a breakpoint on main.c by name 'c'.
 breakpoint = target.BreakpointCreateByName('c', 'a.out')
Ind

[Lldb-commits] [lldb] 5d7c1d8 - [lldb] Readd deleted variable in the sample test

2021-05-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-24T16:29:25+02:00
New Revision: 5d7c1d8f33c305b5113cd1429344524ddc2316d9

URL: 
https://github.com/llvm/llvm-project/commit/5d7c1d8f33c305b5113cd1429344524ddc2316d9
DIFF: 
https://github.com/llvm/llvm-project/commit/5d7c1d8f33c305b5113cd1429344524ddc2316d9.diff

LOG: [lldb] Readd deleted variable in the sample test

In D102771 wanted to make `test_var` global to demonstrate the a no-launch test,
but the old variable is still needed for another test. This just creates the
global var with a different name to demonstrate the no-launch functionality.

Added: 


Modified: 
lldb/test/API/sample_test/TestSampleTest.py
lldb/test/API/sample_test/main.c

Removed: 




diff  --git a/lldb/test/API/sample_test/TestSampleTest.py 
b/lldb/test/API/sample_test/TestSampleTest.py
index a2d56e2fda3d..446f4b9f4d3e 100644
--- a/lldb/test/API/sample_test/TestSampleTest.py
+++ b/lldb/test/API/sample_test/TestSampleTest.py
@@ -50,4 +50,4 @@ def sample_test_no_launch(self):
 """ Same as above but doesn't launch a process."""
 
 target = self.createTestTarget()
-self.expect_expr("test_var", result_value="10")
+self.expect_expr("global_test_var", result_value="10")

diff  --git a/lldb/test/API/sample_test/main.c 
b/lldb/test/API/sample_test/main.c
index ac1611b53440..7f53fd41dc7d 100644
--- a/lldb/test/API/sample_test/main.c
+++ b/lldb/test/API/sample_test/main.c
@@ -1,14 +1,15 @@
 #include 
 
-int test_var = 10;
+int global_test_var = 10;
 
 int
 main()
 {
+  int test_var = 10;
   printf ("Set a breakpoint here: %d.\n", test_var);
   //% test_var = self.frame().FindVariable("test_var")
   //% test_value = test_var.GetValueAsUnsigned()
   //% self.assertTrue(test_var.GetError().Success(), "Failed to fetch 
test_var")
   //% self.assertEqual(test_value, 10, "Failed to get the right value for 
test_var")
-  return 0;
+  return global_test_var;
 }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103020: [lldb] Add missing mutex guards to TargetList::CreateTarget

2021-05-24 Thread Vedant Kumar via Phabricator via lldb-commits
vsk accepted this revision as: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, lgtm.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103020/new/

https://reviews.llvm.org/D103020

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103020: [lldb] Add missing mutex guards to TargetList::CreateTarget

2021-05-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision as: JDevlieghere.
JDevlieghere added a comment.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103020/new/

https://reviews.llvm.org/D103020

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102942: Remove or use variables which are unused but set.

2021-05-24 Thread Michael Benfield via Phabricator via lldb-commits
mbenfield added a comment.

In D102942#2774819 , @dblaikie wrote:

> Sure, all sounds good - if you can, please reach out to the authors of any of 
> the semantics changing changes (the ones related to the `Changed` values in 
> transformations) to see if they could add missing test coverage.

Sure, I emailed Sam Parker and Amara Emerson.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102942/new/

https://reviews.llvm.org/D102942

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ba51da8 - [lldb] Add missing mutex guards to TargetList::CreateTarget

2021-05-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-24T19:49:57+02:00
New Revision: ba51da820e4dc73153009f8a621ef49711294ae1

URL: 
https://github.com/llvm/llvm-project/commit/ba51da820e4dc73153009f8a621ef49711294ae1
DIFF: 
https://github.com/llvm/llvm-project/commit/ba51da820e4dc73153009f8a621ef49711294ae1.diff

LOG: [lldb] Add missing mutex guards to TargetList::CreateTarget

TestMultipleTargets is randomly failing on the bots. The reason for that is that
the test is calling `SBDebugger::CreateTarget` from multiple threads.
`TargetList::CreateTarget` is curiously missing the guard that all of its other
member functions have, so all the threads in the test end up changing the
internal TargetList state at the same time and end up corrupting it.

Reviewed By: vsk, JDevlieghere

Differential Revision: https://reviews.llvm.org/D103020

Added: 


Modified: 
lldb/source/Target/TargetList.cpp

Removed: 




diff  --git a/lldb/source/Target/TargetList.cpp 
b/lldb/source/Target/TargetList.cpp
index 1e5856dd0b221..595799cfc92aa 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -48,6 +48,7 @@ Status TargetList::CreateTarget(Debugger &debugger,
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, triple_str, load_dependent_files,
   platform_options, target_sp);
@@ -62,6 +63,7 @@ Status TargetList::CreateTarget(Debugger &debugger,
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, specified_arch, load_dependent_files,
   platform_sp, target_sp);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103020: [lldb] Add missing mutex guards to TargetList::CreateTarget

2021-05-24 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba51da820e4d: [lldb] Add missing mutex guards to 
TargetList::CreateTarget (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103020/new/

https://reviews.llvm.org/D103020

Files:
  lldb/source/Target/TargetList.cpp


Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,6 +48,7 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, triple_str, load_dependent_files,
   platform_options, target_sp);
@@ -62,6 +63,7 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, specified_arch, load_dependent_files,
   platform_sp, target_sp);


Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,6 +48,7 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, triple_str, load_dependent_files,
   platform_options, target_sp);
@@ -62,6 +63,7 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
+  std::lock_guard guard(m_target_list_mutex);
   auto result = TargetList::CreateTargetInternal(
   debugger, user_exe_path, specified_arch, load_dependent_files,
   platform_sp, target_sp);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 347475.
jankratochvil added a comment.

Update of the testcase but it still does not reproduce the LLDB problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101236/new/

https://reviews.llvm.org/D101236

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/Shell/Expr/no_unique_address.cpp
  lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp

Index: lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
@@ -44,18 +44,18 @@
 // CHECK: TranslationUnitDecl {{.*}}
 // CHECK: |-CXXRecordDecl {{.*}} struct Struct definition
 // CHECK: | |-FieldDecl {{.*}} A 'int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 5
 // CHECK: | |-FieldDecl {{.*}} B 'int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 7
 // CHECK: | |-FieldDecl {{.*}} C 'unsigned int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 3
 // CHECK: | |-FieldDecl {{.*}} D 'unsigned int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 15
 // CHECK: | |-FieldDecl {{.*}} E 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 1
 // CHECK: | |-FieldDecl {{.*}} F 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 2
 // CHECK: | |-FieldDecl {{.*}} G 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 3
 // CHECK: | `-FieldDecl {{.*}} H 'char'
-// CHECK: |   `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: |   {{.}}-IntegerLiteral {{.*}} 'int' 3
Index: lldb/test/Shell/Expr/no_unique_address.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/no_unique_address.cpp
@@ -0,0 +1,15 @@
+// Test LLDB does not assert on miscalculated field offsets.
+
+// RUN: %clang_host %s -g -c -o %t.o
+// RUN: %lldb %t.o -o "p c.c" -o exit | FileCheck %s
+
+// CHECK: (lldb) p c.c
+// CHECK-NEXT: (char) $0 = '\0'
+
+struct A {};
+struct B {
+  [[no_unique_address]] A a;
+};
+struct C : B {
+  char c;
+} c;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7196,6 +7196,7 @@
 if (bit_width)
   field->setBitWidth(bit_width);
 SetMemberOwningModule(field, record_decl);
+field->addAttr(NoUniqueAddressAttr::CreateImplicit(ast->getASTContext()));
 
 if (name.empty()) {
   // Determine whether this field corresponds to an anonymous struct or
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6357,6 +6357,78 @@
 ToD->getTemplateSpecializationKind());
 }
 
+struct LLDBMinimalImport : ASTImporterOptionSpecificTestBase {
+  LLDBMinimalImport() {
+Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
+ ASTContext &FromContext, FileManager &FromFileManager,
+ bool MinimalImport,
+ const std::shared_ptr &SharedState) {
+  auto retval = new ASTImporter(ToContext, ToFileManager, FromContext,
+FromFileManager, true /*MinimalImport*/,
+// We use the regular lookup.
+/*SharedState=*/nullptr);
+  retval->setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+  return retval;
+};
+  }
+};
+
+TEST_P(LLDBMinimalImport, LLDBImportNoUniqueAddress) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  R"(
+// lldb/test/API/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
+template  struct DWrapper {};
+typedef DWrapper DW;
+struct B {
+  DW spd;
+} b;
+struct E {
+  B &b_ref = b;
+  static DW f() { return {}; }
+} e;
+  )",
+  Lang_CXX11);
+
+  auto *FromE = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("E")));
+
+#if 0
+  // Set up a stub external storage.
+  FromTU->setHasExternalLexicalStorage(true);
+  // Set up DeclContextBits.HasLazyExternalLexicalLookups to true.
+  FromTU->setMustBuildLookupTable();
+  struct TestExternalASTSource : ExternalASTSource {};
+  FromTU->getASTContext().setExternalSource(new TestExternalASTSource());
+#endif
+
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+struct E;
+  )",
+  

[Lldb-commits] [PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

  cat >1.cpp < struct DWrapper {};
  typedef DWrapper DW;
  struct B {
DW spd;
  } b;
  struct E {
B &b_ref = b;
static DW f() { return {}; }
  } e;
  EOH
  $ (set -ex;./bin/clang -c -o 1.o 1.cpp -Wall -g;./bin/lldb -b ./1.o -o 'p E' 
-o 'p e')
  (lldb) p E
  (lldb) p e
  lldb: .../clang/lib/AST/Decl.cpp:4188: bool 
clang::FieldDecl::isZeroSize(const clang::ASTContext &) const: Assertion 
`isInvalidDecl() && "valid field has incomplete type"' failed.

So importing just the type `E` is insufficient but I somehow cannot import the 
variable `e`:

auto *FromE = FirstDeclMatcher().match(FromTU, 
varDecl(hasName("e")));
  ...
// ASTTests: .../llvm/include/llvm/Support/Casting.h:269: typename 
cast_retty::ret_type llvm::cast(Y *) [X = clang::DeclContext, Y = 
clang::Decl]: Assertion `isa(Val) && "cast() argument of incompatible 
type!"' failed.
llvm::Error Err = findFromTU(FromE)->Importer->ImportDefinition(FromE);


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101236/new/

https://reviews.llvm.org/D101236

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 347478.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101236/new/

https://reviews.llvm.org/D101236

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/Shell/Expr/no_unique_address.cpp
  lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp

Index: lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp
@@ -44,18 +44,18 @@
 // CHECK: TranslationUnitDecl {{.*}}
 // CHECK: |-CXXRecordDecl {{.*}} struct Struct definition
 // CHECK: | |-FieldDecl {{.*}} A 'int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 5
 // CHECK: | |-FieldDecl {{.*}} B 'int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 7
 // CHECK: | |-FieldDecl {{.*}} C 'unsigned int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 3
 // CHECK: | |-FieldDecl {{.*}} D 'unsigned int'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 15
 // CHECK: | |-FieldDecl {{.*}} E 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 1
 // CHECK: | |-FieldDecl {{.*}} F 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 2
 // CHECK: | |-FieldDecl {{.*}} G 'char'
-// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: | | {{.}}-IntegerLiteral {{.*}} 'int' 3
 // CHECK: | `-FieldDecl {{.*}} H 'char'
-// CHECK: |   `-IntegerLiteral {{.*}} 'int' 3
+// CHECK: |   {{.}}-IntegerLiteral {{.*}} 'int' 3
Index: lldb/test/Shell/Expr/no_unique_address.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/no_unique_address.cpp
@@ -0,0 +1,15 @@
+// Test LLDB does not assert on miscalculated field offsets.
+
+// RUN: %clang_host %s -g -c -o %t.o
+// RUN: %lldb %t.o -o "p c.c" -o exit | FileCheck %s
+
+// CHECK: (lldb) p c.c
+// CHECK-NEXT: (char) $0 = '\0'
+
+struct A {};
+struct B {
+  [[no_unique_address]] A a;
+};
+struct C : B {
+  char c;
+} c;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7196,6 +7196,7 @@
 if (bit_width)
   field->setBitWidth(bit_width);
 SetMemberOwningModule(field, record_decl);
+field->addAttr(NoUniqueAddressAttr::CreateImplicit(ast->getASTContext()));
 
 if (name.empty()) {
   // Determine whether this field corresponds to an anonymous struct or
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6357,6 +6357,78 @@
 ToD->getTemplateSpecializationKind());
 }
 
+struct LLDBMinimalImport : ASTImporterOptionSpecificTestBase {
+  LLDBMinimalImport() {
+Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
+ ASTContext &FromContext, FileManager &FromFileManager,
+ bool MinimalImport,
+ const std::shared_ptr &SharedState) {
+  auto retval = new ASTImporter(ToContext, ToFileManager, FromContext,
+FromFileManager, true /*MinimalImport*/,
+// We use the regular lookup.
+/*SharedState=*/nullptr);
+  retval->setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+  return retval;
+};
+  }
+};
+
+TEST_P(LLDBMinimalImport, LLDBImportNoUniqueAddress) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  R"(
+// lldb/test/API/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
+template  struct DWrapper {};
+typedef DWrapper DW;
+struct B {
+  DW spd;
+} b;
+struct E {
+  B &b_ref = b;
+  static DW f() { return {}; }
+} e;
+  )",
+  Lang_CXX11);
+
+  auto *FromE = FirstDeclMatcher().match(FromTU, varDecl(hasName("e")));
+
+#if 0
+  // Set up a stub external storage.
+  FromTU->setHasExternalLexicalStorage(true);
+  // Set up DeclContextBits.HasLazyExternalLexicalLookups to true.
+  FromTU->setMustBuildLookupTable();
+  struct TestExternalASTSource : ExternalASTSource {};
+  FromTU->getASTContext().setExternalSource(new TestExternalASTSource());
+#endif
+
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+struct E;
+extern E e;
+  )",
+  Lang_CXX11);
+  auto *ToE = FirstDeclMatcher().match(ToTU, varDecl(hasName("e")));
+
+#if 1
+  // Set up a 

[Lldb-commits] [lldb] 4c0b0de - [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables from Target

2021-05-24 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2021-05-24T13:13:12-07:00
New Revision: 4c0b0de904a5622c33e3ed97e86c6792fbc13feb

URL: 
https://github.com/llvm/llvm-project/commit/4c0b0de904a5622c33e3ed97e86c6792fbc13feb
DIFF: 
https://github.com/llvm/llvm-project/commit/4c0b0de904a5622c33e3ed97e86c6792fbc13feb.diff

LOG: [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables 
from Target

More decoupling of plugins and non-plugins. Target doesn't need to
manage ClangModulesDeclVendor and ClangPersistentVariables is always available
in situations where you need ClangModulesDeclVendor.

Differential Revision: https://reviews.llvm.org/D102811

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 219213312f64..2d67977dd6a0 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,8 +37,6 @@
 
 namespace lldb_private {
 
-class ClangModulesDeclVendor;
-
 OptionEnumValues GetDynamicValueTypes();
 
 enum InlineStrategy {
@@ -1336,8 +1334,6 @@ class Target : public 
std::enable_shared_from_this,
 
   SourceManager &GetSourceManager();
 
-  ClangModulesDeclVendor *GetClangModulesDeclVendor();
-
   // Methods.
   lldb::SearchFilterSP
   GetSearchFilterForModule(const FileSpec *containingModule);
@@ -1421,8 +1417,6 @@ class Target : public 
std::enable_shared_from_this,
   typedef std::map REPLMap;
   REPLMap m_repl_map;
 
-  std::unique_ptr m_clang_modules_decl_vendor_up;
-
   lldb::SourceManagerUP m_source_manager_up;
 
   typedef std::map StopHookCollection;

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 19031af400ea..49a34898f866 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -850,8 +850,8 @@ void ClangASTSource::FindDeclInModules(NameSearchContext 
&context,
ConstString name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  ClangModulesDeclVendor *modules_decl_vendor =
-  m_target->GetClangModulesDeclVendor();
+  std::shared_ptr modules_decl_vendor =
+  GetClangModulesDeclVendor();
   if (!modules_decl_vendor)
 return;
 
@@ -1143,8 +1143,8 @@ void 
ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
 // Check the modules only if the debug information didn't have a complete
 // interface.
 
-if (ClangModulesDeclVendor *modules_decl_vendor =
-m_target->GetClangModulesDeclVendor()) {
+if (std::shared_ptr modules_decl_vendor =
+GetClangModulesDeclVendor()) {
   ConstString interface_name(interface_decl->getNameAsString().c_str());
   bool append = false;
   uint32_t max_matches = 1;
@@ -1313,8 +1313,8 @@ void 
ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
 // Check the modules only if the debug information didn't have a complete
 // interface.
 
-ClangModulesDeclVendor *modules_decl_vendor =
-m_target->GetClangModulesDeclVendor();
+std::shared_ptr modules_decl_vendor =
+GetClangModulesDeclVendor();
 
 if (!modules_decl_vendor)
   break;
@@ -1750,3 +1750,10 @@ CompilerType ClangASTSource::GuardedCopyType(const 
CompilerType &src_type) {
 
   return m_clang_ast_context->GetType(copied_qual_type);
 }
+
+std::shared_ptr
+ClangASTSource::GetClangModulesDeclVendor() {
+  auto persistent_vars = llvm::cast(
+  m_target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
+  return persistent_vars->GetClangModulesDeclVendor();
+}

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 14761fbeb26b..3afd1fd5f2d1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -314,6 +314,8 @@ class ClangASTSource : public clang::ExternalASTSource,
   ///

[Lldb-commits] [PATCH] D102811: [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables from Target

2021-05-24 Thread Inactive via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c0b0de904a5: [lldb] Move ClangModulesDeclVendor ownership 
to ClangPersistentVariables from… (authored by xiaobai).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102811/new/

https://reviews.llvm.org/D102811

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2546,23 +2546,6 @@
   return *m_source_manager_up;
 }
 
-ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
-  static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended
-   // we can make it
-   // per-target
-
-  {
-std::lock_guard guard(s_clang_modules_decl_vendor_mutex);
-
-if (!m_clang_modules_decl_vendor_up) {
-  m_clang_modules_decl_vendor_up.reset(
-  ClangModulesDeclVendor::Create(*this));
-}
-  }
-
-  return m_clang_modules_decl_vendor_up.get();
-}
-
 Target::StopHookSP Target::CreateStopHook(StopHook::StopHookKind kind) {
   lldb::user_id_t new_uid = ++m_stop_hook_next_id;
   Target::StopHookSP stop_hook_sp;
Index: lldb/source/Target/CMakeLists.txt
===
--- lldb/source/Target/CMakeLists.txt
+++ lldb/source/Target/CMakeLists.txt
@@ -81,7 +81,6 @@
 lldbInterpreter
 lldbSymbol
 lldbUtility
-lldbPluginExpressionParserClang
 lldbPluginProcessUtility
 
   LINK_COMPONENTS
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9653,7 +9653,8 @@
llvm::Triple triple)
 : TypeSystemClang("scratch ASTContext", triple), m_triple(triple),
   m_target_wp(target.shared_from_this()),
-  m_persistent_variables(new ClangPersistentVariables) {
+  m_persistent_variables(
+  new ClangPersistentVariables(target.shared_from_this())) {
   m_scratch_ast_source_up = CreateASTSource();
   m_scratch_ast_source_up->InstallASTContext(*this);
   llvm::IntrusiveRefCntPtr proxy_ast_source(
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -990,8 +990,11 @@
   bool result = false;
 
   if (auto *target = exe_scope->CalculateTarget().get()) {
-if (auto *clang_modules_decl_vendor =
-target->GetClangModulesDeclVendor()) {
+auto *persistent_vars = llvm::cast(
+target->GetPersistentExpressionStateForLanguage(
+lldb::eLanguageTypeC));
+if (std::shared_ptr clang_modules_decl_vendor =
+persistent_vars->GetClangModulesDeclVendor()) {
   ConstString key_cs(key);
   auto types = clang_modules_decl_vendor->FindTypes(
   key_cs, /*max_matches*/ UINT32_MAX);
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -352,10 +352,6 @@
 
 static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target,
 DiagnosticManager &diagnostic_manager) {
-  ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor();
-  if (!decl_vendor)
-return;
-
   if (!target->GetEnableAutoImportClangModules())
 return;
 
@@ -364,6 +360,11 @@
   if (!persistent_state)
 return;
 
+  std::shared_ptr decl_vendor =
+  persistent_state->GetClangModulesDeclVendor();
+  if (!decl_vendor)
+return;
+
   StackFrame *frame = exe_ctx.GetFrameP

[Lldb-commits] [lldb] 99155e9 - [lldb][NFC] Remove unused header from Target

2021-05-24 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2021-05-24T15:13:08-07:00
New Revision: 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1

URL: 
https://github.com/llvm/llvm-project/commit/99155e913e9bad5f7f8a247f8bb3a3ff3da74af1
DIFF: 
https://github.com/llvm/llvm-project/commit/99155e913e9bad5f7f8a247f8bb3a3ff3da74af1.diff

LOG: [lldb][NFC] Remove unused header from Target

Should have been removed with 4c0b0de904a5622c33e3ed97e86c6792fbc13feb
but I forgot to do so.

Added: 


Modified: 
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 8ebc3ae3098c..550aa14c4db3 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "lldb/Target/Target.h"
-#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
 #include "lldb/Breakpoint/BreakpointIDList.h"
 #include "lldb/Breakpoint/BreakpointPrecondition.h"
 #include "lldb/Breakpoint/BreakpointResolver.h"



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits