[Lldb-commits] [lldb] 6507bc5 - [lldb/Test] Temporarily disable TestSimulatorPlatform.py

2020-06-24 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-23T22:41:01-07:00
New Revision: 6507bc56216ba4441790bc581a5b76d9c2ad9774

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

LOG: [lldb/Test] Temporarily disable TestSimulatorPlatform.py

Added: 


Modified: 
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py

Removed: 




diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index dce37aa6d706..4cc7ea6b8656 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -6,6 +6,7 @@
 import unittest2
 
 
+@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -39,7 +40,6 @@ def test_tvos(self):
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
 @apple_simulator_test('watch')
-@skipIfDarwin # rdar://problem/64552748
 def test_watchos(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='i386',



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


[Lldb-commits] [lldb] 4bfa438 - [lldb] fix typo in docs: withing -> within

2020-06-24 Thread Konrad Kleine via lldb-commits

Author: Konrad Kleine
Date: 2020-06-24T05:19:47-04:00
New Revision: 4bfa43809fe6780159a4980cf601c504cbec6f32

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

LOG: [lldb] fix typo in docs: withing -> within

Added: 


Modified: 
lldb/docs/resources/caveats.rst

Removed: 




diff  --git a/lldb/docs/resources/caveats.rst b/lldb/docs/resources/caveats.rst
index 780fb349051b..7a77b0dce9fd 100644
--- a/lldb/docs/resources/caveats.rst
+++ b/lldb/docs/resources/caveats.rst
@@ -10,7 +10,7 @@ Python
 --
 
 LLDB has a powerful scripting interface which is accessible through Python.
-Python is available either from withing LLDB through a (interactive) script
+Python is available either from within LLDB through a (interactive) script
 interpreter, or as a Python module which you can import from the Python
 interpreter.
 



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


[Lldb-commits] [PATCH] D82396: [lldb/ScriptInterpreter] Extract IO redirection logic and move it out of ScriptInterpreterPython (NFC)

2020-06-24 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Sounds like a good idea, just the error handling needs to be done carefully.




Comment at: lldb/source/Interpreter/ScriptInterpreter.cpp:171
+  if (!nullin) {
+error = nullin.takeError();
+return;

I'm pretty sure this will trigger an assertion about overwriting an unchecked 
error. One way to handle this would be to wrap the error in an 
`ErrorAsOutParameter` object, but I think it's better to replace the 
constructor with a static factory function returning an `Expected`.


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

https://reviews.llvm.org/D82396



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


[Lldb-commits] [PATCH] D81978: Redo of Add terminateCommands to lldb-vscode protocol

2020-06-24 Thread Florian Hahn via Phabricator via lldb-commits
fhahn added a comment.

I noticed that it appears that `  lldb-api :: 
tools/lldb-vscode/attach/TestVSCode_attach.py` is flaky and I noticed it 
failing spuriously relatively frequently

For example http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5519 
failed with

  FAIL: lldb-api :: tools/lldb-vscode/attach/TestVSCode_attach.py (825 of 2068)
   TEST 'lldb-api :: 
tools/lldb-vscode/attach/TestVSCode_attach.py' FAILED 
  Script:
  --
  /usr/bin/python3.6 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/dotest.py
 --arch aarch64 -s 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-traces -S nm -u 
CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy 
--env LLVM_LIBS_DIR=/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib 
--build-dir 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/lldb 
--compiler /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/clang 
--dsymutil /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/dsymutil 
--filecheck 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/FileCheck 
--lldb-libs-dir /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/tools/lldb-vscode/attach
 -p TestVSCode_attach.py
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  lldb version 11.0.0
clang revision 72131423cc952ccbd6d8e021ff7c04fa22297fe3
llvm revision 72131423cc952ccbd6d8e021ff7c04fa22297fe3
  LLDB library dir: /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin
  LLDB import library dir: 
/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib
  Libc++ tests will not be run because: Compiling with -stdlib=libc++ fails 
with the error: :1:10: fatal error: 'algorithm' file not found
  #include 
   ^~~
  1 error generated.
  
  Skipping following debug info categories: ['dsym', 'gmodules']
  description: breakpoint 1.1
  description: breakpoint 1.1
  
  --
  Command Output (stderr):
  --
  
  Session logs for test failures/errors/unexpected successes will go into 
directory 
'/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-traces'
  PASS: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_by_name (TestVSCode_attach.TestVSCode_attach)
  UNSUPPORTED: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_by_name_waitFor (TestVSCode_attach.TestVSCode_attach) (requires one of 
darwin, macosx, ios, watchos, tvos, bridgeos) 
  PASS: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_by_pid (TestVSCode_attach.TestVSCode_attach)
  FAIL: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_commands (TestVSCode_attach.TestVSCode_attach)
  CLEANUP ERROR: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_commands (TestVSCode_attach.TestVSCode_attach)
  PASS: LLDB 
(/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64) :: 
test_terminate_commands (TestVSCode_attach.TestVSCode_attach)
  ==
  FAIL: test_commands (TestVSCode_attach.TestVSCode_attach)
  --
  Traceback (most recent call last):
File 
"/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py",
 line 174, in test_commands
  self.continue_to_breakpoints(breakpoint_ids)
File 
"/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py",
 line 226, in continue_to_breakpoints
  self.verify_breakpoint_hit(breakpoint_ids)
File 
"/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py",
 line 85, in verify_breakpoint_hit
  self.assertTrue(False, "breakpoint not hit")
  AssertionError: False is not True : breakpoint not hit
  
Config=aarch64-/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11
  --
  Ran 5 tests in 27.063s
  
  RESULT: FAILED (3 passes, 1 failures, 0 errors, 1 skipped, 0 expected 
failures, 0 unexpected successes)
  
  --

Not sure if the failure is related to this patch, but it appears to be the most 
recent change.


Reposito

[Lldb-commits] [lldb] 16e17ca - [lldb] Refactor Scalar::TruncOrExtendTo

2020-06-24 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-06-24T15:58:33+02:00
New Revision: 16e17ca16a89daa099fd2726d92f08a49870e5a9

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

LOG: [lldb] Refactor Scalar::TruncOrExtendTo

The "type" argument to the function is mostly useless -- the only
interesting aspect of it is signedness. Pass signedness directly and
compute the value of bits and signedness fields -- that's exactly
what the single caller of this function does.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Utility/Scalar.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 1865a34775ee..203ba565b223 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -130,8 +130,8 @@ class Scalar {
 return (m_type >= e_sint) && (m_type <= e_long_double);
   }
 
-  /// Convert integer to \p type, limited to \p bits size.
-  void TruncOrExtendTo(Scalar::Type type, uint16_t bits);
+  /// Convert to an integer with \p bits and the given signedness.
+  void TruncOrExtendTo(uint16_t bits, bool sign);
 
   bool Promote(Scalar::Type type);
 

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 3bcadbe9ed4a..6050c1922564 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2346,8 +2346,8 @@ bool DWARFExpression::Evaluate(
 return false;
   }
   const uint64_t die_offset = opcodes.GetULEB128(&offset);
-  Scalar::Type type = Scalar::e_void;
   uint64_t bit_size;
+  bool sign;
   if (die_offset == 0) {
 // The generic type has the size of an address on the target
 // machine and an unspecified signedness. Scalar has no
@@ -2357,13 +2357,13 @@ bool DWARFExpression::Evaluate(
 error_ptr->SetErrorString("No module");
   return false;
 }
+sign = false;
 bit_size = module_sp->GetArchitecture().GetAddressByteSize() * 8;
 if (!bit_size) {
   if (error_ptr)
 error_ptr->SetErrorString("unspecified architecture");
   return false;
 }
-type = Scalar::GetBestTypeForBitSize(bit_size, false);
   } else {
 // Retrieve the type DIE that the value is being converted to.
 // FIXME: the constness has annoying ripple effects.
@@ -2386,11 +2386,11 @@ bool DWARFExpression::Evaluate(
 switch (encoding) {
 case DW_ATE_signed:
 case DW_ATE_signed_char:
-  type = Scalar::GetBestTypeForBitSize(bit_size, true);
+  sign = true;
   break;
 case DW_ATE_unsigned:
 case DW_ATE_unsigned_char:
-  type = Scalar::GetBestTypeForBitSize(bit_size, false);
+  sign = false;
   break;
 default:
   if (error_ptr)
@@ -2398,13 +2398,8 @@ bool DWARFExpression::Evaluate(
   return false;
 }
   }
-  if (type == Scalar::e_void) {
-if (error_ptr)
-  error_ptr->SetErrorString("Unsupported pointer size");
-return false;
-  }
   Scalar &top = stack.back().ResolveValue(exe_ctx);
-  top.TruncOrExtendTo(type, bit_size);
+  top.TruncOrExtendTo(bit_size, sign);
   break;
 }
 

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 759e2a7b56fc..748dd5541908 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -327,29 +327,9 @@ Scalar::Type Scalar::GetBestTypeForBitSize(size_t 
bit_size, bool sign) {
   return Scalar::e_void;
 }
 
-void Scalar::TruncOrExtendTo(Scalar::Type type, uint16_t bits) {
-  switch (type) {
-  case e_sint:
-  case e_slong:
-  case e_slonglong:
-  case e_sint128:
-  case e_sint256:
-  case e_sint512:
-m_integer = m_integer.sextOrTrunc(bits);
-break;
-  case e_uint:
-  case e_ulong:
-  case e_ulonglong:
-  case e_uint128:
-  case e_uint256:
-  case e_uint512:
-m_integer = m_integer.zextOrTrunc(bits);
-break;
-  default:
-llvm_unreachable("Promoting a Scalar to a specific number of bits is only "
- "supported for integer types.");
-  }
-  m_type = type;
+void Scalar::TruncOrExtendTo(uint16_t bits, bool sign) {
+  m_integer = sign ? m_integer.sextOrTrunc(bits) : m_integer.zextOrTrunc(bits);
+  m_type = GetBestTypeForBitSize(bits, sign);
 }
 
 bool Scalar::Promote(Scalar::Type type) {

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 590ac2fa8338..572c585c6bfd 100644
--- a/lldb/

Re: [Lldb-commits] [PATCH] D81978: Redo of Add terminateCommands to lldb-vscode protocol

2020-06-24 Thread Walter via lldb-commits
I'll revert this patch. This seems to be the reason

Il Mer 24 Giu 2020, 6:27 AM Florian Hahn via Phabricator <
revi...@reviews.llvm.org> ha scritto:

> fhahn added a comment.
>
> I noticed that it appears that `  lldb-api ::
> tools/lldb-vscode/attach/TestVSCode_attach.py` is flaky and I noticed it
> failing spuriously relatively frequently
>
> For example
> http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5519 failed
> with
>
>   FAIL: lldb-api :: tools/lldb-vscode/attach/TestVSCode_attach.py (825 of
> 2068)
>    TEST 'lldb-api ::
> tools/lldb-vscode/attach/TestVSCode_attach.py' FAILED 
>   Script:
>   --
>   /usr/bin/python3.6
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/dotest.py
> --arch aarch64 -s
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-traces -S
> nm -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env
> OBJCOPY=/usr/bin/objcopy --env
> LLVM_LIBS_DIR=/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib
> --build-dir
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex
> --lldb-module-cache-dir
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
> --clang-module-cache-dir
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-build.noindex/module-cache-clang/lldb-api
> --executable
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/lldb --compiler
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/clang
> --dsymutil
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/dsymutil
> --filecheck
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./bin/FileCheck
> --lldb-libs-dir /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/tools/lldb-vscode/attach
> -p TestVSCode_attach.py
>   --
>   Exit Code: 1
>
>   Command Output (stdout):
>   --
>   lldb version 11.0.0
> clang revision 72131423cc952ccbd6d8e021ff7c04fa22297fe3
> llvm revision 72131423cc952ccbd6d8e021ff7c04fa22297fe3
>   LLDB library dir:
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin
>   LLDB import library dir:
> /home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/./lib
>   Libc++ tests will not be run because: Compiling with -stdlib=libc++
> fails with the error: :1:10: fatal error: 'algorithm' file not found
>   #include 
>^~~
>   1 error generated.
>
>   Skipping following debug info categories: ['dsym', 'gmodules']
>   description: breakpoint 1.1
>   description: breakpoint 1.1
>
>   --
>   Command Output (stderr):
>   --
>
>   Session logs for test failures/errors/unexpected successes will go into
> directory
> '/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/lldb-test-traces'
>   PASS: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_by_name (TestVSCode_attach.TestVSCode_attach)
>   UNSUPPORTED: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_by_name_waitFor (TestVSCode_attach.TestVSCode_attach) (requires one
> of darwin, macosx, ios, watchos, tvos, bridgeos)
>   PASS: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_by_pid (TestVSCode_attach.TestVSCode_attach)
>   FAIL: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_commands (TestVSCode_attach.TestVSCode_attach)
>   CLEANUP ERROR: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_commands (TestVSCode_attach.TestVSCode_attach)
>   PASS: LLDB
> (/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11-aarch64)
> :: test_terminate_commands (TestVSCode_attach.TestVSCode_attach)
>   ==
>   FAIL: test_commands (TestVSCode_attach.TestVSCode_attach)
>   --
>   Traceback (most recent call last):
> File
> "/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py",
> line 174, in test_commands
>   self.continue_to_breakpoints(breakpoint_ids)
> File
> "/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py",
> line 226, in continue_to_breakpoints
>   self.verify_breakpoint_hit(breakpoint_ids)
> File
> "/home/tcwg-buildslave/worker/lldb-cmake-aarch64/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py",
> line 85, in verify_breakpoint_hit
>   self.assertTrue(False, "breakpoint not hit")
>   AssertionError: False is not True : breakpoint not hit
>
> Config=aarch64-/home/tcwg-buildslave/worker/lldb-cmake-aarch64/build/bin/clang-11
>   -

[Lldb-commits] [PATCH] D82378: [lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented

2020-06-24 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D82378#2109467 , @jankratochvil 
wrote:

> In D82378#2109330 , @labath wrote:
>
> > Now this situation is not actually handled by lldb's "augmenter", so the 
> > example somewhat shaky, but it does show that there are gaps in clang/llvm 
> > modelling of unwind info.
>
>
> Good to know but ... I do not see how is this `stdcall` unwinding bug related 
> to this issue whether to use `.eh_frame` or not - 
> `UnwindAssembly_x86::AugmentUnwindPlanFromCallSite` cannot verify any 
> `.eh_frame` is 100% valid.


It's not related, at least not directly.  I was mainly responding to the claim 
that all (current) compilers produce asynchronous unwind tables. This example 
disproves that (well, one could claim that this is an asynchronous unwind 
table, but that it is an incorrect one, but I don't think that distinction is 
relevant).

And if there's one bug/incompleteness, there could very well be others, so I 
was also alluding to the fact that we might need to have some sort of an 
"augmentation framework" for the forseeable future. However, it could very well 
be the case that we no longer need to augment epilogue data, and if that's the 
case deleting the code for doing that would be great (but for that someone 
would need to investigate the epilogue behavior of different compilers more 
closely).

> 
> 
>> As for the DW_AT_producer idea, the main gotcha I see there is that 
>> eh/debug_frame is supposed to be usable even without the rest of the debug 
>> info.
> 
> Producer is also recorded in `.gnu.build.attributes` which is in the main 
> binary (not in external `.debug` info):

Well... I don't think that's an improvement. :/ This section seems to be 
present only on some flavours of linux (my distro doesn't have it), so one 
cannot even apply it to linux universally, much less other operating systems.  
So, I don't see the reason for changing the current detection algorithm. I 
think that a much more worthwhile use of time would be to check whether even 
need to detect something in the first place.

In D82378#2109924 , @jankratochvil 
wrote:

> I do not understand why the testcase has **two** epilogues.  The 
> `UnwindAssembly_x86::AugmentUnwindPlanFromCallSite()` code tests only 
> beginning and end of CFI, it does not read anything in between.
>  The simplified testcase works the same for me: 
> https://people.redhat.com/jkratoch/D82378.patch


True. The reason I did that was because in the single-epilogue case, we would 
unwind correctly using pretty much any method (e.g. the instruction emulation 
method, which was used before this patch). But you're right that that is not 
important for this patch. I'll use the simplified version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82378



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


[Lldb-commits] [PATCH] D82378: [lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented

2020-06-24 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 273043.
labath added a comment.

- remove trailing whitespace
- simplify test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82378

Files:
  lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  lldb/test/Shell/Unwind/Inputs/eh-frame-augment-noop.s
  lldb/test/Shell/Unwind/eh-frame-augment-noop.test


Index: lldb/test/Shell/Unwind/eh-frame-augment-noop.test
===
--- /dev/null
+++ lldb/test/Shell/Unwind/eh-frame-augment-noop.test
@@ -0,0 +1,22 @@
+# Test handing of dwarf expressions specifying the location of registers, if
+# those expressions refer to the frame's CFA value.
+
+# UNSUPPORTED: system-windows
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-augment-noop.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+process launch
+# CHECK: stop reason
+
+thread backtrace
+# CHECK: frame #0: {{.*}}`foo + 2
+# CHECK: frame #1: {{.*}}`asm_main + 5
+
+target modules show-unwind -n foo
+# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'eh_frame 
CFI'
+# CHECK: eh_frame augmented UnwindPlan:
+# CHECK:  row[0]:  0: CFA=rsp +8 => rip=[CFA-8]
+# CHECK-NEXT: row[1]:  1: CFA=rsp+16 => rip=[CFA-8]
+# CHECK-NEXT: row[2]:  3: CFA=rsp +8 => rip=[CFA-8]
Index: lldb/test/Shell/Unwind/Inputs/eh-frame-augment-noop.s
===
--- /dev/null
+++ lldb/test/Shell/Unwind/Inputs/eh-frame-augment-noop.s
@@ -0,0 +1,22 @@
+# A function whose prologue and epilogue are described perfectly.  eh_frame
+# augmentation machinery should detect that no augmentation is needed and use
+# eh_frame directly.
+
+.text
+.globl  foo
+foo:
+.cfi_startproc
+pushq   %rax
+.cfi_def_cfa_offset 16
+int3
+pop %rcx
+.cfi_def_cfa_offset 8
+retq
+.cfi_endproc
+
+.globl asm_main
+asm_main:
+.cfi_startproc
+callq foo
+retq
+.cfi_endproc
Index: lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
===
--- lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -141,7 +141,7 @@
   // and we don't need to modify it at all.
 
   if (first_row_pc_loc.GetOffset() == -wordsize) {
-do_augment_unwindplan = false;
+return true;
   }
 }
   }


Index: lldb/test/Shell/Unwind/eh-frame-augment-noop.test
===
--- /dev/null
+++ lldb/test/Shell/Unwind/eh-frame-augment-noop.test
@@ -0,0 +1,22 @@
+# Test handing of dwarf expressions specifying the location of registers, if
+# those expressions refer to the frame's CFA value.
+
+# UNSUPPORTED: system-windows
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-augment-noop.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+process launch
+# CHECK: stop reason
+
+thread backtrace
+# CHECK: frame #0: {{.*}}`foo + 2
+# CHECK: frame #1: {{.*}}`asm_main + 5
+
+target modules show-unwind -n foo
+# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'eh_frame CFI'
+# CHECK: eh_frame augmented UnwindPlan:
+# CHECK:  row[0]:  0: CFA=rsp +8 => rip=[CFA-8]
+# CHECK-NEXT: row[1]:  1: CFA=rsp+16 => rip=[CFA-8]
+# CHECK-NEXT: row[2]:  3: CFA=rsp +8 => rip=[CFA-8]
Index: lldb/test/Shell/Unwind/Inputs/eh-frame-augment-noop.s
===
--- /dev/null
+++ lldb/test/Shell/Unwind/Inputs/eh-frame-augment-noop.s
@@ -0,0 +1,22 @@
+# A function whose prologue and epilogue are described perfectly.  eh_frame
+# augmentation machinery should detect that no augmentation is needed and use
+# eh_frame directly.
+
+.text
+.globl  foo
+foo:
+.cfi_startproc
+pushq   %rax
+.cfi_def_cfa_offset 16
+int3
+pop %rcx
+.cfi_def_cfa_offset 8
+retq
+.cfi_endproc
+
+.globl asm_main
+asm_main:
+.cfi_startproc
+callq foo
+retq
+.cfi_endproc
Index: lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
===
--- lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -141,7 +141,7 @@
   // and we don't need to modify it at all.
 
   if (first_row_pc_loc.GetOffset() == -wordsize) {
-do_augment_unwindplan = false;
+return true;
   }
 }
   }
___
lldb-commits mailing list
lldb-commits@lists

[Lldb-commits] [lldb] 8e08422 - Disable flaky lldb-vscode tests on aarch64

2020-06-24 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-06-24T08:57:20-07:00
New Revision: 8e08422385d93fd99354286abd495484f4513f88

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

LOG: Disable flaky lldb-vscode tests on aarch64

Summary:
These two tests are flaky only on this arch for some reason. They are testing 
important features and are not flaky on x86_64, so I'll investigate this arm 
issue separatedly.

Some flaky runs:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5517/steps/test/logs/stdio
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5527/steps/test/logs/stdio

Diff that created those tests:
https://reviews.llvm.org/D81978

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py 
b/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
index 389794f76751..ac74c7c51c87 100644
--- a/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
+++ b/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
@@ -117,6 +117,7 @@ def test_by_name_waitFor(self):
 @skipIfWindows
 @skipIfDarwin
 @skipIfNetBSD # Hangs on NetBSD as well
+@skipIf(archs="aarch64") # Example of a flaky run 
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5527/steps/test/logs/stdio
 def test_commands(self):
 '''
 Tests the "initCommands", "preRunCommands", "stopCommands",
@@ -195,7 +196,9 @@ def test_commands(self):
 self.verify_commands('terminateCommands', output, terminateCommands)
 
 @skipIfWindows
+@skipIfDarwin
 @skipIfNetBSD # Hangs on NetBSD as well
+@skipIf(archs="aarch64") # Example of a flaky run 
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5517/steps/test/logs/stdio
 def test_terminate_commands(self):
 '''
 Tests that the "terminateCommands", that can be passed during



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


[Lldb-commits] [PATCH] D82396: [lldb/ScriptInterpreter] Extract IO redirection logic and move it out of ScriptInterpreterPython (NFC)

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.



Comment at: lldb/source/Interpreter/ScriptInterpreter.cpp:171
+  if (!nullin) {
+error = nullin.takeError();
+return;

labath wrote:
> I'm pretty sure this will trigger an assertion about overwriting an unchecked 
> error. One way to handle this would be to wrap the error in an 
> `ErrorAsOutParameter` object, but I think it's better to replace the 
> constructor with a static factory function returning an 
> `Expected`.
That's how I did it at first, but I found this more elegant and compact. Maybe 
the `ErrorAsOutParameter` would tip the scales. I'll change it back to a 
factory. 


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

https://reviews.llvm.org/D82396



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


[Lldb-commits] [PATCH] D82378: [lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented

2020-06-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil accepted this revision.
jankratochvil added a comment.
This revision is now accepted and ready to land.

In D82378#2111675 , @labath wrote:

> It's not related, at least not directly.


My goal was to prove `UnwindAssembly_x86::AugmentUnwindPlanFromCallSite` is no 
longer useful nowadays.  It was trying to detect situation where both:

- `.eh_frame` exists
- `.eh_frame` does not unwind prologue

I cannot force clang/gcc to produce such `.eh_frame`, IMO it should be produced 
with `-funwind-tables -fno-asynchronous-unwind-tables` but that does produce 
the same as `-fasynchronous-unwind-tables`.

Whether the compiler has some unwind info incompleteness/bugs is not important, 
the quality of `.eh_frame` from recent clang+gcc is always better than any 
fallbacks LLDB has.

So given `UnwindAssembly_x86::AugmentUnwindPlanFromCallSite` is no longer 
useful and it can (I think it still can sometimes) falsely discard a good 
`.eh_frame` section it would be best to disable 
`UnwindAssembly_x86::AugmentUnwindPlanFromCallSite` for new compilers. The 
question is how to detect "new compilers" without needing DWARF, my only idea 
is to do it by checking existence of section `.gnu.build.attributes`. If some 
Linux distribution still does not have `.gnu.build.attributes` does not matter, 
it is only a backward compatible improvement of current situation. I will post 
a patch for that as I have hijacked this bug.

> And if there's one bug/incompleteness, there could very well be others, so I 
> was also alluding to the fact that we might need to have some sort of an 
> "augmentation framework" for the forseeable future. However, it could very 
> well be the case that we no longer need to augment epilogue data, and if 
> that's the case deleting the code for doing that would be great (but for that 
> someone would need to investigate the epilogue behavior of different 
> compilers more closely).

I do not see any specific case needing augmentation for code from new compilers.

"deleting the code" - if you mean one does not need to detect 
`.gnu.build.attributes` (or some other way) to detect new compilers and rather 
just assume any code is from a new enough compiler it is even better (and I 
agree).

> Well... I don't think that's an improvement. :/ This section seems to be 
> present only on some flavours of linux (my distro doesn't have it),

When it somewhere is an improvement and somewhere it has no effect I find it 
still as an improvement.

> So, I don't see the reason for changing the current detection algorithm.

I mean to discard the current detection if there is possible a more safe 
detection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82378



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


[Lldb-commits] [PATCH] D82396: [lldb/ScriptInterpreter] Extract IO redirection logic and move it out of ScriptInterpreterPython (NFC)

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 273068.
JDevlieghere added a comment.

This now has a small function change w.r.t. the error message.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D82396

Files:
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -911,23 +911,23 @@
 // another string to pass to PyRun_SimpleString messes up the escaping.  So
 // we use the following more complicated method to pass the command string
 // directly down to Python.
-std::unique_ptr io_redirect;
-if (options.GetEnableIO()) {
-  io_redirect =
-  std::make_unique(m_debugger, result);
-} else {
-  llvm::Error error = llvm::Error::success();
-  io_redirect = std::make_unique(error);
-  if (error) {
-if (result)
-  result->AppendErrorWithFormatv("failed to open /dev/null: {0}\n",
- llvm::fmt_consume(std::move(error)));
-else
-  llvm::consumeError(std::move(error));
-return false;
-  }
+llvm::Expected>
+io_redirect_or_error =
+options.GetEnableIO()
+? ScriptInterpreterIORedirect::Create(m_debugger, result)
+: ScriptInterpreterIORedirect::Create();
+if (!io_redirect_or_error) {
+  if (result)
+result->AppendErrorWithFormatv(
+"failed to redirect I/O: {0}\n",
+llvm::fmt_consume(io_redirect_or_error.takeError()));
+  else
+llvm::consumeError(io_redirect_or_error.takeError());
+  return false;
 }
 
+ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
+
 bool success = false;
 {
   // WARNING!  It's imperative that this RAII scope be as tight as
@@ -944,8 +944,8 @@
   (options.GetSetLLDBGlobals() ? Locker::InitGlobals : 0) |
   ((result && result->GetInteractive()) ? 0 : Locker::NoSTDIN),
   Locker::FreeAcquiredLock | Locker::TearDownSession,
-  io_redirect->GetInputFile(), io_redirect->GetOutputFile(),
-  io_redirect->GetErrorFile());
+  io_redirect.GetInputFile(), io_redirect.GetOutputFile(),
+  io_redirect.GetErrorFile());
 
   // Find the correct script interpreter dictionary in the main module.
   PythonDictionary &session_dict = GetSessionDictionary();
@@ -971,7 +971,7 @@
 }
   }
 
-  io_redirect->Flush();
+  io_redirect.Flush();
 }
 
 if (success)
Index: lldb/source/Interpreter/ScriptInterpreter.cpp
===
--- lldb/source/Interpreter/ScriptInterpreter.cpp
+++ lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -119,12 +119,14 @@
   }
 }
 
-ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(
-Debugger &debugger, CommandReturnObject *result)
-: m_communication("lldb.ScriptInterpreterIORedirect.comm"),
-  m_disconnect(false) {
+llvm::Expected>
+ScriptInterpreterIORedirect::Create(Debugger &debugger,
+CommandReturnObject *result) {
+  std::unique_ptr redirect =
+  std::make_unique();
+
   if (result) {
-m_input_file_sp = debugger.GetInputFileSP();
+redirect->m_input_file_sp = debugger.GetInputFileSP();
 
 Pipe pipe;
 Status pipe_result = pipe.CreateNew(false);
@@ -140,15 +142,16 @@
 #endif
 
 if (conn_up->IsConnected()) {
-  m_communication.SetConnection(std::move(conn_up));
-  m_communication.SetReadThreadBytesReceivedCallback(
+  redirect->m_communication.SetConnection(std::move(conn_up));
+  redirect->m_communication.SetReadThreadBytesReceivedCallback(
   ReadThreadBytesReceived, &result->GetOutputStream());
-  m_communication.StartReadThread();
-  m_disconnect = true;
+  redirect->m_communication.StartReadThread();
+  redirect->m_disconnect = true;
 
   FILE *outfile_handle = fdopen(pipe.ReleaseWriteFileDescriptor(), "w");
-  m_output_file_sp = std::make_shared(outfile_handle, true);
-  m_error_file_sp = m_output_file_sp;
+  redirect->m_output_file_sp =
+  std::make_shared(outfile_handle, true);
+  redirect->m_error_file_sp = redirect->m_output_file_sp;
   if (outfile_handle)
 ::setbuf(outfile_handle, nullptr);
 
@@ -157,33 +160,40 @@
 }
   }
 
-  if (!m_input_file_sp || !m_output_file_sp || !m_error_file_sp)
-debugger.AdoptTopIOHandlerFilesIfInvalid(m_input_file_sp, m_output_file_sp,
- m_error_

[Lldb-commits] [PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-06-24 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen created this revision.
aelitashen added reviewers: wallace, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Make lldb-vscode receive and process module events so that modules can be 
rendered in the IDE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -433,6 +434,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int solib_count = lldb::SBTarget::GetNumModulesFromEvent(event);
+  int i = 0;
+  while (i < solib_count) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+i++;
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -354,6 +354,9 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded | lldb::SBTarget::eBroadcastBitModulesUnloaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,8 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+llvm::json::Value CreateModule(lldb::SBModule &module);
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,25 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule &module) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace("name", std::string(module.GetFileSpec().GetFilename())); // Path in remote
+  std::string module_path = std::string(module.GetFileSpec().GetDirectory()) + "/" + std::string(module.GetFileSpec().GetFilename());
+  object.try_emplace("path", module_path);
+  if (module.GetNumCompileUnits() > 0) {
+object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_path = std::string(module.GetSymbolFileSpec().GetDirectory()) + "/" +  std::string(module.GetSymbolFileSpec().GetFilename());
+object.try_emplace("symbolFilePath", symbol_path);
+  }
+  std::string loaded

[Lldb-commits] [PATCH] D82412: [lldb/Lua] Redirect Lua stdout/stderr to the CommandReturnObject

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 273073.
JDevlieghere added a comment.

Rebase


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

https://reviews.llvm.org/D82412

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/test/Shell/ScriptInterpreter/Lua/io.test


Index: lldb/test/Shell/ScriptInterpreter/Lua/io.test
===
--- lldb/test/Shell/ScriptInterpreter/Lua/io.test
+++ lldb/test/Shell/ScriptInterpreter/Lua/io.test
@@ -1,6 +1,7 @@
 # REQUIRES: lua
 # UNSUPPORTED: lldb-repro
 #
+# RUN: rm -rf %t.stderr %t.stdout
 # RUN: cat %s | %lldb --script-language lua 2> %t.stderr > %t.stdout
 # RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT
 # RUN: cat %t.stderr | FileCheck %s --check-prefix STDERR
@@ -11,6 +12,11 @@
 quit
 script
 io.write(95000 + 14, "\n")
+
 # STDOUT: 95126
 # STDOUT-NOT: 95014
 # STDERR: 95014
+
+# RUN: rm -rf %t.stderr %t.stdout
+# RUN: %lldb --script-language lua -o 'script io.stderr:write(95000 + 126, 
"\n")' 2> %t.stderr > %t.stdout
+# RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StringList.h"
 #include "lldb/Utility/Timer.h"
+#include "llvm/Support/FormatAdapters.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -65,12 +66,45 @@
 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
   CommandReturnObject *result,
   const ExecuteScriptOptions &options) 
{
+  if (command.empty()) {
+if (result)
+  result->AppendError("empty command passed to lua\n");
+return false;
+  }
+
+  llvm::Expected>
+  io_redirect_or_error =
+  options.GetEnableIO()
+  ? ScriptInterpreterIORedirect::Create(m_debugger, result)
+  : ScriptInterpreterIORedirect::Create();
+  if (!io_redirect_or_error) {
+if (result)
+  result->AppendErrorWithFormatv(
+  "failed to redirect I/O: {0}\n",
+  llvm::fmt_consume(io_redirect_or_error.takeError()));
+else
+  llvm::consumeError(io_redirect_or_error.takeError());
+return false;
+  }
+
+  ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
+
+  if (llvm::Error e =
+  m_lua->ChangeIO(io_redirect.GetOutputFile()->GetStream(),
+  io_redirect.GetErrorFile()->GetStream())) {
+result->AppendErrorWithFormatv("lua failed to redirect I/O: {0}\n",
+   llvm::toString(std::move(e)));
+return false;
+  }
+
   if (llvm::Error e = m_lua->Run(command)) {
 result->AppendErrorWithFormatv(
 "lua failed attempting to evaluate '{0}': {1}\n", command,
 llvm::toString(std::move(e)));
 return false;
   }
+
+  io_redirect.Flush();
   return true;
 }
 


Index: lldb/test/Shell/ScriptInterpreter/Lua/io.test
===
--- lldb/test/Shell/ScriptInterpreter/Lua/io.test
+++ lldb/test/Shell/ScriptInterpreter/Lua/io.test
@@ -1,6 +1,7 @@
 # REQUIRES: lua
 # UNSUPPORTED: lldb-repro
 #
+# RUN: rm -rf %t.stderr %t.stdout
 # RUN: cat %s | %lldb --script-language lua 2> %t.stderr > %t.stdout
 # RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT
 # RUN: cat %t.stderr | FileCheck %s --check-prefix STDERR
@@ -11,6 +12,11 @@
 quit
 script
 io.write(95000 + 14, "\n")
+
 # STDOUT: 95126
 # STDOUT-NOT: 95014
 # STDERR: 95014
+
+# RUN: rm -rf %t.stderr %t.stdout
+# RUN: %lldb --script-language lua -o 'script io.stderr:write(95000 + 126, "\n")' 2> %t.stderr > %t.stdout
+# RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StringList.h"
 #include "lldb/Utility/Timer.h"
+#include "llvm/Support/FormatAdapters.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -65,12 +66,45 @@
 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
   CommandReturnObject *result,
   const ExecuteScriptOptions &options) {
+  if (command.empty()) {
+if (result)
+  result->AppendError("empty command passed to lua\n");
+return false;
+  }
+
+  llvm::Expected>
+  io_redirect_or_error =
+  options.GetEnableIO()
+  ? 

Re: [Lldb-commits] [PATCH] D82155: [WIP][lldb/interpreter] Add ability to save lldb session to a file

2020-06-24 Thread Jim Ingham via lldb-commits


> On Jun 22, 2020, at 5:52 AM, Pavel Labath via Phabricator via lldb-commits 
>  wrote:
> 
> labath added a comment.
> 
> This seems like it could be useful in some circumstances, though for the use 
> cases I am imagining (bug reporting) it would be easier to just copy-paste 
> the terminal contents.
> 
> As for the implementation, if the intention is for this to eventually capture 
> all debugger output, then I am not sure if this is the right design. I think 
> it would be fine for python/lua interpreters as those are invoked from the 
> lldb command interpreter, but I have a feeling that routing the output 
> printed via `Debugger::PrintAsync` back to the command interpreter would look 
> pretty weird. It may make sense for the core logic of this to live in the 
> Debugger or the IOHandler(Stack) classes -- though I am not exactly sure 
> about that either as the Debugger and CommandIntepreter classes are fairly 
> tightly coupled. However, I think that would be consistent with the long term 
> goal of reimplementing the command interpreter on top of the SB API (in which 
> case the `Debugger` object should not know anything about the command 
> interpreter (but it would still need to to "something" with the PrintAsync 
> output).

This isn’t directly related to how much and how we should capture lldb session 
output, and maybe I’m misunderstanding your meaning, but I wasn’t expecting 
that moving the command interpreter to use SB API’s would mean the Debugger 
Object would know nothing about the Command interpreter.  It would know as much 
about the command interpreter as it does about the script interpreter, namely 
the Debugger holds these objects and is the one to hand them out.  For instance 
when the breakpoint has a bunch of commands in its command action, it would go 
to the debugger to evaluate those commands.  I think that’s the reasonable 
place from which to vend the command and script interpreters.  So it’s okay IMO 
for the Debugger to know a little bit about these entities.  It shouldn’t know 
anything about the command syntax, etc.  But since it is still the vendor of 
these objects, it seems okay for it to have an affordance to be notified of 
command results.

> 
> The test plan sounds fairly straight forward -- run lldb, execute a bunch of 
> commands, and finish it off with "session save". Then, verify that the file 
> has the "right" contents (e.g. with FileCheck). Besides multiline commands, 
> commands which do recursive processing are also interesting to exercise -- 
> e.g. "command source" or breakpoint callbacks. You also should decide what do 
> you want to happen with commands that are executed through the SB interface 
> (SBCommandInterpreter::HandleCommand) -- those will not normally go to the 
> debugger output, but I believe they will still be captured in the current 
> design...
> 
> 

Yes, I think we should be careful about this.  First off, I think command 
transcripts are not useful if you can’t link output to the command that 
triggered it.  And if we execute a command for instance in a data formatter, 
having that command output show up with no context in the log wouldn’t I think 
be helpful.  I think it would be useful to have a notion of user-actuated 
commands, and try to record those.  And it would also be good to provide some 
context.  For instance, if you have commands in a breakpoint action it would be 
great if you the output would identify them as such.

Jim


> 
> 
> Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2815
> 
> +  if (line.find("session save") == line.npos) {
> +*m_session_transcripts << io_handler.GetPrompt() << ' ' << line.c_str()
> 
> JDevlieghere wrote:
>> this won't work for things like unambiguous abbreviations like `sess save`. 
>> The command should do the saving.
> I don't think it's unreasonable to write to the "transcript" here, but the 
> string matching is obviously suboptimal. However, it's not clear to me why is 
> it even needed -- having the "save" command in the transcript does not 
> necessarily seem like a bad thing, and I believe the way it is implemented 
> means that the command will not show up in the session file that is currently 
> being saved (only in the subsequent ones).
> 
> 
> 
> Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2820
> +llvm::StringRef result_output = result.GetOutputData();
> +if (!result_output.empty())
> +  *m_session_transcripts << result_output;
> 
> These `!empty()` checks are pointless.
> 
> 
> 
> Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2827
> +
> +m_session_transcripts->Flush();
> +  }
> 
> As is this flush call.
> 
> 
> 
> Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2929
> +  Status error;
> +  user_id_t fd_dst = FileCache::GetInstance().OpenFile(
> +  FileSpec(output_file), flags, lldb::eFilePer

[Lldb-commits] [PATCH] D82382: [lldb][NFC] Replace most uses of StringConvert in LLDB with LLVM's to_integer

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Host/common/Socket.cpp:286
   host_str = host_str.substr(1, host_str.size() - 2);
-bool ok = false;
-port = StringConvert::ToUInt32(port_str.c_str(), UINT32_MAX, 10, &ok);
+bool ok = llvm::to_integer(port_str, port);
 if (ok && port <= UINT16_MAX) {

Consider inlining the call?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D82382



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


[Lldb-commits] [PATCH] D82155: [WIP][lldb/interpreter] Add ability to save lldb session to a file

2020-06-24 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 273090.
mib added a comment.

Ran clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td

Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -31,6 +31,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +53,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +77,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,7 +120,8 @@
   m_skip_lldbinit_files(false), m_skip_app_init_files(false),
   m_command_io_handler_sp(), m_comment_char('#'),
   m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
-  m_command_source_depth(0), m_result() {
+  m_command_source_depth(0), m_result(),
+  m_session_transcripts(std::make_shared()) {
   SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
   SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
   SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -142,6 +147,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetSaveSessionOnQuit() const {
+  const uint32_t idx = ePropertySaveSessionOnQuit;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
+  const uint32_t idx = ePropertySaveSessionOnQuit;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -493,6 +509,7 @@
   CommandObjectSP(new CommandObjectReproducer(*this));
   m_command_dict["script"] =
   CommandObjectSP(new CommandObjectScript(*this, script_language));
+  m_command_dict["session"] = CommandObjectSP(new CommandObjectSession(*this));
   m_command_dict["settings"] =
   CommandObjectSP(new CommandObjectMultiwordSettings(*this));
   m_command_dict["source"] =
@@ -2795,6 +2812,11 @@
   lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
+  *m_session_transcripts << io_handler.GetPrompt() << ' ' << line.c_str()
+ << '\n';
+  *m_session_transcripts << result.GetOutputData();
+  *m_session_transcripts << result.GetErrorData();
+
   // Now emit the command output text from the command we just executed
   if ((result.Succeeded() &&
io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
@@ -2877,6 +2899,49 @@
   return false;
 }
 
+bool CommandInterpreter::SaveTranscripts(std::string output_file) {
+  if (output_file.empty()) {
+std::string now = llvm::to_string(std::chrono::system_clock::now());
+std::replace(now.begin(), now.end(), ' ', '_');
+const std::string file_name = "lldb_session_" + now + ".log";
+FileSpec tmp = HostInfo::GetGlobalTempDir();
+tmp.AppendPathComponent(file_name);
+output_file = tmp.GetPath();
+  }
+
+  auto error_out = [&](llvm::StringRef error_message) {
+LLD

[Lldb-commits] [PATCH] D82155: [WIP][lldb/interpreter] Add ability to save lldb session to a file

2020-06-24 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 273087.
mib marked 8 inline comments as done.
mib added a comment.

Addressed Pavel's and Jonas' comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td

Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -31,6 +31,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +53,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +77,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,7 +120,8 @@
   m_skip_lldbinit_files(false), m_skip_app_init_files(false),
   m_command_io_handler_sp(), m_comment_char('#'),
   m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
-  m_command_source_depth(0), m_result() {
+  m_command_source_depth(0), m_result(),
+  m_session_transcripts(std::make_shared()) {
   SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
   SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
   SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -142,6 +147,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetSaveSessionOnQuit() const {
+  const uint32_t idx = ePropertySaveSessionOnQuit;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
+  const uint32_t idx = ePropertySaveSessionOnQuit;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -493,6 +509,7 @@
   CommandObjectSP(new CommandObjectReproducer(*this));
   m_command_dict["script"] =
   CommandObjectSP(new CommandObjectScript(*this, script_language));
+  m_command_dict["session"] = CommandObjectSP(new CommandObjectSession(*this));
   m_command_dict["settings"] =
   CommandObjectSP(new CommandObjectMultiwordSettings(*this));
   m_command_dict["source"] =
@@ -2795,6 +2812,11 @@
   lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
+*m_session_transcripts << io_handler.GetPrompt() << ' ' << line.c_str()
+   << '\n';
+  *m_session_transcripts << result.GetOutputData();
+  *m_session_transcripts << result.GetErrorData();
+
   // Now emit the command output text from the command we just executed
   if ((result.Succeeded() &&
io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
@@ -2877,6 +2899,50 @@
   return false;
 }
 
+bool CommandInterpreter::SaveTranscripts(std::string output_file) {
+  if (output_file.empty()) {
+std::string now = llvm::to_string(std::chrono::system_clock::now());
+std::replace(now.begin(), now.end(), ' ', '_');
+const std::string file_name = "lldb_session_" + now + ".log";
+FileSpec tmp = HostInfo::GetGlobalTempDir();
+tmp.AppendPathComponent(file_name);
+output_file = tmp.GetPath();
+  }
+
+ 

[Lldb-commits] [lldb] d4ef569 - Disable a flaky lldb-vscode test on aarch64

2020-06-24 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-06-24T11:09:21-07:00
New Revision: d4ef569577625d50dfe01ab54c7b9995db3e013f

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

LOG: Disable a flaky lldb-vscode test on aarch64

Summary:
These tests isflaky only on this arch for some reason. It's testing important 
features and is not flaky on x86_64, so I'll investigate this arm issue 
separatedly.

A flaky run:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5540/steps/test/logs/stdio

Diff that created those tests:
https://reviews.llvm.org/D81978

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py 
b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
index c9d99daf9bc6..fb7d71872a16 100644
--- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -430,6 +430,8 @@ def test_extra_launch_commands(self):
 
 @skipIfWindows
 @skipIfNetBSD # Hangs on NetBSD as well
+@skipIfDarwin
+@skipIf(archs="aarch64") # Example of a flaky run 
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5540/steps/test/logs/stdio
 def test_terminate_commands(self):
 '''
 Tests that the "terminateCommands", that can be passed during



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


[Lldb-commits] [lldb] fd19ddb - [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-24T12:19:21-07:00
New Revision: fd19ddb8f2a2b082f492fc59f7f360adf3495701

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

LOG: [Apple Silicon] Initial support for Rosetta

Translated processes talk with a different debugserver, shipped with
macOS 11. This patch detects whether a process is translated and
attaches to the correct debugserver implementation.
It's the first patch of a series. Tested on the lldb test suite.

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

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index c673a16b348c..ebc9586dfa5d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,6 +17,7 @@
 #include 
 #endif
 #include 
+#include 
 #include 
 #include 
 
@@ -3432,6 +3433,23 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
+#if defined(__APPLE__)
+// On macOS 11, we need to support x86_64 applications translated to
+// arm64. We check whether a binary is translated and spawn the correct
+// debugserver accordingly.
+int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+  static_cast(process_info.GetProcessID()) };
+struct kinfo_proc processInfo;
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+   &bufsize, NULL, 0) == 0 && bufsize > 0) {
+  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
+FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
+  }
+}
+#endif
+
 int communication_fd = -1;
 #ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
 // Use a socketpair on non-Windows systems for security and performance



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: jasonmolenda, aprantl, friss.
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.
davide closed this revision.

LGTM.  With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & 
P_TRANSLATED) as a boolean, but that's a style pref as much as anything.


davide added a comment.

In D82491#2112269 , @jasonmolenda 
wrote:

> LGTM.  With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & 
> P_TRANSLATED) as a boolean, but that's a style pref as much as anything.


Fair, let me change that.


davide added a comment.

  commit fd19ddb8f2a2b082f492fc59f7f360adf3495701 (HEAD -> master, 
origin/master, origin/HEAD)
  Author: Davide Italiano 
  Date:   Wed Jun 24 12:18:29 2020 -0700
  
  [Apple Silicon] Initial support for Rosetta
  
  Translated processes talk with a different debugserver, shipped with
  macOS 11. This patch detects whether a process is translated and
  attaches to the correct debugserver implementation.
  It's the first patch of a series. Tested on the lldb test suite.
  
  Differential Revision:  https://reviews.llvm.org/D82491


Translated processes talk with a different debugserver, shipped with macOS 11. 
This patch detects whether a process is translated and attaches to the correct 
debugserver implementation. It's the first patch of a series. Tested on the 
lldb test suite.


https://reviews.llvm.org/D82491

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,6 +17,7 @@
 #include 
 #endif
 #include 
+#include 
 #include 
 #include 
 
@@ -3432,6 +3433,23 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
+#if defined(__APPLE__)
+// On macOS 11, we need to support x86_64 applications translated to
+// arm64. We check whether a binary is translated and spawn the correct
+// debugserver accordingly.
+int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+  static_cast(process_info.GetProcessID()) };
+struct kinfo_proc processInfo;
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+   &bufsize, NULL, 0) == 0 && bufsize > 0) {
+  if ((processInfo.kp_proc.p_flag & P_TRANSLATED) == P_TRANSLATED) {
+FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
+  }
+}
+#endif
+
 int communication_fd = -1;
 #ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
 // Use a socketpair on non-Windows systems for security and performance


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,6 +17,7 @@
 #include 
 #endif
 #include 
+#include 
 #include 
 #include 
 
@@ -3432,6 +3433,23 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
+#if defined(__APPLE__)
+// On macOS 11, we need to support x86_64 applications translated to
+// arm64. We check whether a binary is translated and spawn the correct
+// debugserver accordingly.
+int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+  static_cast(process_info.GetProcessID()) };
+struct kinfo_proc processInfo;
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+   &bufsize, NULL, 0) == 0 && bufsize > 0) {
+  if ((processInfo.kp_proc.p_flag & P_TRANSLATED) == P_TRANSLATED) {
+FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
+  }
+}
+#endif
+
 int communication_fd = -1;
 #ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
 // Use a socketpair on non-Windows systems for security and performance
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-24 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. (I 
have updated my script to use `--date=now` (setting author date to committer 
date))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81200



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


[Lldb-commits] [PATCH] D82493: [Apple Silicon] Debugging of process under Rosetta is supported

2020-06-24 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: jasonmolenda, friss, aprantl.

Remove this early exit. It's vestigial from the ppc -> Intel transition, but it 
doesn't apply anymore:


https://reviews.llvm.org/D82493

Files:
  lldb/source/Host/macosx/objcxx/Host.mm


Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -631,8 +631,7 @@
 kinfo.kp_proc.p_pid == 0 ||  // Skip kernel (kernel pid is zero)
 kinfo.kp_proc.p_stat == SZOMB || // Zombies are bad, they like 
brains...
 kinfo.kp_proc.p_flag & P_TRACED ||   // Being debugged?
-kinfo.kp_proc.p_flag & P_WEXIT ||// Working on exiting?
-kinfo.kp_proc.p_flag & P_TRANSLATED) // Skip translated ppc (Rosetta)
+kinfo.kp_proc.p_flag & P_WEXIT)
   continue;
 
 ProcessInstanceInfo process_info;


Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -631,8 +631,7 @@
 kinfo.kp_proc.p_pid == 0 ||  // Skip kernel (kernel pid is zero)
 kinfo.kp_proc.p_stat == SZOMB || // Zombies are bad, they like brains...
 kinfo.kp_proc.p_flag & P_TRACED ||   // Being debugged?
-kinfo.kp_proc.p_flag & P_WEXIT ||// Working on exiting?
-kinfo.kp_proc.p_flag & P_TRANSLATED) // Skip translated ppc (Rosetta)
+kinfo.kp_proc.p_flag & P_WEXIT)
   continue;
 
 ProcessInstanceInfo process_info;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM.  With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & 
P_TRANSLATED) as a boolean, but that's a style pref as much as anything.


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Davide Italiano via Phabricator via lldb-commits
davide closed this revision.
davide added a comment.

  commit fd19ddb8f2a2b082f492fc59f7f360adf3495701 (HEAD -> master, 
origin/master, origin/HEAD)
  Author: Davide Italiano 
  Date:   Wed Jun 24 12:18:29 2020 -0700
  
  [Apple Silicon] Initial support for Rosetta
  
  Translated processes talk with a different debugserver, shipped with
  macOS 11. This patch detects whether a process is translated and
  attaches to the correct debugserver implementation.
  It's the first patch of a series. Tested on the lldb test suite.
  
  Differential Revision:  https://reviews.llvm.org/D82491


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-06-24 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So great first patch Yifan! A few things to fix up, see inlined comments.

We need to add a test for lldb::SBTarget::eBroadcastBitSymbolsLoaded if 
possible. This can be done by stripping "a.out" into "a.out.stripped" and then 
debugging "a.out.stripped" and then adding symbols using "target symbols add 
..." to add the "a.out".




Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:335
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace("name", std::string(module.GetFileSpec().GetFilename())); 
// Path in remote
+  std::string module_path = std::string(module.GetFileSpec().GetDirectory()) + 
"/" + std::string(module.GetFileSpec().GetFilename());

LLVM coding guidelines limit source lines to 80 characters. So just reformat as 
requested here.



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:340
+object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_path = 
std::string(module.GetSymbolFileSpec().GetDirectory()) + "/" +  
std::string(module.GetSymbolFileSpec().GetFilename());
+object.try_emplace("symbolFilePath", symbol_path);

Ditto



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:343
+  }
+  std::string loaded_addr = 
std::to_string(module.GetObjectFileHeaderAddress().GetLoadAddress(g_vsc.target));
+  object.try_emplace("addressRange", loaded_addr);

Ditto



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:346
+  return llvm::json::Value(std::move(object));
+
+}

remove empty line.



Comment at: lldb/tools/lldb-vscode/JSONUtils.h:241
 
+llvm::json::Value CreateModule(lldb::SBModule &module);
+

Need to add header documentation like the other functions in this file.



Comment at: lldb/tools/lldb-vscode/VSCode.cpp:357-359
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded | 
lldb::SBTarget::eBroadcastBitModulesUnloaded);

reformat per pre-merge checks



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:440
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int solib_count = lldb::SBTarget::GetNumModulesFromEvent(event);

you check for "lldb::SBTarget::eBroadcastBitSymbolsLoaded" here, but didn't 
listen for that event in VSCode.cpp. Either remove 
lldb::SBTarget::eBroadcastBitSymbolsLoaded or add it to the events we want to 
listen for in VSCode.cpp



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:441
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int solib_count = lldb::SBTarget::GetNumModulesFromEvent(event);
+  int i = 0;

rename "solib_count" to "num_modules"?



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:442-445
+  int i = 0;
+  while (i < solib_count) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+i++;

Use for loop:

``` 
for (int i=0; ihttps://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In D82491#2112269 , @jasonmolenda 
wrote:

> LGTM.  With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & 
> P_TRANSLATED) as a boolean, but that's a style pref as much as anything.


Fair, let me change that.


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D82493: [Apple Silicon] Debugging of process under Rosetta is supported

2020-06-24 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Yep.


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

https://reviews.llvm.org/D82493



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


[Lldb-commits] [lldb] b4fdddf - [Apple Silicon] Debugging of process under Rosetta is supported.

2020-06-24 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-24T12:25:01-07:00
New Revision: b4fdddf971b191aa9a6643ab637b87bc1d686254

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

LOG: [Apple Silicon] Debugging of process under Rosetta is supported.

Remove this early exit. It's vestigial from the ppc -> Intel transition,
but it doesn't apply anymore.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 045ba7f3671f..1635132a154e 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -631,8 +631,7 @@ static bool 
GetMacOSXProcessUserAndGroup(ProcessInstanceInfo &process_info) {
 kinfo.kp_proc.p_pid == 0 ||  // Skip kernel (kernel pid is zero)
 kinfo.kp_proc.p_stat == SZOMB || // Zombies are bad, they like 
brains...
 kinfo.kp_proc.p_flag & P_TRACED ||   // Being debugged?
-kinfo.kp_proc.p_flag & P_WEXIT ||// Working on exiting?
-kinfo.kp_proc.p_flag & P_TRANSLATED) // Skip translated ppc (Rosetta)
+kinfo.kp_proc.p_flag & P_WEXIT)
   continue;
 
 ProcessInstanceInfo process_info;



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


[Lldb-commits] [PATCH] D82493: [Apple Silicon] Debugging of process under Rosetta is supported

2020-06-24 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.

  commit b4fdddf971b191aa9a6643ab637b87bc1d686254 (HEAD -> master, 
origin/master, origin/HEAD)
  Author: Davide Italiano 
  Date:   Wed Jun 24 12:25:01 2020 -0700
  
  [Apple Silicon] Debugging of process under Rosetta is supported.
  
  Remove this early exit. It's vestigial from the ppc -> Intel transition,
  but it doesn't apply anymore.


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

https://reviews.llvm.org/D82493



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:3444
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+   &bufsize, NULL, 0) == 0 && bufsize > 0) {

The `sysctl` call seems like something that would fit into host, we already 
have a bunch of those in `Host.mm`. Should we create a function there that 
returns whether a given pid runs under Rosetta?


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [lldb] cad79f7 - [lldb][NFC] Use expect_expr in TestStructTypes.py

2020-06-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-24T22:12:17+02:00
New Revision: cad79f73b6b67c9306ad147381e8a8be5db6d5cf

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

LOG: [lldb][NFC] Use expect_expr in TestStructTypes.py

Added: 


Modified: 
lldb/test/API/lang/c/struct_types/main.c

Removed: 




diff  --git a/lldb/test/API/lang/c/struct_types/main.c 
b/lldb/test/API/lang/c/struct_types/main.c
index 0b87bb193032..08ef0a703f22 100644
--- a/lldb/test/API/lang/c/struct_types/main.c
+++ b/lldb/test/API/lang/c/struct_types/main.c
@@ -17,7 +17,7 @@ int main (int argc, char const *argv[])
 char padding[0];
 }; //% self.expect("frame variable pt.padding[0]", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[0] = "])
//% self.expect("frame variable pt.padding[1]", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[1] = "])
-   //% self.expect("expression -- (pt.padding[0])", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(char)", " = "])
+   //% self.expect_expr("pt.padding[0]", result_type="char")
//% self.expect("image lookup -t point_tag", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['padding[]'])
 
 struct {} empty;
@@ -32,7 +32,7 @@ int main (int argc, char const *argv[])
 struct rect_tag rect = {{1, 2, {}}, {3, 4, {}}};
 struct things_to_sum tts = { 2, 3, 4 };
 
-int sum = sum_things(tts); //% self.expect("expression -- &pt == (struct 
point_tag*)0", substrs = ['false'])
-   //% self.expect("expression -- 
sum_things(tts)", substrs = ['9'])
+int sum = sum_things(tts); //% self.expect_expr("&pt == (struct 
point_tag*)0", result_value="false")
+   //% self.expect_expr("sum_things(tts)", 
result_value="9")
 return 0;
 }



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


[Lldb-commits] [lldb] 58de2a3 - [ProcessGDBRemote] Placate the Windows buildbot.

2020-06-24 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-24T13:23:49-07:00
New Revision: 58de2a3851391dd9fa675ea6bcd26072a0638829

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

LOG: [ProcessGDBRemote] Placate the Windows buildbot.

I'm probably going to rewrite this function anyway, but, in
the meanwhile.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index ebc9586dfa5d..d2b72de03eac 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,7 +17,9 @@
 #include 
 #endif
 #include 
+#ifdef defined(__APPLE__)
 #include 
+#endif
 #include 
 #include 
 



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Eric Christopher via Phabricator via lldb-commits
echristo added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:20
 #include 
+#include 
 #include 

echristo wrote:
> This is problematic in that sys/sysctl is deprecated on linux (causing 
> warnings/Werror failures).
I'm going to #ifdef this only in for apple at the moment matching the use below.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:3444
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+   &bufsize, NULL, 0) == 0 && bufsize > 0) {

JDevlieghere wrote:
> The `sysctl` call seems like something that would fit into host, we already 
> have a bunch of those in `Host.mm`. Should we create a function there that 
> returns whether a given pid runs under Rosetta?
Agreed. That seems much cleaner.


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Eric Christopher via Phabricator via lldb-commits
echristo added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:20
 #include 
+#include 
 #include 

This is problematic in that sys/sysctl is deprecated on linux (causing 
warnings/Werror failures).


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [lldb] 0cd9e59 - [ProcessGDBRemote] Fix a typo in an ifdef from 58de2a3851391d

2020-06-24 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2020-06-24T23:49:33+03:00
New Revision: 0cd9e598291df8c633aaa0c0e1d8eeab95de9680

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

LOG: [ProcessGDBRemote] Fix a typo in an ifdef from 58de2a3851391d

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index d2b72de03eac..39e97c92e343 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,7 +17,7 @@
 #include 
 #endif
 #include 
-#ifdef defined(__APPLE__)
+#if defined(__APPLE__)
 #include 
 #endif
 #include 



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


[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-24 Thread Eric Christopher via Phabricator via lldb-commits
echristo added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:20
 #include 
+#include 
 #include 

echristo wrote:
> echristo wrote:
> > This is problematic in that sys/sysctl is deprecated on linux (causing 
> > warnings/Werror failures).
> I'm going to #ifdef this only in for apple at the moment matching the use 
> below.
I see you've done that already :)


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Just some notes of mine to find out which functions get used in which 
breakpoint case:

  -o 'breakpoint set -f main.c -l 1' -o q
  -o 'b main.c:1' 
  lldb/source/Commands/CommandObjectBreakpoint.cpp:578 = eSetTypeFileAndLine
  lldb/source/Target/Target.cpp:330 = GetInlineStrategy()
  BreakpointSP Target::CreateBreakpoint(const FileSpecList *containingModules,
const FileSpec &file, uint32_t line_no,
lldb/source/Target/Target.cpp:622
  
  -o 'b main'
  -o 'breakpoint set -n main -f noFileOfThisName.xxx' 
containingSourceFiles="noFileOfThisName.xxx"
  lldb/source/Commands/CommandObjectBreakpoint.cpp:614 = eSetTypeFunctionName
  lldb/source/Target/Target.cpp:445 
  Target::CreateBreakpoint(const FileSpecList *containingModules,
   const FileSpecList *containingSourceFiles,
   const std::vector &func_names,
lldb/source/Target/Target.cpp:622




Comment at: lldb/source/Core/SearchFilter.cpp:722
+  return false;
+  }
+

This `IsSourceImplementationFile()` should be checking the filename requested 
by user, not filename found in DWARF. It should be in 
`SearchFilterByModuleListAndCU::GetFilterRequiredItems()` where it should check 
the filename in `m_cu_spec_list`. The whole `GetInlineStrategy()` is there only 
for performance, if it was fast enough it would be always best to use 
`eInlineBreakpointsAlways`. So here when you already have fully parsed DIE for 
the function+type it no longer makes sense to check for any performance 
optimization possibility. If `eInlineBreakpointsNever` or 
`eInlineBreakpointsHeaders` shows more breakpoint locations than expected (and 
still not more than `eInlineBreakpointsAlways`) then it is not a bug but just a 
missed performance optimization.
And after you fully move this 
`GetInlineStrategy()+IsSourceImplementationFile()` into 
`SearchFilterByModuleListAndCU::GetFilterRequiredItems()` then you can drop it 
from `Target::CreateBreakpoint` at `lldb/source/Target/Target.cpp:330` as it no 
longer has any effect there.
IMO one should implement the `DW_AT_decl_file` check also into 
`SymbolFileDWARF::ResolveSymbolContext` at 
`lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp`:1977 and other 
non-DWARF formats. As otherwise properly found candidates can be discarded at 
the end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [PATCH] D82505: [lldb-vscode] Add Support for Module Event

2020-06-24 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen created this revision.
aelitashen added reviewers: wallace, clayborg.
aelitashen added a project: LLDB.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Make lldb-vscode receive and process module events so that modules can be 
rendered in the IDE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82505

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -433,6 +434,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int num_modules = lldb::SBTarget::GetNumModulesFromEvent(event);
+  for (int i = 0; i < num_modules; i++) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -354,6 +354,11 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,16 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+/// Converts Module Event to a Visual Studio Code "Module"
+///
+/// \param[in] module
+/// A LLDB module object to convert into a JSON value
+///
+/// \return
+/// A "Module" JSON object with that follows the formal JSON
+/// definition outlined by Microsoft.
+llvm::json::Value CreateModule(lldb::SBModule &module);
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,31 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule &module) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace(
+"name",
+std::string(module.GetFileSpec().GetFilename()));
+  std::string module_path = std::string(module.GetFileSpec().GetDirectory(

[Lldb-commits] [PATCH] D82507: [lldb/Docs] Add more details to the issues with custom Python installs on macOS

2020-06-24 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: friss.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D82507

Files:
  lldb/docs/resources/caveats.rst


Index: lldb/docs/resources/caveats.rst
===
--- lldb/docs/resources/caveats.rst
+++ lldb/docs/resources/caveats.rst
@@ -31,7 +31,30 @@
 the one used to build and link LLDB.
 
 The previous considerations are especially important during development, but
-apply to binary distributions of LLDB as well. For example, the LLDB that comes
-with Xcode links against the Python 3 that's part of Xcode. Therefore you
-should always use the Python in Xcode (through ``xcrun python3`` or
-``/usr/bin/python3``) to import the lldb module or install packages.
+apply to binary distributions of LLDB as well.
+
+LLDB in Xcode on macOS
+``
+
+Users of lldb in Xcode on macOS commonly run into these issues when they
+install Python, often unknowingly as a dependency pulled in by Homebrew or
+another package manager. The problem is the symlinks this installs in
+``/usr/local/bin`` which comes before ``/usr/bin`` in your path. You can use
+``which python3`` to check to what it resolves.
+
+To be sure you use the Python that matches with the lldb in Xcode use ``xcrun``
+or use the absolute path to the shims in ``/usr/bin``.
+
+::
+
+   $ xcrun python3
+   $ /usr/bin/python3
+
+Similarly, to install packages and be able to use them from within lldb, you'll
+need to install them with the matching ``pip3``.
+
+::
+
+   $ xcrun pip3
+   $ /usr/bin/pip3
+


Index: lldb/docs/resources/caveats.rst
===
--- lldb/docs/resources/caveats.rst
+++ lldb/docs/resources/caveats.rst
@@ -31,7 +31,30 @@
 the one used to build and link LLDB.
 
 The previous considerations are especially important during development, but
-apply to binary distributions of LLDB as well. For example, the LLDB that comes
-with Xcode links against the Python 3 that's part of Xcode. Therefore you
-should always use the Python in Xcode (through ``xcrun python3`` or
-``/usr/bin/python3``) to import the lldb module or install packages.
+apply to binary distributions of LLDB as well.
+
+LLDB in Xcode on macOS
+``
+
+Users of lldb in Xcode on macOS commonly run into these issues when they
+install Python, often unknowingly as a dependency pulled in by Homebrew or
+another package manager. The problem is the symlinks this installs in
+``/usr/local/bin`` which comes before ``/usr/bin`` in your path. You can use
+``which python3`` to check to what it resolves.
+
+To be sure you use the Python that matches with the lldb in Xcode use ``xcrun``
+or use the absolute path to the shims in ``/usr/bin``.
+
+::
+
+   $ xcrun python3
+   $ /usr/bin/python3
+
+Similarly, to install packages and be able to use them from within lldb, you'll
+need to install them with the matching ``pip3``.
+
+::
+
+   $ xcrun pip3
+   $ /usr/bin/pip3
+
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82505: [lldb-vscode] Add Support for Module Event

2020-06-24 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

This seems like a continuation of https://reviews.llvm.org/D82477. I would 
close this one down by selecting abandon revision, and then click the "update 
diff" button in D82477  and upload your new 
patch. I am guessing you did this manually and not with "arc diff"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82505



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


[Lldb-commits] [lldb] 1c0bbe4 - [lldb/API] Use std::make_unique<> (NFC)

2020-06-24 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-24T16:29:30-07:00
New Revision: 1c0bbe4341ac0ffbaf2e1f482239b45166607f2d

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

LOG: [lldb/API] Use std::make_unique<> (NFC)

I was holding off on this change until we moved to C++14 as to not have
to convert llvm::make_unique to std::make_unique. That happened a while
ago so here's the first patch for the API which had a bunch of raw
`new`s.

Added: 


Modified: 
lldb/source/API/SBAddress.cpp
lldb/source/API/SBBreakpointName.cpp
lldb/source/API/SBCommandInterpreterRunOptions.cpp
lldb/source/API/SBDeclaration.cpp
lldb/source/API/SBError.cpp
lldb/source/API/SBLineEntry.cpp
lldb/source/API/SBProcessInfo.cpp
lldb/source/API/SBSourceManager.cpp
lldb/source/API/SBStream.cpp
lldb/source/API/SBStringList.cpp
lldb/source/API/SBSymbolContext.cpp
lldb/source/API/SBType.cpp
lldb/source/API/SBTypeEnumMember.cpp
lldb/source/API/SBTypeSummary.cpp
lldb/source/API/SBValueList.cpp
lldb/source/API/SBVariablesOptions.cpp

Removed: 




diff  --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index d2b9b80973c8..6444a006c0ff 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -89,7 +89,7 @@ SBAddress::operator bool() const {
 void SBAddress::Clear() {
   LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
 
-  m_opaque_up.reset(new Address());
+  m_opaque_up = std::make_unique();
 }
 
 void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
@@ -105,7 +105,7 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) {
   if (lldb_object_ptr)
 ref() = *lldb_object_ptr;
   else
-m_opaque_up.reset(new Address());
+m_opaque_up = std::make_unique();
 }
 
 lldb::addr_t SBAddress::GetFileAddress() const {
@@ -187,7 +187,7 @@ const Address *SBAddress::operator->() const { return 
m_opaque_up.get(); }
 
 Address &SBAddress::ref() {
   if (m_opaque_up == nullptr)
-m_opaque_up.reset(new Address());
+m_opaque_up = std::make_unique();
   return *m_opaque_up;
 }
 

diff  --git a/lldb/source/API/SBBreakpointName.cpp 
b/lldb/source/API/SBBreakpointName.cpp
index e5a0dbc9ef8e..3995defcf97c 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -115,7 +115,7 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, 
const char *name) {
   LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *),
   sb_target, name);
 
-  m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
+  m_impl_up = std::make_unique(sb_target, name);
   // Call FindBreakpointName here to make sure the name is valid, reset if not:
   BreakpointName *bp_name = GetBreakpointName();
   if (!bp_name)
@@ -133,7 +133,8 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, 
const char *name) {
   BreakpointSP bkpt_sp = sb_bkpt.GetSP();
   Target &target = bkpt_sp->GetTarget();
 
-  m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
+  m_impl_up =
+  std::make_unique(target.shared_from_this(), name);
 
   // Call FindBreakpointName here to make sure the name is valid, reset if not:
   BreakpointName *bp_name = GetBreakpointName();
@@ -154,8 +155,8 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName 
&rhs) {
   if (!rhs.m_impl_up)
 return;
   else
-m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
- rhs.m_impl_up->GetName()));
+m_impl_up = std::make_unique(
+rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName());
 }
 
 SBBreakpointName::~SBBreakpointName() = default;
@@ -171,8 +172,8 @@ operator=(const SBBreakpointName &rhs) {
 return LLDB_RECORD_RESULT(*this);
   }
 
-  m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
-   rhs.m_impl_up->GetName()));
+  m_impl_up = 
std::make_unique(rhs.m_impl_up->GetTarget(),
+ rhs.m_impl_up->GetName());
   return LLDB_RECORD_RESULT(*this);
 }
 

diff  --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp 
b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
index 7f880dc4605b..fcfbf5e5401a 100644
--- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp
+++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
@@ -21,7 +21,7 @@ using namespace lldb_private;
 SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
 
-  m_opaque_up.reset(new CommandInterpreterRunOptions());
+  m_opaque_up = std::make_unique();
 }
 
 SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = 

[Lldb-commits] [lldb] 2010444 - [Apple Silicon] Handle macOS in PlatformDarwin

2020-06-24 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-24T16:35:36-07:00
New Revision: 2010444e5e5f2a310334e98d7a65667ed78d23ab

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

LOG: [Apple Silicon] Handle macOS in PlatformDarwin

This makes "target create /bin/ls" properly detect which platform
is needed when running lldb. Covered by many tests in the suite.

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 85cd000d8787..f5ec08a1a199 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -546,6 +546,8 @@ bool 
PlatformDarwin::ARMGetSupportedArchitectureAtIndex(uint32_t idx,
 #define OSNAME "watchos"
 #elif defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE == 1
 #define OSNAME "bridgeos"
+#elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
+#define OSNAME "macosx"
 #else
 #define OSNAME "ios"
 #endif



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


[Lldb-commits] [lldb] 47ac453 - [HostInfoMacOS] Parse correctly the triple for Apple Silicon.

2020-06-24 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-24T16:37:21-07:00
New Revision: 47ac45332e25c89d0ced5108c667fe92cf0f509a

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

LOG: [HostInfoMacOS] Parse correctly the triple for Apple Silicon.

Again, debugging doesn't work on the new platform without this, so
it's implicitly covered by the testsuite.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 8d8db2f246a7..60eacb1e49b2 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -276,6 +276,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
 arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
+#elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
+arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
+arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
 #else
 arch_32.GetTriple().setOS(llvm::Triple::IOS);
 arch_64.GetTriple().setOS(llvm::Triple::IOS);



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


[Lldb-commits] [PATCH] D82505: [lldb-vscode] Add Support for Module Event

2020-06-24 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen updated this revision to Diff 273189.
aelitashen added a comment.

Formatting the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82505

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -433,6 +434,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int num_modules = lldb::SBTarget::GetNumModulesFromEvent(event);
+  for (int i = 0; i < num_modules; i++) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -354,6 +354,11 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,16 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+/// Converts Module Event to a Visual Studio Code "Module"
+///
+/// \param[in] module
+/// A LLDB module object to convert into a JSON value
+///
+/// \return
+/// A "Module" JSON object with that follows the formal JSON
+/// definition outlined by Microsoft.
+llvm::json::Value CreateModule(lldb::SBModule &module);
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,31 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule &module) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace(
+"name",
+std::string(module.GetFileSpec().GetFilename()));
+  std::string module_path = std::string(module.GetFileSpec().GetDirectory()) +
+"/" +
+std::string(module.GetFileSpec().GetFilename());
+

[Lldb-commits] [lldb] 06412da - [lldb] Use std::make_unique<> (NFC)

2020-06-24 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-24T17:48:40-07:00
New Revision: 06412dae82376c12bc64b944e6d21141313b5cf1

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

LOG: [lldb] Use std::make_unique<> (NFC)

Update the rest of lldb to use std::make_unique<>. I used clang-tidy to
automate this, which probably missed cases that are wrapped in ifdefs.

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointLocation.cpp
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Breakpoint/WatchpointOptions.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Core/IOHandler.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/Android/AdbClient.cpp
lldb/source/Plugins/Process/Utility/HistoryThread.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Symbol/SymbolVendor.cpp
lldb/source/Symbol/UnwindTable.cpp
lldb/source/Target/ModuleCache.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadPlanStepInRange.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 646c2e3c628b..93d54c051ee5 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -369,7 +369,7 @@ BreakpointOptions *BreakpointLocation::GetLocationOptions() 
{
   // potentially expensive and we don't want to do that for the simple case
   // where someone is just disabling the location.
   if (m_options_up == nullptr)
-m_options_up.reset(new BreakpointOptions(false));
+m_options_up = std::make_unique(false);
 
   return m_options_up.get();
 }

diff  --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 3886d0329062..0ce7b0f852e8 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -154,7 +154,7 @@ BreakpointOptions::BreakpointOptions(const 
BreakpointOptions &rhs)
   m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(),
   m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
   if (rhs.m_thread_spec_up != nullptr)
-m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+m_thread_spec_up = std::make_unique(*rhs.m_thread_spec_up);
   m_condition_text = rhs.m_condition_text;
   m_condition_text_hash = rhs.m_condition_text_hash;
 }
@@ -170,7 +170,7 @@ operator=(const BreakpointOptions &rhs) {
   m_one_shot = rhs.m_one_shot;
   m_ignore_count = rhs.m_ignore_count;
   if (rhs.m_thread_spec_up != nullptr)
-m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+m_thread_spec_up = std::make_unique(*rhs.m_thread_spec_up);
   m_condition_text = rhs.m_condition_text;
   m_condition_text_hash = rhs.m_condition_text_hash;
   m_auto_continue = rhs.m_auto_continue;