[Lldb-commits] [PATCH] D72823: [Reproducers] Add a tool to transparently capture and replay lldb sessions

2020-01-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, friss.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

This patch introduces a small new tool `(lldb-repro`) to transparently capture 
and replay debugger sessions from the driver. The goal is to run the shell 
tests, generate a reproducers for each one of them, and then run the shell 
tests again, this time replaying the reproducer. I could've implemented all 
this in LLDB, but I felt a separate tool would be better.

Right now this requires you to swap out `lldb` and `lldb-repro`. I hope to find 
a way to automate that so you can pass `--param=run_with_lldb_repro=capture` 
and `--param=run_with_lldb_repro=replay` to lit directly.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D72823

Files:
  lldb/test/Shell/Reproducer/lit.local.cfg
  lldb/test/Shell/lit.cfg.py
  lldb/tools/CMakeLists.txt
  lldb/tools/lldb-repro/CMakeLists.txt
  lldb/tools/lldb-repro/lldb-repro.cpp
  lldb/tools/lldb-repro/lldb-repro.h.cmake

Index: lldb/tools/lldb-repro/lldb-repro.h.cmake
===
--- /dev/null
+++ lldb/tools/lldb-repro/lldb-repro.h.cmake
@@ -0,0 +1,14 @@
+//===-- lldb-repro.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_TOOLS_LLDB_REPRO_H
+#define LLDB_TOOLS_LLDB_REPRO_H
+
+#cmakedefine LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}"
+
+#endif
Index: lldb/tools/lldb-repro/lldb-repro.cpp
===
--- /dev/null
+++ lldb/tools/lldb-repro/lldb-repro.cpp
@@ -0,0 +1,76 @@
+//===-- lldb-repro.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb-repro.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/DJB.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+
+unsigned ComputerHash(StringRef args, StringRef cwd) {
+  const unsigned hash = djbHash(cwd);
+  return djbHash(args, hash);
+}
+
+int main(int argc, const char **argv) {
+  std::string arg_str;
+  for (int i = 1; i < argc; ++i)
+arg_str.append(argv[i]);
+
+  SmallString<256> cwd_str;
+  sys::fs::current_path(cwd_str);
+
+  // Compute the hash.
+  const unsigned hash = ComputerHash(arg_str, cwd_str.str());
+
+  // Compute the reproducer directory.
+  const char *tmpdir = getenv("TMPDIR");
+  if (!tmpdir) {
+WithColor::error() << "unable to get the temp directory form TMPDIR\n";
+return 1;
+  }
+
+  SmallString<256> repro_dir;
+  llvm::sys::path::system_temp_directory(true, repro_dir);
+  sys::path::append(repro_dir, std::to_string(hash));
+
+  // Construct the lldb argument list.
+  std::vector args;
+  args.push_back(LLDB_TEST_EXECUTABLE);
+  if (getenv("LLDB_REPRO_REPLAY")) {
+args.push_back("--replay");
+args.push_back(repro_dir.c_str());
+  } else if (getenv("LLDB_REPRO_CAPTURE")) {
+// Remove any previous reproducer.
+sys::fs::remove_directories(repro_dir);
+
+args.push_back("--capture");
+args.push_back("--capture-path");
+args.push_back(repro_dir.c_str());
+args.push_back("--reproducer-auto-generate");
+
+// Append the original arguments.
+for (int i = 1; i < argc; ++i)
+  args.push_back(argv[i]);
+  } else {
+WithColor::error()
+<< "enable capture or replay by setting the environment variables "
+   "LLDB_REPRO_CAPTURE and LLDB_REPRO_REPLAY respectively\n";
+return 1;
+  }
+
+  return llvm::sys::ExecuteAndWait(LLDB_TEST_EXECUTABLE, args);
+}
Index: lldb/tools/lldb-repro/CMakeLists.txt
===
--- /dev/null
+++ lldb/tools/lldb-repro/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(lldb_repro_input ${CMAKE_CURRENT_SOURCE_DIR}/lldb-repro.h.cmake)
+set(lldb_repro_output ${CMAKE_CURRENT_BINARY_DIR}/lldb-repro.h)
+configure_file(${lldb_repro_input} ${lldb_repro_output})
+
+add_lldb_tool(lldb-repro
+  lldb-repro.cpp
+
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/tools/CMakeLists.txt
===
--- lldb/tools/CMakeLists.txt
+++ lldb/tools/CMakeLists.txt
@@ -7,7 +7,11 @@
 # example is `check-lldb`. So, 

[Lldb-commits] [lldb] 982a77b - [lldb/Reproducers] Print more info for reproducer status

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T20:25:44-08:00
New Revision: 982a77b69408d6d54526b331046b4508a68ef459

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

LOG: [lldb/Reproducers] Print more info for reproducer status

Reproducer status now prints the capture/replay path. It will also print
the status of auto generation when enabled.

Added: 


Modified: 
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Utility/Reproducer.cpp
lldb/test/Shell/Reproducer/TestDriverOptions.test

Removed: 




diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 0524bcf6b24d..873ec3c76b52 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -234,6 +234,9 @@ class Generator final {
   /// Enable or disable auto generate.
   void SetAutoGenerate(bool b);
 
+  /// Return whether auto generate is enabled.
+  bool IsAutoGenerate() const;
+
   /// Create and register a new provider.
   template  T *Create() {
 std::unique_ptr provider = std::make_unique(m_root);

diff  --git a/lldb/source/Commands/CommandObjectReproducer.cpp 
b/lldb/source/Commands/CommandObjectReproducer.cpp
index d15f622314d9..52c42a7336a4 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -258,6 +258,18 @@ class CommandObjectReproducerStatus : public 
CommandObjectParsed {
   result.GetOutputStream() << "Reproducer is off.\n";
 }
 
+if (r.IsCapturing() || r.IsReplaying()) {
+  result.GetOutputStream()
+  << "Path: " << r.GetReproducerPath().GetPath() << '\n';
+}
+
+// Auto generate is hidden unless enabled because this is mostly for
+// development and testing.
+if (Generator *g = r.GetGenerator()) {
+  if (g->IsAutoGenerate())
+result.GetOutputStream() << "Auto generate: on\n";
+}
+
 result.SetStatus(eReturnStatusSuccessFinishResult);
 return result.Succeeded();
   }

diff  --git a/lldb/source/Utility/Reproducer.cpp 
b/lldb/source/Utility/Reproducer.cpp
index 8957763b7fd5..8987cfdac556 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -205,6 +205,8 @@ void Generator::Discard() {
 
 void Generator::SetAutoGenerate(bool b) { m_auto_generate = b; }
 
+bool Generator::IsAutoGenerate() const { return m_auto_generate; }
+
 const FileSpec ::GetRoot() const { return m_root; }
 
 void Generator::AddProvidersToIndex() {

diff  --git a/lldb/test/Shell/Reproducer/TestDriverOptions.test 
b/lldb/test/Shell/Reproducer/TestDriverOptions.test
index e249a401d15b..8bc8288e2e5f 100644
--- a/lldb/test/Shell/Reproducer/TestDriverOptions.test
+++ b/lldb/test/Shell/Reproducer/TestDriverOptions.test
@@ -10,15 +10,17 @@
 #
 # RUN: %lldb --capture --capture-path %t.repro -b -o 'reproducer status' 2>&1 
| FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
 # RUN: %lldb --capture -b -o 'reproducer status' 2>&1 | FileCheck %s 
--check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
-# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | 
FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE
+# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | 
FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE 
--check-prefix NOAUTOGEN
 # RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 
--reproducer-auto-generate  2>&1 | FileCheck %s --check-prefix WARNING2
 #
 # NO-WARNING-NOT: warning: -capture-path specified without -capture
 # WARNING: warning: -capture-path specified without -capture
 # WARNING2: warning: -reproducer-auto-generate specified without -capture
 # STATUS-CAPTURE: Reproducer is in capture mode.
+# NOAUTOGEN-NOT: Auto generate
 
 # Check auto generate.
 # RUN: rm -rf %t.repro
-# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate 
-o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING
+# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate 
-o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING 
--check-prefix AUTOGEN
 # RUN: cat %t.repro/index.yaml
+# AUTOGEN: Auto generate: on



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


[Lldb-commits] [lldb] 066e817 - [lldb/Reproducers] Add a flag to always generating a reproducer

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T19:45:54-08:00
New Revision: 066e817b421e8502a72735988e14713940517aaa

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

LOG: [lldb/Reproducers] Add a flag to always generating a reproducer

Add a flag which always generates a reproducer when normally it would be
discarded. This is meant for testing purposes to capture a debugger
session without modification the session itself.

Added: 


Modified: 
lldb/include/lldb/API/SBReproducer.h
lldb/include/lldb/Utility/Reproducer.h
lldb/source/API/SBReproducer.cpp
lldb/source/Utility/Reproducer.cpp
lldb/test/Shell/Reproducer/TestDriverOptions.test
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Options.td

Removed: 




diff  --git a/lldb/include/lldb/API/SBReproducer.h 
b/lldb/include/lldb/API/SBReproducer.h
index 93d78f55fd76..0a25bcbf541e 100644
--- a/lldb/include/lldb/API/SBReproducer.h
+++ b/lldb/include/lldb/API/SBReproducer.h
@@ -23,6 +23,7 @@ class LLDB_API SBReproducer {
   static const char *Replay(const char *path);
   static const char *Replay(const char *path, bool skip_version_check);
   static const char *GetPath();
+  static bool SetAutoGenerate(bool b);
   static bool Generate();
 };
 

diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 0d23fe8571ff..0524bcf6b24d 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -231,6 +231,9 @@ class Generator final {
   /// might need to clean up files already written to disk.
   void Discard();
 
+  /// Enable or disable auto generate.
+  void SetAutoGenerate(bool b);
+
   /// Create and register a new provider.
   template  T *Create() {
 std::unique_ptr provider = std::make_unique(m_root);
@@ -272,6 +275,9 @@ class Generator final {
 
   /// Flag to ensure that we never call both keep and discard.
   bool m_done = false;
+
+  /// Flag to auto generate a reproducer when it would otherwise be discarded.
+  bool m_auto_generate = false;
 };
 
 class Loader final {

diff  --git a/lldb/source/API/SBReproducer.cpp 
b/lldb/source/API/SBReproducer.cpp
index 3d2de0727444..6d78eba52efb 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -178,6 +178,15 @@ bool SBReproducer::Generate() {
   return false;
 }
 
+bool SBReproducer::SetAutoGenerate(bool b) {
+  auto  = Reproducer::Instance();
+  if (auto generator = r.GetGenerator()) {
+generator->SetAutoGenerate(b);
+return true;
+  }
+  return false;
+}
+
 const char *SBReproducer::GetPath() {
   static std::string path;
   auto  = Reproducer::Instance();

diff  --git a/lldb/source/Utility/Reproducer.cpp 
b/lldb/source/Utility/Reproducer.cpp
index e243d784d185..8957763b7fd5 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -167,8 +167,12 @@ Generator::Generator(FileSpec root) : 
m_root(MakeAbsolute(std::move(root))) {
 }
 
 Generator::~Generator() {
-  if (!m_done)
-Discard();
+  if (!m_done) {
+if (m_auto_generate)
+  Keep();
+else
+  Discard();
+  }
 }
 
 ProviderBase *Generator::Register(std::unique_ptr provider) {
@@ -199,6 +203,8 @@ void Generator::Discard() {
   llvm::sys::fs::remove_directories(m_root.GetPath());
 }
 
+void Generator::SetAutoGenerate(bool b) { m_auto_generate = b; }
+
 const FileSpec ::GetRoot() const { return m_root; }
 
 void Generator::AddProvidersToIndex() {

diff  --git a/lldb/test/Shell/Reproducer/TestDriverOptions.test 
b/lldb/test/Shell/Reproducer/TestDriverOptions.test
index 4b5dfbf063ca..e249a401d15b 100644
--- a/lldb/test/Shell/Reproducer/TestDriverOptions.test
+++ b/lldb/test/Shell/Reproducer/TestDriverOptions.test
@@ -11,7 +11,14 @@
 # RUN: %lldb --capture --capture-path %t.repro -b -o 'reproducer status' 2>&1 
| FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
 # RUN: %lldb --capture -b -o 'reproducer status' 2>&1 | FileCheck %s 
--check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
 # RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | 
FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE
+# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 
--reproducer-auto-generate  2>&1 | FileCheck %s --check-prefix WARNING2
 #
 # NO-WARNING-NOT: warning: -capture-path specified without -capture
 # WARNING: warning: -capture-path specified without -capture
+# WARNING2: warning: -reproducer-auto-generate specified without -capture
 # STATUS-CAPTURE: Reproducer is in capture mode.
+
+# Check auto generate.
+# RUN: rm -rf %t.repro
+# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate 
-o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING
+# RUN: cat 

[Lldb-commits] [lldb] b54a50f - [lldb/Reproducers] Extract function for reading environment override (NFC)

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T19:14:28-08:00
New Revision: b54a50f52e9427f250c192a8618b881732e5d7a4

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

LOG: [lldb/Reproducers] Extract function for reading environment override (NFC)

Create a helper function for reading reproducer overrides from
environment variables.

Added: 


Modified: 
lldb/source/Utility/Reproducer.cpp

Removed: 




diff  --git a/lldb/source/Utility/Reproducer.cpp 
b/lldb/source/Utility/Reproducer.cpp
index b11e1a577ed2..e243d784d185 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -18,6 +18,15 @@ using namespace lldb_private::repro;
 using namespace llvm;
 using namespace llvm::yaml;
 
+static llvm::Optional GetEnv(const char *var) {
+  std::string val = llvm::StringRef(getenv(var)).lower();
+  if (val == "0" || val == "off")
+return false;
+  if (val == "1" || val == "on")
+return true;
+  return {};
+}
+
 Reproducer ::Instance() { return *InstanceImpl(); }
 
 llvm::Error Reproducer::Initialize(ReproducerMode mode,
@@ -27,12 +36,12 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,
 
   // The environment can override the capture mode.
   if (mode != ReproducerMode::Replay) {
-std::string env =
-llvm::StringRef(getenv("LLDB_CAPTURE_REPRODUCER")).lower();
-if (env == "0" || env == "off")
-  mode = ReproducerMode::Off;
-else if (env == "1" || env == "on")
-  mode = ReproducerMode::Capture;
+if (llvm::Optional override = GetEnv("LLDB_CAPTURE_REPRODUCER")) {
+  if (*override)
+mode = ReproducerMode::Capture;
+  else
+mode = ReproducerMode::Off;
+}
   }
 
   switch (mode) {



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added a comment.

In D71575#1823252 , @jingham wrote:

> BTW, I had to fix this patch (cd9e5c32302cd3b34b796683eedb072c6a1cfdc1 
> ) to 
> build on macOS.  uint64_t and size_t are differently spelled (though I think 
> otherwise equivalent.)  One is "long long unsigned int", the other "long 
> unsigned int".  I have no idea why that's true, but std::min refuses to 
> compare a size_t and a unit64_t.  Anyway, I fixed this by casting one of the 
> two sides of the comparison.  But this was causing problems because we have 
> an api (ReadImageData) that takes a uint64_t for the offset and a size_t for 
> the size.  That seems a little weird to me, why are these different types?


I am sorry for this problem, thank you for the fix! Evidently size_t can also 
be 32 bit, like in this case
To be more precise ReadImageData should take an lldb::offset_t as first 
argument (which is indeed an uint64_t) and it should use the same type for the 
size; I'll clean up this in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

BTW, I had to fix this patch (cd9e5c32302cd3b34b796683eedb072c6a1cfdc1 
) to build 
on macOS.  uint64_t and size_t are differently spelled (though I think 
otherwise equivalent.)  One is "long long unsigned int", the other "long 
unsigned int".  I have no idea why that's true, but std::min refuses to compare 
a size_t and a unit64_t.  Anyway, I fixed this by casting one of the two sides 
of the comparison.  But this was causing problems because we have an api 
(ReadImageData) that takes a uint64_t for the offset and a size_t for the size. 
 That seems a little weird to me, why are these different types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575



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


[Lldb-commits] [lldb] cd9e5c3 - Fix the macos build after D71575.

2020-01-15 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-01-15T18:13:44-08:00
New Revision: cd9e5c32302cd3b34b796683eedb072c6a1cfdc1

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

LOG: Fix the macos build after D71575.

size_t and uint64_t are spelled slightly differently on macOS, which was
causing the compiler to error out calling std::min - since the two types have
to be the same.

I fixed this by casting the uint64_t computation to a size_t.  That's probably
not the cleanest solution, but it gets us back to building.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp 
b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index 1f636b719bb6..2c918a8f9db3 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -367,7 +367,7 @@ DataExtractor ObjectFileWasm::ReadImageData(uint64_t 
offset, size_t size) {
   DataExtractor data;
   if (m_file) {
 if (offset < GetByteSize()) {
-  size = std::min(size, GetByteSize() - offset);
+  size = std::min(size, (size_t) (GetByteSize() - offset));
   auto buffer_sp = MapFileData(m_file, size, offset);
   return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
 }



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


[Lldb-commits] [PATCH] D72813: Fixes to lldb's eLaunchFlagLaunchInTTY feature on macOS

2020-01-15 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda marked 3 inline comments as done.
jasonmolenda added a comment.

Thanks for the review Greg.  To really do this reliably, we probably either 
need to use a different kernel API, or push this down into debugserver where we 
can get the process' task port and inspect what its status is.  This patch is 
more a preliminary one to get it working much of the time -- getting it to 
always work is going to require a slightly different approach.




Comment at: lldb/source/Host/macosx/objcxx/Host.mm:154-155
+  // started, and stop at dyld_start, before we attach.
+  const int short_sleep = 10; // 0.1 seconds
+  ::usleep(short_sleep);
+

clayborg wrote:
> This seems racy still?
It is.  darwin-debug is going to call posix_spawn after this, which exec's the 
app binary, which is launched and stopped at dyld_start.  At the same time, 
lldb is going to send the pid to debugserver which is going to attach to it.  
In my own testing, the lldb+debugserver work was much slower than the app 
binary launch even without the sleep. 

I'm talking with the kernel folks to see if there's any way we could do better. 
 The best approach may be to push all this logic down into debugserver which 
can task_for_pid and check the task suspend count directly.  There are some 
other reasons why a task suspend count may be nonzero, but mostly it means 
we're done launching.



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:159
-  const int time_delta_usecs = 10;
-  const int num_retries = timeout_in_seconds / time_delta_usecs;
-  for (int i = 0; i < num_retries; i++) {

clayborg wrote:
> So if we fix this line to be:
> 
> ```
> const int num_retries = timeout_in_seconds * USEC_PER_SEC / time_delta_usecs;
> ```
> 
> This doesn't work? I am assuming you tried this?
That would make the loop execute more than 0 times but the return value from 
proc_pidinfo is the size of the struct read, not an errno value like this is 
treating it as.  And the app will not have a pbi_status of SSTOP when the task 
is suspended.  There's no way to detect this via the BSD side of the kernel 
APIs as near as I can find.



Comment at: lldb/tools/darwin-debug/darwin-debug.cpp:161
+perror("error: send (socket_fd, pid_str, pid_str_len, 0)");
+exit(1);
+  }

clayborg wrote:
> "close(socket_fd)" here if we fail and are going to exit?
Good point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72813



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


[Lldb-commits] [lldb] 1e89fb9 - debugserver: Cut dependency on intrinsics_gen

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T17:20:10-08:00
New Revision: 1e89fb947ed1f8042e13b5840751b73b18cd6534

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

LOG: debugserver: Cut dependency on intrinsics_gen

debugserver does not depend on intrinsics_gen or on llvm.

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index a7d789dd9e19..607ac11ac96f 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -56,6 +56,10 @@ function(get_debugserver_codesign_identity result)
   set(${result} "-" PARENT_SCOPE)
 endfunction()
 
+# debugserver does not depend on intrinsics_gen, or on llvm. Set the common
+# llvm dependencies in the current scope to the empty set.
+set(LLVM_COMMON_DEPENDS)
+
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist")
 
 check_cxx_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments"



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


[Lldb-commits] [PATCH] D72813: Fixes to lldb's eLaunchFlagLaunchInTTY feature on macOS

2020-01-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:154-155
+  // started, and stop at dyld_start, before we attach.
+  const int short_sleep = 10; // 0.1 seconds
+  ::usleep(short_sleep);
+

This seems racy still?



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:159
-  const int time_delta_usecs = 10;
-  const int num_retries = timeout_in_seconds / time_delta_usecs;
-  for (int i = 0; i < num_retries; i++) {

So if we fix this line to be:

```
const int num_retries = timeout_in_seconds * USEC_PER_SEC / time_delta_usecs;
```

This doesn't work? I am assuming you tried this?



Comment at: lldb/tools/darwin-debug/darwin-debug.cpp:161
+perror("error: send (socket_fd, pid_str, pid_str_len, 0)");
+exit(1);
+  }

"close(socket_fd)" here if we fail and are going to exit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72813



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


[Lldb-commits] [lldb] 9efd57e - [lldb/Tools] Remove lldb-mi.exports

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T16:50:17-08:00
New Revision: 9efd57e3b7daa7ebd891084b8564440c5ef297ad

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

LOG: [lldb/Tools] Remove lldb-mi.exports

lldb-mi was removed from the repo a while ago.

Added: 


Modified: 


Removed: 
lldb/tools/lldb-mi/lldb-mi.exports



diff  --git a/lldb/tools/lldb-mi/lldb-mi.exports 
b/lldb/tools/lldb-mi/lldb-mi.exports
deleted file mode 100644
index e69de29bb2d1..



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bafceced6a7: [LLDB] Add ObjectFileWasm plugin for 
WebAssembly debugging (authored by paolosev, committed by dschuff).

Changed prior to commit:
  https://reviews.llvm.org/D71575?vs=238168=238391#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/Shell/ObjectFile/wasm/basic.yaml
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -56,6 +56,7 @@
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
 #include "Plugins/Platform/Android/PlatformAndroid.h"
 #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
 #include "Plugins/Platform/Linux/PlatformLinux.h"
@@ -152,6 +153,7 @@
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
+  wasm::ObjectFileWasm::Initialize();
 
   ScriptInterpreterNone::Initialize();
 
@@ -345,6 +347,7 @@
   ObjectFileELF::Terminate();
   ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
+  wasm::ObjectFileWasm::Terminate();
 
   // Now shutdown the common parts, in reverse order.
   SystemInitializerCommon::Terminate();
Index: lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
@@ -0,0 +1,54 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x0
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CUSTOM
+Name:.debug_info
+Payload: 4C00
+  - Type:CUSTOM
+Name:.debug_abbrev
+Payload: 0111
+  - Type:CUSTOM
+Name:.debug_line
+Payload: 5100
+  - Type:CUSTOM
+Name:.debug_str
+Payload: 636CFF
+...
Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -0,0 +1,67 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0xa
+
+# CHECK: Name: code
+# CHECK: Type: code
+# CHECK: VM address: 0x0
+# CHECK: VM size: 56
+# CHECK: File size: 56
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:

[Lldb-commits] [PATCH] D72813: Fixes to lldb's eLaunchFlagLaunchInTTY feature on macOS

2020-01-15 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added reviewers: clayborg, jingham.
Herald added a project: LLDB.

On macOS lldb has an option that can be added to SBLaunchInfo to create a new 
Terminal window and run the inferior in that new window.  lldb uses some 
AppleScript to open the new window and run the process there.  It runs 
darwin-debug in the window to set up the architecture / 
current-working-directory / environment variables before launching the actual 
inferior process.  lldb opens a socket on the local filesystem and passes the 
name to darwin-debug; darwin-debug sends back its pid to lldb over the socket, 
so lldb can attach to the inferior process once it has been exec'ed.  
AppleScript sits between lldb and the inferior, so the normal way we control 
processes at the start does not work.  We want to attach to the inferior binary 
once it has been started, and is sitting at its entry point in dyld_start, 
stopped, waiting for lldb to connect.

Today, darwin-debug sends its pid over the socket, then parses / constructs the 
environment variables to be passed to the inferior, then calls posix_spawn to 
start the inferior.  lldb gets the pid, then calls WaitForProcessToSIGSTOP 
which is intended to poll repeatedly for 5 seconds to detect when the inferior 
process has stopped in dyld_start.  Unfortunately this function has a few bugs 
- the main loop never runs, the return value from proc_pidinfo is incorrectly 
handled so none of the intended code will ever run, and finally the condition 
that it's looking for -- pbi_status==SSTOP -- is not going to indicate that the 
inferior has been suspended.

The only way to detect that the inferior has been started, and is sitting at 
dyld_start suspended, is to use mach calls (task_info()) which requires that 
lldb task_for_pid the inferior, which lldb doesn't have permissions for.  I 
haven't found a kernel API that doesn't require the task port which I can query 
the suspend count with yet.

The bug being fixed is that lldb attaches before the inferior has started when 
we have a lot of environment variables (darwin-debug is still processing the 
env vars when lldb attaches to it) and the UI layer isn't clear what is going 
on.

This patch changes darwin-debug so it sends its pid just before it calls 
posix_spawn.  It changes lldb to wait up to 5 seconds to receive the pid, then 
it adds an extra 0.1 seconds of sleep in lldb before it tries to attach to the 
inferior (plus the time it takes to construct the attach packet and send it to 
debugserver, and debugserver to decode that packet and try to attach).

Fred suggested using the closing of the socket between lldb and darwin-debug as 
a way of telling when the exec() is actually happening, but the Read methods in 
lldb don't detect that closing via close-on-exec in my testing and I didn't dig 
in much further on this - it's straightforward to get the pid before we call 
posix_spawn which is close enough.

rdar://problem/29760580


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72813

Files:
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/tools/darwin-debug/darwin-debug.cpp

Index: lldb/tools/darwin-debug/darwin-debug.cpp
===
--- lldb/tools/darwin-debug/darwin-debug.cpp
+++ lldb/tools/darwin-debug/darwin-debug.cpp
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -97,7 +99,7 @@
 
 pid_t posix_spawn_for_debug(char *const *argv, char *const *envp,
 const char *working_dir, cpu_type_t cpu_type,
-int disable_aslr) {
+int disable_aslr, int socket_fd) {
   pid_t pid = 0;
 
   const char *path = argv[0];
@@ -147,6 +149,29 @@
   if (working_dir)
 ::chdir(working_dir);
 
+  // We were able to connect to the socket, now write our PID so whomever
+  // launched us will know this process's ID
+  char pid_str[64];
+  const int pid_str_len =
+  ::snprintf(pid_str, sizeof(pid_str), "%i", ::getpid());
+  const int bytes_sent = ::send(socket_fd, pid_str, pid_str_len, 0);
+
+  if (pid_str_len != bytes_sent) {
+perror("error: send (socket_fd, pid_str, pid_str_len, 0)");
+exit(1);
+  }
+
+  // Set the socket socket_fd marked as close-on-exec, leave
+  // it open for now.  lldb might use this to detect when the
+  // exec has happened, and we can attach to the inferior
+  // safely.
+  errno = 0;
+  int opts = fcntl (socket_fd, F_GETFL);
+  if (errno == 0) {
+opts = opts | O_CLOEXEC;
+fcntl (socket_fd, F_SETFL, opts);
+  }
+
   exit_with_errno(::posix_spawnp(, path, NULL, , (char *const *)argv,
  (char *const *)envp),
   "posix_spawn() error: ");
@@ -290,21 +315,6 @@
 exit(1);
   }
 
-  // We were able to connect to the socket, now write our 

[Lldb-commits] [lldb] 4bafcec - [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Derek Schuff via lldb-commits

Author: Paolo Severini
Date: 2020-01-15T16:25:35-08:00
New Revision: 4bafceced6a7641be7b090229c6ccef22cf55bff

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

LOG: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

Summary:
This is the first in a series of patches to enable LLDB debugging of
WebAssembly targets.

Current versions of Clang emit (partial) DWARF debug information in WebAssembly
modules and we can leverage this debug information to give LLDB the ability to
do source-level debugging of Wasm code that runs in a WebAssembly engine.

A way to do this could be to use the remote debugging functionalities provided
by LLDB via the GDB-remote protocol. Remote debugging can indeed be useful not
only to connect a debugger to a process running on a remote machine, but also to
connect the debugger to a managed VM or script engine that runs locally,
provided that the engine implements a GDB-remote stub that offers the ability to
access the engine runtime internal state.

To make this work, the GDB-remote protocol would need to be extended with a few
Wasm-specific custom query commands, used to access aspects of the Wasm engine
state (like the Wasm memory, Wasm local and global variables, and so on).
Furthermore, the DWARF format would need to be enriched with a few Wasm-specific
extensions, here detailed: https://yurydelendik.github.io/webassembly-dwarf.

This CL introduce classes **ObjectFileWasm**, a file plugin to represent a Wasm
module loaded in a debuggee process. It knows how to parse Wasm modules and
store the Code section and the DWARF-specific sections.

Reviewers: jasonmolenda, clayborg, labath

Tags: #lldb

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

Added: 
lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/test/Shell/ObjectFile/wasm/basic.yaml
lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml

Modified: 
lldb/include/lldb/Utility/ArchSpec.h
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/ObjectFile/CMakeLists.txt
lldb/source/Utility/ArchSpec.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ArchSpec.h 
b/lldb/include/lldb/Utility/ArchSpec.h
index 15e2fdb10c32..6e209dfd2e46 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -188,6 +188,8 @@ class ArchSpec {
 
 eCore_arc, // little endian ARC
 
+eCore_wasm32,
+
 kNumCores,
 
 kCore_invalid,

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 06f1a6cd3b75..2c567974891c 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -73,6 +73,7 @@
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
 #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
 #include "Plugins/Platform/Android/PlatformAndroid.h"
 #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
@@ -177,6 +178,7 @@ llvm::Error SystemInitializerFull::Initialize() {
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
+  wasm::ObjectFileWasm::Initialize();
 
   ObjectContainerBSDArchive::Initialize();
   ObjectContainerUniversalMachO::Initialize();
@@ -404,6 +406,7 @@ void SystemInitializerFull::Terminate() {
   ObjectFileELF::Terminate();
   ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
+  wasm::ObjectFileWasm::Terminate();
 
   ObjectContainerBSDArchive::Terminate();
   ObjectContainerUniversalMachO::Terminate();

diff  --git a/lldb/source/Plugins/ObjectFile/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
index 4edd667b9723..76f6d7ad0d78 100644
--- a/lldb/source/Plugins/ObjectFile/CMakeLists.txt
+++ b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
@@ -3,3 +3,4 @@ add_subdirectory(ELF)
 add_subdirectory(Mach-O)
 add_subdirectory(PECOFF)
 add_subdirectory(JIT)
+add_subdirectory(wasm)
\ No newline at end of file

diff  --git a/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
new file mode 100644
index ..5069b6b19b95
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_lldb_library(lldbPluginObjectFileWasm PLUGIN
+  ObjectFileWasm.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbUtility
+  LINK_COMPONENTS
+

[Lldb-commits] [lldb] cf95849 - [lldb/Utils] Patch all variables used by lldb-dotest (2/2)

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T16:01:42-08:00
New Revision: cf958498c4b49447ab1ba6bb61a7d8816d306107

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

LOG: [lldb/Utils] Patch all variables used by lldb-dotest (2/2)

Instead of passing all the arguments for dotest.py as a single CMake
variable, lldb-dotest now uses separate variables for the different test
binaries. Before this change they'd all get patched as part of the
LLDB_DOTEST_ARGS. We need to patch the new variables as well.

Added: 


Modified: 
lldb/utils/lldb-dotest/CMakeLists.txt

Removed: 




diff  --git a/lldb/utils/lldb-dotest/CMakeLists.txt 
b/lldb/utils/lldb-dotest/CMakeLists.txt
index 5c568ddf6997..4fd16f0f90b3 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -26,9 +26,21 @@ if(LLDB_BUILT_STANDALONE)
 if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES)
   # Multi-configuration generator like Xcode (with a matching config).
   string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_SOURCE_DIR 
"${LLDB_SOURCE_DIR}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} 
LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_EXECUTABLE 
"${LLDB_TEST_EXECUTABLE}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_COMPILER 
"${LLDB_TEST_COMPILER}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_DSYMUTIL 
"${LLDB_TEST_DSYMUTIL}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_FILECHECK 
"${LLDB_TEST_FILECHECK}")
 else()
   # Single-configuration generator like Ninja.
   string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_SOURCE_DIR 
"${LLDB_SOURCE_DIR}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_BUILD_DIRECTORY 
"${LLDB_TEST_BUILD_DIRECTORY}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_EXECUTABLE 
"${LLDB_TEST_EXECUTABLE}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_COMPILER 
"${LLDB_TEST_COMPILER}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_DSYMUTIL 
"${LLDB_TEST_DSYMUTIL}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_FILECHECK 
"${LLDB_TEST_FILECHECK}")
 endif()
 
 configure_file(



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


[Lldb-commits] [lldb] eac134d - [lldb/Utils] Patch all variables used by lit (3/3)

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T16:01:42-08:00
New Revision: eac134ddf0344ff44bcd6a6285b6498e080cd1e3

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

LOG: [lldb/Utils] Patch all variables used by lit (3/3)

Instead of passing all the arguments for dotest.py as a single CMake
variable, lit now uses separate variables for the different test
binaries. Before this change they'd all get patched as part of the
LLDB_DOTEST_ARGS. We need to patch the new variables as well.

Added: 


Modified: 
lldb/test/API/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 16daa1e0ec25..1ea2844c2fea 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -139,6 +139,12 @@ if(LLDB_BUILT_STANDALONE)
   # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our 
configuration name placeholder.
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
   string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
+  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
 
   # Remaining ones must be paths to the provided LLVM build-tree.
   if(LLVM_CONFIGURATION_TYPES)
@@ -160,6 +166,13 @@ if(LLDB_BUILT_STANDALONE)
 endif()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_SOURCE_DIR 
"${LLDB_SOURCE_DIR}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
 
 # Configure the API test suite.
 configure_lit_site_cfg(



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


[Lldb-commits] [lldb] 81fc1be - [lldb/Utils] Patch all variables used by lldb-dotest

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T15:17:16-08:00
New Revision: 81fc1be601e7a8b73b675d318af9b1ba046fb5f5

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

LOG: [lldb/Utils] Patch all variables used by lldb-dotest

Instead of passing all the arguments for dotest.py as a single CMake
variable, lldb-dotest now uses separate variables for the different test
binaries. Before this change they'd all get patched as part of the
LLDB_DOTEST_ARGS. We need to patch the new variables as well.

Added: 


Modified: 
lldb/utils/lldb-dotest/CMakeLists.txt

Removed: 




diff  --git a/lldb/utils/lldb-dotest/CMakeLists.txt 
b/lldb/utils/lldb-dotest/CMakeLists.txt
index 4f1bd7304abf..5c568ddf6997 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -15,6 +15,12 @@ if(LLDB_BUILT_STANDALONE)
 # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our actual 
configuration names.
 string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} 
config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} 
LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
 
 # Remaining ones must be paths to the provided LLVM build-tree.
 if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES)
@@ -34,6 +40,12 @@ elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
   foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_SOURCE_DIR 
"${LLDB_SOURCE_DIR}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_EXECUTABLE 
"${LLDB_TEST_EXECUTABLE}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_COMPILER 
"${LLDB_TEST_COMPILER}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_DSYMUTIL 
"${LLDB_TEST_DSYMUTIL}")
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_FILECHECK 
"${LLDB_TEST_FILECHECK}")
 configure_file(
   lldb-dotest.in
   ${LLDB_DOTEST_DIR}/lldb-dotest



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


[Lldb-commits] [lldb] 7ce2de2 - [lldb/Debugger] Rename IO handler methods to be more meaningful (NFC)

2020-01-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-15T14:58:16-08:00
New Revision: 7ce2de2ce4e7d4dd8e1e5a7a5b35c0f98e46681d

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

LOG: [lldb/Debugger] Rename IO handler methods to be more meaningful (NFC)

Make it clear form the method names whether they are synchronous or
asynchronous.

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectGUI.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Expression/REPL.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index a8048427c8f1..6ee39f62be98 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -190,13 +190,15 @@ class Debugger : public 
std::enable_shared_from_this,
lldb::StreamFileSP ,
lldb::StreamFileSP );
 
-  void PushIOHandler(const lldb::IOHandlerSP _sp,
- bool cancel_top_handler = true);
+  /// Run the given IO handler and return immediately.
+  void RunIOHandlerAsync(const lldb::IOHandlerSP _sp,
+ bool cancel_top_handler = true);
 
-  bool PopIOHandler(const lldb::IOHandlerSP _sp);
+  /// Run the given IO handler and block until it's complete.
+  void RunIOHandlerSync(const lldb::IOHandlerSP _sp);
 
-  // Synchronously run an input reader until it is done
-  void RunIOHandler(const lldb::IOHandlerSP _sp);
+  ///  Remove the given IO handler if it's currently active.
+  bool RemoveIOHandler(const lldb::IOHandlerSP _sp);
 
   bool IsTopIOHandler(const lldb::IOHandlerSP _sp);
 
@@ -339,6 +341,11 @@ class Debugger : public 
std::enable_shared_from_this,
 
   static lldb::thread_result_t EventHandlerThread(lldb::thread_arg_t arg);
 
+  void PushIOHandler(const lldb::IOHandlerSP _sp,
+ bool cancel_top_handler = true);
+
+  bool PopIOHandler(const lldb::IOHandlerSP _sp);
+
   bool HasIOHandlerThread();
 
   bool StartIOHandlerThread();
@@ -402,7 +409,7 @@ class Debugger : public 
std::enable_shared_from_this,
   std::array
   m_script_interpreters;
 
-  IOHandlerStack m_input_reader_stack;
+  IOHandlerStack m_io_handler_stack;
   llvm::StringMap> m_log_streams;
   std::shared_ptr m_log_callback_stream_sp;
   ConstString m_instance_name;

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 388db6fad631..ffa261dae33c 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1007,7 +1007,7 @@ a number follows 'f':"
   *this, nullptr));
 
   if (io_handler_sp) {
-debugger.PushIOHandler(io_handler_sp);
+debugger.RunIOHandlerAsync(io_handler_sp);
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
   }
 } else {

diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp 
b/lldb/source/Commands/CommandObjectExpression.cpp
index db90dde98eff..375343ae8be3 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -535,7 +535,7 @@ void CommandObjectExpression::GetMultilineExpression() {
 "Enter expressions, then terminate with an empty line to evaluate:\n");
 output_sp->Flush();
   }
-  debugger.PushIOHandler(io_handler_sp);
+  debugger.RunIOHandlerAsync(io_handler_sp);
 }
 
 static EvaluateExpressionOptions
@@ -622,10 +622,8 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef 
command,
   }
 
   IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
-
   io_handler_sp->SetIsDone(false);
-
-  debugger.PushIOHandler(io_handler_sp);
+  debugger.RunIOHandlerAsync(io_handler_sp);
 } else {
   repl_error.SetErrorStringWithFormat(
   "Couldn't create a REPL for %s",

diff  --git a/lldb/source/Commands/CommandObjectGUI.cpp 
b/lldb/source/Commands/CommandObjectGUI.cpp
index 67ddc68a169e..762163b2670a 100644
--- a/lldb/source/Commands/CommandObjectGUI.cpp
+++ b/lldb/source/Commands/CommandObjectGUI.cpp
@@ -35,7 +35,7 @@ bool CommandObjectGUI::DoExecute(Args , 
CommandReturnObject ) {
 input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
-debugger.PushIOHandler(io_handler_sp);
+

[Lldb-commits] [lldb] 8d2f252 - lldb: Run TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on Darwin only

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T14:00:05-08:00
New Revision: 8d2f252bb8e4d199be8498c4ee2245117ef08fd2

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

LOG: lldb: Run TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on 
Darwin only

See https://bugs.llvm.org/show_bug.cgi?id=44561, these tests are failing
on an aarch64/Linux bot:

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/655

For some reason the backtrace the tests are expecting to find is
incomplete.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
index d0a4b69c27d4..4581a75fa0a5 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
@@ -17,7 +17,7 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@skipUnlessDarwin # llvm.org/PR44561
 def test_cross_dso_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
index 80f20a874f06..dcdf95911de2 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
@@ -17,7 +17,7 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@skipUnlessDarwin # llvm.org/PR44561
 def test_cross_object_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 238358.
JDevlieghere added a comment.

Synchronize between `RunIOHandler` and `ExecuteIOHandlers` using a mutex. When 
running an IO handler synchronously, block `ExecuteIOHandlers` until we're 
finished.


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

https://reviews.llvm.org/D72748

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Core/Debugger.cpp

Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -895,23 +895,62 @@
 }
 
 void Debugger::ExecuteIOHandlers() {
+  IOHandlerSP reader_sp = m_input_reader_stack.Top();
   while (true) {
-IOHandlerSP reader_sp(m_input_reader_stack.Top());
 if (!reader_sp)
   break;
 
 reader_sp->Run();
 
-// Remove all input readers that are done from the top of the stack
+{
+  std::lock_guard guard(m_io_hanlder_synchronous_mutex);
+
+  // Remove all input readers that are done from the top of the stack
+  while (true) {
+IOHandlerSP top_reader_sp = m_input_reader_stack.Top();
+if (top_reader_sp && top_reader_sp->GetIsDone())
+  PopIOHandler(top_reader_sp);
+else
+  break;
+  }
+  reader_sp = m_input_reader_stack.Top();
+}
+  }
+  ClearIOHandlers();
+}
+
+void Debugger::RunIOHandler(const IOHandlerSP _sp) {
+  std::lock_guard guard(m_io_hanlder_synchronous_mutex);
+
+  PushIOHandler(reader_sp);
+  IOHandlerSP top_reader_sp = reader_sp;
+
+  while (top_reader_sp) {
+if (!top_reader_sp)
+  break;
+
+top_reader_sp->Run();
+
+// Don't unwind past the starting point.
+if (top_reader_sp.get() == reader_sp.get()) {
+  if (PopIOHandler(reader_sp))
+break;
+}
+
+// If we pushed new IO handlers, pop them if they're done or restart the
+// loop to run them if they're not.
 while (true) {
-  IOHandlerSP top_reader_sp = m_input_reader_stack.Top();
-  if (top_reader_sp && top_reader_sp->GetIsDone())
+  top_reader_sp = m_input_reader_stack.Top();
+  if (top_reader_sp && top_reader_sp->GetIsDone()) {
 PopIOHandler(top_reader_sp);
-  else
+// Don't unwind past the starting point.
+if (top_reader_sp.get() == reader_sp.get())
+  return;
+  } else {
 break;
+  }
 }
   }
-  ClearIOHandlers();
 }
 
 bool Debugger::IsTopIOHandler(const lldb::IOHandlerSP _sp) {
@@ -941,28 +980,6 @@
   return m_input_reader_stack.GetTopIOHandlerHelpPrologue();
 }
 
-void Debugger::RunIOHandler(const IOHandlerSP _sp) {
-  PushIOHandler(reader_sp);
-
-  IOHandlerSP top_reader_sp = reader_sp;
-  while (top_reader_sp) {
-top_reader_sp->Run();
-
-if (top_reader_sp.get() == reader_sp.get()) {
-  if (PopIOHandler(reader_sp))
-break;
-}
-
-while (true) {
-  top_reader_sp = m_input_reader_stack.Top();
-  if (top_reader_sp && top_reader_sp->GetIsDone())
-PopIOHandler(top_reader_sp);
-  else
-break;
-}
-  }
-}
-
 void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP , StreamFileSP ,
StreamFileSP ) {
   // Before an IOHandler runs, it must have in/out/err streams. This function
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -403,6 +403,8 @@
   m_script_interpreters;
 
   IOHandlerStack m_input_reader_stack;
+  std::mutex m_io_hanlder_synchronous_mutex;
+
   llvm::StringMap> m_log_streams;
   std::shared_ptr m_log_callback_stream_sp;
   ConstString m_instance_name;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D72489: [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-15 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0120556c7e2: [DWARF] Emit DW_AT_call_return_pc as an 
address (authored by vsk).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D72489?vs=237419=238350#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72489

Files:
  lldb/include/lldb/Symbol/Function.h
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One.mk
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One/One.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two.mk
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two/Two.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/main.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/shared.h
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/One.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Two.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/main.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/shared.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Symbol/Function.cpp
  llvm/include/llvm/CodeGen/DebugHandlerBase.h
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/X86/debug_addr.ll
  llvm/test/tools/dsymutil/Inputs/call-site-entry.c
  llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64
  llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64.o
  llvm/test/tools/dsymutil/call-site-entry-linking.test
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -1363,6 +1363,10 @@
   // it. Otherwise (when no relocations where applied) just use the
   // one we just decoded.
   Addr = (Info.OrigHighPc ? Info.OrigHighPc : Addr) + Info.PCOffset;
+  } else if (AttrSpec.Attr == dwarf::DW_AT_call_return_pc) {
+// Relocate a return PC address within a call site entry.
+if (Die.getTag() == dwarf::DW_TAG_call_site)
+  Addr += Info.PCOffset;
   }
 
   Die.addValue(DIEAlloc, static_cast(AttrSpec.Attr),
Index: llvm/test/tools/dsymutil/call-site-entry-linking.test
===
--- /dev/null
+++ llvm/test/tools/dsymutil/call-site-entry-linking.test
@@ -0,0 +1,4 @@
+RUN: dsymutil -oso-prepend-path=%p %p/Inputs/call-site-entry.macho.x86_64 -o %t.dSYM
+RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc
+
+CHECK: DW_AT_call_return_pc  (0x00010fa4)
Index: llvm/test/tools/dsymutil/Inputs/call-site-entry.c
===
--- /dev/null
+++ llvm/test/tools/dsymutil/Inputs/call-site-entry.c
@@ -0,0 +1,25 @@
+/*
+ * This file is used to test dsymutil support for call site entries
+ * (DW_TAG_call_site / DW_AT_call_return_pc).
+ *
+ * Instructions for regenerating binaries (on Darwin/x86_64):
+ *
+ * 1. Copy the source to a top-level directory to work around having absolute
+ *paths in the symtab's OSO entries.
+ *
+ *mkdir -p /Inputs/ && cp call-site-entry.c /Inputs && cd /Inputs
+ *
+ * 2. Compile with call site info enabled.
+ *
+ *clang -g -O1 -Xclang -disable-llvm-passes call-site-entry.c -c -o call-site-entry.macho.x86_64.o
+ *clang call-site-entry.macho.x86_64.o -o call-site-entry.macho.x86_64
+ *
+ * 3. Copy the binaries back into the repo's Inputs directory. You'll need
+ *-oso-prepend-path=%p to link.
+ */
+
+__attribute__((optnone)) int f() {}
+
+int main() {
+  f();
+}
Index: llvm/test/DebugInfo/X86/debug_addr.ll
===
--- llvm/test/DebugInfo/X86/debug_addr.ll
+++ llvm/test/DebugInfo/X86/debug_addr.ll
@@ -9,6 +9,7 @@
 ; }
 ;
 ; void bar() {
+;   foo();
 ; }
 
 ; DWARF4: .debug_info contents:
@@ -18,11 +19,14 @@
 ; DWARF4-NOT: DW_TAG_{{.*}}
 ; DWARF4: 

[Lldb-commits] [lldb] f012055 - [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T13:02:23-08:00
New Revision: f0120556c7e2ef14ff3da5bd7d5717cedf94b767

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

LOG: [DWARF] Emit DW_AT_call_return_pc as an address

This reverts D53469, which changed llvm's DWARF emission to emit
DW_AT_call_return_pc as a function-local offset. Such an encoding is not
compatible with post-link block re-ordering tools and isn't standards-
compliant.

In addition to reverting back to the original DW_AT_call_return_pc
encoding, teach lldb how to fix up DW_AT_call_return_pc when the address
comes from an object file pointed-to by a debug map. While doing this I
noticed that lldb's support for tail calls that cross a DSO/object file
boundary wasn't covered, so I added tests for that. This latter case
exercises the newly added return PC fixup.

The dsymutil changes in this patch were originally included in D49887:
the associated test should be sufficient to test DW_AT_call_return_pc
encoding purely on the llvm side.

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

Added: 

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One.mk

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One/One.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two.mk

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two/Two.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/main.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/shared.h

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/One.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Two.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/main.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/shared.h
llvm/test/tools/dsymutil/Inputs/call-site-entry.c
llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64
llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64.o
llvm/test/tools/dsymutil/call-site-entry-linking.test

Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Symbol/Function.cpp
llvm/include/llvm/CodeGen/DebugHandlerBase.h
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/X86/debug_addr.ll
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index f675b5fdffa6..c8f888c3bdd1 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -281,8 +281,7 @@ class CallEdge {
   /// made the call.
   lldb::addr_t GetReturnPCAddress(Function , Target ) const;
 
-  /// Like \ref GetReturnPCAddress, but returns an unslid function-local PC
-  /// offset.
+  /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
   /// Get the call site parameters available at this call edge.
@@ -294,9 +293,8 @@ class CallEdge {
   CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &)
   : return_pc(return_pc), parameters(std::move(parameters)) {}
 
-  /// An invalid address if this is a tail call. Otherwise, the function-local
-  /// PC offset. Adding this PC offset to the function's base load address
-  /// gives the return PC for the call.
+  /// An invalid address if this is a tail call. Otherwise, the return PC for
+  /// the call. Note that this is a file address which must be resolved.
   lldb::addr_t return_pc;
 
   CallSiteParameterArray parameters;

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
new file mode 100644
index ..fd44eb4be9c3
--- /dev/null
+++ 

[Lldb-commits] [PATCH] D72650: [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging

2020-01-15 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 238342.
paolosev added a comment.

Modified test to have two "inlined" yaml files and use "yaml2obj --docnum".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72650

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/SymbolVendor/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/wasm/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
  lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -76,6 +76,7 @@
 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
 #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SymbolVendor/wasm/SymbolVendorWasm.h"
 #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
 #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
 #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
@@ -201,6 +202,7 @@
   SymbolFileDWARF::Initialize();
   SymbolFilePDB::Initialize();
   SymbolFileSymtab::Initialize();
+  wasm::SymbolVendorWasm::Initialize();
   UnwindAssemblyInstEmulation::Initialize();
   UnwindAssembly_x86::Initialize();
   EmulateInstructionARM64::Initialize();
@@ -288,6 +290,7 @@
   SymbolFileDWARF::Terminate();
   SymbolFilePDB::Terminate();
   SymbolFileSymtab::Terminate();
+  wasm::SymbolVendorWasm::Terminate();
   UnwindAssembly_x86::Terminate();
   UnwindAssemblyInstEmulation::Terminate();
   EmulateInstructionARM64::Terminate();
Index: lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
@@ -0,0 +1,85 @@
+# RUN: yaml2obj -docnum=1 %s > test.wasm
+# RUN: yaml2obj -docnum=2 %s > test_sym.wasm
+# RUN: lldb-test object-file test.wasm | FileCheck %s
+
+# This test checks that SymbolVendorWasm correctly loads DWARF debug sections
+# that have been stripped out into a separated Wasm module. The original Wasm
+# module contains a "external_debug_info" custom section with the absolute or
+# relative path of the debug module.
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0xa
+
+# CHECK: Name: code
+# CHECK: Type: code
+# CHECK: VM address: 0x0
+# CHECK: VM size: 56
+# CHECK: File size: 56
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:238080808000210141102102200120026B21032003200036020C200328020C2104200328020C2105200420056C210620060F0B
+  - Type:CUSTOM
+Name:external_debug_info
+Payload: 0D746573745F73796D2E7761736D  # test_sym.wasm
+
+...
+
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CUSTOM
+Name:.debug_info
+Payload: 4C00
+  - Type:CUSTOM
+Name:.debug_abbrev
+Payload: 0111
+  - Type:CUSTOM
+Name:.debug_line
+Payload: 5100
+  - Type:CUSTOM
+Name:.debug_str
+Payload: 636CFF
+
+...
Index: lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
===
--- /dev/null
+++ lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
@@ -0,0 +1,44 @@
+//===-- SymbolVendorWasm.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[Lldb-commits] [PATCH] D72489: [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-15 Thread Vedant Kumar via Phabricator via lldb-commits
vsk marked 2 inline comments as done.
vsk added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:990
+assert(PCAddr && "Missing return PC information for a call");
+addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_return_pc, PCAddr);
   }

djtodoro wrote:
> Why don't we use the `getDwarf5OrGNUAttr()` for the `return_pc/low_pc`, since 
> we use the address in both cases now?
I'll plan a follow-up for this, thanks.



Comment at: llvm/test/tools/dsymutil/Inputs/call-site-entry.c:21-27
+int zero() {
+  return 0;
+}
+
+int main() {
+  return zero();
+}

dblaikie wrote:
> Would this be able to be simplified down to: 
> 
> ```
> __attribute__((optnone)) void f() {
> }
> int main() {
>   f();
> }
> ```
> 
> (the attribute might be simpler than the command line argument to disable 
> optimizations)
> 
> Or does the function need to return int to get a call_site?
That's a nice simplification, I'll fold that in before committing.


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

https://reviews.llvm.org/D72489



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


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere planned changes to this revision.
JDevlieghere added a comment.

I'm working on a different approach that should address al the concerns raised 
so far.


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

https://reviews.llvm.org/D72748



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


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D72748#1822443 , @clayborg wrote:

> So I did a bunch of original IOHandler. And there are many complex cases for 
> sure. One thing to be aware of is that if you won't use editline() and we 
> call fgets() in the default implementation, there is no way to cancel this 
> IIRC. So it might be worth trying this without editline support to make sure 
> things don't deadlock. If the test suite is happy, then this looks worth 
> trying, though with all the complexities I don't think we can guarantee this 
> doesn't cause issues in some unexpected way. The main things that worry me 
> are:
>
> - REPL issues since the REPL and (lldb) prompt switch between themselves in a 
> tricky way where they swap IOHandlers
> - running from python script directly when no IOHandlers are pushed because 
> no command interpreter is being run and all the fallout from the cases 
> (HandleCommand that results in a python breakpoint callback etc)
> - the process IO handler that does STDIO for a process
> - when no editline, we use fgets() that can't be canceled


The fgets part is problematic in other ways.  For instance, Python based 
commands in stop hooks work in command line lldb, but in Xcode which doesn't 
use editline, when we go to fflush the I/O channel on switching to the Python 
interpreter, fflush deadlocks against the lock held by fgets.  I wonder if we 
should just stop using fgets and use select everywhere we can, as it doesn't 
have this problem.


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

https://reviews.llvm.org/D72748



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-01-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: 
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp:121
+ : image_load_address);
+  if (m_process->GetTarget().SetSectionLoadAddress(section_sp, load_addr))
+loaded_module_list.AppendIfNeeded(module_sp);

Is there only ever just a code address and an image address? If you have more 
than 2 sections you don't want to load the different sections at the same 
address because converting a load address back into a section should provide a 
one to one mapping. So looking up 0x1000 currently should not return N 
sections, it should return 1 section. If this doesn't happen the binary search 
of an address in the target section load list could return any of the sections 
that match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D70314: [lldb] Add expect_expr function for testing expression evaluation in dotests.

2020-01-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70314



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


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

So I did a bunch of original IOHandler. And there are many complex cases for 
sure. One thing to be aware of is that if you won't use editline() and we call 
fgets() in the default implementation, there is no way to cancel this IIRC. So 
it might be worth trying this without editline support to make sure things 
don't deadlock. If the test suite is happy, then this looks worth trying, 
though with all the complexities I don't think we can guarantee this doesn't 
cause issues in some unexpected way. The main things that worry me are:

- REPL issues since the REPL and (lldb) prompt switch between themselves in a 
tricky way where they swap IOHandlers
- running from python script directly when no IOHandlers are pushed because no 
command interpreter is being run and all the fallout from the cases 
(HandleCommand that results in a python breakpoint callback etc)
- the process IO handler that does STDIO for a process
- when no editline, we use fgets() that can't be canceled


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

https://reviews.llvm.org/D72748



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added a comment.

In D71575#1821312 , @labath wrote:

> Thanks. I think this is looking very good now. Excited to have this ready.
>
> Do you have commit access?


No, I certainly don't have commit access, this would be my first accepted 
patch. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575



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


[Lldb-commits] [PATCH] D70314: [lldb] Add expect_expr function for testing expression evaluation in dotests.

2020-01-15 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13f22f5d5958: [lldb] Add expect_expr function for testing 
expression evaluation in dotests. (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70314

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2366,6 +2366,45 @@
 self.assertTrue(matched if matching else not matched,
 msg if msg else EXP_MSG(str, output, exe))
 
+def expect_expr(
+self,
+expr,
+result_summary=None,
+result_value=None,
+result_type=None,
+error_msg=None,
+):
+"""
+Evaluates the given expression and verifies the result.
+:param expr: The expression as a string.
+:param result_summary: The summary that the expression should have. 
None if the summary should not be checked.
+:param result_value: The value that the expression should have. None 
if the value should not be checked.
+:param result_type: The type that the expression result should have. 
None if the type should not be checked.
+:param error_msg: The error message the expression should return. None 
if the error output should not be checked.
+"""
+self.assertTrue(expr.strip() == expr, "Expression contains 
trailing/leading whitespace: '" + expr + "'")
+
+frame = self.frame()
+eval_result = frame.EvaluateExpression(expr)
+
+if error_msg:
+self.assertFalse(eval_result.IsValid())
+self.assertEqual(error_msg, eval_result.GetError().GetCString())
+return
+
+if not eval_result.GetError().Success():
+self.assertTrue(eval_result.GetError().Success(),
+"Unexpected failure with msg: " + 
eval_result.GetError().GetCString())
+
+if result_type:
+self.assertEqual(result_type, eval_result.GetTypeName())
+
+if result_value:
+self.assertEqual(result_value, eval_result.GetValue())
+
+if result_summary:
+self.assertEqual(result_summary, eval_result.GetSummary())
+
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""
 trace = (True if traceAlways else trace)
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -96,10 +96,11 @@
 cappedSummary.find("someText") <= 0,
 "cappedSummary includes the full string")
 
+self.expect_expr("s", result_type=ns+"::wstring", 
result_summary='L"hello world! מזל טוב!"')
+
 self.expect(
 "frame variable",
 substrs=[
-'(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
 '(%s::wstring) S = L"!"'%ns,
 '(const wchar_t *) mazeltov = 0x',
 'L"מזל טוב"',
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
===
--- 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
@@ -39,7 +39,7 @@
 
 # Test different builtin functions.
 
-self.expect("expr __builtin_isinf(0.0f)", substrs=["(int) $", " = 
0\n"])
-self.expect("expr __builtin_isnormal(0.0f)", substrs=["(int) $", " = 
0\n"])
-self.expect("expr __builtin_constant_p(1)", substrs=["(int) $", " = 
1\n"])
-self.expect("expr __builtin_abs(-14)", substrs=["(int) $", " = 14\n"])
+self.expect_expr("__builtin_isinf(0.0f)", result_type="int", 
result_value="0")
+self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", 
result_value="0")
+self.expect_expr("__builtin_constant_p(1)", result_type="int", 
result_value="1")
+self.expect_expr("__builtin_abs(-14)", 

[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I think this is a great start. We can see how we can extend this later...


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

https://reviews.llvm.org/D70314



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


[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 238209.
teemperor added a comment.

- Removed substr functionality.
- Using `frame()` now.


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

https://reviews.llvm.org/D70314

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2366,6 +2366,45 @@
 self.assertTrue(matched if matching else not matched,
 msg if msg else EXP_MSG(str, output, exe))
 
+def expect_expr(
+self,
+expr,
+result_summary=None,
+result_value=None,
+result_type=None,
+error_msg=None,
+):
+"""
+Evaluates the given expression and verifies the result.
+:param expr: The expression as a string.
+:param result_summary: The summary that the expression should have. 
None if the summary should not be checked.
+:param result_value: The value that the expression should have. None 
if the value should not be checked.
+:param result_type: The type that the expression result should have. 
None if the type should not be checked.
+:param error_msg: The error message the expression should return. None 
if the error output should not be checked.
+"""
+self.assertTrue(expr.strip() == expr, "Expression contains 
trailing/leading whitespace: '" + expr + "'")
+
+frame = self.frame()
+eval_result = frame.EvaluateExpression(expr)
+
+if error_msg:
+self.assertFalse(eval_result.IsValid())
+self.assertEqual(error_msg, eval_result.GetError().GetCString())
+return
+
+if not eval_result.GetError().Success():
+self.assertTrue(eval_result.GetError().Success(),
+"Unexpected failure with msg: " + 
eval_result.GetError().GetCString())
+
+if result_type:
+self.assertEqual(result_type, eval_result.GetTypeName())
+
+if result_value:
+self.assertEqual(result_value, eval_result.GetValue())
+
+if result_summary:
+self.assertEqual(result_summary, eval_result.GetSummary())
+
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""
 trace = (True if traceAlways else trace)
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -96,10 +96,11 @@
 cappedSummary.find("someText") <= 0,
 "cappedSummary includes the full string")
 
+self.expect_expr("s", result_type=ns+"::wstring", 
result_summary='L"hello world! מזל טוב!"')
+
 self.expect(
 "frame variable",
 substrs=[
-'(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
 '(%s::wstring) S = L"!"'%ns,
 '(const wchar_t *) mazeltov = 0x',
 'L"מזל טוב"',
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
===
--- 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
@@ -39,7 +39,7 @@
 
 # Test different builtin functions.
 
-self.expect("expr __builtin_isinf(0.0f)", substrs=["(int) $", " = 
0\n"])
-self.expect("expr __builtin_isnormal(0.0f)", substrs=["(int) $", " = 
0\n"])
-self.expect("expr __builtin_constant_p(1)", substrs=["(int) $", " = 
1\n"])
-self.expect("expr __builtin_abs(-14)", substrs=["(int) $", " = 14\n"])
+self.expect_expr("__builtin_isinf(0.0f)", result_type="int", 
result_value="0")
+self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", 
result_value="0")
+self.expect_expr("__builtin_constant_p(1)", result_type="int", 
result_value="1")
+self.expect_expr("__builtin_abs(-14)", result_type="int", 
result_value="14")


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

[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This seems fine, assuming it is sufficient to achieve your goals.




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:2396-2407
+if type(expected) is list:
+remaining = got
+for expected_part in expected:
+# Find the expected string.
+i = remaining.find(expected_part)
+# Assert that we found the string.
+outer_self.assertTrue(i != -1, "Couldn't find '" + 
expected_part

maybe something like `self.expect(got, substrs=expected, exe=False)` ?



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:2413
+
+frame = 
self.dbg.GetTargetAtIndex(0).GetProcess().GetThreadAtIndex(0).GetFrameAtIndex(0)
+eval_result = frame.EvaluateExpression(expr)

`frame = self.frame()`. If it turns out useful, we could also add an argument 
to run the expression on a specific frame...


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

https://reviews.llvm.org/D70314



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


[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 238205.
teemperor added a comment.

- Removed everything that is not summary or value.


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

https://reviews.llvm.org/D70314

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py

Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2366,6 +2366,71 @@
 self.assertTrue(matched if matching else not matched,
 msg if msg else EXP_MSG(str, output, exe))
 
+def expect_expr(
+self,
+expr,
+result_summary=None,
+result_value=None,
+result_type=None,
+error_msg=None,
+):
+"""
+Evaluates the given expression and verifies the result.
+:param expr: The expression as a string.
+:param result_summary: The summary that the expression should have. None if the summary should not be checked.
+:param result_value: The value that the expression should have. None if the value should not be checked.
+:param result_type: The type that the expression result should have. None if the type should not be checked.
+:param error_msg: The error message the expression should return. None if the error output should not be checked.
+
+result_summary, result_value, result_type and error_message can have the following types which influences how
+their values are compared to their respective output:
+  * A list of strings: expect_expr will search for the list of strings in the respective output.
+   The output is expected to contain these strings in the listed order.
+  * Any string type: expect_expr will assume that the respective output is equal to the given string.
+"""
+# Utility method that checks result_value, result_type and error_message.
+def check_str(outer_self, expected, got):
+self.assertIsNotNone(expected)
+self.assertIsNotNone(got)
+# We got a list, so treat is as a list of needles we need to find in the given order.
+if type(expected) is list:
+remaining = got
+for expected_part in expected:
+# Find the expected string.
+i = remaining.find(expected_part)
+# Assert that we found the string.
+outer_self.assertTrue(i != -1, "Couldn't find '" + expected_part
+  + "' in remaining output '" + remaining +
+  "'.\nFull string was: '" + got + "'")
+# Keep searching only the rest of the string to ensure the
+# strings are found in the given order.
+remaining = remaining[i + len(expected_part):]
+else: # Otherwise we probably got one of Python's many string classes.
+outer_self.assertEqual(got, expected)
+
+self.assertTrue(expr.strip() == expr, "Expression contains trailing/leading whitespace: '" + expr + "'")
+
+frame = self.dbg.GetTargetAtIndex(0).GetProcess().GetThreadAtIndex(0).GetFrameAtIndex(0)
+eval_result = frame.EvaluateExpression(expr)
+
+if error_msg:
+self.assertFalse(eval_result.IsValid())
+check_str(self, error_msg, eval_result.GetError().GetCString())
+return
+
+if not eval_result.GetError().Success():
+self.assertTrue(eval_result.GetError().Success(),
+"Unexpected failure with msg: " + eval_result.GetError().GetCString())
+
+if result_type:
+check_str(self, result_type, eval_result.GetTypeName())
+
+if result_value:
+check_str(self, result_value, eval_result.GetValue())
+
+if result_summary:
+check_str(self, result_summary, eval_result.GetSummary())
+
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""
 trace = (True if traceAlways else trace)
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Testing dynamic loaders is a bit tricky as they require an actual process 
around. The best thing available to us right now is the "gdb-client" approach, 
which consists of mocking the responses of the gdb server. It's not the easiest 
way to write tests, but I don't think it should be that difficult in this case 
-- you shouldn't need to mock that many packets -- the main one is 
`qXfer:libraries`. Then you should be able to run something like "image lookup 
-a" (or `SBTarget::ResolveLoadAddress`, if you want to try your hand at the 
scripting API) and check that it resolves to the correct section+offset pair. 
You can look at the existing tests in 
`packages/Python/lldbsuite/test/functionalities/gdb_remote_client/` to see how 
this works...

I will have some more questions about the interaction of this function with 
ObjectFileWasm::SetLoadAddress, but I need to think this over a bit...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D72650: [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D72650#1820897 , @paolosev wrote:

> In D72650#1819403 , @labath wrote:
>
> > The patch looks pretty good. A reasonable way to test this would be again 
> > via `lldb-test object-file` . The command dumps the "unified section list" 
> > of the module, so if the debug info sections show up there, you know the 
> > symbol vendor has done it's job. You can look at 
> > `test/Shell/ObjectFile/ELF/build-id-case.yaml` for inspiration.
>
>
> Thank you for the suggestion! I added a test. 
>  I would have liked to use `llvm-objcopy --strip-all` in my test, but 
> llvm-objcopy does not support wasm yet (I started 
>  working on this feature but I found out 
> that there was already an ongoing effort: https://reviews.llvm.org/D70930, 
> and https://reviews.llvm.org/D70970) .
>  So I created with two separated yaml files.


That's fine. I think I actually prefer separate yaml representations, as that 
makes what goes into which file more explicit, and shields the test from 
changes in objcopy behavior. What you could consider is "inlining" the two yaml 
files into `unified-debug-sections.yaml`, and using the `yaml2obj --docnum` 
functionality (as in e.g., 
`test/Shell/Minidump/memory-region-from-module.yaml`) to create two wasm files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72650



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


[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I also got rid of the expr->frame var->expr flow and it's not just expr->frame 
var. I don't want to remove them as we found two formatter bugs by testing both 
but once these thing don't break constantly then we can remove the 'expr' 
variant from the simple expression function.


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

https://reviews.llvm.org/D70314



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


[Lldb-commits] [PATCH] D70314: [lldb] Add better test commands for expression evaluation

2020-01-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 238189.
teemperor added a comment.

- Moved to using the SBAPI.

We can't get fully rid of parsing some output as GetDescription of SBValue 
returns `(type) $0 = VALUE\n` but there
seems to be no way to get rid of the stuff around the value we want. But we now 
only strip it away instead of
trying to parse the type etc.


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

https://reviews.llvm.org/D70314

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py

Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2366,6 +2366,95 @@
 self.assertTrue(matched if matching else not matched,
 msg if msg else EXP_MSG(str, output, exe))
 
+class ExpressionRunMode:
+  # Run the expression in the expression evaluator (similar to 'expression').
+  EXPRESSION = object()
+  # Interpret the expression as just a variable that should be printed (similar to 'frame var').
+  PRINT_VAR = object()
+
+def expect_expr(
+self,
+expr,
+result_value=None,
+result_type=None,
+error_msg=None,
+run_mode=ExpressionRunMode.EXPRESSION
+):
+"""
+Evaluates the given expression and verifies the result.
+:param expr: The expression as a string.
+:param result_value: The value that the expression should have. None if the value should not be checked.
+:param result_type: The type that the expression result should have. None if the type should not be checked.
+:param error_msg: The error message the expression should return. None if the error output should not be checked.
+:param run_type: How the expression should be run. See ExpressionRunMode.
+
+result_value, result_type and error_message can have the following types which influences how
+their values are compared to their respective output:
+  * A list of strings: expect_expr will search for the list of strings in the respective output.
+   The output is expected to contain these strings in the listed order.
+  * Any string type: expect_expr will assume that the respective output is equal to the given string.
+"""
+# Utility method that checks result_value, result_type and error_message.
+def check_str(outer_self, expected, got):
+self.assertIsNotNone(expected)
+self.assertIsNotNone(got)
+# We got a list, so treat is as a list of needles we need to find in the given order.
+if type(expected) is list:
+remaining = got
+for expected_part in expected:
+# Find the expected string.
+i = remaining.find(expected_part)
+# Assert that we found the string.
+outer_self.assertTrue(i != -1, "Couldn't find '" + expected_part
+  + "' in remaining output '" + remaining +
+  "'.\nFull string was: '" + got + "'")
+# Keep searching only the rest of the string to ensure the
+# strings are found in the given order.
+remaining = remaining[i + len(expected_part):]
+else: # Otherwise we probably got one of Python's many string classes.
+outer_self.assertEqual(got, expected)
+
+self.assertTrue(expr.strip() == expr, "Expression contains trailing/leading whitespace: '" + expr + "'")
+
+frame = self.dbg.GetTargetAtIndex(0).GetProcess().GetThreadAtIndex(0).GetFrameAtIndex(0)
+
+if run_mode is self.ExpressionRunMode.PRINT_VAR:
+  eval_result = frame.FindVariable(expr)
+elif run_mode is self.ExpressionRunMode.EXPRESSION:
+  eval_result = frame.EvaluateExpression(expr)
+else:
+  self.fail("Unknown run mode " + str(run_mode))
+
+if error_msg:
+self.assertFalse(eval_result.IsValid())
+check_str(self, error_msg, eval_result.GetError().GetCString())
+return
+
+if not eval_result.GetError().Success():
+self.assertTrue(eval_result.GetError().Success(),
+"Unexpected failure with msg: " + eval_result.GetError().GetCString())
+
+if result_type:
+check_str(self, result_type, eval_result.GetTypeName())
+if result_value:
+ss = lldb.SBStream()
+eval_result.GetDescription(ss)
+

[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Thanks. I think this is looking very good now. Excited to have this ready.

Do you have commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575



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


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Though I have messed with IOHandlers in the past, I have successfully 
suppressed most of the memories of it. I think I have a rough understanding of 
what the bug is, but I don't understand the solution yet.

With this patch, what does guarantee that the IOHandler for the `"command 
source -s true ./test.lldb"` thingy completes before the breakpoint callback is 
finished (I assume that the intention is for this to be executed synchronously)?

I don't know if this matters, but another detail to be aware of is that the 
IOHandler stack will be different if driving lldb through python (without 
calling SBDebugger::RunCommandInterpreter). In this case there won't be a stdio 
editline handler sitting at the bottom of the stack.




Comment at: lldb/source/Core/Debugger.cpp:1020
+  // they aren't running yet.
+  if (asynchronous_if_needed && !m_synchronous_reader_lock.owns_lock()) {
+ExecuteIOHandlers();

This looks very clever, but it can still be racy if someone calls 
ExecuteIOHandlers concurrently to the `owns_lock` check...

A better way to achieve this (if I understand correctly what you are trying to 
achieve) would be to have a `ExecuteIOHandlersIfNeeded` function which does 
something like
```
std::unique_lock lock(m_synchronous_reader_mutex, std::try_lock);
if (lock)
  ReallyExecuteIOHandlers(); // No locking in here
```


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

https://reviews.llvm.org/D72748



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