[Lldb-commits] [PATCH] D82732: WIP: Use SB APIs in CommandObjects

2020-07-08 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/include/lldb/API/SBBreakpoint.h:142
+
+  lldb::BreakpointSP GetSP() const;
+

I assume this is WIP code and we already told you that, but we can't expose the 
internal `lldb_private::*` classes (or their `lldb::*SP` typedef). So this 
needs to be replaced with SB API patches.



Comment at: lldb/include/lldb/API/SBTarget.h:69
 
+  bool IsProcessValid() const;
+

This should rather be a `IsAlive` function in SBProcess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82732



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


[Lldb-commits] [lldb] e9f9434 - [lldb] Skip TestIOHandlerResizeNoEditline on Windows

2020-07-08 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-07-08T11:45:38+02:00
New Revision: e9f943429c895e4d6d29505fab2fad365fe2766e

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

LOG: [lldb] Skip TestIOHandlerResizeNoEditline on Windows

It seems opening the empty file and trying use that file object as an input
stream doesn't work on Windows. Skipping it for now.

Added: 


Modified: 
lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py

Removed: 




diff  --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py 
b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
index 323e511496cd..9f0d562e8afc 100644
--- a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
+++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
@@ -9,6 +9,7 @@ class TestCase(TestBase):
 
 @no_debug_info_test
 @skipIfReproducer
+@skipIfWindows
 def test_resize_no_editline(self):
 """ Tests terminal resizing if the editline isn't used. """
 dbg = lldb.SBDebugger.Create(False)



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


[Lldb-commits] [lldb] ebee165 - [lldb][NFC] Fix indentation in expect_expr

2020-07-08 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-07-08T12:33:31+02:00
New Revision: ebee165184a8000b7f650f0946b25b6ea51859b8

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

LOG: [lldb][NFC] Fix indentation in expect_expr

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 35865d9e0d5c..ddb79de0ab32 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2476,10 +2476,10 @@ def expect_expr(
 options.SetIgnoreBreakpoints(True)
 
 if self.frame().IsValid():
-  options.SetLanguage(frame.GuessLanguage())
-  eval_result = self.frame().EvaluateExpression(expr, options)
+options.SetLanguage(frame.GuessLanguage())
+eval_result = self.frame().EvaluateExpression(expr, options)
 else:
-  eval_result = self.target().EvaluateExpression(expr, options)
+eval_result = self.target().EvaluateExpression(expr, options)
 
 self.assertSuccess(eval_result.GetError())
 



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


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for fixing this.




Comment at: lldb/source/Core/ValueObject.cpp:690
 
-  if (!valobj && synthetic_array_member)
-valobj = GetSyntheticValue()
- ->GetChildAtIndex(synthetic_index, synthetic_array_member)
- .get();
+  // In case of an incomplete type, LLDB will try to use the ValueObject's
+  // synthetic value to create the child ValueObject.

Sorry for the pedantry, but the wording "LLDB will try to ..." makes me think 
that there is some other part of lldb which "tries to use the synthetic value", 
and this code is somehow responding to that behavior.
But IIUC, this *is* the code which is using the synthetic value. In that case, 
it would be enough to say "In case of an incomplete type, **try to use** the 
synthetic value to ...".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83327



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


[Lldb-commits] [PATCH] D81697: Add support for batch-testing to the LLDB testsuite.

2020-07-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D81697#2138024 , @bbli wrote:

> F12311388: image.png 
>
> Hi, so I think I got the fix working. Attached is a screenshot of the new 
> output, with title "Build Command Stdout Ouput". Should I submit a new pull 
> request for this?


Yes, that looks better. Please create a patch for that. It might be even better 
if the stdout+stderr contents came as a single stream (as if run by `cmd 
2>&1`). That way the error messages on stderr will appear right next to the 
compiler invocation (which goes to stdout). I believe this could be achieved by 
setting `stderr` to `STDOUT` (instead of `PIPE`).

> Also just wondering,  it seems you guys have added a lldb_extensions 
> dictionary to the `CalledProcessError` class. Was this monkey-patched in, 
> because I don't see `subprocess` as one of the vendored third party libraries 
> in the repo?

It looks like this just uses the lack of access protections in python to create 
a new field in a random object (lldbtest.py:442). A cleaner approach would be 
to create a new class for this exception (perhaps by subclassing 
CalledProcessError).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81697



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


[Lldb-commits] [lldb] 695b33a - [lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)

2020-07-08 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-08T13:35:31+02:00
New Revision: 695b33a56919af8873eecb47cb83fa17a271e99f

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

LOG: [lldb/API] Overwrite variables with 
SBLaunchInfo::SetEnvironment(append=true)

Summary:
This function was documented to overwrite entries with D76111, which was
adding a couple of similar functions. However, this function (unlike the
functions added in that patch) was/is not actually overwriting variables
-- any pre-existing variables would get ignored.

This behavior does not seem to be intentional. In fact, before the refactor in
D41359, this function could introduce duplicate entries, which could
have very surprising effects both inside lldb and on other applications
(some applications would take the first value, some the second one; in
lldb, attempting to unset a variable could make the second variable
become active, etc.).

Overwriting seems to be the most reasonable behavior here, so change the
code to match documentation.

Reviewers: clayborg, wallace, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/API/SBLaunchInfo.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py

Removed: 




diff  --git a/lldb/source/API/SBLaunchInfo.cpp 
b/lldb/source/API/SBLaunchInfo.cpp
index ba13072e8f9b..cda8134c9853 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -190,9 +190,10 @@ void SBLaunchInfo::SetEnvironment(const SBEnvironment 
&env, bool append) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
  (const lldb::SBEnvironment &, bool), env, append);
   Environment &refEnv = env.ref();
-  if (append)
-m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
-  else
+  if (append) {
+for (auto &KV : refEnv)
+  m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+  } else
 m_opaque_sp->GetEnvironment() = refEnv;
   m_opaque_sp->RegenerateEnvp();
 }

diff  --git a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py 
b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
index c1937f985e28..6389854ce58f 100644
--- a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,6 +53,11 @@ def test_launch_info(self):
 launch_info.SetEnvironment(env, append=True)
 self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
 
+env.Set("FOO", "baz", overwrite=True)
+launch_info.SetEnvironment(env, append=True)
+self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
+self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
+
 # Make sure we can replace the launchInfo's environment
 env.Clear()
 env.Set("BAR", "foo", overwrite=True)
@@ -120,6 +125,11 @@ def test_creating_and_modifying_environment(self):
 env.SetEntries(entries, append=False)
 self.assertEqualEntries(env, ["X=x", "Y=y"])
 
+entries.Clear()
+entries.AppendList(["X=y", "Y=x"], 2)
+env.SetEntries(entries, append=True)
+self.assertEqualEntries(env, ["X=y", "Y=x"])
+
 # Test clear
 env.Clear()
 self.assertEqualEntries(env, [])



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


[Lldb-commits] [PATCH] D83306: [lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)

2020-07-08 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG695b33a56919: [lldb/API] Overwrite variables with 
SBLaunchInfo::SetEnvironment(append=true) (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83306

Files:
  lldb/source/API/SBLaunchInfo.cpp
  lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py


Index: lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
===
--- lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,6 +53,11 @@
 launch_info.SetEnvironment(env, append=True)
 self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
 
+env.Set("FOO", "baz", overwrite=True)
+launch_info.SetEnvironment(env, append=True)
+self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
+self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
+
 # Make sure we can replace the launchInfo's environment
 env.Clear()
 env.Set("BAR", "foo", overwrite=True)
@@ -120,6 +125,11 @@
 env.SetEntries(entries, append=False)
 self.assertEqualEntries(env, ["X=x", "Y=y"])
 
+entries.Clear()
+entries.AppendList(["X=y", "Y=x"], 2)
+env.SetEntries(entries, append=True)
+self.assertEqualEntries(env, ["X=y", "Y=x"])
+
 # Test clear
 env.Clear()
 self.assertEqualEntries(env, [])
Index: lldb/source/API/SBLaunchInfo.cpp
===
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -190,9 +190,10 @@
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
  (const lldb::SBEnvironment &, bool), env, append);
   Environment &refEnv = env.ref();
-  if (append)
-m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
-  else
+  if (append) {
+for (auto &KV : refEnv)
+  m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+  } else
 m_opaque_sp->GetEnvironment() = refEnv;
   m_opaque_sp->RegenerateEnvp();
 }


Index: lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
===
--- lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,6 +53,11 @@
 launch_info.SetEnvironment(env, append=True)
 self.assertEqual(launch_info.GetEnvironment().GetNumValues(), env_count + 1)
 
+env.Set("FOO", "baz", overwrite=True)
+launch_info.SetEnvironment(env, append=True)
+self.assertEqual(launch_info.GetEnvironment().GetNumValues(), env_count + 1)
+self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
+
 # Make sure we can replace the launchInfo's environment
 env.Clear()
 env.Set("BAR", "foo", overwrite=True)
@@ -120,6 +125,11 @@
 env.SetEntries(entries, append=False)
 self.assertEqualEntries(env, ["X=x", "Y=y"])
 
+entries.Clear()
+entries.AppendList(["X=y", "Y=x"], 2)
+env.SetEntries(entries, append=True)
+self.assertEqualEntries(env, ["X=y", "Y=x"])
+
 # Test clear
 env.Clear()
 self.assertEqualEntries(env, [])
Index: lldb/source/API/SBLaunchInfo.cpp
===
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -190,9 +190,10 @@
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
  (const lldb::SBEnvironment &, bool), env, append);
   Environment &refEnv = env.ref();
-  if (append)
-m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
-  else
+  if (append) {
+for (auto &KV : refEnv)
+  m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+  } else
 m_opaque_sp->GetEnvironment() = refEnv;
   m_opaque_sp->RegenerateEnvp();
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 88c8247 - [lldb/Utility] Simplify Scalar float accessors

2020-07-08 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-08T13:57:32+02:00
New Revision: 88c82474d2ef92d0cda7d902206d90a73eed9c9d

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

LOG: [lldb/Utility] Simplify Scalar float accessors

Make use of APFloat conversion methods to avoid needing to switch based
on the stored value type.

Added: 


Modified: 
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6e2715130c70..87ac6c23892d 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -23,6 +23,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+using llvm::APFloat;
+
 namespace {
 enum class Category { Void, Integral, Float };
 }
@@ -641,98 +643,48 @@ llvm::APInt Scalar::UInt128(const llvm::APInt 
&fail_value) const {
 }
 
 float Scalar::Float(float fail_value) const {
-  switch (m_type) {
-  case e_void:
+  switch (GetCategory(m_type)) {
+  case Category::Void:
 break;
-  case e_sint:
-  case e_slong:
-  case e_slonglong:
-  case e_sint128:
-  case e_sint256:
-  case e_sint512:
-return llvm::APIntOps::RoundSignedAPIntToFloat(m_integer);
-
-  case e_uint:
-  case e_ulong:
-  case e_ulonglong:
-  case e_uint128:
-  case e_uint256:
-  case e_uint512:
+  case Category::Integral:
+if (IsSigned(m_type))
+  return llvm::APIntOps::RoundSignedAPIntToFloat(m_integer);
 return llvm::APIntOps::RoundAPIntToFloat(m_integer);
 
-  case e_float:
-return m_float.convertToFloat();
-  case e_double:
-return static_cast(m_float.convertToDouble());
-  case e_long_double:
-llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return ldbl_val.bitsToFloat();
+  case Category::Float: {
+APFloat result = m_float;
+bool losesInfo;
+result.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven,
+   &losesInfo);
+return result.convertToFloat();
+  }
   }
   return fail_value;
 }
 
 double Scalar::Double(double fail_value) const {
-  switch (m_type) {
-  case e_void:
+  switch (GetCategory(m_type)) {
+  case Category::Void:
 break;
-  case e_sint:
-  case e_slong:
-  case e_slonglong:
-  case e_sint128:
-  case e_sint256:
-  case e_sint512:
-return llvm::APIntOps::RoundSignedAPIntToDouble(m_integer);
-
-  case e_uint:
-  case e_ulong:
-  case e_ulonglong:
-  case e_uint128:
-  case e_uint256:
-  case e_uint512:
+  case Category::Integral:
+if (IsSigned(m_type))
+  return llvm::APIntOps::RoundSignedAPIntToDouble(m_integer);
 return llvm::APIntOps::RoundAPIntToDouble(m_integer);
 
-  case e_float:
-return static_cast(m_float.convertToFloat());
-  case e_double:
-return m_float.convertToDouble();
-  case e_long_double:
-llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return ldbl_val.bitsToFloat();
+  case Category::Float: {
+APFloat result = m_float;
+bool losesInfo;
+result.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
+   &losesInfo);
+return result.convertToDouble();
+  }
   }
   return fail_value;
 }
 
 long double Scalar::LongDouble(long double fail_value) const {
-  switch (m_type) {
-  case e_void:
-break;
-  case e_sint:
-  case e_slong:
-  case e_slonglong:
-  case e_sint128:
-  case e_sint256:
-  case e_sint512:
-return static_cast(
-llvm::APIntOps::RoundSignedAPIntToDouble(m_integer));
-
-  case e_uint:
-  case e_ulong:
-  case e_ulonglong:
-  case e_uint128:
-  case e_uint256:
-  case e_uint512:
-return static_cast(
-llvm::APIntOps::RoundAPIntToDouble(m_integer));
-
-  case e_float:
-return static_cast(m_float.convertToFloat());
-  case e_double:
-return static_cast(m_float.convertToDouble());
-  case e_long_double:
-llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return static_cast(ldbl_val.bitsToDouble());
-  }
-  return fail_value;
+  /// No way to get more precision at the moment.
+  return static_cast(Double(fail_value));
 }
 
 Scalar &Scalar::operator+=(const Scalar &rhs) {



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


[Lldb-commits] [lldb] 9c31da8 - [lldb/Core] Update comment to make it more explicit (NFC)

2020-07-08 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-07-08T14:03:59+02:00
New Revision: 9c31da853855eb952bbad98b99978df8c515e9b2

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

LOG: [lldb/Core] Update comment to make it more explicit (NFC)

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 8600469580e8..e6fad3ada5f0 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -687,7 +687,7 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
 language_flags);
   }
 
-  // In case of an incomplete type, LLDB will try to use the ValueObject's
+  // In case of an incomplete type, try to use the ValueObject's
   // synthetic value to create the child ValueObject.
   if (!valobj && synthetic_array_member) {
 if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {



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


[Lldb-commits] [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:2197
 // least as many of them as possible).
 return RD->isTrivial() && RD->isCXX11StandardLayout();
   }

teemperor wrote:
> See here for the POD check that we might get wrong.
I don't believe we are getting this wrong or at least not in the original 
problem. Going back and checking it we seem to be getting this right.



Comment at: lldb/test/Shell/Expr/Inputs/layout.cpp:40
+  D2 d2;
+  D3 d3;
+

teemperor wrote:
> Do we actually need these locals in addition to the globals?
I left them in by accident.


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

https://reviews.llvm.org/D83008



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


[Lldb-commits] [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 276407.
shafik added a comment.

Moved from shell test


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

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/API/lang/cpp/alignas_base_class/Makefile
  lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
  lldb/test/API/lang/cpp/alignas_base_class/main.cpp


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", 
result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the patch!


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

https://reviews.llvm.org/D83008



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


[Lldb-commits] [PATCH] D77043: Fix process gdb-remote usage of value_regs/invalidate_regs

2020-07-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The idea seems ok (though could use a test), but I am wondering if it wouldn't 
be better to do this conversion during (or immediately after) parsing. If I 
remember the previous discussions correctly, we've established that the 
value/invalidate_regs fields in the RegisterInfo structs are expected to 
contain "lldb" register numbers, but that the natural thing to do in the 
target.xml is to transfer "process plugin" (i.e., the `regnum` field) in these 
fields.

If that's true, then it would be better to do the conversion during parsing, so 
that we don't violate any invariants that some other parts of code may be 
assuming.


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

https://reviews.llvm.org/D77043



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


[Lldb-commits] [lldb] 7fd2969 - [lldb] Modernize/clean up ValueObject::GetChildMemberWithName

2020-07-08 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-08T17:42:47+02:00
New Revision: 7fd29699d6042af674c4f4ad185c91f82cb73b52

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

LOG: [lldb] Modernize/clean up ValueObject::GetChildMemberWithName

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index e6fad3ada5f0..f13ad63dfb61 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -574,15 +574,13 @@ size_t ValueObject::GetIndexOfChildWithName(ConstString 
name) {
 
 ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
   bool can_create) {
-  // when getting a child by name, it could be buried inside some base classes
-  // (which really aren't part of the expression path), so we need a vector of
-  // indexes that can get us down to the correct child
-  ValueObjectSP child_sp;
-
-  // We may need to update our value if we are dynamic
+  // We may need to update our value if we are dynamic.
   if (IsPossibleDynamicType())
 UpdateValueIfNeeded(false);
 
+  // When getting a child by name, it could be buried inside some base classes
+  // (which really aren't part of the expression path), so we need a vector of
+  // indexes that can get us down to the correct child.
   std::vector child_indexes;
   bool omit_empty_base_classes = true;
 
@@ -592,20 +590,13 @@ ValueObjectSP 
ValueObject::GetChildMemberWithName(ConstString name,
   const size_t num_child_indexes =
   GetCompilerType().GetIndexOfChildMemberWithName(
   name.GetCString(), omit_empty_base_classes, child_indexes);
-  if (num_child_indexes > 0) {
-std::vector::const_iterator pos = child_indexes.begin();
-std::vector::const_iterator end = child_indexes.end();
-
-child_sp = GetChildAtIndex(*pos, can_create);
-for (++pos; pos != end; ++pos) {
-  if (child_sp) {
-ValueObjectSP new_child_sp(child_sp->GetChildAtIndex(*pos, 
can_create));
-child_sp = new_child_sp;
-  } else {
-child_sp.reset();
-  }
-}
-  }
+  if (num_child_indexes == 0)
+return nullptr;
+
+  ValueObjectSP child_sp = GetSP();
+  for (uint32_t idx : child_indexes)
+if (child_sp)
+  child_sp = child_sp->GetChildAtIndex(idx, can_create);
   return child_sp;
 }
 



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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-07-08 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 updated this revision to Diff 276468.
gedatsu217 added a comment.

I fixed the code according to your advice.


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

https://reviews.llvm.org/D81001

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp

Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1866,6 +1866,17 @@
   HandleCompletionMatches(request);
 }
 
+llvm::Optional
+CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) {
+  const size_t s = m_command_history.GetSize();
+  for (size_t i = 0; i < s; ++i) {
+llvm::StringRef entry = m_command_history.GetStringAtIndex(i);
+if (entry.consume_front(line))
+  return entry.str();
+  }
+  return llvm::None;
+}
+
 CommandInterpreter::~CommandInterpreter() {}
 
 void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/Editline.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -1002,8 +1003,20 @@
 case CompletionMode::Normal: {
   std::string to_add = completion.GetCompletion();
   to_add = to_add.substr(request.GetCursorArgumentPrefix().size());
+  std::string to_add_autosuggestion = "";
+  m_suggestion_callback(line, to_add_autosuggestion,
+m_suggestion_callback_baton);
   if (request.GetParsedArg().IsQuoted())
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  if (!to_add_autosuggestion.empty() && !to_add.empty()) {
+size_t length = to_add.length();
+if (to_add_autosuggestion.length() > length &&
+to_add == to_add_autosuggestion.substr(0, length)) {
+  to_add.push_back(' ');
+  el_insertstr(m_editline, to_add.c_str());
+  return CC_REFRESH;
+}
+  }
   to_add.push_back(' ');
   el_insertstr(m_editline, to_add.c_str());
   break;
@@ -1040,6 +1053,43 @@
   return CC_REDISPLAY;
 }
 
+unsigned char Editline::ApplyAutosuggestCommand(int ch) {
+  const LineInfo *line_info = el_line(m_editline);
+  llvm::StringRef line(line_info->buffer,
+   line_info->lastchar - line_info->buffer);
+  std::string to_add = "";
+  m_suggestion_callback(line, to_add, m_suggestion_callback_baton);
+
+  if (to_add.empty())
+return CC_REFRESH;
+
+  el_insertstr(m_editline, to_add.c_str());
+  return CC_REDISPLAY;
+}
+
+unsigned char Editline::TypedCharacter(int ch) {
+  std::string typed = std::string(1, ch);
+  el_insertstr(m_editline, typed.c_str());
+  const LineInfo *line_info = el_line(m_editline);
+  llvm::StringRef line(line_info->buffer,
+   line_info->lastchar - line_info->buffer);
+
+  std::string to_add = "";
+  m_suggestion_callback(line, to_add, m_suggestion_callback_baton);
+
+  if (to_add.empty())
+return CC_REDISPLAY;
+
+  std::string to_add_color = ansi::FormatAnsiTerminalCodes("${ansi.faint}") +
+ to_add +
+ ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+  fputs(typed.c_str(), m_output_file);
+  fputs(to_add_color.c_str(), m_output_file);
+  MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
+
+  return CC_REFRESH;
+}
+
 void Editline::ConfigureEditor(bool multiline) {
   if (m_editline && m_multiline_enabled == multiline)
 return;
@@ -1153,7 +1203,38 @@
   if (!multiline) {
 el_set(m_editline, EL_BIND, "^r", "em-inc-search-prev",
NULL); // Cycle through backwards search, entering string
+
+if (m_suggestion_callback) {
+  el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-apply-complete"),
+  EditLineConstString("Adopt autocompletion"),
+  (EditlineCommandCallbackType)([](EditLine *editline, int ch) {
+return Editline::InstanceFor(editline)->ApplyAutosuggestCommand(
+ch);
+  }));
+
+  el_set(m_editline, EL_BIND, "^f", "lldb-apply-complete",
+ NULL); // Apply a part that is suggested automatically
+
+  el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-typed-character"),
+  EditLineConstString("Typed character"),
+

[Lldb-commits] [lldb] 63b0f8c - [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread via lldb-commits

Author: shafik
Date: 2020-07-08T10:07:15-07:00
New Revision: 63b0f8c788d8c6978feb099fd6db8fe219c4d166

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

LOG: [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct 
bases class offsets from the external source

Currently the ItaniumRecordLayoutBuilder when laying out base classes has the 
virtual
and non-virtual bases mixed up when pulling the base class layouts from the 
external source.

This came up in an LLDB bug where on arm64 because of differences in how it 
deals with
tail padding would layout the bases differently without the correct layout from 
the
external source (LLDB). This would result in some fields being off by 4 bytes.

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

Added: 
lldb/test/API/lang/cpp/alignas_base_class/Makefile
lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
lldb/test/API/lang/cpp/alignas_base_class/main.cpp

Modified: 
clang/lib/AST/RecordLayoutBuilder.cpp

Removed: 




diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index b44957a35279..d56c7e2ab8c0 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/Makefile 
b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
new file mode 100644
index ..25f37ab7fe5f
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", 
result_value="8")

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp 
b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
new file mode 100644
index ..8dfced6c784e
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}



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


[Lldb-commits] [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63b0f8c788d8: [RecordLayout] Fix ItaniumRecordLayoutBuilder 
so that is grabs the correct… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/API/lang/cpp/alignas_base_class/Makefile
  lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
  lldb/test/API/lang/cpp/alignas_base_class/main.cpp


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", 
result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
___
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-07-08 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://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] D83072: [lldb-vscode] Add Compile Unit List to Modules View

2020-07-08 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen updated this revision to Diff 276515.
aelitashen added a comment.

Recover Messy Diff History


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83072

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  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
@@ -1174,6 +1174,31 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+void request_getCompileUnits(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  lldb::SBProcess process = g_vsc.target.GetProcess();
+  llvm::json::Object body;
+  llvm::json::Array units;
+  auto arguments = request.getObject("arguments");
+  std::string module_id = std::string(GetString(arguments, "moduleId"));
+  int num_modules = g_vsc.target.GetNumModules();
+  for (int i = 0; i < num_modules; i++) {
+auto curr_module = g_vsc.target.GetModuleAtIndex(i);
+if (module_id == curr_module.GetUUIDString()) {
+  int num_units = curr_module.GetNumCompileUnits();
+  for (int j = 0; j < num_units; j++) {
+auto curr_unit = curr_module.GetCompileUnitAtIndex(j);\
+units.emplace_back(CreateCompileUnit(curr_unit));\
+  }
+  body.try_emplace("compileUnits", std::move(units));
+  break;
+}
+  }
+  response.try_emplace("body", std::move(body));
+  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
+}
+
 // "InitializeRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
@@ -2759,6 +2784,7 @@
   REQUEST_CALLBACK(disconnect),
   REQUEST_CALLBACK(evaluate),
   REQUEST_CALLBACK(exceptionInfo),
+  REQUEST_CALLBACK(getCompileUnits),
   REQUEST_CALLBACK(initialize),
   REQUEST_CALLBACK(launch),
   REQUEST_CALLBACK(next),
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -441,6 +441,8 @@
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex);
 
+llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
+
 } // namespace lldb_vscode
 
 #endif
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -937,4 +937,12 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit) {
+  llvm::json::Object object;
+  std::string path = std::string(unit.GetFileSpec().GetDirectory()) + "/" +
+  std::string(unit.GetFileSpec().GetFilename());
+  object.try_emplace("compileUnitPath", path);
+  return llvm::json::Value(std::move(object));
+}
+
 } // namespace lldb_vscode
Index: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
===
--- lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
+++ lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
@@ -46,4 +46,22 @@
 self.assertIn('symbolFilePath', program_module)
 self.assertEqual(symbol_path, program_module['symbolFilePath'])
 self.assertIn('addressRange', program_module)
-
\ No newline at end of file
+
+def test_compile_units(self):
+program= self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+main_source_path = self.getSourcePath(source)
+breakpoint1_line = line_number(source, '// breakpoint 1')
+lines = [breakpoint1_line]
+breakpoint_ids = self.set_source_breakpoints(source, lines)
+self.continue_to_breakpoints(breakpoint_ids)
+moduleId = self.vscode.get_active_modules()['a.out']['id']
+response = self.vscode.request_getCompileUnits(moduleId)
+print(response['body'])
+self.assertTrue(response['body'])
+self.assertTrue(len(response['body']['compileUnits']) == 1,
+'Only one source file should exist')
+self.assertTrue(response['body']['compileUnits'][0]['compileUnitPath'] == main_source_path, 
+'Real path to main.cpp matches')
+ 
\ No newline at end of file
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/t

[Lldb-commits] [lldb] 27d52cd - Revert "[lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)"

2020-07-08 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-07-08T13:09:24-07:00
New Revision: 27d52cd86a2cf82214b71519dffd450c54cf87ae

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

LOG: Revert "[lldb/API] Overwrite variables with 
SBLaunchInfo::SetEnvironment(append=true)"

This reverts commit 695b33a56919af8873eecb47cb83fa17a271e99f beacuse
it broke the macOS bot.

Added: 


Modified: 
lldb/source/API/SBLaunchInfo.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py

Removed: 




diff  --git a/lldb/source/API/SBLaunchInfo.cpp 
b/lldb/source/API/SBLaunchInfo.cpp
index cda8134c9853..ba13072e8f9b 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -190,10 +190,9 @@ void SBLaunchInfo::SetEnvironment(const SBEnvironment 
&env, bool append) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
  (const lldb::SBEnvironment &, bool), env, append);
   Environment &refEnv = env.ref();
-  if (append) {
-for (auto &KV : refEnv)
-  m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
-  } else
+  if (append)
+m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
+  else
 m_opaque_sp->GetEnvironment() = refEnv;
   m_opaque_sp->RegenerateEnvp();
 }

diff  --git a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py 
b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
index 6389854ce58f..c1937f985e28 100644
--- a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,11 +53,6 @@ def test_launch_info(self):
 launch_info.SetEnvironment(env, append=True)
 self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
 
-env.Set("FOO", "baz", overwrite=True)
-launch_info.SetEnvironment(env, append=True)
-self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
-self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
-
 # Make sure we can replace the launchInfo's environment
 env.Clear()
 env.Set("BAR", "foo", overwrite=True)
@@ -125,11 +120,6 @@ def test_creating_and_modifying_environment(self):
 env.SetEntries(entries, append=False)
 self.assertEqualEntries(env, ["X=x", "Y=y"])
 
-entries.Clear()
-entries.AppendList(["X=y", "Y=x"], 2)
-env.SetEntries(entries, append=True)
-self.assertEqualEntries(env, ["X=y", "Y=x"])
-
 # Test clear
 env.Clear()
 self.assertEqualEntries(env, [])



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


[Lldb-commits] [PATCH] D83306: [lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)

2020-07-08 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

This broke macOS:

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/22425/

I reverted it in:

  commit 27d52cd86a2cf82214b71519dffd450c54cf87ae (HEAD -> master, 
origin/master, origin/HEAD)
  Author: Davide Italiano 
  Date:   Wed Jul 8 13:00:29 2020 -0700
  Revert "[lldb/API] Overwrite variables with 
SBLaunchInfo::SetEnvironment(append=true)"
  This reverts commit 695b33a56919af8873eecb47cb83fa17a271e99f beacuse
  it broke the macOS bot.

Let me know if you need any help/info to reproduce [just shoot me an e-mail], 
but ToT + `ninja check-lldb` on a recent'ish 10.15 should do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83306



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


[Lldb-commits] [PATCH] D83425: [lldb] add printing of stdout compile errors to lldbsuite

2020-07-08 Thread Benson Li via Phabricator via lldb-commits
bbli created this revision.
bbli added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch will add printing of the output of stdout during compile errors, 
right below output of stderr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83425

Files:
  lldb/packages/Python/lldbsuite/test_event/build_exception.py


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -4,13 +4,14 @@
 super(BuildError, self).__init__("Error when building test subject")
 self.command = called_process_error.lldb_extensions.get(
 "command", "")
-self.build_error = called_process_error.lldb_extensions.get(
+self.stderr = called_process_error.lldb_extensions.get(
 "stderr_content", "")
+self.stdout = 
called_process_error.lldb_extensions.get("stdout_content","")
 
 def __str__(self):
-return self.format_build_error(self.command, self.build_error)
+return self.format_build_error(self.command, self.stderr, self.stdout)
 
 @staticmethod
-def format_build_error(command, command_output):
+def format_build_error(command, stderr_output, stdout_output):
 return "Error when building test subject.\n\nBuild 
Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8"))
+command, stderr_output.decode("utf-8")+ 
stdout_output.decode("utf-8"))


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -4,13 +4,14 @@
 super(BuildError, self).__init__("Error when building test subject")
 self.command = called_process_error.lldb_extensions.get(
 "command", "")
-self.build_error = called_process_error.lldb_extensions.get(
+self.stderr = called_process_error.lldb_extensions.get(
 "stderr_content", "")
+self.stdout = called_process_error.lldb_extensions.get("stdout_content","")
 
 def __str__(self):
-return self.format_build_error(self.command, self.build_error)
+return self.format_build_error(self.command, self.stderr, self.stdout)
 
 @staticmethod
-def format_build_error(command, command_output):
+def format_build_error(command, stderr_output, stdout_output):
 return "Error when building test subject.\n\nBuild Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8"))
+command, stderr_output.decode("utf-8")+ stdout_output.decode("utf-8"))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83072: [lldb-vscode] Add Compile Unit List to Modules View

2020-07-08 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.

Just use the SBFileSpec::GetPath(...) and document the compile unit request, 
args and response, and this will be ready.




Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:942-943
+  llvm::json::Object object;
+  std::string path = std::string(unit.GetFileSpec().GetDirectory()) + "/" +
+  std::string(unit.GetFileSpec().GetFilename());
+  object.try_emplace("compileUnitPath", path);

Let LLDB handle the '/' like we did using SBFileSpec::GetPath(...) here.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1177
 
+void request_getCompileUnits(const llvm::json::Object &request) {
+  llvm::json::Object response;

We need to document the packet format like ""InitializeRequest" on lines 
1202-1277. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83072



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


[Lldb-commits] [PATCH] D83433: Fix how we handle bit-fields for Objective-C when creating an AST

2020-07-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: teemperor, jingham, aprantl.

Currently expressions dealing with bit-fields in Objective-C objects is pretty 
broken. When generating debug-info for Objective-C bit-fields we don't generate 
offsets because the Objective-C runtime is supposed to handle generating the 
offsets for us.

When we parse the DWARF we expect to always have valid bit offsets and if we 
don't we treat that as an error and stop adding bit-fields to the AST.

Later on when we do a name lookup we don't find the `ObjCIvarDecl` in the 
`ObjCInterfaceDecl` in some cases since we never added it and then we don't go 
to the runtime to obtain the offset.

This will fix how we handle bit-fields for the Objective-C case and add tests 
to verify this fix but also to documents areas that still don't work and will 
be addressed in follow-up PRs.


https://reviews.llvm.org/D83433

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/objc/bitfield_ivars/Makefile
  lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
  lldb/test/API/lang/objc/bitfield_ivars/main.m

Index: lldb/test/API/lang/objc/bitfield_ivars/main.m
===
--- lldb/test/API/lang/objc/bitfield_ivars/main.m
+++ lldb/test/API/lang/objc/bitfield_ivars/main.m
@@ -34,10 +34,31 @@
 
 @end
 
+@interface HasBitfield2 : NSObject {
+@public
+  unsigned int x;
+
+  unsigned field1 : 15;
+  unsigned field2 : 4;
+  unsigned field3 : 4;
+}
+@end
+
+@implementation HasBitfield2
+- (id)init {
+  return (self = [super init]);
+}
+@end
+
 int main(int argc, const char * argv[]) {
 ContainsAHasBitfield *chb = [[ContainsAHasBitfield alloc] init];
-printf("%d\n", chb->hb->field2); //% self.expect("expression -- chb->hb->field1", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 0"])
- //% self.expect("expression -- chb->hb->field2", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 1"]) # this must happen second
-return 0;
+HasBitfield2 *hb2 = [[HasBitfield2 alloc] init];
+
+hb2->x = 100;
+hb2->field1 = 10;
+hb2->field2 = 3;
+hb2->field3 = 4;
+
+return 0; // break here
 }
 
Index: lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
===
--- lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -1,12 +1,32 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
-
-lldbinline.MakeInlineTest(
-__file__,
-globals(),
-[
-# This is a Darwin-only failure related to incorrect expression-
-# evaluation for single-bit ObjC bitfields.
-decorators.skipUnlessDarwin,
-decorators.expectedFailureAll(
-bugnumber="rdar://problem/17990991")])
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestBitfieldIvars(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+self.expect_expr("chb->hb->field1", result_type="unsigned int", result_value="0")
+
+## FIXME field2 should have a value of 1
+self.expect("expr chb->hb->field2", matching=False, substrs = ["= 1"]) # this must happen second
+
+self.expect_expr("hb2->field1", result_type="unsigned int", result_value="10")
+self.expect_expr("hb2->field2", result_type="unsigned int", result_value="3")
+self.expect_expr("hb2->field3", result_type="unsigned int", result_value="4")
+
+@expectedFailureAll()
+def ExpressionOnObject(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+## FIXME expression with individual bit-fields obtains correct values but not with the whole object
+self.expect("expr *hb2", substrs = [ 'x =', '100',
+ 'field1 =', '10',
+ 'field2 =', '3',
+ 'field3 =', '4'])
Index: lldb/test/API/lang/objc/bitfield_ivars/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/objc/bitfield_ivars/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS = -framework Foundation
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2609,10 +2609,11 @@
   }
 }
 
-if ((this_field_info.bit_offset >= parent

[Lldb-commits] [PATCH] D83433: Fix how we handle bit-fields for Objective-C when creating an AST

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2612
 
-if ((this_field_info.bit_offset >= parent_bit_size) ||
-(last_field_info.IsBitfield() &&
- !last_field_info.NextBitfieldOffsetIsValid(
- this_field_info.bit_offset))) {
+if (class_language != eLanguageTypeObjC &&
+((this_field_info.bit_offset >= parent_bit_size) ||

I think we should add a comment here explaining why this doesn't apply to 
Objective-C. Also, what about a C struct in Objective-C, or a C++ class in 
Objective-C++?


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

https://reviews.llvm.org/D83433



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


[Lldb-commits] [lldb] 3728133 - Unify the ExecutionContextScope computation in Materializer.

2020-07-08 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-07-08T15:18:21-07:00
New Revision: 3728133d3f124c4c6972b118b0265de48ba89db1

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

LOG: Unify the ExecutionContextScope computation in Materializer.

This is an NFC cleanup for Clang, and a bugfix for the Swift
branch. In swift-lldb one target may have multiple scratch
TypeSystems, so it is important to pick the one that belongs to the
current frame, rather than the one for the current target.



Added: 


Modified: 
lldb/source/Expression/Materializer.cpp

Removed: 




diff  --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index dccba5885bd9..f33462053f22 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -785,7 +785,9 @@ class EntityResultVariable : public Materializer::Entity {
 
   const lldb::addr_t load_addr = process_address + m_offset;
 
-  ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+  ExecutionContextScope *exe_scope = frame_sp.get();
+  if (!exe_scope)
+exe_scope = map.GetBestExecutionContextScope();
 
   llvm::Optional byte_size = m_type.GetByteSize(exe_scope);
   if (!byte_size) {
@@ -835,7 +837,9 @@ class EntityResultVariable : public Materializer::Entity {
  lldb::addr_t frame_bottom, Status &err) override {
 err.Clear();
 
-ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+ExecutionContextScope *exe_scope = frame_sp.get();
+if (!exe_scope)
+  exe_scope = map.GetBestExecutionContextScope();
 
 if (!exe_scope) {
   err.SetErrorString("Couldn't dematerialize a result variable: invalid "
@@ -1061,7 +1065,9 @@ class EntitySymbol : public Materializer::Entity {
 
 const Address sym_address = m_symbol.GetAddress();
 
-ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+ExecutionContextScope *exe_scope = frame_sp.get();
+if (!exe_scope)
+  exe_scope = map.GetBestExecutionContextScope();
 
 lldb::TargetSP target_sp;
 
@@ -1342,7 +1348,6 @@ Materializer::DematerializerSP
 Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
   lldb::addr_t process_address, Status &error) {
   ExecutionContextScope *exe_scope = frame_sp.get();
-
   if (!exe_scope)
 exe_scope = map.GetBestExecutionContextScope();
 
@@ -1393,7 +1398,9 @@ void Materializer::Dematerializer::Dematerialize(Status 
&error,
   if (thread_sp)
 frame_sp = thread_sp->GetFrameWithStackID(m_stack_id);
 
-  ExecutionContextScope *exe_scope = m_map->GetBestExecutionContextScope();
+  ExecutionContextScope *exe_scope = frame_sp.get();
+  if (!exe_scope)
+exe_scope = m_map->GetBestExecutionContextScope();
 
   if (!IsValid()) {
 error.SetErrorToGenericError();



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


[Lldb-commits] [lldb] 9726dc4 - Updated the list of supported platforms in LLDB to include Apple silicon.

2020-07-08 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-07-08T15:33:00-07:00
New Revision: 9726dc4d072376f71c40024804e3bf1193ba5dd8

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

LOG: Updated the list of supported platforms in LLDB to include Apple silicon.

Added: 


Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 29f63b328381..50441f5be910 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -69,12 +69,12 @@ Platform Support
 LLDB is known to work on the following platforms, but ports to new platforms
 are welcome:
 
-* macOS desktop user space debugging for i386 and x86_64
-* iOS, tvOS, and watchOS simulator debugging on i386 and x86_64
+* macOS debugging for i386, x86_64 and AArch64
+* iOS, tvOS, and watchOS simulator debugging on i386, x86_64 and AArch64
 * iOS, tvOS, and watchOS device debugging on ARM and AArch64
-* Linux local user-space debugging for i386, x86_64 and PPC64le
-* FreeBSD local user-space debugging for i386 and x86_64
-* Windows local user-space debugging for i386 (*)
+* Linux user-space debugging for i386, x86_64 and PPC64le
+* FreeBSD user-space debugging for i386 and x86_64
+* Windows user-space debugging for i386 (*)
 
 (*) Support for Windows is under active development. Basic functionality is
 expected to work, with functionality improving rapidly.



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


[Lldb-commits] [PATCH] D83359: [Function] Lock the function when parsing call site info

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Looks plausible.




Comment at: lldb/include/lldb/Symbol/Function.h:661
+  std::mutex
+  m_call_edges_lock; ///< Exclusive lock that controls read/write
+ ///  access to m_call_edges and m_call_edges_resolved.

nit: When inline comments span multiple lines it's IMO less confusing to 
convert them to up-front comments.
```
  /// Exclusive lock that controls read/write
  /// access to m_call_edges and m_call_edges_resolved.
  std::mutex m_call_edges_lock;
```

I also doubt that the ones in this file are formatted correctly, I think the 
continuation needs to also use `///<`.



Comment at: lldb/source/Symbol/Function.cpp:293
 llvm::ArrayRef> Function::GetCallEdges() {
+  std::lock_guard guard(m_call_edges_lock);
+

Can this be called on the same thread and would we benefit from a 
recursive_mutex?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83359



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


[Lldb-commits] [PATCH] D83425: [lldb] add printing of stdout compile errors to lldbsuite

2020-07-08 Thread Benson Li via Phabricator via lldb-commits
bbli updated this revision to Diff 276590.
bbli added a comment.

Changed back to original function signature, as this method gets called once 
outside the class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83425

Files:
  lldb/packages/Python/lldbsuite/test_event/build_exception.py
  lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py


Index: lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
@@ -258,7 +258,7 @@
 build_issue_description = self._replace_invalid_xml(
 BuildError.format_build_error(
 test_event.get("build_command", ""),
-test_event.get("build_error", "")))
+test_event.get("build_error", "").decode("utf-8")))
 
 result = self._common_add_testcase_entry(
 test_event,
Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -5,7 +5,7 @@
 self.command = called_process_error.lldb_extensions.get(
 "command", "")
 self.build_error = called_process_error.lldb_extensions.get(
-"stderr_content", "")
+"stderr_content", "").decode("utf-8") + 
called_process_error.lldb_extensions.get("stdout_content","").decode("utf-8")
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)
@@ -13,4 +13,4 @@
 @staticmethod
 def format_build_error(command, command_output):
 return "Error when building test subject.\n\nBuild 
Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8"))
+command, command_output)


Index: lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
@@ -258,7 +258,7 @@
 build_issue_description = self._replace_invalid_xml(
 BuildError.format_build_error(
 test_event.get("build_command", ""),
-test_event.get("build_error", "")))
+test_event.get("build_error", "").decode("utf-8")))
 
 result = self._common_add_testcase_entry(
 test_event,
Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -5,7 +5,7 @@
 self.command = called_process_error.lldb_extensions.get(
 "command", "")
 self.build_error = called_process_error.lldb_extensions.get(
-"stderr_content", "")
+"stderr_content", "").decode("utf-8") + called_process_error.lldb_extensions.get("stdout_content","").decode("utf-8")
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)
@@ -13,4 +13,4 @@
 @staticmethod
 def format_build_error(command, command_output):
 return "Error when building test subject.\n\nBuild Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8"))
+command, command_output)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83441: [ldb/Reproducers] Add YamlRecorder and MultiProvider

2020-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor.

This patch does several things that are all closely related:

- It introduces a new `YamlRecorder` as a counterpart to the existing 
`DataRecorder`. As the name suggests the former serializes data as yaml while 
the latter uses raw texts or bytes.
- It introduces a new `MultiProvider` base class which can be backed by either 
a `DataRecorder` or a `YamlRecorder`.
- It reimplements the `CommandProvider` in terms of the new `MultiProvider`.
- Finally, it adds unit testing coverage for the `MultiProvider`, a naive 
`YamlProvider` built on top of the new `YamlRecorder` and the existing 
`MutliLoader`.

This is the basis of a future patch that I'm working on which will implement a 
Provider through the `YamlRecorder`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D83441

Files:
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Utility/Reproducer.cpp
  lldb/unittests/Utility/ReproducerTest.cpp

Index: lldb/unittests/Utility/ReproducerTest.cpp
===
--- lldb/unittests/Utility/ReproducerTest.cpp
+++ lldb/unittests/Utility/ReproducerTest.cpp
@@ -31,8 +31,26 @@
   static char ID;
 };
 
+class YamlMultiProvider
+: public MultiProvider {
+public:
+  struct Info {
+static const char *name;
+static const char *file;
+  };
+
+  YamlMultiProvider(const FileSpec &directory)
+  : MultiProvider(directory) {}
+
+  static char ID;
+};
+
 const char *DummyProvider::Info::name = "dummy";
 const char *DummyProvider::Info::file = "dummy.yaml";
+const char *YamlMultiProvider::Info::name = "mutli";
+const char *YamlMultiProvider::Info::file = "mutli.yaml";
+char DummyProvider::ID = 0;
+char YamlMultiProvider::ID = 0;
 
 class DummyReproducer : public Reproducer {
 public:
@@ -42,7 +60,26 @@
   using Reproducer::SetReplay;
 };
 
-char DummyProvider::ID = 0;
+struct YamlData {
+  YamlData() : i(-1){};
+  YamlData(int i) : i(i){};
+  int i;
+};
+
+inline bool operator==(const YamlData &LHS, const YamlData &RHS) {
+  return LHS.i == RHS.i;
+}
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(YamlData)
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(std::vector)
+
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits {
+  static void mapping(IO &io, YamlData &Y) { io.mapRequired("i", Y.i); };
+};
+} // namespace yaml
+} // namespace llvm
 
 TEST(ReproducerTest, SetCapture) {
   DummyReproducer reproducer;
@@ -144,3 +181,82 @@
   auto &provider_alt = generator.GetOrCreate();
   EXPECT_EQ(&provider, &provider_alt);
 }
+
+TEST(GeneratorTest, YamlMultiProvider) {
+  SmallString<128> root;
+  std::error_code ec = llvm::sys::fs::createUniqueDirectory("reproducer", root);
+  ASSERT_FALSE(static_cast(ec));
+
+  YamlData data0(0);
+  YamlData data1(1);
+  YamlData data2(2);
+  YamlData data3(3);
+
+  {
+DummyReproducer reproducer;
+EXPECT_THAT_ERROR(reproducer.SetCapture(FileSpec(root.str())), Succeeded());
+
+auto &generator = *reproducer.GetGenerator();
+auto *provider = generator.Create();
+ASSERT_NE(nullptr, provider);
+
+auto *recorder = provider->GetNewRecorder();
+ASSERT_NE(nullptr, recorder);
+recorder->Record(data0);
+recorder->Record(data1);
+
+recorder = provider->GetNewRecorder();
+ASSERT_NE(nullptr, recorder);
+recorder->Record(data2);
+recorder->Record(data3);
+
+generator.Keep();
+  }
+
+  {
+DummyReproducer reproducer;
+EXPECT_THAT_ERROR(reproducer.SetReplay(FileSpec(root.str())), Succeeded());
+
+auto &loader = *reproducer.GetLoader();
+std::unique_ptr> multi_loader =
+repro::MultiLoader::Create(&loader);
+
+// Read the first file.
+{
+  llvm::Optional file = multi_loader->GetNextFile();
+  EXPECT_TRUE(static_cast(file));
+
+  auto buffer = llvm::MemoryBuffer::getFile(*file);
+  EXPECT_TRUE(static_cast(buffer));
+
+  yaml::Input yin((*buffer)->getBuffer());
+  std::vector data;
+  yin >> data;
+
+  ASSERT_EQ(data.size(), 2U);
+  EXPECT_EQ(data[0], data0);
+  EXPECT_EQ(data[1], data1);
+}
+
+// Read the second file.
+{
+  llvm::Optional file = multi_loader->GetNextFile();
+  EXPECT_TRUE(static_cast(file));
+
+  auto buffer = llvm::MemoryBuffer::getFile(*file);
+  EXPECT_TRUE(static_cast(buffer));
+
+  yaml::Input yin((*buffer)->getBuffer());
+  std::vector data;
+  yin >> data;
+
+  ASSERT_EQ(data.size(), 2U);
+  EXPECT_EQ(data[0], data2);
+  EXPECT_EQ(data[1], data3);
+}
+
+// There is no third file.
+llvm::Optional file = multi_loader->GetNextFile();
+EXPECT_FALSE(static_cast(file));
+  }
+}
Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -7,6 +7,7 @@
 //===

[Lldb-commits] [PATCH] D83072: [lldb-vscode] Add Compile Unit List to Modules View

2020-07-08 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen updated this revision to Diff 276596.
aelitashen added a comment.

Fix Path and Add Documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83072

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  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
@@ -1174,6 +1174,72 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "getCompileUnitsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Compile Unit request; value of command field is
+// 'getCompileUnits'.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "getCompileUnits" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/getCompileUnitRequestArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "getCompileUnitsRequestArguments": {
+//   "type": "object",
+//   "description": "Arguments for 'getCompileUnits' request.",
+//   "properties": {
+// "moduleId": {
+//   "type": "string",
+//   "description": "The ID of the module."
+// }
+//   },
+//   "required": [ "moduleId" ]
+// },
+// "getCompileUnitsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to 'getCompileUnits' request.",
+// "properties": {
+//   "body": {
+// "description": "Response to 'getCompileUnits' request. Array of
+// paths of compile units."
+//   }
+// }
+//   }]
+// }
+
+void request_getCompileUnits(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  lldb::SBProcess process = g_vsc.target.GetProcess();
+  llvm::json::Object body;
+  llvm::json::Array units;
+  auto arguments = request.getObject("arguments");
+  std::string module_id = std::string(GetString(arguments, "moduleId"));
+  int num_modules = g_vsc.target.GetNumModules();
+  for (int i = 0; i < num_modules; i++) {
+auto curr_module = g_vsc.target.GetModuleAtIndex(i);
+if (module_id == curr_module.GetUUIDString()) {
+  int num_units = curr_module.GetNumCompileUnits();
+  for (int j = 0; j < num_units; j++) {
+auto curr_unit = curr_module.GetCompileUnitAtIndex(j);\
+units.emplace_back(CreateCompileUnit(curr_unit));\
+  }
+  body.try_emplace("compileUnits", std::move(units));
+  break;
+}
+  }
+  response.try_emplace("body", std::move(body));
+  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
+}
+
 // "InitializeRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
@@ -2759,6 +2825,7 @@
   REQUEST_CALLBACK(disconnect),
   REQUEST_CALLBACK(evaluate),
   REQUEST_CALLBACK(exceptionInfo),
+  REQUEST_CALLBACK(getCompileUnits),
   REQUEST_CALLBACK(initialize),
   REQUEST_CALLBACK(launch),
   REQUEST_CALLBACK(next),
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -441,6 +441,8 @@
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex);
 
+llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
+
 } // namespace lldb_vscode
 
 #endif
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -937,4 +937,13 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit) {
+  llvm::json::Object object;
+  char unit_path_arr[PATH_MAX];
+  unit.GetFileSpec().GetPath(unit_path_arr, sizeof(unit_path_arr));
+  std::string unit_path(unit_path_arr);
+  object.try_emplace("compileUnitPath", unit_path);
+  return llvm::json::Value(std::move(object));
+}
+
 } // namespace lldb_vscode
Index: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
===
--- lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
+++ lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
@@ -46,4 +46,22 @@
 self.assertIn('symbolFilePath', program_module)
 self.assertEqual(symbol_path, program_module['symbolFilePath'])
 self.assertIn('addressRange', program_module)

[Lldb-commits] [PATCH] D83441: [ldb/Reproducers] Add YamlRecorder and MultiProvider

2020-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 276597.
JDevlieghere added a comment.

Use `ScopeExit` to cleanup reproducer after test completes.


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

https://reviews.llvm.org/D83441

Files:
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Utility/Reproducer.cpp
  lldb/unittests/Utility/ReproducerTest.cpp

Index: lldb/unittests/Utility/ReproducerTest.cpp
===
--- lldb/unittests/Utility/ReproducerTest.cpp
+++ lldb/unittests/Utility/ReproducerTest.cpp
@@ -9,6 +9,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
 
@@ -31,8 +32,26 @@
   static char ID;
 };
 
+class YamlMultiProvider
+: public MultiProvider {
+public:
+  struct Info {
+static const char *name;
+static const char *file;
+  };
+
+  YamlMultiProvider(const FileSpec &directory)
+  : MultiProvider(directory) {}
+
+  static char ID;
+};
+
 const char *DummyProvider::Info::name = "dummy";
 const char *DummyProvider::Info::file = "dummy.yaml";
+const char *YamlMultiProvider::Info::name = "mutli";
+const char *YamlMultiProvider::Info::file = "mutli.yaml";
+char DummyProvider::ID = 0;
+char YamlMultiProvider::ID = 0;
 
 class DummyReproducer : public Reproducer {
 public:
@@ -42,7 +61,26 @@
   using Reproducer::SetReplay;
 };
 
-char DummyProvider::ID = 0;
+struct YamlData {
+  YamlData() : i(-1){};
+  YamlData(int i) : i(i){};
+  int i;
+};
+
+inline bool operator==(const YamlData &LHS, const YamlData &RHS) {
+  return LHS.i == RHS.i;
+}
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(YamlData)
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(std::vector)
+
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits {
+  static void mapping(IO &io, YamlData &Y) { io.mapRequired("i", Y.i); };
+};
+} // namespace yaml
+} // namespace llvm
 
 TEST(ReproducerTest, SetCapture) {
   DummyReproducer reproducer;
@@ -144,3 +182,85 @@
   auto &provider_alt = generator.GetOrCreate();
   EXPECT_EQ(&provider, &provider_alt);
 }
+
+TEST(GeneratorTest, YamlMultiProvider) {
+  SmallString<128> root;
+  std::error_code ec = llvm::sys::fs::createUniqueDirectory("reproducer", root);
+  ASSERT_FALSE(static_cast(ec));
+
+  auto cleanup = llvm::make_scope_exit(
+  [&] { EXPECT_FALSE(llvm::sys::fs::remove_directories(root.str())); });
+
+  YamlData data0(0);
+  YamlData data1(1);
+  YamlData data2(2);
+  YamlData data3(3);
+
+  {
+DummyReproducer reproducer;
+EXPECT_THAT_ERROR(reproducer.SetCapture(FileSpec(root.str())), Succeeded());
+
+auto &generator = *reproducer.GetGenerator();
+auto *provider = generator.Create();
+ASSERT_NE(nullptr, provider);
+
+auto *recorder = provider->GetNewRecorder();
+ASSERT_NE(nullptr, recorder);
+recorder->Record(data0);
+recorder->Record(data1);
+
+recorder = provider->GetNewRecorder();
+ASSERT_NE(nullptr, recorder);
+recorder->Record(data2);
+recorder->Record(data3);
+
+generator.Keep();
+  }
+
+  {
+DummyReproducer reproducer;
+EXPECT_THAT_ERROR(reproducer.SetReplay(FileSpec(root.str())), Succeeded());
+
+auto &loader = *reproducer.GetLoader();
+std::unique_ptr> multi_loader =
+repro::MultiLoader::Create(&loader);
+
+// Read the first file.
+{
+  llvm::Optional file = multi_loader->GetNextFile();
+  EXPECT_TRUE(static_cast(file));
+
+  auto buffer = llvm::MemoryBuffer::getFile(*file);
+  EXPECT_TRUE(static_cast(buffer));
+
+  yaml::Input yin((*buffer)->getBuffer());
+  std::vector data;
+  yin >> data;
+
+  ASSERT_EQ(data.size(), 2U);
+  EXPECT_EQ(data[0], data0);
+  EXPECT_EQ(data[1], data1);
+}
+
+// Read the second file.
+{
+  llvm::Optional file = multi_loader->GetNextFile();
+  EXPECT_TRUE(static_cast(file));
+
+  auto buffer = llvm::MemoryBuffer::getFile(*file);
+  EXPECT_TRUE(static_cast(buffer));
+
+  yaml::Input yin((*buffer)->getBuffer());
+  std::vector data;
+  yin >> data;
+
+  ASSERT_EQ(data.size(), 2U);
+  EXPECT_EQ(data[0], data2);
+  EXPECT_EQ(data[1], data3);
+}
+
+// There is no third file.
+llvm::Optional file = multi_loader->GetNextFile();
+EXPECT_FALSE(static_cast(file));
+  }
+}
Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "lldb/Utility/Reproducer.h"
+#include "lldb/Utility/Event.h"
 #include "lldb/Utility/LLDBAssert.h"
 
 #include "llvm/Support/FileSystem.h"
@@ -272,40 +273,15 @@
   return std::move(recorder);
 }
 
-DataRecorder *CommandProvider::GetNewDataRecorder() {
-  std::size_t i = m_data_recor

[Lldb-commits] [PATCH] D83443: Fix debugserver reporting of deployment target

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jasonmolenda, friss.

This patch fixes debugserver incorrectly returning the SDK version instead of 
the minimum deployment target version.

rdar://problem/65001691


https://reviews.llvm.org/D83443

Files:
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -614,9 +614,9 @@
&vers_cmd) != sizeof(struct version_min_command))
   return;
 info.platform = platform;
-info.major_version = vers_cmd.sdk >> 16;
-info.minor_version = (vers_cmd.sdk >> 8) & 0xffu;
-info.patch_version = vers_cmd.sdk & 0xffu;
+info.major_version = vers_cmd.version >> 16;
+info.minor_version = (vers_cmd.version >> 8) & 0xffu;
+info.patch_version = vers_cmd.version & 0xffu;
 info.maybe_simulator = true;
   };
   switch (cmd) {
@@ -639,9 +639,9 @@
&build_vers) != sizeof(struct build_version_command))
   break;
 info.platform = build_vers.platform;
-info.major_version = build_vers.sdk >> 16;
-info.minor_version = (build_vers.sdk >> 8) & 0xffu;
-info.patch_version = build_vers.sdk & 0xffu;
+info.major_version = build_vers.minos >> 16;
+info.minor_version = (build_vers.minos >> 8) & 0xffu;
+info.patch_version = build_vers.minos & 0xffu;
 break;
   }
 #endif
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -23,14 +23,44 @@
   found += 1
 self.assertEquals(found, 1, "wrong load command")
 
-
-def run_with(self, arch, os, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env})
+def check_debugserver(self, log, expected_platform, expected_version):
+"""scan the debugserver packet log"""
+logfile = open(log, "r")
+dylib_info = None
+reponse = False
+response = False
+for line in logfile:
+if response:
+while line[0] != '$':
+line = line[1:]
+line = line[1:]
+# Unescape '}'.
+dylib_info = json.loads(line.replace('}]','}')[:-4])
+response = False
+if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+response = True
+
+self.assertTrue(dylib_info)
+aout_info = None
+for image in dylib_info['images']:
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)
+self.assertEquals(aout_info['min_version_os_name'], expected_platform)
+if expected_version:
+self.assertEquals(aout_info['min_version_os_sdk'], expected_version)
+
+
+def run_with(self, arch, os, vers, env, expected_load_command):
+self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+self.check_load_commands(expected_load_command)
+log = self.getBuildArtifact('packets.log')
+self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.check_load_commands(expected_load_command)
 self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
@@ -38,7 +68,7 @@
 def test_ios(self):
 """Test running an iOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='ios', env='simulator',
+  os='ios', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -47,7 +77,7 @@
 def test_tvos(self):
 """Test running an tvOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='tvos', env='simulator',
+  os='tvos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -58,7 +88,7 @@
 def test_watchos_i386(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='i386',
-  os='watchos', env='simulator',
+  os='watchos', vers='', env='simulator',
   expected_load_command='LC_BUILD

[Lldb-commits] [PATCH] D83443: Fix debugserver reporting of deployment target

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 276605.
aprantl added a comment.

delete a redundant statement


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

https://reviews.llvm.org/D83443

Files:
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -614,9 +614,9 @@
&vers_cmd) != sizeof(struct version_min_command))
   return;
 info.platform = platform;
-info.major_version = vers_cmd.sdk >> 16;
-info.minor_version = (vers_cmd.sdk >> 8) & 0xffu;
-info.patch_version = vers_cmd.sdk & 0xffu;
+info.major_version = vers_cmd.version >> 16;
+info.minor_version = (vers_cmd.version >> 8) & 0xffu;
+info.patch_version = vers_cmd.version & 0xffu;
 info.maybe_simulator = true;
   };
   switch (cmd) {
@@ -639,9 +639,9 @@
&build_vers) != sizeof(struct build_version_command))
   break;
 info.platform = build_vers.platform;
-info.major_version = build_vers.sdk >> 16;
-info.minor_version = (build_vers.sdk >> 8) & 0xffu;
-info.patch_version = build_vers.sdk & 0xffu;
+info.major_version = build_vers.minos >> 16;
+info.minor_version = (build_vers.minos >> 8) & 0xffu;
+info.patch_version = build_vers.minos & 0xffu;
 break;
   }
 #endif
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -23,14 +23,43 @@
   found += 1
 self.assertEquals(found, 1, "wrong load command")
 
-
-def run_with(self, arch, os, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env})
+def check_debugserver(self, log, expected_platform, expected_version):
+"""scan the debugserver packet log"""
+logfile = open(log, "r")
+dylib_info = None
+response = False
+for line in logfile:
+if response:
+while line[0] != '$':
+line = line[1:]
+line = line[1:]
+# Unescape '}'.
+dylib_info = json.loads(line.replace('}]','}')[:-4])
+response = False
+if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+response = True
+
+self.assertTrue(dylib_info)
+aout_info = None
+for image in dylib_info['images']:
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)
+self.assertEquals(aout_info['min_version_os_name'], expected_platform)
+if expected_version:
+self.assertEquals(aout_info['min_version_os_sdk'], expected_version)
+
+
+def run_with(self, arch, os, vers, env, expected_load_command):
+self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+self.check_load_commands(expected_load_command)
+log = self.getBuildArtifact('packets.log')
+self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.check_load_commands(expected_load_command)
 self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
@@ -38,7 +67,7 @@
 def test_ios(self):
 """Test running an iOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='ios', env='simulator',
+  os='ios', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -47,7 +76,7 @@
 def test_tvos(self):
 """Test running an tvOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='tvos', env='simulator',
+  os='tvos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -58,7 +87,7 @@
 def test_watchos_i386(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='i386',
-  os='watchos', env='simulator',
+  os='watchos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -69,7 +98,7 @@
 def test_watchos_arm

[Lldb-commits] [PATCH] D83443: Fix debugserver reporting of deployment target

2020-07-08 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py:30
+dylib_info = None
+reponse = False
+response = False

typo?



Comment at: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py:47
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)

add a `break` to get out of the loop quicker?


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

https://reviews.llvm.org/D83443



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


[Lldb-commits] [PATCH] D83443: Fix debugserver reporting of deployment target

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked 2 inline comments as done.
aprantl added inline comments.



Comment at: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py:47
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)

friss wrote:
> add a `break` to get out of the loop quicker?
No, that's a hidden feature. In the simulator cases 
jGetLoadedDynamicLibrariesInfos is called twice and the interesting information 
is only in the second response.


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

https://reviews.llvm.org/D83443



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


[Lldb-commits] [lldb] 15149e4 - Fix debugserver reporting of deployment target

2020-07-08 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-07-08T17:21:43-07:00
New Revision: 15149e406486092a3665791545ab9474471c0f14

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

LOG: Fix debugserver reporting of deployment target

This patch fixes debugserver incorrectly returning the SDK version
instead of the minimum deployment target version.

rdar://problem/65001691

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

Added: 


Modified: 
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index c12e920e3b82..6e67fdc879be 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -23,14 +23,43 @@ def check_load_commands(self, expected_load_command):
   found += 1
 self.assertEquals(found, 1, "wrong load command")
 
-
-def run_with(self, arch, os, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env})
+def check_debugserver(self, log, expected_platform, expected_version):
+"""scan the debugserver packet log"""
+logfile = open(log, "r")
+dylib_info = None
+response = False
+for line in logfile:
+if response:
+while line[0] != '$':
+line = line[1:]
+line = line[1:]
+# Unescape '}'.
+dylib_info = json.loads(line.replace('}]','}')[:-4])
+response = False
+if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+response = True
+
+self.assertTrue(dylib_info)
+aout_info = None
+for image in dylib_info['images']:
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)
+self.assertEquals(aout_info['min_version_os_name'], expected_platform)
+if expected_version:
+self.assertEquals(aout_info['min_version_os_sdk'], 
expected_version)
+
+
+def run_with(self, arch, os, vers, env, expected_load_command):
+self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+self.check_load_commands(expected_load_command)
+log = self.getBuildArtifact('packets.log')
+self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.check_load_commands(expected_load_command)
 self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
@@ -38,7 +67,7 @@ def run_with(self, arch, os, env, expected_load_command):
 def test_ios(self):
 """Test running an iOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='ios', env='simulator',
+  os='ios', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -47,7 +76,7 @@ def test_ios(self):
 def test_tvos(self):
 """Test running an tvOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='tvos', env='simulator',
+  os='tvos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -58,7 +87,7 @@ def test_tvos(self):
 def test_watchos_i386(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='i386',
-  os='watchos', env='simulator',
+  os='watchos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -69,7 +98,7 @@ def test_watchos_i386(self):
 def test_watchos_armv7k(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='armv7k',
-  os='watchos', env='simulator',
+  os='watchos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 
@@ -90,9 +119,20 @@ def test_lc_version_min_iphoneos(self):
 """Test running a back-deploying iOS simulator binary
with a legacy iOS load command"""
 self.run_with(arch=self.getArchitecture(),
-  os='io

[Lldb-commits] [PATCH] D83443: Fix debugserver reporting of deployment target

2020-07-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15149e406486: Fix debugserver reporting of deployment target 
(authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D83443?vs=276605&id=276608#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83443

Files:
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -614,9 +614,9 @@
&vers_cmd) != sizeof(struct version_min_command))
   return;
 info.platform = platform;
-info.major_version = vers_cmd.sdk >> 16;
-info.minor_version = (vers_cmd.sdk >> 8) & 0xffu;
-info.patch_version = vers_cmd.sdk & 0xffu;
+info.major_version = vers_cmd.version >> 16;
+info.minor_version = (vers_cmd.version >> 8) & 0xffu;
+info.patch_version = vers_cmd.version & 0xffu;
 info.maybe_simulator = true;
   };
   switch (cmd) {
@@ -639,9 +639,9 @@
&build_vers) != sizeof(struct build_version_command))
   break;
 info.platform = build_vers.platform;
-info.major_version = build_vers.sdk >> 16;
-info.minor_version = (build_vers.sdk >> 8) & 0xffu;
-info.patch_version = build_vers.sdk & 0xffu;
+info.major_version = build_vers.minos >> 16;
+info.minor_version = (build_vers.minos >> 8) & 0xffu;
+info.patch_version = build_vers.minos & 0xffu;
 break;
   }
 #endif
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -23,14 +23,43 @@
   found += 1
 self.assertEquals(found, 1, "wrong load command")
 
-
-def run_with(self, arch, os, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env})
+def check_debugserver(self, log, expected_platform, expected_version):
+"""scan the debugserver packet log"""
+logfile = open(log, "r")
+dylib_info = None
+response = False
+for line in logfile:
+if response:
+while line[0] != '$':
+line = line[1:]
+line = line[1:]
+# Unescape '}'.
+dylib_info = json.loads(line.replace('}]','}')[:-4])
+response = False
+if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+response = True
+
+self.assertTrue(dylib_info)
+aout_info = None
+for image in dylib_info['images']:
+if image['pathname'].endswith('a.out'):
+aout_info = image
+self.assertTrue(aout_info)
+self.assertEquals(aout_info['min_version_os_name'], expected_platform)
+if expected_version:
+self.assertEquals(aout_info['min_version_os_sdk'], expected_version)
+
+
+def run_with(self, arch, os, vers, env, expected_load_command):
+self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+self.check_load_commands(expected_load_command)
+log = self.getBuildArtifact('packets.log')
+self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.check_load_commands(expected_load_command)
 self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
@@ -38,7 +67,7 @@
 def test_ios(self):
 """Test running an iOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='ios', env='simulator',
+  os='ios', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -47,7 +76,7 @@
 def test_tvos(self):
 """Test running an tvOS simulator binary"""
 self.run_with(arch=self.getArchitecture(),
-  os='tvos', env='simulator',
+  os='tvos', vers='', env='simulator',
   expected_load_command='LC_BUILD_VERSION')
 
 @skipUnlessDarwin
@@ -58,7 +87,7 @@
 def test_watchos_i386(self):
 """Test running a 32-bit watchOS simulator binary"""
 self.run_with(arch='i386',
-  os='wa

[Lldb-commits] [PATCH] D81697: Add support for batch-testing to the LLDB testsuite.

2020-07-08 Thread Benson Li via Phabricator via lldb-commits
bbli added a comment.

Hi Pavel, so I submitted the new patch(which I added you as a reviewer of) but 
it looks like the remote build failed. I ran `ninja check-lldb` locally and it 
works fine. How would I go about debugging this? I tried clicking on the links 
to the failed build, but couldn't really interpret it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81697



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


[Lldb-commits] [PATCH] D83446: [WIP][lldb/Reproducers] Synchronize the command interpreter with asynchronous events

2020-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, friss.
Herald added a subscriber: abidh.

Add synchronization for asynchronous events. This fixes an un expected packet 
during replay when an asynchronous event triggers a GDB packet. Consider the 
following example:

  $ ./bin/lldb --capture
  (lldb) gdb-remote 13000
  Process 770 stopped
  * thread #1, stop reason = signal SIGSTOP
  frame #0: 0x000105071000 dyld`_dyld_start
  (lldb) cont
  Process 770 resuming
  Process 770 exited with status = 0 (0x)
  (lldb) reproducer generate
  
  $ ./bin/lldb --replay /path/to/reproducer
  (lldb) gdb-remote 13000
  (lldb) cont
  Reproducer expected packet: '$jThreadExtendedInfo:{"thread":14341}#01'
  Reproducer received packet: 'c'
  LLVM ERROR: Encountered unexpected packet during replay

The way the thread state is displayed at the prompt is asynchronous. It reacts 
to an event, in this case a process state change on connection.

I haven't bothered too much with naming. The same logic should be applicable to 
other situations that require synchronization.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D83446

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Utility/Reproducer.cpp

Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 
 using namespace lldb_private;
 using namespace lldb_private::repro;
@@ -305,12 +306,109 @@
 m_collector->addDirectory(dir);
 }
 
+std::unique_ptr SynchronizerProvider::GetNewSynchronizer() {
+  return std::make_unique(GetNewRecorder());
+}
+
+CaptureSynchronizer::CaptureSynchronizer(YamlRecorder *recorder)
+: m_recorder(recorder) {
+  assert(recorder);
+}
+
+void CaptureSynchronizer::AddEvent() {
+  std::lock_guard lock(m_mutex);
+  m_current.events++;
+  m_events_modified = true;
+  AddBarrier();
+}
+
+void CaptureSynchronizer::AddCommand() {
+  std::lock_guard lock(m_mutex);
+  m_current.commands++;
+  m_commands_modified = true;
+  AddBarrier();
+}
+
+void CaptureSynchronizer::AddBarrier() {
+  // Caller locks.
+  if (m_commands_modified && m_events_modified) {
+if (m_recorder)
+  m_recorder->Record(m_current);
+m_commands_modified = false;
+m_events_modified = false;
+  }
+}
+
+ReplaySynchronizer::ReplaySynchronizer(
+std::vector barriers)
+: m_barriers(std::move(barriers)) {}
+
+void llvm::yaml::MappingTraits::mapping(
+IO &io, Synchronizer::Barrier &B) {
+  io.mapRequired("commands", B.commands);
+  io.mapRequired("events", B.events);
+}
+
+void ReplaySynchronizer::AddEvent() {
+  m_events++;
+  m_condition_variable.notify_one();
+}
+
+void ReplaySynchronizer::AddCommand() {
+  m_commands++;
+
+  if (m_barriers.empty())
+return;
+
+  if (m_commands > m_barriers.back().commands) {
+std::unique_lock lock(m_mutex);
+m_condition_variable.wait(
+lock, [&] { return m_events >= m_barriers.back().events; });
+m_barriers.pop_back();
+  }
+}
+
+std::unique_ptr lldb_private::repro::GetNewSynchronizer() {
+  auto &r = repro::Reproducer::Instance();
+
+  if (repro::Generator *g = r.GetGenerator()) {
+return g->GetOrCreate().GetNewSynchronizer();
+  }
+
+  if (repro::Loader *l = r.GetLoader()) {
+static std::unique_ptr>
+multi_loader = repro::MultiLoader::Create(l);
+if (!multi_loader)
+  return {};
+
+llvm::Optional file = multi_loader->GetNextFile();
+if (!file)
+  return {};
+
+auto buffer = llvm::MemoryBuffer::getFile(*file);
+if (auto err = buffer.getError())
+  return {};
+
+std::vector barriers;
+yaml::Input yin((*buffer)->getBuffer());
+yin >> barriers;
+
+/// The ReplaySynchronizer treats barriers like a stack.
+std::reverse(barriers.begin(), barriers.end());
+
+return std::make_unique(std::move(barriers));
+  }
+
+  return {};
+}
+
 void ProviderBase::anchor() {}
 char CommandProvider::ID = 0;
 char FileProvider::ID = 0;
 char ProviderBase::ID = 0;
 char VersionProvider::ID = 0;
 char WorkingDirectoryProvider::ID = 0;
+char SynchronizerProvider::ID = 0;
 const char *CommandProvider::Info::file = "command-interpreter.yaml";
 const char *CommandProvider::Info::name = "command-interpreter";
 const char *FileProvider::Info::file = "files.yaml";
@@ -319,3 +417,5 @@
 const char *VersionProvider::Info::name = "version";
 const char *WorkingDirectoryProvider::Info::file = "cwd.txt";
 const char *WorkingDirectoryProvider::Info::name = "cwd";
+const char *SynchronizerProvider::Info::file = "synchronizer.yaml";
+const char *SynchronizerProvider::Info::name = "synchronizer";
Index: lldb/source/Interpreter/CommandInter

[Lldb-commits] [PATCH] D83450: Delegate UpdateChildrenPointerType to the Root ValueObject

2020-07-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

This is a refinement on 96601ec28b7efe5abf3479a1aa91bcedb235bbbd.  The intent 
of that change was to do the same work for the computation of the locations of 
the children of ValueObjectVariable as was done for the root 
ValueObjectVariable.  This original patch did that by moving the computation 
from ValueObjectVariable to ValueObject.  That fixed the problem but caused a 
handful of swift-lldb testsuite failures and a crash or two.

The problem is that synthetic value objects can sometimes represent objects in 
target memory, and other times they might be made up wholly in lldb memory, 
with pointers from one synthetic object to another, and so the 
ValueObjectVariable computation was not appropriate.

This patch delegates the computation to the root of the ValueObject in 
question.  That solves the problem for ValueObjectVariable while not messing up 
the computation for ValueObjectConstResult or ValueObjectSynthetic.

This patch resolves all the swift-lldb failures and also still passes the 
non-swift testsuite.

The representation through ValueObjects of Swift Types is quite byzantine, and 
the ValueObject system is frustratingly self-healing, and I haven't yet been 
able to cons up a non-swift test case that will trigger the same failures we 
were seeing with swift data types.  I'm still working on that, but I thought 
I'd get the code changes out for review while working on that, since we 
actually DO have tests for the change, just not in the non-swift tree...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83450

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectVariable.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectVariable.cpp

Index: lldb/source/Core/ValueObjectVariable.cpp
===
--- lldb/source/Core/ValueObjectVariable.cpp
+++ lldb/source/Core/ValueObjectVariable.cpp
@@ -242,9 +242,64 @@
   m_resolved_value.SetContext(Value::eContextTypeInvalid, nullptr);
 }
   }
+  
   return m_error.Success();
 }
 
+void ValueObjectVariable::DoUpdateChildrenAddressType(ValueObject &valobj) {
+  Value::ValueType value_type = valobj.GetValue().GetValueType();
+  ExecutionContext exe_ctx(GetExecutionContextRef());
+  Process *process = exe_ctx.GetProcessPtr();
+  const bool process_is_alive = process && process->IsAlive();
+  const uint32_t type_info = valobj.GetCompilerType().GetTypeInfo();
+  const bool is_pointer_or_ref =
+  (type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
+
+  switch (value_type) {
+  case Value::eValueTypeFileAddress:
+// If this type is a pointer, then its children will be considered load
+// addresses if the pointer or reference is dereferenced, but only if
+// the process is alive.
+//
+// There could be global variables like in the following code:
+// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
+// Foo g_foo1;
+// Foo g_foo2;
+// LinkedListNode g_second_node = { &g_foo2, NULL };
+// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
+//
+// When we aren't running, we should be able to look at these variables
+// using the "target variable" command. Children of the "g_first_node"
+// always will be of the same address type as the parent. But children
+// of the "next" member of LinkedListNode will become load addresses if
+// we have a live process, or remain a file address if it was a file
+// address.
+if (process_is_alive && is_pointer_or_ref)
+  valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+else
+  valobj.SetAddressTypeOfChildren(eAddressTypeFile);
+break;
+  case Value::eValueTypeHostAddress:
+// Same as above for load addresses, except children of pointer or refs
+// are always load addresses. Host addresses are used to store freeze
+// dried variables. If this type is a struct, the entire struct
+// contents will be copied into the heap of the
+// LLDB process, but we do not currently follow any pointers.
+if (is_pointer_or_ref)
+  valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+else
+  valobj.SetAddressTypeOfChildren(eAddressTypeHost);
+break;
+  case Value::eValueTypeLoadAddress:
+  case Value::eValueTypeScalar:
+  case Value::eValueTypeVector:
+valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+break;
+  }
+}
+
+
+
 bool ValueObjectVariable::IsInScope() {
   const ExecutionContextRef &exe_ctx_ref = GetExecutionContextRef();
   if (exe_ctx_ref.HasFrameRef()) {
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -140,58 +140,6 @@
 // Destructor
 ValueObject::~ValueObject(

[Lldb-commits] [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-08 Thread Michele Scandale via Phabricator via lldb-commits
michele.scandale created this revision.
michele.scandale added reviewers: chandlerc, beanz, zturner.
Herald added subscribers: lldb-commits, cfe-commits, MaskRay, aheejin, 
arichardson, sbc100, mgorny, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added projects: clang, LLDB.

The `intrinsics_gen` target exists in the CMake exports since r309389
(see LLVMConfig.cmake.in), hence projects can depend on `intrinsics_gen`
even it they are built separately from LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83454

Files:
  clang/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  lld/COFF/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/MinGW/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/wasm/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt

Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
@@ -1,8 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
-
 add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN
   RenderScriptRuntime.cpp
   RenderScriptExpressionOpts.cpp
@@ -10,7 +5,7 @@
   RenderScriptScriptGroup.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbBreakpoint
Index: lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===
--- lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbPluginExpressionParserClang
   ASTResultSynthesizer.cpp
   ASTStructExtractor.cpp
@@ -29,7 +25,7 @@
   NameSearchContext.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/source/Expression/CMakeLists.txt
===
--- lldb/source/Expression/CMakeLists.txt
+++ lldb/source/Expression/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbExpression
   DiagnosticManager.cpp
   DWARFExpression.cpp
@@ -18,7 +14,7 @@
   UtilityFunction.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -64,7 +64,7 @@
 # some of these generated headers. This approach is copied from Clang's main
 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
 # in llvm-svn 308844.
-if(LLVM_ENABLE_MODULES AND NOT LLDB_BUILT_STANDALONE)
+if(LLVM_ENABLE_MODULES)
   list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
 endif()
 
Index: lld/wasm/CMakeLists.txt
===
--- lld/wasm/CMakeLists.txt
+++ lld/wasm/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(WasmOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldWasm
   Driver.cpp
   InputChunks.cpp
@@ -37,5 +33,5 @@
 
   DEPENDS
   WasmOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/lib/Core/CMakeLists.txt
===
--- lld/lib/Core/CMakeLists.txt
+++ lld/lib/Core/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldCore
   DefinedAtom.cpp
   Error.cpp
@@ -24,5 +20,5 @@
   ${LLVM_PTHREAD_LIB}
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/MinGW/CMakeLists.txt
===
--- lld/MinGW/CMakeLists.txt
+++ lld/MinGW/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(MinGWOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldMinGW
   Driver.cpp
 
@@ -19,5 +15,5 @@
 
   DEPENDS
   MinGWOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
 )
Index: lld/ELF/CMakeLists.txt