[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D68723#1703051 , @devnexen wrote:

> LGTM otherwise.


I don't think this change should be reverted. It can just be repaired by adding 
some `(void)!xxx;`


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 224266.
teemperor added a comment.

- GetHasSourceSize -> HasSourceSize
- Moved some code around according to feedback.


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

https://reviews.llvm.org/D68010

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp

Index: lldb/source/Plugins/Language/ObjC/NSString.cpp
===
--- lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -171,6 +171,7 @@
   options.SetStream(&stream);
   options.SetQuote('"');
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -183,6 +184,7 @@
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -200,6 +202,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
 options.SetLanguage(summary_options.GetLanguage());
@@ -222,6 +225,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -242,6 +246,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -264,6 +269,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -287,6 +293,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
 options.SetLanguage(summary_options.GetLanguage());
Index: lldb/source/DataFormatters/StringPrinter.cpp
===
--- lldb/source/DataFormatters/StringPrinter.cpp
+++ lldb/source/DataFormatters/StringPrinter.cpp
@@ -537,27 +537,33 @@
   if (!options.GetStream())
 return false;
 
-  uint32_t sourceSize = options.GetSourceSize();
+  uint32_t sourceSize;
   bool needs_zero_terminator = options.GetNeedsZeroTermination();
 
   bool is_truncated = false;
   const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
 
-  if (!sourceSize) {
+  if (options.HasSourceSize()) {
+sourceSize = options.GetSourceSize();
+if (!options.GetIgnoreMaxLength()) {
+  if (sourceSize > max_size) {
+sourceSize = max_size;
+is_truncated = true;
+  }
+}
+  } else {
 sourceSize = max_size;
 needs_zero_terminator = true;
-  } else if (!options.GetIgnoreMaxLength()) {
-if (sourceSize > max_size) {
-  sourceSize = max_size;
-  is_truncated = true;
-}
   }
 
   const int bufferSPSize = sourceSize * type_width;
 
   lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0));
 
-  if (!buffer_sp->GetBytes())
+  // Check if we got bytes. We never get any bytes if we have an empty
+  // string, but we still continue so that we end up actually printing
+  // an empty string ("").
+  if (sourceSize != 0 && !buffer_sp->GetBytes())
 return false;
 
   Status error;
Index: lldb/p

[Lldb-commits] [PATCH] D68738: update TestRunCommandInterpreterAPI to use SBFile

2019-10-10 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.

Makes sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68738



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


[Lldb-commits] [PATCH] D68737: SBFile::GetFile: convert SBFile back into python native files.

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It looks pretty straight-forward. The two main comments I have are:

- implement rtti to get rid of the `GetPythonObject` method on the base class
- it looks like the implementations of new apis you're adding (GetOptions, 
mainly) have to go out of their way to ignore errors, only for their callers to 
synthesize new Error objects. It seems like it would be better to just use 
Expecteds throughout.




Comment at: lldb/include/lldb/Host/File.h:56
   static bool DescriptorIsValid(int descriptor) { return descriptor >= 0; };
+  static const char *GetStreamOpenModeFromOptions(uint32_t options);
 

change the argument type to OpenOptions. For some reason, lldb has historically 
used integer types for passing enumerations around, but we're now slowly 
changing that..



Comment at: lldb/include/lldb/Host/File.h:316
+  ///The PyObject* that this File wraps, or NULL.
+  virtual void *GetPythonObject() const;
+

We've spend a lot of time removing python from the lowest layers, and this 
let's it back in through the back door. It would be way better to add support 
for llvm-style rtti to this class, so that the python code can `dyn_cast` to a 
`PythonFile` when it needs to (re)construct the python object. You can take a 
look at CPPLanguageRuntime::classof  (and friend) for how to implement this in 
a plugin-friendly manner.



Comment at: lldb/include/lldb/Host/File.h:328
+  ///OpenOptions flags for this file, or 0 if unknown.
+  virtual uint32_t GetOptions() const;
+

How about returning Expected from here?



Comment at: lldb/include/lldb/Host/File.h:330
+
+  const char *GetOpenMode() const {
+return GetStreamOpenModeFromOptions(GetOptions());

and Expected from here?



Comment at: 
lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py:776
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME implement SBFile::GetFile
 @skipIf(py_version=['<', (3,)])

So, if I understand correctly, these tests check that you can feed a file 
opened by python into lldb, and then pump it back out to python. Are there any 
tests which do the opposite (have lldb open a file, move it to python and then 
reinject it into lldb)?



Comment at: lldb/scripts/interface/SBFile.i:81
+
+%feature("docstring", "convert this SBFile into a python io.IOBase file 
object");
+FileSP GetFile();

I am somewhat surprised that there's no ownership handling in this patch 
(whereas ownership transfer was a fairly big chunk of the conversion in the 
other direction). Could you maybe explain what are the ownership expectations 
of the file returned through here (and what happens when we close it for 
instance)?



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h:674-682
+  PythonFile(File &file, const char *mode = nullptr) {
+auto f = FromFile(file, mode);
+if (f)
+  *this = std::move(f.get());
+else {
+  Reset();
+  llvm::consumeError(f.takeError());

It looks like there's just one caller of this constructor (the "out" typemap 
for FILE*). Can we just inline this stuff there and delete this constructor?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68737



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


[Lldb-commits] [PATCH] D68731: Remove CC autodetection from Makefile.rules

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

Yay


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

https://reviews.llvm.org/D68731



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


[Lldb-commits] [PATCH] D68750: Implement serialization and deserialization of scripted points

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

LGTM, thanks a lot!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68750



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


[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:316
 
-# Use a shared module cache when building in the default test build directory.
-CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 
$(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE))

JDevlieghere wrote:
> We should have a fallback here that defaults to `$(BUILDDIR)/module-cache` if 
> the variable is not set in the environment.
Is that wise, given D68731 tries to move away from autodetecting stuff in 
`make`?

What I think would be more useful is to pass this variable via the command like 
instead of the environment. That way it will be visible in the `make` 
invocation that dotest prints and the exact make invocation can be reproduced 
by copy-pasting. It shouldn't be even hard to do that -- you'd just need 
builder_base.py to fetch this from the `configuration` object and inject it 
into the make arguments.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68755



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


[Lldb-commits] [lldb] r374289 - [lldb][NFC] Use unique_ptr in DiagnosticManager to express ownership

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 01:30:10 2019
New Revision: 374289

URL: http://llvm.org/viewvc/llvm-project?rev=374289&view=rev
Log:
[lldb][NFC] Use unique_ptr in DiagnosticManager to express ownership

Modified:
lldb/trunk/include/lldb/Expression/DiagnosticManager.h
lldb/trunk/source/Expression/DiagnosticManager.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp

Modified: lldb/trunk/include/lldb/Expression/DiagnosticManager.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DiagnosticManager.h?rev=374289&r1=374288&r2=374289&view=diff
==
--- lldb/trunk/include/lldb/Expression/DiagnosticManager.h (original)
+++ lldb/trunk/include/lldb/Expression/DiagnosticManager.h Thu Oct 10 01:30:10 
2019
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 
 #include 
@@ -87,7 +88,7 @@ protected:
   uint32_t m_compiler_id; // Compiler-specific diagnostic ID
 };
 
-typedef std::vector DiagnosticList;
+typedef std::vector> DiagnosticList;
 
 class DiagnosticManager {
 public:
@@ -96,33 +97,24 @@ public:
 m_fixed_expression.clear();
   }
 
-  // The diagnostic manager holds a list of diagnostics, which are owned by the
-  // manager.
   const DiagnosticList &Diagnostics() { return m_diagnostics; }
 
-  ~DiagnosticManager() {
-for (Diagnostic *diag : m_diagnostics) {
-  delete diag;
-}
-  }
-
   bool HasFixIts() const {
-for (Diagnostic *diag : m_diagnostics) {
-  if (diag->HasFixIts())
-return true;
-}
-return false;
+return llvm::any_of(m_diagnostics,
+[](const std::unique_ptr &diag) {
+  return diag->HasFixIts();
+});
   }
 
   void AddDiagnostic(llvm::StringRef message, DiagnosticSeverity severity,
  DiagnosticOrigin origin,
  uint32_t compiler_id = LLDB_INVALID_COMPILER_ID) {
-m_diagnostics.push_back(
-new Diagnostic(message, severity, origin, compiler_id));
+m_diagnostics.emplace_back(
+std::make_unique(message, severity, origin, compiler_id));
   }
 
-  void AddDiagnostic(Diagnostic *diagnostic) {
-m_diagnostics.push_back(diagnostic);
+  void AddDiagnostic(std::unique_ptr diagnostic) {
+m_diagnostics.push_back(std::move(diagnostic));
   }
 
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)

Modified: lldb/trunk/source/Expression/DiagnosticManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DiagnosticManager.cpp?rev=374289&r1=374288&r2=374289&view=diff
==
--- lldb/trunk/source/Expression/DiagnosticManager.cpp (original)
+++ lldb/trunk/source/Expression/DiagnosticManager.cpp Thu Oct 10 01:30:10 2019
@@ -47,7 +47,7 @@ static const char *StringForSeverity(Dia
 std::string DiagnosticManager::GetString(char separator) {
   std::string ret;
 
-  for (const Diagnostic *diagnostic : Diagnostics()) {
+  for (const auto &diagnostic : Diagnostics()) {
 ret.append(StringForSeverity(diagnostic->GetSeverity()));
 ret.append(diagnostic->GetMessage());
 ret.push_back(separator);

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=374289&r1=374288&r2=374289&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Thu Oct 10 01:30:10 2019
@@ -208,9 +208,8 @@ public:
   // around them.
   std::string stripped_output = llvm::StringRef(m_output).trim();
 
-  ClangDiagnostic *new_diagnostic =
-  new ClangDiagnostic(stripped_output, severity, Info.getID());
-  m_manager->AddDiagnostic(new_diagnostic);
+  auto new_diagnostic = std::make_unique(
+  stripped_output, severity, Info.getID());
 
   // Don't store away warning fixits, since the compiler doesn't have
   // enough context in an expression for the warning to be useful.
@@ -224,6 +223,8 @@ public:
 new_diagnostic->AddFixitHint(fixit);
 }
   }
+
+  m_manager->AddDiagnostic(std::move(new_diagnostic));
 }
   }
 
@@ -1100,8 +1101,8 @@ bool ClangExpressionParser::RewriteExpre
   if (num_diags == 0)
 return false;
 
-  for (const Diagnostic *diag : diagnostic_manager.Diagnostics()) {
-const ClangDiagnostic *diagnostic = llvm::dyn_cast(diag);
+  for (const auto &diag : diagnostic_manager.Diagnostics()) {
+const auto *diagnostic = l

[Lldb-commits] [PATCH] D68454: Fix the unwinding plan augmentation from x86 assembly

2019-10-10 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

Thank you for the review! Could you also possibly commit the change for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68454



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


[Lldb-commits] [PATCH] D68734: update SBDebugger::SetInputFile() etc to work on native Files

2019-10-10 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.

Looks fine to me. The public-consumptionness of the FileSP overloads was also 
discussed in D68546 , and I currently do not 
see a better solution than this one. The way I've resolved this issue for 
myself is to look at the FileSP argument as a placeholder for some hypothetical 
future feature which would allow C++ users to pass in custom file objects into 
lldb (i.e. do the same thing that python can do now). If/when we have that, we 
can replace FileSP with the new thing, and have the python objects typemap to 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68734



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


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I don't think having Expected members is a reasonable thing to do. If we 
want to keep the notion of validity explicit (which is consistent with the 
direction lldb is moving in), then I think the members should be Optional. 
The initialization code can take the Expected result, do something with the 
error, and then emplace the result into the Optional member in case of 
success.


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread David CARLIER via Phabricator via lldb-commits
devnexen added a comment.

In D68723#1703098 , @MaskRay wrote:

> In D68723#1703051 , @devnexen wrote:
>
> > LGTM otherwise.
>
>
> I don't think this change should be reverted. It can just be repaired by 
> adding some `(void)!xxx;`




In D68723#1703098 , @MaskRay wrote:

> In D68723#1703051 , @devnexen wrote:
>
> > LGTM otherwise.
>
>
> I don't think this change should be reverted. It can just be repaired by 
> adding some `(void)!xxx;`


I would prefer this approach indeed but either way I m in that s a real issue 
at the moment since LLVM runtime check is on in the FreeBSD's system.


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [PATCH] D68770: [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

2019-10-10 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, rnk.
Herald added a project: LLDB.

This avoids the currently MSVC specific codepath of using the wchar entry point 
and converting that to utf8.

In the main lldb driver, we had this MSVC specific codepath, but in other 
potentially important entry points (like lldb-server), there's none at all. So 
if this is fine, we should probably add the same InitLLVM call to other lldb 
entry points as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68770

Files:
  lldb/tools/driver/Driver.cpp


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -19,8 +19,8 @@
 #include "lldb/API/SBStringList.h"
 
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -807,23 +807,9 @@
   return llvm::None;
 }
 
-int
-#ifdef _MSC_VER
-wmain(int argc, wchar_t const *wargv[])
-#else
-main(int argc, char const *argv[])
-#endif
+int main(int argc, char const *argv[])
 {
-#ifdef _MSC_VER
-  // Convert wide arguments to UTF-8
-  std::vector argvStrings(argc);
-  std::vector argvPointers(argc);
-  for (int i = 0; i != argc; ++i) {
-llvm::convertWideToUTF8(wargv[i], argvStrings[i]);
-argvPointers[i] = argvStrings[i].c_str();
-  }
-  const char **argv = argvPointers.data();
-#endif
+  llvm::InitLLVM IL(argc, argv);
 
   // Print stack trace on crash.
   llvm::StringRef ToolName = llvm::sys::path::filename(argv[0]);


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -19,8 +19,8 @@
 #include "lldb/API/SBStringList.h"
 
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -807,23 +807,9 @@
   return llvm::None;
 }
 
-int
-#ifdef _MSC_VER
-wmain(int argc, wchar_t const *wargv[])
-#else
-main(int argc, char const *argv[])
-#endif
+int main(int argc, char const *argv[])
 {
-#ifdef _MSC_VER
-  // Convert wide arguments to UTF-8
-  std::vector argvStrings(argc);
-  std::vector argvPointers(argc);
-  for (int i = 0; i != argc; ++i) {
-llvm::convertWideToUTF8(wargv[i], argvStrings[i]);
-argvPointers[i] = argvStrings[i].c_str();
-  }
-  const char **argv = argvPointers.data();
-#endif
+  llvm::InitLLVM IL(argc, argv);
 
   // Print stack trace on crash.
   llvm::StringRef ToolName = llvm::sys::path::filename(argv[0]);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread David CARLIER via Phabricator via lldb-commits
devnexen added a comment.

@dim I LGTMed this but would it a real issue for you to take on a less 
disruptive approach proposed by MaskRay ?


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [lldb] r374299 - s/@expectedFailure/@expectedFailureAll in TestFileHandle

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 02:52:32 2019
New Revision: 374299

URL: http://llvm.org/viewvc/llvm-project?rev=374299&view=rev
Log:
s/@expectedFailure/@expectedFailureAll in TestFileHandle

The test isn't using @expectedFailure correctly, which causes weird
errors, at least with python2, at least with linux. Possibly that
function shouldn't even be public as it's main use is as a backed for
other decorators.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374299&r1=374298&r2=374299&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Thu Oct 10 02:52:32 2019
@@ -12,8 +12,7 @@ from contextlib import contextmanager
 
 import lldb
 from lldbsuite.test import  lldbtest
-from lldbsuite.test.decorators import (
-add_test_categories, skipIf, skipIfWindows, expectedFailure)
+from lldbsuite.test.decorators import *
 
 class OhNoe(Exception):
 pass
@@ -400,7 +399,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME IOHandler still using FILE*
+@expectedFailureAll() # FIXME IOHandler still using FILE*
 def test_string_inout(self):
 inf = io.StringIO("help help\n")
 outf = io.StringIO()
@@ -416,7 +415,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME IOHandler still using FILE*
+@expectedFailureAll() # FIXME IOHandler still using FILE*
 def test_bytes_inout(self):
 inf = io.BytesIO(b"help help\nhelp b\n")
 outf = io.BytesIO()
@@ -462,7 +461,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure #FIXME bug in ScriptInterpreterPython
+@expectedFailureAll() #FIXME bug in ScriptInterpreterPython
 def test_replace_stdout_with_nonfile(self):
 debugger = self.debugger
 f = io.StringIO()
@@ -550,7 +549,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailure # fixme multiple problems with this
+@expectedFailureAll() # fixme multiple problems with this
 def test_string_out(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)
@@ -560,7 +559,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME need FileSP version of SBDebugger::SetErrorFile
+@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 @skipIf(py_version=['<', (3,)])
 def test_string_error(self):
 f = io.StringIO()
@@ -631,7 +630,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME need FileSP version of SBDebugger::SetErrorFile
+@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 @skipIf(py_version=['<', (3,)])
 def test_file_out(self):
 with open(self.out_filename, 'w') as f:
@@ -655,7 +654,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME need FileSP version of SBDebugger::SetErrorFile
+@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 def test_file_error(self):
 with open(self.out_filename, 'w') as f:
 status = self.debugger.SetErrorFile(f)
@@ -747,7 +746,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME need FileSP version of SBDebugger::SetOutputFile
+@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetOutputFile
 def test_close(self):
 debugger = self.debugger
 with open(self.out_filename, 'w') as f:
@@ -768,7 +767,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailure # FIXME need FileSP version of SBDebugger::SetOutputFile
+@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetOutputFile
 def test_stdout(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)
@@ -778,7 +777,7 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME implement SBFile::GetFile
+@expectedFailureAll() # FIXME implement SBFile::GetFile
 @skipIf(py_version=['<', (3,)])
 def test_identity(self):
 


___
lldb-commits 

[Lldb-commits] [PATCH] D68773: [lldb] Fix out of bounds read in DataExtractor::GetCStr and add actually unit test that function.

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

The `if (*cstr_end == '\0')` in the previous code checked if the previous loop 
terminated because it
found a null terminator or because it reached the end of the data. However, in 
the case that we hit
the end of the data before finding a null terminator, `cstr_end` points behind 
the last byte in our
data and `*cstr_end` reads the memory behind the array (which may be 
uninitialised)

This patch just rewrites that function use `std::find` and adds the relevant 
unit tests.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68773

Files:
  lldb/source/Utility/DataExtractor.cpp
  lldb/unittests/Utility/DataExtractorTest.cpp

Index: lldb/unittests/Utility/DataExtractorTest.cpp
===
--- lldb/unittests/Utility/DataExtractorTest.cpp
+++ lldb/unittests/Utility/DataExtractorTest.cpp
@@ -49,6 +49,51 @@
   EXPECT_EQ(nullptr, E.PeekData(4, 1));
 }
 
+TEST(DataExtractorTest, GetCStr) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(5U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrEmpty) {
+  uint8_t buffer[] = {'X', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("", E.GetCStr(&offset));
+  EXPECT_EQ(2U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrUnterminated) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtEnd) {
+  uint8_t buffer[] = {'X'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtNullOffset) {
+  uint8_t buffer[] = {'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 0;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(4U, offset);
+}
+
 TEST(DataExtractorTest, GetMaxU64) {
   uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
   DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -816,26 +816,25 @@
 // non-zero and there aren't enough available bytes, nullptr will be returned
 // and "offset_ptr" will not be updated.
 const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
-  const char *cstr = reinterpret_cast(PeekData(*offset_ptr, 1));
-  if (cstr) {
-const char *cstr_end = cstr;
-const char *end = reinterpret_cast(m_end);
-while (cstr_end < end && *cstr_end)
-  ++cstr_end;
-
-// Now we are either at the end of the data or we point to the
-// NULL C string terminator with cstr_end...
-if (*cstr_end == '\0') {
-  // Advance the offset with one extra byte for the NULL terminator
-  *offset_ptr += (cstr_end - cstr + 1);
-  return cstr;
-}
+  const char *start = reinterpret_cast(PeekData(*offset_ptr, 1));
+  // Already at the end of the data.
+  if (!start)
+return nullptr;
 
-// We reached the end of the data without finding a NULL C string
-// terminator. Fall through and return nullptr otherwise anyone that would
-// have used the result as a C string can wander into unknown memory...
-  }
-  return nullptr;
+  const char *end = reinterpret_cast(m_end);
+
+  // Check all bytes for a null terminator that terminates a C string.
+  const char *terminator_or_end = std::find(start, end, '\0');
+
+  // We didn't find a null terminator, so return nullptr to indicate that there
+  // is no valid C string at that offset.
+  if (terminator_or_end == end)
+return nullptr;
+
+  // Update offset_ptr for the caller to point to the data behind the
+  // terminator (which is 1 byte long).
+  *offset_ptr += (terminator_or_end - start + 1UL);
+  return start;
 }
 
 // Extracts a NULL terminated C string from the fixed length field of length
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D68723#1703322 , @devnexen wrote:

> @dim I LGTMed this but would it a real issue for you to take on a less 
> disruptive approach proposed by MaskRay ?


I think we should do what @labath suggested (changing Expected to Optional) if 
that is not very difficult.


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Thanks for the explanation! Doesn't seem like removing this breaks Swift, so 
I'll land this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68696



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


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread David CARLIER via Phabricator via lldb-commits
devnexen added a comment.

In D68723#1703379 , @MaskRay wrote:

> In D68723#1703322 , @devnexen wrote:
>
> > @dim I LGTMed this but would it a real issue for you to take on a less 
> > disruptive approach proposed by MaskRay ?
>
>
> I think we should do what @labath suggested (changing Expected to Optional) 
> if that is not very difficult.


Good point, I missed it. Should be alright to.


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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [lldb] r374307 - [lldb][NFC] Use llvm::all_of instead of std::all_of in CppModuleConfiguration

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 03:56:12 2019
New Revision: 374307

URL: http://llvm.org/viewvc/llvm-project?rev=374307&view=rev
Log:
[lldb][NFC] Use llvm::all_of instead of std::all_of in CppModuleConfiguration

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp?rev=374307&r1=374306&r2=374307&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
Thu Oct 10 03:56:12 2019
@@ -63,9 +63,9 @@ bool CppModuleConfiguration::hasValidCon
 CppModuleConfiguration::CppModuleConfiguration(
 const FileSpecList &support_files) {
   // Analyze all files we were given to build the configuration.
-  bool error = !std::all_of(support_files.begin(), support_files.end(),
-std::bind(&CppModuleConfiguration::analyzeFile,
-  this, std::placeholders::_1));
+  bool error = !llvm::all_of(support_files,
+ std::bind(&CppModuleConfiguration::analyzeFile,
+   this, std::placeholders::_1));
   // If we have a valid configuration at this point, set the
   // include directories and module list that should be used.
   if (!error && hasValidConfig()) {


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


[Lldb-commits] [lldb] r374311 - [lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 04:15:38 2019
New Revision: 374311

URL: http://llvm.org/viewvc/llvm-project?rev=374311&view=rev
Log:
[lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that 
function.

Summary:
The `if (*cstr_end == '\0')` in the previous code checked if the previous loop 
terminated because it
found a null terminator or because it reached the end of the data. However, in 
the case that we hit
the end of the data before finding a null terminator, `cstr_end` points behind 
the last byte in our
data and `*cstr_end` reads the memory behind the array (which may be 
uninitialised)

This patch just rewrites that function use `std::find` and adds the relevant 
unit tests.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Utility/DataExtractor.cpp
lldb/trunk/unittests/Utility/DataExtractorTest.cpp

Modified: lldb/trunk/source/Utility/DataExtractor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/DataExtractor.cpp?rev=374311&r1=374310&r2=374311&view=diff
==
--- lldb/trunk/source/Utility/DataExtractor.cpp (original)
+++ lldb/trunk/source/Utility/DataExtractor.cpp Thu Oct 10 04:15:38 2019
@@ -816,26 +816,25 @@ DataExtractor::CopyByteOrderedData(offse
 // non-zero and there aren't enough available bytes, nullptr will be returned
 // and "offset_ptr" will not be updated.
 const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
-  const char *cstr = reinterpret_cast(PeekData(*offset_ptr, 1));
-  if (cstr) {
-const char *cstr_end = cstr;
-const char *end = reinterpret_cast(m_end);
-while (cstr_end < end && *cstr_end)
-  ++cstr_end;
+  const char *start = reinterpret_cast(PeekData(*offset_ptr, 1));
+  // Already at the end of the data.
+  if (!start)
+return nullptr;
 
-// Now we are either at the end of the data or we point to the
-// NULL C string terminator with cstr_end...
-if (*cstr_end == '\0') {
-  // Advance the offset with one extra byte for the NULL terminator
-  *offset_ptr += (cstr_end - cstr + 1);
-  return cstr;
-}
+  const char *end = reinterpret_cast(m_end);
 
-// We reached the end of the data without finding a NULL C string
-// terminator. Fall through and return nullptr otherwise anyone that would
-// have used the result as a C string can wander into unknown memory...
-  }
-  return nullptr;
+  // Check all bytes for a null terminator that terminates a C string.
+  const char *terminator_or_end = std::find(start, end, '\0');
+
+  // We didn't find a null terminator, so return nullptr to indicate that there
+  // is no valid C string at that offset.
+  if (terminator_or_end == end)
+return nullptr;
+
+  // Update offset_ptr for the caller to point to the data behind the
+  // terminator (which is 1 byte long).
+  *offset_ptr += (terminator_or_end - start + 1UL);
+  return start;
 }
 
 // Extracts a NULL terminated C string from the fixed length field of length

Modified: lldb/trunk/unittests/Utility/DataExtractorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/DataExtractorTest.cpp?rev=374311&r1=374310&r2=374311&view=diff
==
--- lldb/trunk/unittests/Utility/DataExtractorTest.cpp (original)
+++ lldb/trunk/unittests/Utility/DataExtractorTest.cpp Thu Oct 10 04:15:38 2019
@@ -49,6 +49,51 @@ TEST(DataExtractorTest, PeekData) {
   EXPECT_EQ(nullptr, E.PeekData(4, 1));
 }
 
+TEST(DataExtractorTest, GetCStr) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(5U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrEmpty) {
+  uint8_t buffer[] = {'X', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("", E.GetCStr(&offset));
+  EXPECT_EQ(2U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrUnterminated) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtEnd) {
+  uint8_t buffer[] = {'X'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtNullOffset) {
+  uint8_t buffer[] = {'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 0;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(4U, offset);
+}
+
 TEST(D

[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-10 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:111
+
+  explicit MemoryInfoListStream(std::vector Infos)
+  : Stream(StreamKind::MemoryInfoList,

grimar wrote:
> Maybe be more explicit here, i.e.
> 
> ```
> std::vector &&Infos
> ```
> ?
Or let the constructor take `iterator_range` 
as the argument, and change the call site below.



Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:116
+
+  MemoryInfoListStream()
+  : Stream(StreamKind::MemoryInfoList,

Move default constructor above.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68773: [lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG067bb1f546ef: [lldb] Fix out of bounds read in 
DataExtractor::GetCStr and add unit test that… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68773

Files:
  lldb/source/Utility/DataExtractor.cpp
  lldb/unittests/Utility/DataExtractorTest.cpp

Index: lldb/unittests/Utility/DataExtractorTest.cpp
===
--- lldb/unittests/Utility/DataExtractorTest.cpp
+++ lldb/unittests/Utility/DataExtractorTest.cpp
@@ -49,6 +49,51 @@
   EXPECT_EQ(nullptr, E.PeekData(4, 1));
 }
 
+TEST(DataExtractorTest, GetCStr) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(5U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrEmpty) {
+  uint8_t buffer[] = {'X', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_STREQ("", E.GetCStr(&offset));
+  EXPECT_EQ(2U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrUnterminated) {
+  uint8_t buffer[] = {'X', 'f', 'o', 'o'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtEnd) {
+  uint8_t buffer[] = {'X'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 1;
+  EXPECT_EQ(nullptr, E.GetCStr(&offset));
+  EXPECT_EQ(1U, offset);
+}
+
+TEST(DataExtractorTest, GetCStrAtNullOffset) {
+  uint8_t buffer[] = {'f', 'o', 'o', '\0'};
+  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+  lldb::offset_t offset = 0;
+  EXPECT_STREQ("foo", E.GetCStr(&offset));
+  EXPECT_EQ(4U, offset);
+}
+
 TEST(DataExtractorTest, GetMaxU64) {
   uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
   DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -816,26 +816,25 @@
 // non-zero and there aren't enough available bytes, nullptr will be returned
 // and "offset_ptr" will not be updated.
 const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
-  const char *cstr = reinterpret_cast(PeekData(*offset_ptr, 1));
-  if (cstr) {
-const char *cstr_end = cstr;
-const char *end = reinterpret_cast(m_end);
-while (cstr_end < end && *cstr_end)
-  ++cstr_end;
-
-// Now we are either at the end of the data or we point to the
-// NULL C string terminator with cstr_end...
-if (*cstr_end == '\0') {
-  // Advance the offset with one extra byte for the NULL terminator
-  *offset_ptr += (cstr_end - cstr + 1);
-  return cstr;
-}
+  const char *start = reinterpret_cast(PeekData(*offset_ptr, 1));
+  // Already at the end of the data.
+  if (!start)
+return nullptr;
 
-// We reached the end of the data without finding a NULL C string
-// terminator. Fall through and return nullptr otherwise anyone that would
-// have used the result as a C string can wander into unknown memory...
-  }
-  return nullptr;
+  const char *end = reinterpret_cast(m_end);
+
+  // Check all bytes for a null terminator that terminates a C string.
+  const char *terminator_or_end = std::find(start, end, '\0');
+
+  // We didn't find a null terminator, so return nullptr to indicate that there
+  // is no valid C string at that offset.
+  if (terminator_or_end == end)
+return nullptr;
+
+  // Update offset_ptr for the caller to point to the data behind the
+  // terminator (which is 1 byte long).
+  *offset_ptr += (terminator_or_end - start + 1UL);
+  return start;
 }
 
 // Extracts a NULL terminated C string from the fixed length field of length
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374313 - [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 04:26:51 2019
New Revision: 374313

URL: http://llvm.org/viewvc/llvm-project?rev=374313&view=rev
Log:
[lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

Summary:
The SearchCallback has a bool parameter that we always set to false, we never 
use in any callback implementation and that also changes its name
from one file to the other (either `containing` and `complete`). It was added 
in the original LLDB check in, so there isn't any history what
this was supposed to be, so let's just remove it.

Reviewers: jingham, JDevlieghere, labath

Reviewed By: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h
lldb/trunk/include/lldb/Core/AddressResolverFileLine.h
lldb/trunk/include/lldb/Core/AddressResolverName.h
lldb/trunk/include/lldb/Core/FileLineResolver.h
lldb/trunk/include/lldb/Core/SearchFilter.h
lldb/trunk/include/lldb/Interpreter/CommandCompletions.h
lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Core/AddressResolverFileLine.cpp
lldb/trunk/source/Core/AddressResolverName.cpp
lldb/trunk/source/Core/FileLineResolver.cpp
lldb/trunk/source/Core/SearchFilter.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
lldb/trunk/source/Target/LanguageRuntime.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h?rev=374313&r1=374312&r2=374313&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h Thu Oct 10 
04:26:51 2019
@@ -41,8 +41,8 @@ public:
   ModuleList &modules) override;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address 
*addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override;
 

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h?rev=374313&r1=374312&r2=374313&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h Thu Oct 10 
04:26:51 2019
@@ -35,8 +35,8 @@ public:
   ~BreakpointResolverFileLine() override;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address 
*addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override;
 

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h?rev=374313&r1=374312&r2=374313&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h Thu Oct 10 
04:26:51 2019
@@ -37,8 +37,8 @@ public:
   ~BreakpointResolverFileRegex() override;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address 
*addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDep

[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95e264fc8a93: [lldb][NFC] Remove strange bool parameter from 
Searcher::SearchCallback (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68696

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Core/AddressResolverFileLine.h
  lldb/include/lldb/Core/AddressResolverName.h
  lldb/include/lldb/Core/FileLineResolver.h
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Core/AddressResolverFileLine.cpp
  lldb/source/Core/AddressResolverName.cpp
  lldb/source/Core/FileLineResolver.cpp
  lldb/source/Core/SearchFilter.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp

Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -111,12 +111,11 @@
   ~ExceptionBreakpointResolver() override = default;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override {
+  SymbolContext &context,
+  Address *addr) override {
 
 if (SetActualResolver())
-  return m_actual_resolver_sp->SearchCallback(filter, context, addr,
-  containing);
+  return m_actual_resolver_sp->SearchCallback(filter, context, addr);
 else
   return eCallbackReturnStop;
   }
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -67,8 +67,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
@@ -117,8 +117,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
@@ -262,8 +262,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -790,7 +790,7 @@
 // symbol.
 Searcher::CallbackReturn
 RSBreakpointResolver::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *, bool) {
+ SymbolContext &context,

[Lldb-commits] [lldb] r374322 - TestFileHandle.py: relax exception type checks

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 05:07:30 2019
New Revision: 374322

URL: http://llvm.org/viewvc/llvm-project?rev=374322&view=rev
Log:
TestFileHandle.py: relax exception type checks

the exceptions returned differ between swig4 (TypeError) and swig<=3
(NotImplementedError). Just check for the base Exception class instead.

Theoretically we could switch on the swig version and expect the precise
type directly, but checking the exact type does not seem that important.

Thanks to Raphael for helping me figure this out.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374322&r1=374321&r2=374322&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Thu Oct 10 05:07:30 2019
@@ -667,10 +667,10 @@ class FileHandleTestCase(lldbtest.TestBa
 
 @add_test_categories(['pyapi'])
 def test_exceptions(self):
-self.assertRaises(TypeError, lldb.SBFile, None)
-self.assertRaises(TypeError, lldb.SBFile, "ham sandwich")
+self.assertRaises(Exception, lldb.SBFile, None)
+self.assertRaises(Exception, lldb.SBFile, "ham sandwich")
 if sys.version_info[0] < 3:
-self.assertRaises(TypeError, lldb.SBFile, ReallyBadIO())
+self.assertRaises(Exception, lldb.SBFile, ReallyBadIO())
 else:
 self.assertRaises(OhNoe, lldb.SBFile, ReallyBadIO())
 error, n = lldb.SBFile(BadIO()).Write(b"FOO")


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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Fixed now by rL374322 , there was a 
regression - Linux Fedora 30 x86_64:

  ==
  ERROR: test_exceptions (TestFileHandle.FileHandleTestCase)
  --
  Traceback (most recent call last):
File 
"/home/jkratoch/redhat/llvm-monorepo2/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py",
 line 483, in test_exceptions
  self.assertRaises(TypeError, lldb.SBFile, None)
File 
"/home/jkratoch/redhat/llvm-monorepo2/lldb/third_party/Python/module/unittest2/unittest2/case.py",
 line 534, in assertRaises
  callableObj(*args, **kwargs)
File 
"/home/jkratoch/redhat/llvm-monorepo2-clangassert/lib/python2.7/site-packages/lldb/__init__.py",
 line 5334, in __init__
  this = _lldb.new_SBFile(*args)
  NotImplementedError: Wrong number or type of arguments for overloaded 
function 'new_SBFile'.
Possible C/C++ prototypes are:
  lldb::SBFile::SBFile()
  lldb::SBFile::SBFile(int,char const *,bool)
  lldb::SBFile::SBFile(lldb::FileSP)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [lldb] r374325 - [Windows] Introduce a switch for the `lldb-server` mode on Windows

2019-10-10 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Thu Oct 10 05:21:04 2019
New Revision: 374325

URL: http://llvm.org/viewvc/llvm-project?rev=374325&view=rev
Log:
[Windows] Introduce a switch for the `lldb-server` mode on Windows

Summary:
This patch introduces a switch, based on the environment variable
`LLDB_USE_LLDB_SERVER`, to determine whether to use the `ProcessWindows` plugin
(the old way) or the `lldb-server` way for debugging on Windows.

Reviewers: labath, amccarth, asmith, stella.stamenova

Reviewed By: labath, amccarth

Subscribers: mstorsjo, abidh, JDevlieghere, lldb-commits, leonid.mashinskiy

Tags: #lldb

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

Modified:
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=374325&r1=374324&r2=374325&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Thu Oct 
10 05:21:04 2019
@@ -81,13 +81,24 @@ ProcessSP ProcessWindows::CreateInstance
   return ProcessSP(new ProcessWindows(target_sp, listener_sp));
 }
 
+static bool ShouldUseLLDBServer() {
+  llvm::StringRef use_lldb_server = ::getenv("LLDB_USE_LLDB_SERVER");
+  return use_lldb_server.equals_lower("on") ||
+ use_lldb_server.equals_lower("yes") ||
+ use_lldb_server.equals_lower("1") ||
+ use_lldb_server.equals_lower("true");
+}
+
 void ProcessWindows::Initialize() {
-  static llvm::once_flag g_once_flag;
+  if (!ShouldUseLLDBServer()) {
+static llvm::once_flag g_once_flag;
 
-  llvm::call_once(g_once_flag, []() {
-PluginManager::RegisterPlugin(GetPluginNameStatic(),
-  GetPluginDescriptionStatic(), 
CreateInstance);
-  });
+llvm::call_once(g_once_flag, []() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(),
+CreateInstance);
+});
+  }
 }
 
 void ProcessWindows::Terminate() {}


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


[Lldb-commits] [PATCH] D68258: [Windows] Introduce a switch for the `lldb-server` mode on Windows

2019-10-10 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0891366571b2: [Windows] Introduce a switch for the 
`lldb-server` mode on Windows (authored by aleksandr.urakov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68258

Files:
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -81,13 +81,24 @@
   return ProcessSP(new ProcessWindows(target_sp, listener_sp));
 }
 
-void ProcessWindows::Initialize() {
-  static llvm::once_flag g_once_flag;
+static bool ShouldUseLLDBServer() {
+  llvm::StringRef use_lldb_server = ::getenv("LLDB_USE_LLDB_SERVER");
+  return use_lldb_server.equals_lower("on") ||
+ use_lldb_server.equals_lower("yes") ||
+ use_lldb_server.equals_lower("1") ||
+ use_lldb_server.equals_lower("true");
+}
 
-  llvm::call_once(g_once_flag, []() {
-PluginManager::RegisterPlugin(GetPluginNameStatic(),
-  GetPluginDescriptionStatic(), 
CreateInstance);
-  });
+void ProcessWindows::Initialize() {
+  if (!ShouldUseLLDBServer()) {
+static llvm::once_flag g_once_flag;
+
+llvm::call_once(g_once_flag, []() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(),
+CreateInstance);
+});
+  }
 }
 
 void ProcessWindows::Terminate() {}


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -81,13 +81,24 @@
   return ProcessSP(new ProcessWindows(target_sp, listener_sp));
 }
 
-void ProcessWindows::Initialize() {
-  static llvm::once_flag g_once_flag;
+static bool ShouldUseLLDBServer() {
+  llvm::StringRef use_lldb_server = ::getenv("LLDB_USE_LLDB_SERVER");
+  return use_lldb_server.equals_lower("on") ||
+ use_lldb_server.equals_lower("yes") ||
+ use_lldb_server.equals_lower("1") ||
+ use_lldb_server.equals_lower("true");
+}
 
-  llvm::call_once(g_once_flag, []() {
-PluginManager::RegisterPlugin(GetPluginNameStatic(),
-  GetPluginDescriptionStatic(), CreateInstance);
-  });
+void ProcessWindows::Initialize() {
+  if (!ShouldUseLLDBServer()) {
+static llvm::once_flag g_once_flag;
+
+llvm::call_once(g_once_flag, []() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(),
+CreateInstance);
+});
+  }
 }
 
 void ProcessWindows::Terminate() {}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374331 - File: Handle more cases in GetOptionsFromMode

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 05:40:27 2019
New Revision: 374331

URL: http://llvm.org/viewvc/llvm-project?rev=374331&view=rev
Log:
File: Handle more cases in GetOptionsFromMode

The "b" (binary) flag is meaningless most of the time, but the relevant
standars allow it. The standards permit one to spell it both as "r+b"
and "rb+", so handle both cases.

This fixes TestFileHandle.test_binary_inout with python2.

Modified:
lldb/trunk/source/Host/common/File.cpp

Modified: lldb/trunk/source/Host/common/File.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=374331&r1=374330&r2=374331&view=diff
==
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Thu Oct 10 05:40:27 2019
@@ -70,15 +70,17 @@ static const char *GetStreamOpenModeFrom
 
 uint32_t File::GetOptionsFromMode(llvm::StringRef mode) {
   return llvm::StringSwitch(mode)
-  .Case("r", File::eOpenOptionRead)
-  .Case("w", File::eOpenOptionWrite)
-  .Case("a", File::eOpenOptionWrite | File::eOpenOptionAppend |
- File::eOpenOptionCanCreate)
-  .Case("r+", File::eOpenOptionRead | File::eOpenOptionWrite)
-  .Case("w+", File::eOpenOptionRead | File::eOpenOptionWrite |
-  File::eOpenOptionCanCreate | File::eOpenOptionTruncate)
-  .Case("a+", File::eOpenOptionRead | File::eOpenOptionWrite |
-  File::eOpenOptionAppend | File::eOpenOptionCanCreate)
+  .Cases("r", "rb", eOpenOptionRead)
+  .Cases("w", "wb", eOpenOptionWrite)
+  .Cases("a", "ab",
+ eOpenOptionWrite | eOpenOptionAppend | eOpenOptionCanCreate)
+  .Cases("r+", "rb+", "r+b", eOpenOptionRead | eOpenOptionWrite)
+  .Cases("w+", "wb+", "w+b",
+ eOpenOptionRead | eOpenOptionWrite | eOpenOptionCanCreate |
+ eOpenOptionTruncate)
+  .Cases("a+", "ab+", "a+b",
+ eOpenOptionRead | eOpenOptionWrite | eOpenOptionAppend |
+ eOpenOptionCanCreate)
   .Default(0);
 }
 


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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Yeah, as Jan mentions, I've had to make some tweaks (r374331, r374322, r374299) 
in order to get this passing on all python and swig versions. Let me know if 
you have questions/issues/etc about any of those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [lldb] r374335 - [lldb] Make sure import-std-module/sysroot actually passes for the right reasons

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 05:57:14 2019
New Revision: 374335

URL: http://llvm.org/viewvc/llvm-project?rev=374335&view=rev
Log:
[lldb] Make sure import-std-module/sysroot actually passes for the right reasons

This test was previously passing because myabs was actually emitted into the
debug information and we called that. The test itself was broken as it didn't
use the libc++ directory structure (the /v1/ directory was just called 
/include/).

This patch gives myabs a default argument which we can't get from debug 
information
and inlines the function to make sure we can't call it from LLDB without loading
the C++ module.

Added:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap
Removed:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/
Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile?rev=374335&r1=374334&r2=374335&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 Thu Oct 10 05:57:14 2019
@@ -3,7 +3,7 @@
 # system headers.
 NO_TEST_COMMON_H := 1
 
-CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/include/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
+CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
 CXX_SOURCES := main.cpp
 
 include Makefile.rules

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py?rev=374335&r1=374334&r2=374335&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
 Thu Oct 10 05:57:14 2019
@@ -27,4 +27,6 @@ class ImportStdModule(TestBase):
 
 # Call our custom function in our sysroot std module.
 # If this gives us the correct result, then we used the sysroot.
-self.expect("expr std::myabs(-42)", substrs=['(int) $0 = 42'])
+# We rely on the default argument of -123 to make sure we actually 
have the C++ module.
+# (We don't have default arguments in the debug information).
+self.expect("expr std::myabs()", substrs=['(int) $0 = 123'])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp?rev=374335&r1=374334&r2=374335&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
 Thu Oct 10 05:57:14 2019
@@ -2,5 +2,6 @@
 
 int main(int argc, char **argv) {
   libc_struct s;
+  std::vector v;
   return 0; // Set break point at this line.
 }

Added: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c%2B%2B/v1/algorithm?rev=374335&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/incl

[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 3 inline comments as done.
labath added inline comments.



Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:116
+
+  MemoryInfoListStream()
+  : Stream(StreamKind::MemoryInfoList,

MaskRay wrote:
> Move default constructor above.
Done, I've also moved the constructor of SystemInfoStream for consistency.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rG3aa7e76677f1: MinidumpYAML: Add support for the memory info 
list stream (authored by labath).
Herald added a subscriber: hiraditya.

Changed prior to commit:
  https://reviews.llvm.org/D68645?vs=224065&id=224327#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68645

Files:
  llvm/include/llvm/BinaryFormat/Minidump.h
  llvm/include/llvm/ObjectYAML/MinidumpYAML.h
  llvm/lib/ObjectYAML/MinidumpEmitter.cpp
  llvm/lib/ObjectYAML/MinidumpYAML.cpp
  llvm/test/tools/obj2yaml/basic-minidump.yaml

Index: llvm/test/tools/obj2yaml/basic-minidump.yaml
===
--- llvm/test/tools/obj2yaml/basic-minidump.yaml
+++ llvm/test/tools/obj2yaml/basic-minidump.yaml
@@ -55,6 +55,27 @@
 Memory Ranges:   
   - Start of Memory Range: 0x7C7D7E7F80818283
 Content:   '8485868788'
+  - Type:MemoryInfoList
+Memory Ranges:
+  - Base Address:0x
+Allocation Protect: [  ]
+Region Size: 0x0001
+State:   [ MEM_FREE ]
+Protect: [ PAGE_NO_ACCESS ]
+Type:[  ]
+  - Base Address:0x0001
+Allocation Protect: [ PAGE_READ_WRITE ]
+Region Size: 0x0001
+State:   [ MEM_COMMIT ]
+Type:[ MEM_MAPPED ]
+  - Base Address:0x0002
+Allocation Base: 0x
+Allocation Protect: [ PAGE_READ_WRITE, PAGE_WRITECOMBINE ]
+Reserved0:   0xDEADBEEF
+Region Size: 0x0001
+State:   [ MEM_COMMIT, MEM_FREE ]
+Type:[ MEM_PRIVATE, MEM_MAPPED ]
+Reserved1:   0xBAADF00D
 ...
 
 # CHECK:  --- !minidump
@@ -112,4 +133,25 @@
 # CHECK-NEXT: Memory Ranges:   
 # CHECK-NEXT:   - Start of Memory Range: 0x7C7D7E7F80818283
 # CHECK-NEXT: Content:   '8485868788'
+# CHECK-NEXT:   - Type:MemoryInfoList
+# CHECK-NEXT: Memory Ranges:
+# CHECK-NEXT:   - Base Address:   0x
+# CHECK-NEXT: Allocation Protect: [  ]
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_FREE ]
+# CHECK-NEXT: Protect:[ PAGE_NO_ACCESS ]
+# CHECK-NEXT: Type:   [  ]
+# CHECK-NEXT:   - Base Address:   0x0001
+# CHECK-NEXT: Allocation Protect: [ PAGE_READ_WRITE ]
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_COMMIT ]
+# CHECK-NEXT: Type:   [ MEM_MAPPED ]
+# CHECK-NEXT:   - Base Address:   0x0002
+# CHECK-NEXT: Allocation Base:0x
+# CHECK-NEXT: Allocation Protect: [ PAGE_READ_WRITE, PAGE_WRITECOMBINE ]
+# CHECK-NEXT: Reserved0:  0xDEADBEEF
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_COMMIT, MEM_FREE ]
+# CHECK-NEXT: Type:   [ MEM_PRIVATE, MEM_MAPPED ]
+# CHECK-NEXT: Reserved1:  0xBAADF00D
 # CHECK-NEXT: ...
Index: llvm/lib/ObjectYAML/MinidumpYAML.cpp
===
--- llvm/lib/ObjectYAML/MinidumpYAML.cpp
+++ llvm/lib/ObjectYAML/MinidumpYAML.cpp
@@ -69,6 +69,8 @@
 
 Stream::StreamKind Stream::getKind(StreamType Type) {
   switch (Type) {
+  case StreamType::MemoryInfoList:
+return StreamKind::MemoryInfoList;
   case StreamType::MemoryList:
 return StreamKind::MemoryList;
   case StreamType::ModuleList:
@@ -93,6 +95,8 @@
 std::unique_ptr Stream::create(StreamType Type) {
   StreamKind Kind = getKind(Type);
   switch (Kind) {
+  case StreamKind::MemoryInfoList:
+return std::make_unique();
   case StreamKind::MemoryList:
 return std::make_unique();
   case StreamKind::ModuleList:
@@ -109,6 +113,25 @@
   llvm_unreachable("Unhandled stream kind!");
 }
 
+void yaml::ScalarBitSetTraits::bitset(
+IO &IO, MemoryProtection &Protect) {
+#define HANDLE_MDMP_PROTECT(CODE, NAME, NATIVENAME)\
+  IO.bitSetCase(Protect, #NATIVENAME, MemoryProtection::NAME);
+#include "llvm/BinaryFormat/MinidumpConstants.def"
+}
+
+void yaml::ScalarBitSetTraits::bitset(IO &IO, MemoryState &State) {
+#define HANDLE_MDMP_MEMSTATE(CODE, NAME, NATIVENAME)   \
+  IO.bitSetCase(State, #NATIVENAME, MemoryState::NAME);
+#include "llvm/BinaryFormat/MinidumpConstants.def"
+}
+
+void yaml::ScalarBitSetTraits::bitset(IO &IO, MemoryType &Type) {
+#define HANDLE_MDMP_MEMTYPE(CODE, NAME, NATIVENAME)\
+  IO.bitSetCase(Type, #NA

[Lldb-commits] [lldb] r374341 - Fix some dangling else warnings

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 06:23:02 2019
New Revision: 374341

URL: http://llvm.org/viewvc/llvm-project?rev=374341&view=rev
Log:
Fix some dangling else warnings

EXPECT_EQ contains an if-else statement. It also contains some magic to
suppress the dangling else warnings, but it seems that some new
compilers can see through that...

Modified:
lldb/trunk/unittests/Process/minidump/RegisterContextMinidumpTest.cpp

Modified: lldb/trunk/unittests/Process/minidump/RegisterContextMinidumpTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/minidump/RegisterContextMinidumpTest.cpp?rev=374341&r1=374340&r2=374341&view=diff
==
--- lldb/trunk/unittests/Process/minidump/RegisterContextMinidumpTest.cpp 
(original)
+++ lldb/trunk/unittests/Process/minidump/RegisterContextMinidumpTest.cpp Thu 
Oct 10 06:23:02 2019
@@ -157,33 +157,34 @@ static void TestARMRegInfo(const lldb_pr
 EXPECT_NE(info->kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM);
   }
   // Verify generic register are set correctly
-  if (name == "r0")
+  if (name == "r0") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_ARG1);
-  else if (name == "r1")
+  } else if (name == "r1") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_ARG2);
-  else if (name == "r2")
+  } else if (name == "r2") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_ARG3);
-  else if (name == "r3")
+  } else if (name == "r3") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_ARG4);
-  else if (name == "sp")
+  } else if (name == "sp") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_SP);
-  else if (name == "fp")
+  } else if (name == "fp") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_FP);
-  else if (name == "lr")
+  } else if (name == "lr") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_RA);
-  else if (name == "pc")
+  } else if (name == "pc") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_PC);
-  else if (name == "cpsr")
+  } else if (name == "cpsr") {
 EXPECT_EQ(info->kinds[lldb::eRegisterKindGeneric],
   (uint32_t)LLDB_REGNUM_GENERIC_FLAGS);
+  }
 }
 
 TEST(RegisterContextMinidump, CheckRegisterContextMinidump_ARM) {


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


[Lldb-commits] [lldb] r374342 - Fix the unwinding plan augmentation from x86 assembly

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 06:23:09 2019
New Revision: 374342

URL: http://llvm.org/viewvc/llvm-project?rev=374342&view=rev
Log:
Fix the unwinding plan augmentation from x86 assembly

Unwind plan augmentation should compute the plan row at offset x from
the instruction before offset x, but currently we compute it from the
instruction at offset x. Note that this behavior is a regression
introduced when moving the x86 assembly inspection engine to its own
file
(https://github.com/llvm/llvm-project/commit/1c9858b298d79ce82c45a2954096718b39550109#diff-375a2be066db6f34bb9a71442c9b71fcL913);
the original version handled this properly by copying the previous
instruction out before advancing the instruction pointer.

The relevant bug with more info is here: 
https://bugs.llvm.org/show_bug.cgi?id=43561

Differential Revision: https://reviews.llvm.org/D68454
Patch by Jaroslav Sevcik .

Modified:
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Modified: 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp?rev=374342&r1=374341&r2=374342&view=diff
==
--- 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
Thu Oct 10 06:23:09 2019
@@ -1371,7 +1371,6 @@ bool x86AssemblyInspectionEngine::Augmen
   int row_id = 1;
   bool unwind_plan_updated = false;
   UnwindPlan::RowSP row(new UnwindPlan::Row(*first_row));
-  m_cur_insn = data + offset;
 
   // After a mid-function epilogue we will need to re-insert the original
   // unwind rules so unwinds work for the remainder of the function.  These
@@ -1381,19 +1380,17 @@ bool x86AssemblyInspectionEngine::Augmen
   while (offset < size) {
 m_cur_insn = data + offset;
 int insn_len;
-if (!instruction_length(m_cur_insn, insn_len, size - offset)
-|| insn_len == 0 
-|| insn_len > kMaxInstructionByteSize) {
+if (!instruction_length(m_cur_insn, insn_len, size - offset) ||
+insn_len == 0 || insn_len > kMaxInstructionByteSize) {
   // An unrecognized/junk instruction.
   break;
 }
 
 // Advance offsets.
 offset += insn_len;
-m_cur_insn = data + offset;
 
 // offset is pointing beyond the bounds of the function; stop looping.
-if (offset >= size) 
+if (offset >= size)
   continue;
 
 if (reinstate_unwind_state) {
@@ -1547,16 +1544,18 @@ bool x86AssemblyInspectionEngine::Augmen
   // [0x5d] pop %rbp/%ebp
   //  => [0xc3] ret
   if (pop_rbp_pattern_p() || leave_pattern_p()) {
-offset += 1;
-row->SetOffset(offset);
-row->GetCFAValue().SetIsRegisterPlusOffset(
-first_row->GetCFAValue().GetRegisterNumber(), m_wordsize);
-
-UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
-unwind_plan.InsertRow(new_row);
-unwind_plan_updated = true;
-reinstate_unwind_state = true;
-continue;
+m_cur_insn++;
+if (ret_pattern_p()) {
+  row->SetOffset(offset);
+  row->GetCFAValue().SetIsRegisterPlusOffset(
+  first_row->GetCFAValue().GetRegisterNumber(), m_wordsize);
+
+  UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
+  unwind_plan.InsertRow(new_row);
+  unwind_plan_updated = true;
+  reinstate_unwind_state = true;
+  continue;
+}
   }
 } else {
   // CFA register is not sp or fp.

Modified: 
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp?rev=374342&r1=374341&r2=374342&view=diff
==
--- lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
(original)
+++ lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
Thu Oct 10 06:23:09 2019
@@ -2199,6 +2199,97 @@ TEST_F(Testx86AssemblyInspectionEngine,
   EXPECT_EQ(-40, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestSpArithx86_64Augmented) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine64 = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x55, // pushq %rbp
+  0x48, 0x89, 0xe5, // movq %rsp, %rbp
+
+  // x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite
+  // has a bug where it can't augment a function that is just
+  // prologue+epilogue - it needs at least one other instruction
+ 

[Lldb-commits] [PATCH] D68454: Fix the unwinding plan augmentation from x86 assembly

2019-10-10 Thread Pavel Labath via Phabricator via lldb-commits
labath closed this revision.
labath added a comment.

I can do *that*: r374342


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68454



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


[Lldb-commits] [lldb] r374350 - [lldb] Add log output for the support files we pass to the CppModuleConfiguration

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 06:43:37 2019
New Revision: 374350

URL: http://llvm.org/viewvc/llvm-project?rev=374350&view=rev
Log:
[lldb] Add log output for the support files we pass to the 
CppModuleConfiguration

CppModuleConfiguration is the most likely point of failure when we have weird
setups where we fail to load a C++ module. With this logging it should be easier
to figure out why we can't find a valid configuration as the configuration only
depends on the list of file paths.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=374350&r1=374349&r2=374350&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
Thu Oct 10 06:43:37 2019
@@ -444,6 +444,8 @@ static CppModuleConfiguration LogConfigE
 
 CppModuleConfiguration GetModuleConfig(lldb::LanguageType language,
ExecutionContext &exe_ctx) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
   // Don't do anything if this is not a C++ module configuration.
   if (!SupportsCxxModuleImport(language))
 return LogConfigError("Language doesn't support C++ modules");
@@ -483,6 +485,15 @@ CppModuleConfiguration GetModuleConfig(l
   }
 }
   });
+
+  LLDB_LOG(log, "[C++ module config] Found {0} support files to analyze",
+   files.GetSize());
+  if (log && log->GetVerbose()) {
+for (const FileSpec &f : files)
+  LLDB_LOGV(log, "[C++ module config] Analyzing support file: {0}",
+f.GetPath());
+  }
+
   // Try to create a configuration from the files. If there is no valid
   // configuration possible with the files, this just returns an invalid
   // configuration.


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


[Lldb-commits] [lldb] r374352 - [lldb] Fix minidebuginfo-set-and-hit-breakpoint.test

2019-10-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Oct 10 07:00:32 2019
New Revision: 374352

URL: http://llvm.org/viewvc/llvm-project?rev=374352&view=rev
Log:
[lldb] Fix minidebuginfo-set-and-hit-breakpoint.test

This was failing for me because of this error:
llvm-objcopy: error: 
'build/tools/lldb/test/ObjectFile/ELF/Output/minidebuginfo-set-and-hit-breakpoint.test.tmp.mini_debuginfo':
 section '.dynsym' cannot be removed because it is referenced by the section 
'.hash'

Patch by Konrad Kleine!

Modified:

lldb/trunk/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test

Modified: 
lldb/trunk/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test?rev=374352&r1=374351&r2=374352&view=diff
==
--- 
lldb/trunk/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test 
(original)
+++ 
lldb/trunk/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test 
Thu Oct 10 07:00:32 2019
@@ -42,7 +42,7 @@
 # .rela.dyn and .dynsym sections can be removed once llvm-objcopy
 # --only-keep-debug starts to work.
 # RUN: llvm-objcopy --remove-section=.rela.plt --remove-section=.rela.dyn \
-# RUN:   --remove-section=.gnu.version --remove-section=.gnu.hash 
--remove-section=.dynsym %t.mini_debuginfo
+# RUN:   --remove-section=.gnu.version --remove-section=.gnu.hash 
--remove-section=.hash --remove-section=.dynsym %t.mini_debuginfo
 
 # Drop the full debug info from the original binary.
 


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


[Lldb-commits] [lldb] r374353 - unwind-via-stack-win.yaml: update for changes in yaml format

2019-10-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Oct 10 07:01:59 2019
New Revision: 374353

URL: http://llvm.org/viewvc/llvm-project?rev=374353&view=rev
Log:
unwind-via-stack-win.yaml: update for changes in yaml format

Modified:
lldb/trunk/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml

Modified: 
lldb/trunk/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml?rev=374353&r1=374352&r2=374353&view=diff
==
--- lldb/trunk/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml 
(original)
+++ lldb/trunk/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml 
Thu Oct 10 07:01:59 2019
@@ -24,7 +24,21 @@ Streams:
   - Start of Memory Range: 0x00CFFE78
 Content: 
79100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B100B0085100B0094842777
   - Type:MemoryInfoList
-Content: 
100032100B400010100126770E101001
+Memory Ranges:
+  - Base Address:0x000B1000
+Allocation Base: 0x
+Allocation Protect: [  ]
+Region Size: 0x4000
+State:   [ MEM_COMMIT ]
+Protect: [ PAGE_EXECUTE ]
+Type:[ MEM_IMAGE ]
+  - Base Address:0x7726
+Allocation Base: 0x
+Allocation Protect: [  ]
+Region Size: 0x000E
+State:   [ MEM_COMMIT ]
+Protect: [ PAGE_EXECUTE ]
+Type:[ MEM_IMAGE ]
   - Type:SystemInfo
 Processor Arch:  X86
 Platform ID: Win32NT


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


[Lldb-commits] [PATCH] D68734: update SBDebugger::SetInputFile() etc to work on native Files

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Sounds good. LGTM then. Thanks for the explanation. I was out on vacation for a 
week and catching up on email.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68734



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


[Lldb-commits] [PATCH] D68719: Fix build with Visual Studio

2019-10-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Hi Haibo,

Sadly, D68628  doesn't fix the issue. It adds 
"Debug" to the python path, but the script still tries to find 'liblldb.dll' in 
the wrong location.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68719: Fix build with Visual Studio

2019-10-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

This command produces an incorrect path for Visual Studio since it concatenates 
the root build directory with 'bin/liblldb.dll' bypassing configuration name.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68727: Allow pexpect tests to work in remote testsuite runs

2019-10-10 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

In D68727#1703073 , @labath wrote:

> I don't see harm in adding this, but I am curious about what are you planning 
> to use this for. My takeaway from all of the pexpect discussions we've had in 
> the past was that pexpect should only be used for stuff that really, really 
> needs an interactive terminal to work (i.e., stuff like batch mode, the "gui" 
> command, interactive command line editing/libedit stuff, etc.). All of these 
> seem like innately host-related stuff, and I am having trouble imagining a 
> feature/test that requires an interactive terminal, but only works on remote 
> targets.


I don't have any specific plans. I was going through our test suite and 
cleaning up the remote on-device runs. Those tests were failing because they 
had never been exercised in this configuration, so I took a look at what it 
would take to get them to work, and it was easy enough. I'm no opposed to 
skipping those tests if we're running with a remote platform, if we don't think 
they'll ever be useful in this config.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68727



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


[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:316
 
-# Use a shared module cache when building in the default test build directory.
-CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 
$(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE))

labath wrote:
> JDevlieghere wrote:
> > We should have a fallback here that defaults to `$(BUILDDIR)/module-cache` 
> > if the variable is not set in the environment.
> Is that wise, given D68731 tries to move away from autodetecting stuff in 
> `make`?
> 
> What I think would be more useful is to pass this variable via the command 
> like instead of the environment. That way it will be visible in the `make` 
> invocation that dotest prints and the exact make invocation can be reproduced 
> by copy-pasting. It shouldn't be even hard to do that -- you'd just need 
> builder_base.py to fetch this from the `configuration` object and inject it 
> into the make arguments.
+1

We shouldn't pass anything in the environment, it makes reproducing build 
failures a pain. (other variables I think are in the same bucket: DSYMUTIL and 
SDKROOT) 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68755



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


Re: [Lldb-commits] [lldb] r374335 - [lldb] Make sure import-std-module/sysroot actually passes for the right reasons

2019-10-10 Thread Frédéric Riss via lldb-commits


> On Oct 10, 2019, at 5:57 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> Author: teemperor
> Date: Thu Oct 10 05:57:14 2019
> New Revision: 374335
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=374335&view=rev
> Log:
> [lldb] Make sure import-std-module/sysroot actually passes for the right 
> reasons
> 
> This test was previously passing because myabs was actually emitted into the
> debug information and we called that. The test itself was broken as it didn't
> use the libc++ directory structure (the /v1/ directory was just called 
> /include/).
> 
> This patch gives myabs a default argument which we can't get from debug 
> information

Just FYI: debug information can express default arguments even though Clang 
doesn’t emit this for now. At some point in the future, this test could stop 
testing what you expect. Would it work to force the function to not have any 
debug info (I think __attribute__(no_debug_info)) would do that.

> and inlines the function to make sure we can't call it from LLDB without 
> loading
> the C++ module.
> 
> Added:
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap
> Removed:
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/
> Modified:
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
>
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
> 
> Modified: 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile?rev=374335&r1=374334&r2=374335&view=diff
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
>  (original)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
>  Thu Oct 10 05:57:14 2019
> @@ -3,7 +3,7 @@
> # system headers.
> NO_TEST_COMMON_H := 1
> 
> -CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/include/ -I 
> $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
> +CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I 
> $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
> CXX_SOURCES := main.cpp
> 
> include Makefile.rules
> 
> Modified: 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py?rev=374335&r1=374334&r2=374335&view=diff
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
>  (original)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
>  Thu Oct 10 05:57:14 2019
> @@ -27,4 +27,6 @@ class ImportStdModule(TestBase):
> 
> # Call our custom function in our sysroot std module.
> # If this gives us the correct result, then we used the sysroot.
> -self.expect("expr std::myabs(-42)", substrs=['(int) $0 = 42'])
> +# We rely on the default argument of -123 to make sure we actually 
> have the C++ module.
> +# (We don't have default arguments in the debug information).
> +self.expect("expr std::myabs()", substrs=['(int) $0 = 123'])
> 
> Modified: 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp?rev=374335&r1=374334&r2=374335&view=diff
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
>  (original)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
>  Thu Oct 10 05:57:14 2019
> @@ -2,5 +2,6 @@
> 
> int main(int argc, char **argv) {
>   libc_struct s;
> +  std::vector v;
>   return 0; // Set break point at this line.
> }
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/commands/expression/imp

[Lldb-commits] [PATCH] D68658: LLDB: Use LLVM's type for minidump ExceptionStream [NFC]

2019-10-10 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet updated this revision to Diff 224356.
JosephTremoulet added a comment.

- Define DumpRequested constant in-line, per feedback in D68656 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68658

Files:
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -252,10 +252,10 @@
 
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
-  const MinidumpExceptionStream *exception_stream =
+  const llvm::minidump::ExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
-  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+  ASSERT_EQ(11UL, exception_stream->ExceptionRecord.ExceptionCode);
 }
 
 void check_mem_range_exists(MinidumpParser &parser, const uint64_t range_start,
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.h
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -108,7 +108,7 @@
   FileSpec m_core_file;
   lldb::DataBufferSP m_core_data;
   llvm::ArrayRef m_thread_list;
-  const MinidumpExceptionStream *m_active_exception;
+  const minidump::ExceptionStream *m_active_exception;
   lldb::CommandObjectSP m_command_sp;
   bool m_is_wow64;
 };
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -241,36 +241,45 @@
   if (!m_active_exception)
 return;
 
-  if (m_active_exception->exception_record.exception_code ==
-  MinidumpException::DumpRequested) {
+  constexpr uint32_t BreakpadDumpRequested = 0x;
+  if (m_active_exception->ExceptionRecord.ExceptionCode ==
+  BreakpadDumpRequested) {
+// This "ExceptionCode" value is a sentinel that is sometimes used
+// when generating a dump for a process that hasn't crashed.
+
+// TODO: The definition and use of this "dump requested" constant
+// in Breakpad are actually Linux-specific, and for similar use
+// cases on Mac/Windows it defines differnt constants, referring
+// to them as "simulated" exceptions; consider moving this check
+// down to the OS-specific paths and checking each OS for its own
+// constant.
 return;
   }
 
   lldb::StopInfoSP stop_info;
   lldb::ThreadSP stop_thread;
 
-  Process::m_thread_list.SetSelectedThreadByID(m_active_exception->thread_id);
+  Process::m_thread_list.SetSelectedThreadByID(m_active_exception->ThreadId);
   stop_thread = Process::m_thread_list.GetSelectedThread();
   ArchSpec arch = GetArchitecture();
 
   if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
 stop_info = StopInfo::CreateStopReasonWithSignal(
-*stop_thread, m_active_exception->exception_record.exception_code);
+*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode);
   } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
 stop_info = StopInfoMachException::CreateStopReasonWithMachException(
-*stop_thread, m_active_exception->exception_record.exception_code, 2,
-m_active_exception->exception_record.exception_flags,
-m_active_exception->exception_record.exception_address, 0);
+*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode, 2,
+m_active_exception->ExceptionRecord.ExceptionFlags,
+m_active_exception->ExceptionRecord.ExceptionAddress, 0);
   } else {
 std::string desc;
 llvm::raw_string_ostream desc_stream(desc);
 desc_stream << "Exception "
 << llvm::format_hex(
-   m_active_exception->exception_record.exception_code, 8)
+   m_active_exception->ExceptionRecord.ExceptionCode, 8)
 << " encountered at address "
 << llvm::format_hex(
-   m_active_exception->exception_record.exception_address,
-   8);
+   m_active_exception->ExceptionRecord.ExceptionAddress, 8);
 stop_info = StopInfo::CreateStopReasonWithException(
 *stop_thread, desc_stream.str().c_str());
   }
@@ 

[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

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

LGTM, apart from the outstanding comments.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68755



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


[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I think this addresses all outstanding questions?


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [lldb] r374371 - Increase timeout in gdbclientutils.py to decrease chance of test failing under ASAN.

2019-10-10 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Oct 10 08:59:17 2019
New Revision: 374371

URL: http://llvm.org/viewvc/llvm-project?rev=374371&view=rev
Log:
Increase timeout in gdbclientutils.py to decrease chance of test failing under 
ASAN.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py?rev=374371&r1=374370&r2=374371&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 Thu Oct 10 08:59:17 2019
@@ -296,7 +296,7 @@ class MockGDBServer:
 try:
 # accept() is stubborn and won't fail even when the socket is
 # shutdown, so we'll use a timeout
-self._socket.settimeout(2.0)
+self._socket.settimeout(20.0)
 client, client_addr = self._socket.accept()
 self._client = client
 # The connected client inherits its timeout from self._socket,


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


[Lldb-commits] [lldb] r374375 - Increase timeout in pexpect to lower chances of tests failing under ASAN.

2019-10-10 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Oct 10 09:16:49 2019
New Revision: 374375

URL: http://llvm.org/viewvc/llvm-project?rev=374375&view=rev
Log:
Increase timeout in pexpect to lower chances of tests failing under ASAN.

If this doesn't actually work, I'll revert the change and just disable
the remaining thee pexpect tests under asan.

Modified:
lldb/trunk/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py

Modified: lldb/trunk/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py?rev=374375&r1=374374&r2=374375&view=diff
==
--- lldb/trunk/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py 
(original)
+++ lldb/trunk/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py Thu 
Oct 10 09:16:49 2019
@@ -640,7 +640,7 @@ class spawn(SpawnBase):
 # this to happen. I think isalive() reports True, but the
 # process is dead to the kernel.
 # Make one last attempt to see if the kernel is up to date.
-time.sleep(self.delayafterterminate)
+time.sleep(self.delayafterterminate * 10)
 if not self.isalive():
 return True
 else:


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


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Please see my comment D68719#1703785 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68728



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


[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

So now we are doing two lookups each time we are doing a lookup? One idea to 
improve upon this would be to do this search a bit later on after we lookup 
"iterator" and only do this extra context matching if we find at last a certain 
number of results? So the flow would go:

- do normal lookup on "iterator" and find N matches
- if N is large enough then do your search above?

See inline code for an example of a possible improvement




Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:114
 
   // When searching for a scoped type (for exampe,
   // "std::vector::const_iterator") searching for the innermost

s/exampe/example/



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:120-127
+  if (!has_qualified_name_hash && (context.GetSize() > 1) &&
+  (context[1].tag == DW_TAG_class_type ||
+   context[1].tag == DW_TAG_structure_type)) {
 DIEArray class_matches;
 m_apple_types_up->FindByName(context[1].name, class_matches);
 if (class_matches.empty())
   return;

This should probably be moved down into line 139 and 143 instead of checking 
"if (! has_qualified_name_hash..."? See inline comments below.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:138-143
   } else if (has_tag) {
 if (log)
   m_module.LogMessage(log, "FindByNameAndTag()");
 m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
   } else
 m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);

We can probably move your code above to here:
```
  } else {
if (context.GetSize() > 1) && (context[1].tag == DW_TAG_class_type ||
   context[1].tag == DW_TAG_structure_type)) {
  DIEArray class_matches;
  m_apple_types_up->FindByName(context[1].name, class_matches);
  if (class_matches.empty())
return;
}
if (has_tag) {
  if (log)
m_module.LogMessage(log, "FindByNameAndTag()");
  m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, 
offsets);
} else
  m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
  }
```

Or better yet:
```
 } else {
if (has_tag) {
  if (log)
m_module.LogMessage(log, "FindByNameAndTag()");
  m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, 
offsets);
} else
  m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
// If we have too many matches, we might want to ensure that the context
// that this type is contained in actually exists so we don't end up 
pulling 
// in too much DWARF for common type like "iterator".
if (offsets.size() > THRESHOLD) {
  if (context.GetSize() > 1) && (context[1].tag == DW_TAG_class_type ||
 context[1].tag == DW_TAG_structure_type)) {
DIEArray class_matches;
m_apple_types_up->FindByName(context[1].name, class_matches);
if (class_matches.empty()) {
  offsets.clear();
  return;
}
  }
}
  }
```

We might also be able to remove some offsets from "offsets" by iterating 
through "offsets" and removing any values that come before an entry in 
"class_matches". For example if offsets contains:
```
offsets = [0x1100, 0x2100, 0x3100, 0x4100]
```
and
```
class_offsets = [0x4000]
```
could we remove "[0x1100, 0x2100, 0x3100]" from offsets? Maybe not with 
DW_AT_specification and DW_AT_abstract_origin?


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

2019-10-10 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:544
   bool is_truncated = false;
   const auto max_size = 
process_sp->GetTarget().GetMaximumSizeOfStringSummary();
 

Why not just make this `uint32_t` making this `auto` gains us nothing but now I 
am left wondering do the types match later on when we use `max_size`.


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

https://reviews.llvm.org/D68010



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


[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:316
 
-# Use a shared module cache when building in the default test build directory.
-CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 
$(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE))

friss wrote:
> labath wrote:
> > JDevlieghere wrote:
> > > We should have a fallback here that defaults to 
> > > `$(BUILDDIR)/module-cache` if the variable is not set in the environment.
> > Is that wise, given D68731 tries to move away from autodetecting stuff in 
> > `make`?
> > 
> > What I think would be more useful is to pass this variable via the command 
> > like instead of the environment. That way it will be visible in the `make` 
> > invocation that dotest prints and the exact make invocation can be 
> > reproduced by copy-pasting. It shouldn't be even hard to do that -- you'd 
> > just need builder_base.py to fetch this from the `configuration` object and 
> > inject it into the make arguments.
> +1
> 
> We shouldn't pass anything in the environment, it makes reproducing build 
> failures a pain. (other variables I think are in the same bucket: DSYMUTIL 
> and SDKROOT) 
https://reviews.llvm.org/D68812


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68755



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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, friss, aprantl.
Herald added a project: LLDB.

Pass the DSYMUTIL and SDKROOT variables on the command line instead of the 
environment. This makes it easier to reproduce the make invocation during 
development.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68812

Files:
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -104,6 +104,23 @@
 else:
 return ""
 
+def getDsymutilSpec():
+"""
+Helper function to return the key-value string to specify the dsymutil
+used for the make system.
+"""
+if "DSYMUTIL" in os.environ:
+return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
+return "";
+
+def getSDKRootSpec():
+"""
+Helper function to return the key-value string to specify the SDK root
+used for the make system.
+"""
+if "SDKROOT" in os.environ:
+return "SDKROOT={}".format(os.environ["SDKROOT"])
+return "";
 
 def getCmdLine(d):
 """
@@ -145,8 +162,13 @@
 testname=None):
 """Build the binaries the default way."""
 commands = []
-commands.append(getMake(testdir, testname) + ["all", 
getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
+["all",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 
@@ -164,8 +186,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+["MAKE_DSYM=NO",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 # True signifies that we can handle building dwarf.
@@ -182,9 +208,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", "MAKE_DWO=YES",
+["MAKE_DSYM=NO",
+ "MAKE_DWO=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
@@ -206,6 +235,8 @@
  "MAKE_GMODULES=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 lldbtest.system(commands, sender=sender)


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -104,6 +104,23 @@
 else:
 return ""
 
+def getDsymutilSpec():
+"""
+Helper function to return the key-value string to specify the dsymutil
+used for the make system.
+"""
+if "DSYMUTIL" in os.environ:
+return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
+return "";
+
+def getSDKRootSpec():
+"""
+Helper function to return the key-value string to specify the SDK root
+used for the make system.
+"""
+if "SDKROOT" in os.environ:
+return "SDKROOT={}".format(os.environ["SDKROOT"])
+return "";
 
 def getCmdLine(d):
 """
@@ -145,8 +162,13 @@
 testname=None):
 """Build the binaries the default way."""
 commands = []
-commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
+["all",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 
@@ -164,8 +186,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands

[Lldb-commits] false alarm [Re: [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.]

2019-10-10 Thread Jan Kratochvil via lldb-commits
On Thu, 10 Oct 2019 00:22:09 +0200, Jan Kratochvil wrote:
> --
> There are now:
> Failing Tests (5):
> lldb-api :: 
> commands/expression/multiline-completion/TestMultilineCompletion.py
> lldb-api :: commands/gui/basic/TestGuiBasic.py
> lldb-api :: driver/batch_mode/TestBatchMode.py
> lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
> lldb-api :: python_api/file_handle/TestFileHandle.py
> 
> due to:
> ERROR: test_close (TestFileHandle.FileHandleTestCase)
> --
> Traceback (most recent call last):
>   File 
> "/home/jkratoch/redhat/llvm-monorepo2/lldb/packages/Python/lldbsuite/test/decorators.py",
>  line 96, in expectedFailure_impl
> @wraps(func)
>   File "/usr/lib64/python2.7/functools.py", line 33, in update_wrapper
> setattr(wrapper, attr, getattr(wrapped, attr))
> AttributeError: 'FileHandleTestCase' object has no attribute '__name__'
> etc.
> 
> I haven't yet tracked it down, I will bugreport that elsewhere.

That was a false alarm:
https://reviews.llvm.org/rL370054#684622
Solved by @labath, I had leftover *.pyc file in
./lldb/third_party/Python/module/pexpect-2.4/, it started working
after deleting it.

It got there by some bisecting since a very old commit.


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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

It would be great if we could ensure that if a test fails, that the "dotest" 
command line text has everything it needs as well, including the options and 
paths to lldb, framework, shared library and other settings. If I "ninja 
check-lldb", I have to manually insert many arguments before the command the 
FAIL file says to run will work.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68812



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


[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 224394.
JDevlieghere added a comment.

- Rebased on top of D68812 .
- Pass the module cache on the command line.


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

https://reviews.llvm.org/D68755

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/test/API/lit.cfg
  lldb/test/API/lit.site.cfg.in
  lldb/test/CMakeLists.txt
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -20,8 +20,9 @@
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
+# The shell tests use their own module caches.
+config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
+config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
@@ -32,7 +33,6 @@
 config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
 config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params
 config.lldb_lit_tools_dir = config.lldb_lit_tools_dir % lit_config.params
-
 except KeyError as e:
 key, = e.args
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -69,9 +69,9 @@
 # incremental build whenever clang changes underneath, so doing it once per
 # lit.py invocation is close enough.
 for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
-if os.path.isdir(cachedir):
-print("Deleting module cache at %s."%cachedir)
-shutil.rmtree(cachedir)
+  if os.path.isdir(cachedir):
+ print("Deleting module cache at %s."%cachedir)
+ shutil.rmtree(cachedir)
 
 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
 # requires that killProcessAndChildren() is supported on the platform and
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -3,6 +3,12 @@
 
 add_subdirectory(API)
 
+# Configure and create module cache directories.
+set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
+set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_LLDB})
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_CLANG})
+
 # LLVM_BUILD_MODE is used in lit.site.cfg
 if (CMAKE_CFG_INTDIR STREQUAL ".")
   set(LLVM_BUILD_MODE ".")
@@ -17,8 +23,6 @@
 get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
 set(dotest_args_replacement ${LLVM_BUILD_MODE})
 
-set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
-set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
 
 if(LLDB_BUILT_STANDALONE)
   # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
Index: lldb/test/API/lit.site.cfg.in
===
--- lldb/test/API/lit.site.cfg.in
+++ lldb/test/API/lit.site.cfg.in
@@ -17,13 +17,14 @@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
 config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
 config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
 config.dotest_lit_args_str = None
+# The API tests use their own module caches.
+config.lldb_module_cache = os.path.join("@LLDB_TEST_

[Lldb-commits] [lldb] r374382 - [test] Trim the symbtab test case (NFC)

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 10:12:57 2019
New Revision: 374382

URL: http://llvm.org/viewvc/llvm-project?rev=374382&view=rev
Log:
[test] Trim the symbtab test case (NFC)

We don't actually need the section content for this tests.

Modified:
lldb/trunk/test/Shell/ObjectFile/MachO/symtab.yaml

Modified: lldb/trunk/test/Shell/ObjectFile/MachO/symtab.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/ObjectFile/MachO/symtab.yaml?rev=374382&r1=374381&r2=374382&view=diff
==
--- lldb/trunk/test/Shell/ObjectFile/MachO/symtab.yaml (original)
+++ lldb/trunk/test/Shell/ObjectFile/MachO/symtab.yaml Thu Oct 10 10:12:57 2019
@@ -51,7 +51,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: 
554889E54883EC30488D05411231C948C7052C12570448C7052912AE08488B151A12897DE44889C7488D45E8488975D84889C6B82100488955D04889C2E83001488B7DD0488D35F511E84000488D7DE8E81D0131C04883C4305DC3662E0F1F84000F1F44554889E548C745F0488975F848897DF05DC3662E0F1F8400554889E54883EC3048C745F848C745F048C745E848897DF8488975F0488B06488945E848897DD8488945E0488D3D6211E81D00488D7DD84889C6E891FF4883C4305DC3662E0F1F8400904883EC284889F8488B0F4883F9000F9CC2F6C2014889CE48897C2420488944241848894C24104889742408750A488B4424084883C428C3488B44241048C1F82048F7D8488B4C241089CA4863F2488B7C24204801F731D289D6488934244889C6488B1424488B0C24E81F004889C1488B54241848890248894C2408EBAE
   - sectname:__stubs
 segname: __TEXT
 addr:0x00010F60
@@ -64,7 +63,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x0006
 reserved3:   0x
-content: FF259A10FF259C10FF259E10
   - sectname:__stub_helper
 segname: __TEXT
 addr:0x00010F74
@@ -77,7 +75,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: 
4C8D1D9D104153FF257D009068E9E6FF681900E9DCFF683000E9D2FF
   - sectname:__swift5_typeref
 segname: __TEXT
 addr:0x00010FA2
@@ -90,7 +87,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: 53695F53697400
   - sectname:__const
 segname: __TEXT
 addr:0x00010FAA
@@ -103,7 +99,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: '0300'
   - sectname:__unwind_info
 segname: __TEXT
 addr:0x00010FAC
@@ -116,7 +111,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: 
01001C001C001C000200E00D34003400600F340003000C00020014000201000106020001
   - cmd: LC_SEGMENT_64
 cmdsize: 232
 segname: __DATA_CONST
@@ -141,7 +135,6 @@ LoadCommands:
 reserved1:   0x0003
 reserved2:   0x
 reserved3:   0x
-content: ''
   - sectname:__objc_imageinfo
 segname: __DATA_CONST
 addr:0x00011008
@@ -154,7 +147,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: '40070105'
   - cmd: LC_SEGMENT_64
 cmdsize: 312
 segname: __DATA
@@ -179,7 +171,6 @@ LoadCommands:
 reserved1:   0x0004
 reserved2:   0x
 reserved3:   0x
-content: 840F01008E0F0100980F0100
   - sectname:__data
 segname: __DATA
 addr:0x00012018
@@ -192,7 +183,6 @@ LoadCommands:
 reserved1:   0x
 reserved2:   0x
 reserved3:   0x
-content: 82EFFAFF
   - sectname:__common
 segname: __DATA
 addr:0x00012028


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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

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

Thanks! It was so annoying having to manually specify DSYMUTIL=dsymutil when 
reproducing builds.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68812



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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D68812#1704235 , @clayborg wrote:

> It would be great if we could ensure that if a test fails, that the "dotest" 
> command line text has everything it needs as well, including the options and 
> paths to lldb, framework, shared library and other settings. If I "ninja 
> check-lldb", I have to manually insert many arguments before the command the 
> FAIL file says to run will work.


Any reason you want to run dotest.py directly? If you use `bin/lldb-dotest` 
you'll get all dotest arguments that CMake configuration. Even better is to use 
`lit --filter `, which guarantees that you'll have the 
exact same dotest.py invocation as during `check-ldlb`.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68812



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


[Lldb-commits] [lldb] r374386 - [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 10:27:09 2019
New Revision: 374386

URL: http://llvm.org/viewvc/llvm-project?rev=374386&view=rev
Log:
[test] Use a different module cache for Shell and API tests.

Before the test reorganization, everything was part of a single test
suite with a single module cache. Now that things are properly separated
this is no longer the case. Only the shell tests inherited the logic to
properly configure and wipe the module caches. This patch adds that
logic back for the API tests. While doing so, I noticed that we were
configuring a Clang module cache in CMake, but weren't actually using it
from dotest.py. I included a fix for that in this patch as well.

Differential revision: https://reviews.llvm.org/D68755

Modified:
lldb/trunk/packages/Python/lldbsuite/test/configuration.py
lldb/trunk/packages/Python/lldbsuite/test/dotest.py
lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
lldb/trunk/test/API/lit.cfg
lldb/trunk/test/API/lit.site.cfg.in
lldb/trunk/test/CMakeLists.txt
lldb/trunk/test/Shell/lit.cfg.py
lldb/trunk/test/Shell/lit.site.cfg.py.in

Modified: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/configuration.py?rev=374386&r1=374385&r2=374386&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py Thu Oct 10 
10:27:09 2019
@@ -107,7 +107,9 @@ lldb_platform_working_dir = None
 test_build_dir = None
 
 # The clang module cache directory used by lldb.
-module_cache_dir = None
+lldb_module_cache_dir = None
+# The clang module cache directory used by clang.
+clang_module_cache_dir = None
 
 # The only directory to scan for tests. If multiple test directories are
 # specified, and an exclusive test subdirectory is specified, the latter option

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=374386&r1=374385&r2=374386&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Oct 10 10:27:09 2019
@@ -426,11 +426,18 @@ def parseOptionsAndInitTestdirs():
 configuration.lldb_platform_working_dir = 
args.lldb_platform_working_dir
 if args.test_build_dir:
 configuration.test_build_dir = args.test_build_dir
-if args.module_cache_dir:
-configuration.module_cache_dir = args.module_cache_dir
+if args.lldb_module_cache_dir:
+configuration.lldb_module_cache_dir = args.lldb_module_cache_dir
 else:
-configuration.module_cache_dir = 
os.path.join(configuration.test_build_dir,
-  'module-cache-lldb')
+configuration.lldb_module_cache_dir = os.path.join(
+configuration.test_build_dir, 'module-cache-lldb')
+if args.clang_module_cache_dir:
+configuration.clang_module_cache_dir = args.clang_module_cache_dir
+else:
+configuration.clang_module_cache_dir = os.path.join(
+configuration.test_build_dir, 'module-cache-clang')
+
+os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
 
 # Gather all the dirs passed on the command line.
 if len(args.args) > 0:

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=374386&r1=374385&r2=374386&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Thu Oct 10 
10:27:09 2019
@@ -150,10 +150,15 @@ def create_parser():
 default='lldb-test-build.noindex',
 help='The root build directory for the tests. It will be removed 
before running.')
 group.add_argument(
-'--module-cache-dir',
-dest='module_cache_dir',
+'--lldb-module-cache-dir',
+dest='lldb_module_cache_dir',
 metavar='The clang module cache directory used by LLDB',
-help='The clang module cache directory used by LLDB. This is not the 
one used by the makefiles. Defaults to /module-cache-lldb.')
+help='The clang module cache directory used by LLDB. Defaults to /module-cache-lldb.')
+group.add_argument(
+'--clang-module-cache-dir',
+dest='clang_module_cache_dir',
+metavar='The clang mod

[Lldb-commits] [lldb] r374385 - [test] Pass DSYMUTIL and SDKROOT as part of the Make invocation.

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 10:27:06 2019
New Revision: 374385

URL: http://llvm.org/viewvc/llvm-project?rev=374385&view=rev
Log:
[test] Pass DSYMUTIL and SDKROOT as part of the Make invocation.

Pass the DSYMUTIL and SDKROOT variables on the command line instead of
the environment. This makes it easier to reproduce the make invocation
during development.

Differential revision: https://reviews.llvm.org/D68812

Modified:
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py?rev=374385&r1=374384&r2=374385&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py Thu Oct 
10 10:27:06 2019
@@ -104,6 +104,23 @@ def getCCSpec(compiler):
 else:
 return ""
 
+def getDsymutilSpec():
+"""
+Helper function to return the key-value string to specify the dsymutil
+used for the make system.
+"""
+if "DSYMUTIL" in os.environ:
+return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
+return "";
+
+def getSDKRootSpec():
+"""
+Helper function to return the key-value string to specify the SDK root
+used for the make system.
+"""
+if "SDKROOT" in os.environ:
+return "SDKROOT={}".format(os.environ["SDKROOT"])
+return "";
 
 def getCmdLine(d):
 """
@@ -145,8 +162,13 @@ def buildDefault(
 testname=None):
 """Build the binaries the default way."""
 commands = []
-commands.append(getMake(testdir, testname) + ["all", 
getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
+["all",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 
@@ -164,8 +186,12 @@ def buildDwarf(
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+["MAKE_DSYM=NO",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 # True signifies that we can handle building dwarf.
@@ -182,9 +208,12 @@ def buildDwo(
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", "MAKE_DWO=YES",
+["MAKE_DSYM=NO",
+ "MAKE_DWO=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
@@ -206,6 +235,8 @@ def buildGModules(
  "MAKE_GMODULES=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 lldbtest.system(commands, sender=sender)


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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d2cf936ac6c: [test] Pass DSYMUTIL and SDKROOT as part of 
the Make invocation. (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68812

Files:
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -104,6 +104,23 @@
 else:
 return ""
 
+def getDsymutilSpec():
+"""
+Helper function to return the key-value string to specify the dsymutil
+used for the make system.
+"""
+if "DSYMUTIL" in os.environ:
+return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
+return "";
+
+def getSDKRootSpec():
+"""
+Helper function to return the key-value string to specify the SDK root
+used for the make system.
+"""
+if "SDKROOT" in os.environ:
+return "SDKROOT={}".format(os.environ["SDKROOT"])
+return "";
 
 def getCmdLine(d):
 """
@@ -145,8 +162,13 @@
 testname=None):
 """Build the binaries the default way."""
 commands = []
-commands.append(getMake(testdir, testname) + ["all", 
getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
+["all",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 
@@ -164,8 +186,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+["MAKE_DSYM=NO",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 # True signifies that we can handle building dwarf.
@@ -182,9 +208,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=NO", "MAKE_DWO=YES",
+["MAKE_DSYM=NO",
+ "MAKE_DWO=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
@@ -206,6 +235,8 @@
  "MAKE_GMODULES=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
  getCmdLine(dictionary)])
 
 lldbtest.system(commands, sender=sender)


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -104,6 +104,23 @@
 else:
 return ""
 
+def getDsymutilSpec():
+"""
+Helper function to return the key-value string to specify the dsymutil
+used for the make system.
+"""
+if "DSYMUTIL" in os.environ:
+return "DSYMUTIL={}".format(os.environ["DSYMUTIL"])
+return "";
+
+def getSDKRootSpec():
+"""
+Helper function to return the key-value string to specify the SDK root
+used for the make system.
+"""
+if "SDKROOT" in os.environ:
+return "SDKROOT={}".format(os.environ["SDKROOT"])
+return "";
 
 def getCmdLine(d):
 """
@@ -145,8 +162,13 @@
 testname=None):
 """Build the binaries the default way."""
 commands = []
-commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture),
- getCCSpec(compiler), getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
+["all",
+ getArchSpec(architecture),
+ getCCSpec(compiler),
+ getDsymutilSpec(),
+ getSDKRootSpec(),
+ getCmdLine(dictionary)])
 
 runBuildCommands(commands, sender=sender)
 
@@ -164,8 +186,12 @@
 """Build the binaries with dwarf debug info."""
 commands = []
 commands.appen

[Lldb-commits] [PATCH] D68755: [test] Use a different module cache for Shell and API tests.

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG27c23653aec7: [test] Use a different module cache for Shell 
and API tests. (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68755

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/test/API/lit.cfg
  lldb/test/API/lit.site.cfg.in
  lldb/test/CMakeLists.txt
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -20,8 +20,9 @@
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
+# The shell tests use their own module caches.
+config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
+config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
@@ -32,7 +33,6 @@
 config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
 config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params
 config.lldb_lit_tools_dir = config.lldb_lit_tools_dir % lit_config.params
-
 except KeyError as e:
 key, = e.args
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -69,9 +69,9 @@
 # incremental build whenever clang changes underneath, so doing it once per
 # lit.py invocation is close enough.
 for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
-if os.path.isdir(cachedir):
-print("Deleting module cache at %s."%cachedir)
-shutil.rmtree(cachedir)
+  if os.path.isdir(cachedir):
+ print("Deleting module cache at %s."%cachedir)
+ shutil.rmtree(cachedir)
 
 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
 # requires that killProcessAndChildren() is supported on the platform and
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -3,6 +3,12 @@
 
 add_subdirectory(API)
 
+# Configure and create module cache directories.
+set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
+set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_LLDB})
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_CLANG})
+
 # LLVM_BUILD_MODE is used in lit.site.cfg
 if (CMAKE_CFG_INTDIR STREQUAL ".")
   set(LLVM_BUILD_MODE ".")
@@ -17,8 +23,6 @@
 get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
 set(dotest_args_replacement ${LLVM_BUILD_MODE})
 
-set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
-set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
 
 if(LLDB_BUILT_STANDALONE)
   # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
Index: lldb/test/API/lit.site.cfg.in
===
--- lldb/test/API/lit.site.cfg.in
+++ lldb/test/API/lit.site.cfg.in
@@ -17,13 +17,14 @@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
 config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
 config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
 config.dotest_lit_args_str = None
+# The API tests use their own module caches.
+config

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:138-143
   } else if (has_tag) {
 if (log)
   m_module.LogMessage(log, "FindByNameAndTag()");
 m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
   } else
 m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);

clayborg wrote:
> We can probably move your code above to here:
> ```
>   } else {
> if (context.GetSize() > 1) && (context[1].tag == DW_TAG_class_type ||
>context[1].tag == DW_TAG_structure_type)) {
>   DIEArray class_matches;
>   m_apple_types_up->FindByName(context[1].name, class_matches);
>   if (class_matches.empty())
> return;
> }
> if (has_tag) {
>   if (log)
> m_module.LogMessage(log, "FindByNameAndTag()");
>   m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, 
> offsets);
> } else
>   m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
>   }
> ```
> 
> Or better yet:
> ```
>  } else {
> if (has_tag) {
>   if (log)
> m_module.LogMessage(log, "FindByNameAndTag()");
>   m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, 
> offsets);
> } else
>   m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
> // If we have too many matches, we might want to ensure that the context
> // that this type is contained in actually exists so we don't end up 
> pulling 
> // in too much DWARF for common type like "iterator".
> if (offsets.size() > THRESHOLD) {
>   if (context.GetSize() > 1) && (context[1].tag == DW_TAG_class_type ||
>  context[1].tag == 
> DW_TAG_structure_type)) {
> DIEArray class_matches;
> m_apple_types_up->FindByName(context[1].name, class_matches);
> if (class_matches.empty()) {
>   offsets.clear();
>   return;
> }
>   }
> }
>   }
> ```
> 
> We might also be able to remove some offsets from "offsets" by iterating 
> through "offsets" and removing any values that come before an entry in 
> "class_matches". For example if offsets contains:
> ```
> offsets = [0x1100, 0x2100, 0x3100, 0x4100]
> ```
> and
> ```
> class_offsets = [0x4000]
> ```
> could we remove "[0x1100, 0x2100, 0x3100]" from offsets? Maybe not with 
> DW_AT_specification and DW_AT_abstract_origin?
Moving the code into the `else` (first suggestion) is equivalent, but may be 
more obvious to read. Thanks.

The second suggestions is not a clear win to me. The point of this patch is to 
eliminate entire .o files quickly that don't have the parent class type in it, 
in order to avoid extracting type DIEs for matches. The assumption here is that 
an accelerator table lookup is much cheaper than extracting a DIE. I believe 
the threshold is 1.

I also learned to never make assumptions about performance, so here are some 
numbers for my clang benchmark:

```
original: 8.7s
this patch: 5.9s
threshold 100: 6.5s
threshold  50: 6.5s
threshold  25: 6.5s
threshold  12: 6.4s
threshold   6: 6.4s
threshold   3: 6.4s
threshold   1: 6.5s
```



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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [lldb] r374394 - Implement serializing scripted breakpoints and their extra args.

2019-10-10 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Thu Oct 10 10:44:50 2019
New Revision: 374394

URL: http://llvm.org/viewvc/llvm-project?rev=374394&view=rev
Log:
Implement serializing scripted breakpoints and their extra args.

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/resolver.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/side_effect.py
Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h?rev=374394&r1=374393&r2=374394&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverScripted.h Thu Oct 10 
10:44:50 2019
@@ -26,8 +26,7 @@ public:
   BreakpointResolverScripted(Breakpoint *bkpt,
  const llvm::StringRef class_name,
  lldb::SearchDepth depth,
- StructuredDataImpl *args_data,
- ScriptInterpreter &script_interp);
+ StructuredDataImpl *args_data);
 
   ~BreakpointResolverScripted() override;
 

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py?rev=374394&r1=374393&r2=374394&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 Thu Oct 10 10:44:50 2019
@@ -47,7 +47,12 @@ class BreakpointSerialization(TestBase):
 self.build()
 self.setup_targets_and_cleanup()
 self.do_check_names()
-
+
+def test_scripted_extra_args(self):
+self.build()
+self.setup_targets_and_cleanup()
+self.do_check_extra_args()
+
 def setup_targets_and_cleanup(self):
 def cleanup ():
 self.RemoveTempFile(self.bkpts_file_path)
@@ -289,3 +294,85 @@ class BreakpointSerialization(TestBase):
 error = 
self.copy_target.BreakpointsCreateFromFile(self.bkpts_file_spec, names_list, 
copy_bps)
 self.assertTrue(error.Success(), "Failed reading breakpoints from 
file: %s"%(error.GetCString()))
 self.assertTrue(copy_bps.GetSize() == 1, "Found the matching 
breakpoint.")
+
+def do_check_extra_args(self):
+
+import side_effect
+   interp = self.dbg.GetCommandInterpreter()
+   error = lldb.SBError()
+
+   script_name = os.path.join(self.getSourceDir(), "resolver.py")
+
+command = "command script import " + script_name
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand(command, result)
+self.assertTrue(result.Succeeded(), "com scr imp failed: 
%s"%(result.GetError()))
+
+# First make sure a scripted breakpoint with no args works:
+bkpt = 
self.orig_target.BreakpointCreateFromScript("resolver.Resolver", 
lldb.SBStructuredData(),
+   
lldb.SBFileSpecList(), lldb.SBFileSpecList())
+self.assertTrue(bkpt.IsValid(), "Bkpt is valid")
+write_bps = lldb.SBBreakpointList(self.orig_target)
+
+error = self.orig_target.BreakpointsWriteToFile(self.bkpts_file_spec, 
write_bps)
+self.assertTrue(error.Success(), "Failed writing breakpoints: 
%s"%(error.GetCString()))
+
+side_effect.g_extra_args = None
+copy_bps = lldb.SBBreakpointList(self.copy_target)
+error = 
self.copy_target.BreakpointsCreateFromFile(self.bkpts_file_spec, copy_bps)
+self.assertTrue(error.Success(), "Failed reading breakpoints: 
%s"%(error.GetCString()))
+
+self.assertEqual(copy_bps.GetSize(), 1, "Got one breakpoint from 
file.")
+no_keys = lldb.SBStringList()
+side_effect.g_extra_args.GetKeys(no_keys)
+self.assertEqual(no_keys.GetSize(), 0, "Should have no keys")
+
+self.orig_target.DeleteAllBreakpoints()
+self.copy_target.DeleteAllBreakpoints()
+
+# Now try one with extra args:
+
+extra_args = lldb.SBStructuredData()
+stream = ll

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 224407.
aprantl added a comment.

Address feedback from Greg.


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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,7 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
@@ -119,12 +120,32 @@
   m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
 m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
 type_name.GetStringRef(), tag, qualified_name_hash, offsets);
-  } else if (has_tag) {
+return;
+  }
+
+  if (has_tag) {
+// When searching for a scoped type (for example,
+// "std::vector::const_iterator") searching for the innermost
+// name alone ("const_iterator) could yield many false positives. By
+// searching for the parent type ("vector") first we can avoid
+// extracting type DIEs from object files that would fail the filter
+// anyway.
+if (!has_qualified_name_hash && (context.GetSize() > 1) &&
+(context[1].tag == DW_TAG_class_type ||
+ context[1].tag == DW_TAG_structure_type)) {
+  DIEArray class_matches;
+  m_apple_types_up->FindByName(context[1].name, class_matches);
+  if (class_matches.empty())
+return;
+}
+
 if (log)
   m_module.LogMessage(log, "FindByNameAndTag()");
 m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
-  } else
-m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
+return;
+  }
+
+  m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
 }
 
 void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===
--- /dev/nul

[Lldb-commits] [PATCH] D68750: Implement serialization and deserialization of scripted points

2019-10-10 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47b33dcc0df8: Implement serializing scripted breakpoints and 
their extra args. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68750

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/resolver.py
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/side_effect.py
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -609,8 +609,7 @@
 extra_args_impl->SetObjectSP(extra_args_sp);
 
   BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
-  nullptr, class_name, depth, extra_args_impl,
-  *GetDebugger().GetScriptInterpreter()));
+  nullptr, class_name, depth, extra_args_impl));
   return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
 }
 
Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -29,8 +29,7 @@
 Breakpoint *bkpt, 
 const llvm::StringRef class_name,
 lldb::SearchDepth depth,
-StructuredDataImpl *args_data,
-ScriptInterpreter &script_interp)
+StructuredDataImpl *args_data)
 : BreakpointResolver(bkpt, BreakpointResolver::PythonResolver),
   m_class_name(class_name), m_depth(depth), m_args_ptr(args_data) {
   CreateImplementationIfNeeded();
@@ -68,45 +67,25 @@
   llvm::StringRef class_name;
   bool success;
   
-  if (!bkpt)
-return nullptr;
-
   success = options_dict.GetValueForKeyAsString(
   GetKey(OptionNames::PythonClassName), class_name);
   if (!success) {
 error.SetErrorString("BRFL::CFSD: Couldn't find class name entry.");
 return nullptr;
   }
-  lldb::SearchDepth depth;
-  int depth_as_int;
-  success = options_dict.GetValueForKeyAsInteger(
-  GetKey(OptionNames::SearchDepth), depth_as_int);
-  if (!success) {
-error.SetErrorString("BRFL::CFSD: Couldn't find class name entry.");
-return nullptr;
-  }
-  if (depth_as_int >= (int) OptionNames::LastOptionName) {
-error.SetErrorString("BRFL::CFSD: Invalid value for search depth.");
-return nullptr;
-  }
-  depth = (lldb::SearchDepth) depth_as_int;
+  // The Python function will actually provide the search depth, this is a
+  // placeholder.
+  lldb::SearchDepth depth = lldb::eSearchDepthTarget;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
   StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {
-// FIXME: The resolver needs a copy of the ARGS dict that it can own,
-// so I need to make a copy constructor for the Dictionary so I can pass
-// that to it here.  For now the args are empty.
-//StructuredData::Dictionary *dict_copy = new StructuredData::Dictionary(args_dict);
-
+  args_data_impl->SetObjectSP(args_dict->shared_from_this());
   }
-  ScriptInterpreter *script_interp = bkpt->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
-  return new BreakpointResolverScripted(bkpt, class_name, depth, args_data_impl,
-  *script_interp);
+  return new BreakpointResolverScripted(bkpt, class_name, depth, 
+args_data_impl);
 }
 
 StructuredData::ObjectSP
@@ -116,6 +95,10 @@
 
   options_dict_sp->AddStringItem(GetKey(OptionNames::PythonClassName),
m_class_name);
+  if (m_args_ptr->IsValid())
+  options_dict_sp->AddItem(GetKey(OptionNames::ScriptArgs),
+  m_args_ptr->GetObjectSP());
+
   return WrapOptionsDict(options_dict_sp);
 }
 
@@ -171,11 +154,10 @@
 
 lldb::BreakpointResolverSP
 BreakpointResolverScripted::CopyForBreakpoint(Breakpoint &breakpoint) {
-  ScriptInterpreter *script_interp = GetScriptInterpreter();
   // FIXME: Have to make a copy of the arguments from the m_args_ptr and then
   // pass that to the new resolver.
   lldb::BreakpointResolverSP ret_sp(
-  new BreakpointResolverScripted(&breakpoint, m_class_name, 
-   m_depth, nullptr, *script_interp));
+  new BreakpointResolverScripted(&breakpoint, m_class_name, m_depth, 
+ nu

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Sounds good, thanks for entertaining the extra fix and proving it didn't work!


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [PATCH] D68812: [test] Pass DSYMUTIL and SDKROOT as part of the make invocation.

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D68812#1704275 , @JDevlieghere 
wrote:

> In D68812#1704235 , @clayborg wrote:
>
> > It would be great if we could ensure that if a test fails, that the 
> > "dotest" command line text has everything it needs as well, including the 
> > options and paths to lldb, framework, shared library and other settings. If 
> > I "ninja check-lldb", I have to manually insert many arguments before the 
> > command the FAIL file says to run will work.
>
>
> Any reason you want to run dotest.py directly? If you use `bin/lldb-dotest` 
> you'll get all dotest arguments that CMake configuration. Even better is to 
> use `lit --filter `, which guarantees that you'll have 
> the exact same dotest.py invocation as during `check-ldlb`.


it is mainly because that is what the FAIL file for the test run specifies to 
run. Not sure if that is fixed yet, but that is my ask here was that we fix the 
code that says "run this command to reproduce this test", which last I checked, 
was saying to run dotest.py directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68812



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


[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:116
   // "std::vector::const_iterator") searching for the innermost
   // name alone ("const_iterator) could yield many false positives. By
   // searching for the parent type ("vector") first we can avoid

Missing `"` before `)`.


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [lldb] r374402 - Remove CC autodetection from Makefile.rules

2019-10-10 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Oct 10 10:59:18 2019
New Revision: 374402

URL: http://llvm.org/viewvc/llvm-project?rev=374402&view=rev
Log:
Remove CC autodetection from Makefile.rules

Auto-detecting CC in Makefile.rules is no longer useful. Ever since
out-of-tree builds we are better off just running lldb-dotest which
sets it directly. This also makes it harder to accidentally unset CC
in a Makefile.

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=374402&r1=374401&r2=374402&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Thu Oct 10 
10:59:18 2019
@@ -171,15 +171,8 @@ endif
 #   o cxx_compiler
 #   o cxx_linker
 #--
-CC ?= clang
-ifeq "$(CC)" "cc"
-   ifneq "$(shell which clang)" ""
-   CC = clang
-   else ifneq "$(shell which clang-3.5)" ""
-   CC = clang-3.5
-   else ifneq "$(shell which gcc)" ""
-   CC = gcc
-   endif
+ifeq "$(CC)" ""
+$(error "C compiler is not specified. Please run tests through lldb-dotest or 
lit")
 endif
 
 #--


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


[Lldb-commits] [lldb] r374401 - Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Oct 10 10:59:15 2019
New Revision: 374401

URL: http://llvm.org/viewvc/llvm-project?rev=374401&view=rev
Log:
Speed up accelerator table lookups

When debugging a large program like clang and doing "frame variable
*this", the ValueObject pretty printer is doing hundreds of scoped
FindTypes lookups. The ones that take longest are the ones where the
DWARFDeclContext ends in something like ::Iterator which produces many
false positives that need to be filtered out *after* extracting the
DIEs. This patch demonstrates a way to filter out false positives at
the accerator table lookup step.

With this patch
  lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v *this" -b -- ...
goes (in user time) from 5.6s -> 4.8s
or (in wall clock) from 6.9s -> 6.0s.

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile?rev=374401&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile 
Thu Oct 10 10:59:15 2019
@@ -0,0 +1,7 @@
+# There is no guaranteed order in which the linker will order these
+# files, so we just have a lot of them to make it unlikely that we hit
+# the right one first by pure luck.
+
+CXX_SOURCES := main.cpp a.cpp b.cpp c.cpp d.cpp e.cpp f.cpp g.cpp
+
+include Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py?rev=374401&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
 Thu Oct 10 10:59:15 2019
@@ -0,0 +1,31 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CPPAcceleratorTableTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@skipIf(debug_info=no_match(["dwarf"]))
+def test(self):
+"""Test that type lookups fail early (performance)"""
+self.build()
+logfile = self.getBuildArtifact('dwarf.log')
+self.expect('log enable dwarf lookups -f' + logfile)
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, 'break here', lldb.SBFileSpec('main.cpp'))
+# Pick one from the middle of the list to have a high chance
+# of it not being in the first file looked at.
+self.expect('frame variable inner_d')
+
+log = open(logfile, 'r')
+n = 0
+for line in log:
+if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
+self.assertTrue("d.o" in line)
+n += 1
+
+self.assertEqual(n, 1, log)

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp?rev=374401&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp 
Thu Oct 10 10:59:15 2019
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(A)

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
URL: 

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG418893d8f2f3: Speed up accelerator table lookups (authored 
by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,7 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
@@ -119,12 +120,32 @@
   m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
 m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
 type_name.GetStringRef(), tag, qualified_name_hash, offsets);
-  } else if (has_tag) {
+return;
+  }
+
+  if (has_tag) {
+// When searching for a scoped type (for example,
+// "std::vector::const_iterator") searching for the innermost
+// name alone ("const_iterator") could yield many false
+// positives. By searching for the parent type ("vector")
+// first we can avoid extracting type DIEs from object files that
+// would fail the filter anyway.
+if (!has_qualified_name_hash && (context.GetSize() > 1) &&
+(context[1].tag == DW_TAG_class_type ||
+ context[1].tag == DW_TAG_structure_type)) {
+  DIEArray class_matches;
+  m_apple_types_up->FindByName(context[1].name, class_matches);
+  if (class_matches.empty())
+return;
+}
+
 if (log)
   m_module.LogMessage(log, "FindByNameAndTag()");
 m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
-  } else
-m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
+return;
+  }
+
+  m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
 }
 
 void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/

[Lldb-commits] [PATCH] D68731: Remove CC autodetection from Makefile.rules

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a07b99c90e5: Remove CC autodetection from Makefile.rules 
(authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68731

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -171,15 +171,8 @@
 #   o cxx_compiler
 #   o cxx_linker
 #--
-CC ?= clang
-ifeq "$(CC)" "cc"
-   ifneq "$(shell which clang)" ""
-   CC = clang
-   else ifneq "$(shell which clang-3.5)" ""
-   CC = clang-3.5
-   else ifneq "$(shell which gcc)" ""
-   CC = gcc
-   endif
+ifeq "$(CC)" ""
+$(error "C compiler is not specified. Please run tests through lldb-dotest or 
lit")
 endif
 
 #--


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -171,15 +171,8 @@
 #   o cxx_compiler
 #   o cxx_linker
 #--
-CC ?= clang
-ifeq "$(CC)" "cc"
-	ifneq "$(shell which clang)" ""
-		CC = clang
-	else ifneq "$(shell which clang-3.5)" ""
-		CC = clang-3.5
-	else ifneq "$(shell which gcc)" ""
-		CC = gcc
-	endif
+ifeq "$(CC)" ""
+$(error "C compiler is not specified. Please run tests through lldb-dotest or lit")
 endif
 
 #--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374412 - Die, TABS, die, die, die, die...

2019-10-10 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Thu Oct 10 11:19:27 2019
New Revision: 374412

URL: http://llvm.org/viewvc/llvm-project?rev=374412&view=rev
Log:
Die, TABS, die, die, die, die...

Not sure how tabs got into this file, but they don't belong there.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py?rev=374412&r1=374411&r2=374412&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 Thu Oct 10 11:19:27 2019
@@ -298,10 +298,10 @@ class BreakpointSerialization(TestBase):
 def do_check_extra_args(self):
 
 import side_effect
-   interp = self.dbg.GetCommandInterpreter()
-   error = lldb.SBError()
+interp = self.dbg.GetCommandInterpreter()
+error = lldb.SBError()
 
-   script_name = os.path.join(self.getSourceDir(), "resolver.py")
+script_name = os.path.join(self.getSourceDir(), "resolver.py")
 
 command = "command script import " + script_name
 result = lldb.SBCommandReturnObject()
@@ -376,3 +376,7 @@ class BreakpointSerialization(TestBase):
 self.assertEqual(copy_value, "second_value")
 else:
 self.Fail("Unknown key: %s"%(key))
+<<< HEAD
+===
+
+>>> Die, TABS, die, die, die, die...


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


[Lldb-commits] [lldb] r374414 - Remove merge marker :-)

2019-10-10 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Oct 10 11:30:47 2019
New Revision: 374414

URL: http://llvm.org/viewvc/llvm-project?rev=374414&view=rev
Log:
Remove merge marker :-)

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py?rev=374414&r1=374413&r2=374414&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 Thu Oct 10 11:30:47 2019
@@ -376,7 +376,3 @@ class BreakpointSerialization(TestBase):
 self.assertEqual(copy_value, "second_value")
 else:
 self.Fail("Unknown key: %s"%(key))
-<<< HEAD
-===
-
->>> Die, TABS, die, die, die, die...


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


[Lldb-commits] [lldb] r374417 - TestFileHandle.py: fix for Python 3.6

2019-10-10 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Thu Oct 10 11:38:23 2019
New Revision: 374417

URL: http://llvm.org/viewvc/llvm-project?rev=374417&view=rev
Log:
TestFileHandle.py: fix for Python 3.6

Summary:
Python 3.6 stringifies exceptions as `ExceptionClass("foo",)` instead
of `ExceptionClass("foo")`.   This patch makes the test assertions a
little more flexible so the test passes anyway.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374417&r1=374416&r2=374417&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Thu Oct 10 11:38:23 2019
@@ -676,11 +676,11 @@ class FileHandleTestCase(lldbtest.TestBa
 error, n = lldb.SBFile(BadIO()).Write(b"FOO")
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 
 
 @add_test_categories(['pyapi'])


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


[Lldb-commits] [PATCH] D68745: TestFileHandle.py: fix for Python 3.6

2019-10-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4faec5e01ad1: TestFileHandle.py: fix for Python 3.6 
(authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68745

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py


Index: 
lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -676,11 +676,11 @@
 error, n = lldb.SBFile(BadIO()).Write(b"FOO")
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 
 
 @add_test_categories(['pyapi'])


Index: lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -676,11 +676,11 @@
 error, n = lldb.SBFile(BadIO()).Write(b"FOO")
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
 self.assertEqual(n, 0)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "OhNoe('OH NOE')")
+self.assertIn('OH NOE', error.GetCString())
 
 
 @add_test_categories(['pyapi'])
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374422 - update SBDebugger::SetInputFile() etc to work on native Files

2019-10-10 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Thu Oct 10 12:10:59 2019
New Revision: 374422

URL: http://llvm.org/viewvc/llvm-project?rev=374422&view=rev
Log:
update SBDebugger::SetInputFile() etc to work on native Files

Summary:
This patch adds FileSP versions of SetInputFile(),
SetOutputFile, and SetErrorFile().   SWIG will convert native
python file objects into FileSP.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: clayborg, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/API/SBDebugger.h

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
lldb/trunk/scripts/interface/SBDebugger.i
lldb/trunk/source/API/SBDebugger.cpp

Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=374422&r1=374421&r2=374422&view=diff
==
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Thu Oct 10 12:10:59 2019
@@ -94,6 +94,12 @@ public:
 
   SBError SetErrorFile(SBFile file);
 
+  SBError SetInputFile(FileSP file);
+
+  SBError SetOutputFile(FileSP file);
+
+  SBError SetErrorFile(FileSP file);
+
   SBFile GetInputFile();
 
   SBFile GetOutputFile();

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374422&r1=374421&r2=374422&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Thu Oct 10 12:10:59 2019
@@ -549,7 +549,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailureAll() # fixme multiple problems with this
 def test_string_out(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)
@@ -559,7 +558,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 @skipIf(py_version=['<', (3,)])
 def test_string_error(self):
 f = io.StringIO()
@@ -630,7 +628,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 @skipIf(py_version=['<', (3,)])
 def test_file_out(self):
 with open(self.out_filename, 'w') as f:
@@ -654,7 +651,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetErrorFile
 def test_file_error(self):
 with open(self.out_filename, 'w') as f:
 status = self.debugger.SetErrorFile(f)
@@ -746,7 +742,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetOutputFile
 def test_close(self):
 debugger = self.debugger
 with open(self.out_filename, 'w') as f:
@@ -767,7 +762,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailureAll() # FIXME need FileSP version of 
SBDebugger::SetOutputFile
 def test_stdout(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)

Modified: lldb/trunk/scripts/interface/SBDebugger.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBDebugger.i?rev=374422&r1=374421&r2=374422&view=diff
==
--- lldb/trunk/scripts/interface/SBDebugger.i (original)
+++ lldb/trunk/scripts/interface/SBDebugger.i Thu Oct 10 12:10:59 2019
@@ -165,21 +165,27 @@ public:
 void
 SkipLLDBInitFiles (bool b);
 
+%feature("autodoc", "DEPRECATED, use SetInputFile");
 void
 SetInputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetOutputFile");
 void
 SetOutputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetErrorFile");
 void
 SetErrorFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use GetInputFile");
 FILE *
 GetInputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetOutputFile");
 FILE *
 GetOutputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetErrorFile");
 FILE *
 GetErrorFileHandle ();
 
@@ -192,6 +198,15 @@ public:
 SBError
 SetErrorFile (SBF

[Lldb-commits] [PATCH] D68734: update SBDebugger::SetInputFile() etc to work on native Files

2019-10-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc040b30ffc3d: update SBDebugger::SetInputFile() etc to work 
on native Files (authored by lawrence_danna).

Changed prior to commit:
  https://reviews.llvm.org/D68734?vs=224174&id=224437#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68734

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBDebugger.i
  lldb/source/API/SBDebugger.cpp

Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -292,6 +292,11 @@
   SetInputFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
+SBError SBDebugger::SetInputFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp);
+  return SetInputFile(SBFile(file_sp));
+}
+
 // Shouldn't really be settable after initialization as this could cause lots
 // of problems; don't want users trying to switch modes in the middle of a
 // debugging session.
@@ -332,6 +337,11 @@
   return error;
 }
 
+SBError SBDebugger::SetOutputFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp);
+  return SetOutputFile(SBFile(file_sp));
+}
+
 void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
  transfer_ownership);
@@ -359,6 +369,11 @@
   SetErrorFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
+SBError SBDebugger::SetErrorFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp);
+  return SetErrorFile(SBFile(file_sp));
+}
+
 SBError SBDebugger::SetErrorFile(SBFile file) {
   LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (SBFile file), file);
   SBError error;
@@ -1576,6 +1591,8 @@
 
 static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
 
+static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
+
 static bool GetDefaultArchitectureRedirect(char *arch_name,
size_t arch_name_len) {
   // The function is writing to its argument. Without the redirect it would
@@ -1606,6 +1623,16 @@
  SBFile)>::method<&SBDebugger::SetErrorFile>::doit,
  &SetFileRedirect);
 
+  R.Register(&invoke::method<&SBDebugger::SetInputFile>::doit,
+ &SetFileRedirect);
+  R.Register(&invoke::method<&SBDebugger::SetOutputFile>::doit,
+ &SetFileRedirect);
+  R.Register(&invoke::method<&SBDebugger::SetErrorFile>::doit,
+ &SetFileRedirect);
+
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
Index: lldb/scripts/interface/SBDebugger.i
===
--- lldb/scripts/interface/SBDebugger.i
+++ lldb/scripts/interface/SBDebugger.i
@@ -165,21 +165,27 @@
 void
 SkipLLDBInitFiles (bool b);
 
+%feature("autodoc", "DEPRECATED, use SetInputFile");
 void
 SetInputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetOutputFile");
 void
 SetOutputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetErrorFile");
 void
 SetErrorFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use GetInputFile");
 FILE *
 GetInputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetOutputFile");
 FILE *
 GetOutputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetErrorFile");
 FILE *
 GetErrorFileHandle ();
 
@@ -192,6 +198,15 @@
 SBError
 SetErrorFile (SBFile file);
 
+SBError
+SetInputFile (FileSP file);
+
+SBError
+SetOutputFile (FileSP file);
+
+SBError
+SetErrorFile (FileSP file);
+
 SBFile
 GetInputFile ();
 
Index: lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -549,7 +549,6 @@
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailureAll() # fixme multiple problems with this
 def test_string_out(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)
@@ -559,7 +558,6 @@
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME need FileSP version of SBDebugger::SetError

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 224409.
aprantl added a comment.

and feedback from Jonas.


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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,7 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
@@ -119,12 +120,32 @@
   m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
 m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
 type_name.GetStringRef(), tag, qualified_name_hash, offsets);
-  } else if (has_tag) {
+return;
+  }
+
+  if (has_tag) {
+// When searching for a scoped type (for example,
+// "std::vector::const_iterator") searching for the innermost
+// name alone ("const_iterator") could yield many false
+// positives. By searching for the parent type ("vector")
+// first we can avoid extracting type DIEs from object files that
+// would fail the filter anyway.
+if (!has_qualified_name_hash && (context.GetSize() > 1) &&
+(context[1].tag == DW_TAG_class_type ||
+ context[1].tag == DW_TAG_structure_type)) {
+  DIEArray class_matches;
+  m_apple_types_up->FindByName(context[1].name, class_matches);
+  if (class_matches.empty())
+return;
+}
+
 if (log)
   m_module.LogMessage(log, "FindByNameAndTag()");
 m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
-  } else
-m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
+return;
+  }
+
+  m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
 }
 
 void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===
--- /dev/null

[Lldb-commits] [lldb] r374424 - update TestRunCommandInterpreterAPI to use SBFile

2019-10-10 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Thu Oct 10 12:24:07 2019
New Revision: 374424

URL: http://llvm.org/viewvc/llvm-project?rev=374424&view=rev
Log:
update TestRunCommandInterpreterAPI to use SBFile

Summary:
If you look at what this test is doing, it's actually quite
mysterious why it works at all.   It sets the input file
inside a "with open".   As soon as the with block ends,
that file will be closed.   And yet somehow LLDB reads
commands from it anyway.What's actually happening is that
the file descriptor gets dup'd when something inside LLDB
calls File::GetStream().   I think it's fair to say that
what this test is doing is illegal and it has no right
to expect it to work.

This patch updates the test with two cases.  One uses
the SBFile api, and actually transfers ownership of
the original file descriptor to the debugger.   The other
just uses the old FILE* API, but in a sane way.

I also set NO_DEBUG_INFO_TESTCASE, because this test doesn't
use any debug info and doesn't need to run three times.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: aprantl, lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py?rev=374424&r1=374423&r2=374424&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
 Thu Oct 10 12:24:07 2019
@@ -5,8 +5,46 @@ import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+class CommandRunInterpreterLegacyAPICase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+self.stdin_path = self.getBuildArtifact("stdin.txt")
+
+with open(self.stdin_path, 'w') as input_handle:
+input_handle.write("nonexistingcommand\nquit")
+
+# Python will close the file descriptor if all references
+# to the filehandle object lapse, so we need to keep one
+# around.
+self.filehandle = open(self.stdin_path, 'r')
+self.dbg.SetInputFileHandle(self.filehandle, False)
+
+# No need to track the output
+self.devnull = open(os.devnull, 'w')
+self.dbg.SetOutputFileHandle(self.devnull, False)
+self.dbg.SetErrorFileHandle (self.devnull, False)
+
+@add_test_categories(['pyapi'])
+def test_run_session_with_error_and_quit(self):
+"""Run non-existing and quit command returns appropriate values"""
+
+n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter(
+True, False, lldb.SBCommandInterpreterRunOptions(), 0, False,
+False)
+
+self.assertGreater(n_errors, 0)
+self.assertTrue(quit_requested)
+self.assertFalse(has_crashed)
+
+
 class CommandRunInterpreterAPICase(TestBase):
 
+NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
@@ -17,13 +55,12 @@ class CommandRunInterpreterAPICase(TestB
 with open(self.stdin_path, 'w') as input_handle:
 input_handle.write("nonexistingcommand\nquit")
 
-with open(self.stdin_path, 'r') as input_handle:
-self.dbg.SetInputFileHandle(input_handle, False)
+self.dbg.SetInputFile(open(self.stdin_path, 'r'))
 
 # No need to track the output
 devnull = open(os.devnull, 'w')
-self.dbg.SetOutputFileHandle(devnull, False)
-self.dbg.SetErrorFileHandle(devnull, False)
+self.dbg.SetOutputFile(devnull)
+self.dbg.SetErrorFile(devnull)
 
 @add_test_categories(['pyapi'])
 def test_run_session_with_error_and_quit(self):


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


[Lldb-commits] [PATCH] D68738: update TestRunCommandInterpreterAPI to use SBFile

2019-10-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab1cd65f1914: update TestRunCommandInterpreterAPI to use 
SBFile (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68738

Files:
  
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py


Index: 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
===
--- 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
+++ 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
@@ -5,8 +5,46 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+class CommandRunInterpreterLegacyAPICase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+self.stdin_path = self.getBuildArtifact("stdin.txt")
+
+with open(self.stdin_path, 'w') as input_handle:
+input_handle.write("nonexistingcommand\nquit")
+
+# Python will close the file descriptor if all references
+# to the filehandle object lapse, so we need to keep one
+# around.
+self.filehandle = open(self.stdin_path, 'r')
+self.dbg.SetInputFileHandle(self.filehandle, False)
+
+# No need to track the output
+self.devnull = open(os.devnull, 'w')
+self.dbg.SetOutputFileHandle(self.devnull, False)
+self.dbg.SetErrorFileHandle (self.devnull, False)
+
+@add_test_categories(['pyapi'])
+def test_run_session_with_error_and_quit(self):
+"""Run non-existing and quit command returns appropriate values"""
+
+n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter(
+True, False, lldb.SBCommandInterpreterRunOptions(), 0, False,
+False)
+
+self.assertGreater(n_errors, 0)
+self.assertTrue(quit_requested)
+self.assertFalse(has_crashed)
+
+
 class CommandRunInterpreterAPICase(TestBase):
 
+NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
@@ -17,13 +55,12 @@
 with open(self.stdin_path, 'w') as input_handle:
 input_handle.write("nonexistingcommand\nquit")
 
-with open(self.stdin_path, 'r') as input_handle:
-self.dbg.SetInputFileHandle(input_handle, False)
+self.dbg.SetInputFile(open(self.stdin_path, 'r'))
 
 # No need to track the output
 devnull = open(os.devnull, 'w')
-self.dbg.SetOutputFileHandle(devnull, False)
-self.dbg.SetErrorFileHandle(devnull, False)
+self.dbg.SetOutputFile(devnull)
+self.dbg.SetErrorFile(devnull)
 
 @add_test_categories(['pyapi'])
 def test_run_session_with_error_and_quit(self):


Index: lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
@@ -5,8 +5,46 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+class CommandRunInterpreterLegacyAPICase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+self.stdin_path = self.getBuildArtifact("stdin.txt")
+
+with open(self.stdin_path, 'w') as input_handle:
+input_handle.write("nonexistingcommand\nquit")
+
+# Python will close the file descriptor if all references
+# to the filehandle object lapse, so we need to keep one
+# around.
+self.filehandle = open(self.stdin_path, 'r')
+self.dbg.SetInputFileHandle(self.filehandle, False)
+
+# No need to track the output
+self.devnull = open(os.devnull, 'w')
+self.dbg.SetOutputFileHandle(self.devnull, False)
+self.dbg.SetErrorFileHandle (self.devnull, False)
+
+@add_test_categories(['pyapi'])
+def test_run_session_with_error_and_quit(self):
+"""Run non-existing and quit command returns appropriate values"""
+
+n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter(
+True, False, lldb.SBCommandInterpreterRunOptions(), 0, False,
+False)
+
+self.assertGreater(n_errors, 0)
+self.assertTrue(quit_requested)
+self.assertFalse(has_crashed)
+
+
 class CommandRunInterpreterAPICase(TestBase):
 
+NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
@@ -17,

[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Dimitry Andric via Phabricator via lldb-commits
dim updated this revision to Diff 224447.
dim added a comment.
Herald added a subscriber: jfb.

Convert `m_(monitor|operation)_thread` to `llvm::Optional<>`.


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

https://reviews.llvm.org/D68723

Files:
  source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  source/Plugins/Process/FreeBSD/ProcessMonitor.h

Index: source/Plugins/Process/FreeBSD/ProcessMonitor.h
===
--- source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -183,8 +183,8 @@
 private:
   ProcessFreeBSD *m_process;
 
-  llvm::Expected m_operation_thread;
-  llvm::Expected m_monitor_thread;
+  llvm::Optional m_operation_thread;
+  llvm::Optional m_monitor_thread;
   lldb::pid_t m_pid;
 
   int m_terminal_fd;
Index: source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -703,7 +703,7 @@
 const lldb_private::ProcessLaunchInfo & /* launch_info */,
 lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   std::unique_ptr args(
@@ -730,20 +730,22 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process launch failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   sem_init(&m_operation_pending, 0, 0);
@@ -768,14 +770,16 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process attach failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::~ProcessMonitor() { StopMonitor(); }
@@ -784,13 +788,15 @@
 void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread && m_operation_thread->IsJoinable())
 return;
 
-  m_operation_thread =
-  ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
-  if (!m_operation_thread)
- error = m_operation_thread.takeError();
+  llvm::Expected operation_thread =
+ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::LaunchOpThread(void *arg) {
@@ -952,14 +958,15 @@
  lldb_private::Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread && m_operation_thread->IsJoinable())
 return;
 
-  m_operation_thread =
-  ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
-
-  if (!m_operation_thread)
-	error = m_operation_thread.takeError();
+  llvm::Expected operation_thread =
+ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::AttachOpThread(void *arg) {
@@ -1374,7 +1381,7 @@
 }
 
 void ProcessMonitor::StopMonitoringChildProcess() {
-  if (m_monitor_thread->IsJoinable()) {
+  if (m_monitor_thread && m_monitor_thread->IsJoinable()) {
 m_monitor_thread->Cancel();
 m_monitor_thread->Join(nullptr);
 m_monit

[Lldb-commits] [lldb] r374430 - [Docs] Update testing documentaton

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 12:35:20 2019
New Revision: 374430

URL: http://llvm.org/viewvc/llvm-project?rev=374430&view=rev
Log:
[Docs] Update testing documentaton

Update the test documentation after the directory reorganization.

Modified:
lldb/trunk/docs/resources/test.rst

Modified: lldb/trunk/docs/resources/test.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/resources/test.rst?rev=374430&r1=374429&r2=374430&view=diff
==
--- lldb/trunk/docs/resources/test.rst (original)
+++ lldb/trunk/docs/resources/test.rst Thu Oct 10 12:35:20 2019
@@ -3,18 +3,22 @@ Testing
 
 The LLDB test suite consists of three different kinds of test:
 
-* Python scripts located under ``lldb/packages/Python/lldbsuite``.
-  These are written using python's unittest2 testing framework.
-
-* Unit tests, located under ``lldb/unittests``.   These are written in C++,
+* Unit test. These are located under ``lldb/unittests`` and are written in C++
   using googletest.
-
-* LIT tests, located under ``lldb/lit``.  These use the LLVM Integrated Tester.
-
-Many of the tests are accompanied by a C (C++, ObjC, etc.) source file. Each 
test
-first compiles the source file and then uses LLDB to debug the resulting 
executable.
-
-The tests verify both the LLDB command line interface and the scripting API.
+* Integration tests that test the debugger through the SB API. These are
+  located under ``lldb/packages/Python/lldbsuite`` and are written in Python
+  using ``dotest`` (LLDB's custom testing framework on top of unittest2).
+* Integration tests that test the debugger through the command line. These are
+  locarted under `lldb/tests/Shell` and are written in a shell-style format
+  using FileCheck to verify its output.
+
+All three test suites use the `LLVM Integrated Tester
+`_ (lit) as their test driver. The
+test suites can be run as a whole or separately.
+
+Many of the tests are accompanied by a C (C++, ObjC, etc.) source file. Each
+test first compiles the source file and then uses LLDB to debug the resulting
+executable.
 
 .. contents::
:local:
@@ -54,23 +58,69 @@ built with a custom version of clang, do
 Note that multiple ``-A`` and ``-C`` flags can be specified to
 ``LLDB_TEST_USER_ARGS``.
 
+Running a Single Test Suite
+---
+
+Each test suite can be run separately, similar to running the whole test suite
+with ``check-lldb``.
 
-Running a Specific Test or Set of Tests: Python

+* Use ``check-lldb-unit`` to run just the unit tests.
+* Use ``check-lldb-api`` to run just the SB API tests.
+* Use ``check-lldb-shell`` to run just the shell tests.
+
+You can run specific subdirectories by appending the directory name to the
+target. For example, to run all the tests in ``ObjectFile``, you can use the
+target ``check-lldb-shell-objectfile``. However, because the unit tests and API
+tests don't actually live under ``lldb/test``, this convenience is only
+available for the shell tests.
+
+Running a Single Test
+-
+
+The recommended way to run a single test is by invoking the lit driver with a
+filter. This ensures that the test is run with the same configuration as when
+run as part of a test suite.
+
+::
+
+   > ./bin/llvm-lit -sv lldb/test --filter 
+
+
+Because lit automatically scans a directory for tests, it's also possible to
+pass a subdirectory to run a specific subset of the tests.
+
+::
+
+   > ./bin/llvm-lit -sv 
tools/lldb/test/Shell/Commands/CommandScriptImmediateOutput
+
+
+For the SB API tests it is possible to forward arguments to ``dotest.py`` by
+passing ``--param`` to lit and setting a value for ``dotest-args``.
+
+::
+
+   > ./bin/llvm-lit -sv tools/lldb/test --param dotest-args='-C gcc'
+
+
+Below is an overview of running individual test in the unit and API test suites
+without going through the lit driver.
+
+Running a Specific Test or Set of Tests: API Tests
+--
 
 In addition to running all the LLDB test suites with the ``check-lldb`` CMake
 target above, it is possible to run individual LLDB tests. If you have a CMake
 build you can use the ``lldb-dotest`` binary, which is a wrapper around
-``dotest.py`` that passes all the arguments configured by CMake. Alternatively,
-you can use ``dotest.py`` directly, if you want to run a test one-off with a
-different configuration.
+``dotest.py`` that passes all the arguments configured by CMake.
 
+Alternatively, you can use ``dotest.py`` directly, if you want to run a test
+one-off with a different configuration.
 
 For example, to run the test cases defined in TestInferiorCrashing.py, run:
 
 ::
 
-   > lldb-dotest -p TestInferiorCrashing.py
+   > ./bin/lldb-dotest -p TestInferiorCrashing.py
 
 ::
 
@@ -83,7 +133,7 @@ off),  all tests in that directory will
 
 ::
 
-   > lldb-dotest 

[Lldb-commits] [PATCH] D68737: SBFile::GetFile: convert SBFile back into python native files.

2019-10-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna marked 3 inline comments as done.
lawrence_danna added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py:776
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME implement SBFile::GetFile
 @skipIf(py_version=['<', (3,)])

labath wrote:
> So, if I understand correctly, these tests check that you can feed a file 
> opened by python into lldb, and then pump it back out to python. Are there 
> any tests which do the opposite (have lldb open a file, move it to python and 
> then reinject it into lldb)?
Yea, `foo is bar` in python is essentially a pointer comparison between the 
`PyObject*` pointers, so this is testing that you get the same identical file 
object back in the situations where you should.

There's no test going the other way, because going the other way isn't 
implemented.   I didn't write anything that could stash an arbitrary 
`lldb_private::File` in a python object .   If you convert a non-python `File`, 
you will get a new python file based on the descriptor, if it's available, or 
the conversion will fail if one is not.   We do test that here, on line 801, 
we're testing that a `NativeFile` is converted to a working python file and the 
file descriptors match.

We could, in a follow-on patch make the other direction work with identity too, 
but right now I can't think of what it would be useful for.



Comment at: lldb/scripts/interface/SBFile.i:81
+
+%feature("docstring", "convert this SBFile into a python io.IOBase file 
object");
+FileSP GetFile();

labath wrote:
> I am somewhat surprised that there's no ownership handling in this patch 
> (whereas ownership transfer was a fairly big chunk of the conversion in the 
> other direction). Could you maybe explain what are the ownership expectations 
> of the file returned through here (and what happens when we close it for 
> instance)?
Oh, yea good point.`GetFile` returns a borrowed file, it shouldn't be 
closed.   I'll add a comment explaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68737



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


[Lldb-commits] [PATCH] D68737: SBFile::GetFile: convert SBFile back into python native files.

2019-10-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna marked an inline comment as done.
lawrence_danna added inline comments.



Comment at: lldb/include/lldb/Host/File.h:316
+  ///The PyObject* that this File wraps, or NULL.
+  virtual void *GetPythonObject() const;
+

labath wrote:
> We've spend a lot of time removing python from the lowest layers, and this 
> let's it back in through the back door. It would be way better to add support 
> for llvm-style rtti to this class, so that the python code can `dyn_cast` to 
> a `PythonFile` when it needs to (re)construct the python object. You can take 
> a look at CPPLanguageRuntime::classof  (and friend) for how to implement this 
> in a plugin-friendly manner.
Ah, thanks.  I orginally wrote this using `dyn_cast` but I found myself putting 
classnames of python things in an enum in `File.h`, so I thought "what's the 
point?" -- and I converted it to just using the virtual method.   The `static 
char ID` trick is nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68737



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


[Lldb-commits] [lldb] r374434 - [test] Cleanup top-level lit.cfg.py

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 12:51:47 2019
New Revision: 374434

URL: http://llvm.org/viewvc/llvm-project?rev=374434&view=rev
Log:
[test] Cleanup top-level lit.cfg.py

Modified:
lldb/trunk/test/lit.cfg.py

Modified: lldb/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lit.cfg.py?rev=374434&r1=374433&r2=374434&view=diff
==
--- lldb/trunk/test/lit.cfg.py (original)
+++ lldb/trunk/test/lit.cfg.py Thu Oct 10 12:51:47 2019
@@ -1,41 +1,15 @@
 # -*- Python -*-
 
 import os
-import platform
-import re
-import shutil
-import site
-import sys
 
 import lit.formats
 from lit.llvm import llvm_config
-from lit.llvm.subst import FindTool
-from lit.llvm.subst import ToolSubst
-from distutils.spawn import find_executable
 
 # This is the top level configuration. Most of these configuration options will
 # be overriden by individual lit configuration files in the test
-# subdirectories.
+# subdirectories. Anything configured here will *not* be loaded when pointing
+# lit at on of the subdirectories.
 
-# name: The name of this test suite.
 config.name = 'lldb'
-
-# testFormat: The test format to use to interpret tests.
-config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
-
-# suffixes: A list of file extensions to treat as test files. This is overriden
-# by individual lit.local.cfg files in the test subdirectories.
-config.suffixes = ['.test', '.cpp', '.s']
-
-# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
-# subdirectories contain auxiliary inputs for various tests in their parent
-# directories.
-config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
-
-# test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
-
-# test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.lldb_obj_root, 'test')
-
-llvm_config.use_default_substitutions()


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


[Lldb-commits] [lldb] r374435 - [test] Add timeout to API tests.

2019-10-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Oct 10 12:51:50 2019
New Revision: 374435

URL: http://llvm.org/viewvc/llvm-project?rev=374435&view=rev
Log:
[test] Add timeout to API tests.

Before the reorganiziation, the API tests were inheriting the timeout
from the top-level lit file. Now that this is no longer the case, the
lldb-api test suite needs to set its own timeout.

Modified:
lldb/trunk/test/API/lit.cfg
lldb/trunk/test/Shell/lit.cfg.py

Modified: lldb/trunk/test/API/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/API/lit.cfg?rev=374435&r1=374434&r2=374435&view=diff
==
--- lldb/trunk/test/API/lit.cfg (original)
+++ lldb/trunk/test/API/lit.cfg Thu Oct 10 12:51:50 2019
@@ -61,6 +61,15 @@ for cachedir in [config.clang_module_cac
 print("Deleting module cache at %s."%cachedir)
 shutil.rmtree(cachedir)
 
+# Set a default per-test timeout of 10 minutes. Setting a timeout per test
+# requires that killProcessAndChildren() is supported on the platform and
+# lit complains if the value is set but it is not supported.
+supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
+if supported:
+lit_config.maxIndividualTestTime = 600
+else:
+lit_config.warning("Could not set a default per-test timeout. " + errormsg)
+
 # Build dotest command.
 dotest_cmd = [config.dotest_path]
 dotest_cmd.extend(config.dotest_args_str.split(';'))

Modified: lldb/trunk/test/Shell/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/lit.cfg.py?rev=374435&r1=374434&r2=374435&view=diff
==
--- lldb/trunk/test/Shell/lit.cfg.py (original)
+++ lldb/trunk/test/Shell/lit.cfg.py Thu Oct 10 12:51:50 2019
@@ -39,9 +39,7 @@ config.test_exec_root = os.path.join(con
 
 
 llvm_config.use_default_substitutions()
-
 toolchain.use_lldb_substitutions(config)
-
 toolchain.use_support_substitutions(config)
 
 


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


[Lldb-commits] [PATCH] D68770: [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

2019-10-10 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Cool.  I didn't know about InitLLVM.  That makes things much cleaner.

Though I do recall recently seeing another complaint about `argv[0]` not being 
preserved as typed but being replaced by an absolute path.  That will 
definitely happen now on Windows.  Is that a problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68770



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


[Lldb-commits] [lldb] r374444 - Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Dimitry Andric via lldb-commits
Author: dim
Date: Thu Oct 10 13:26:59 2019
New Revision: 37

URL: http://llvm.org/viewvc/llvm-project?rev=37&view=rev
Log:
Fix process launch failure on FreeBSD after r365761

Summary:
After rLLDB365761, and with `LLVM_ENABLE_ABI_BREAKING_CHECKS` enabled,
launching any process on FreeBSD crashes lldb with:

```
Expected must be checked before access or destruction.
Expected value was in success state. (Note: Expected values in success 
mode must still be checked prior to being destroyed).
```

This is because `m_operation_thread` and `m_monitor_thread` were wrapped
in `llvm::Expected<>`, but this requires the objects to be correctly
initialized before accessing them.

To fix the crashes, use `llvm::Optional<>` for the members (as indicated
by labath), and use local variables to store the return values of
`LaunchThread` and `StartMonitoringChildProcess`.  Then, only assign to
the member variables after checking if the return values indicated
success.

Reviewers: devnexen, emaste, MaskRay, mgorny

Reviewed By: devnexen

Subscribers: jfb, labath, krytarowski, lldb-commits

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

Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=37&r1=374443&r2=37&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Thu Oct 10 
13:26:59 2019
@@ -703,7 +703,7 @@ ProcessMonitor::ProcessMonitor(
 const lldb_private::ProcessLaunchInfo & /* launch_info */,
 lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), 
m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), 
m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   std::unique_ptr args(
@@ -730,20 +730,22 @@ ProcessMonitor::ProcessMonitor(
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process launch failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), 
m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(pid), m_terminal_fd(-1), 
m_operation(0) {
   using namespace std::placeholders;
 
   sem_init(&m_operation_pending, 0, 0);
@@ -768,14 +770,16 @@ ProcessMonitor::ProcessMonitor(ProcessFr
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process attach failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::~ProcessMonitor() { StopMonitor(); }
@@ -784,13 +788,15 @@ ProcessMonitor::~ProcessMonitor() { Stop
 void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread && m_operation_thread->IsJoinable())
 return;
 
-  m_operation_thread =
-  ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
-  if (!m_operation_thread)
- error = m_operation_thread.takeError();
+  llvm::Expected operation_thread =
+ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::LaunchOpThread(void *arg) {
@@ -952,14 +958,15 @@ void ProcessMonitor::StartAttachOpThread
  lldb_private::Status &error) {
   static const char *g_thread_name = "lldb.process.freeb

[Lldb-commits] [PATCH] D68770: [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

2019-10-10 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68770#1704663 , @amccarth wrote:

> Cool.  I didn't know about InitLLVM.  That makes things much cleaner.
>
> Though I do recall recently seeing another complaint about `argv[0]` not 
> being preserved as typed but being replaced by an absolute path.  That will 
> definitely happen now on Windows.  Is that a problem?


I remember seeing such behaviour elsewhere (clang) as well. I don't think that 
InitLLVM does any such rewrite of argv[0] though, so this patch should pretty 
much be a plain refactoring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68770



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


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-10 Thread Dimitry Andric via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa42942e0ecd6: Fix process launch failure on FreeBSD after 
r365761 (authored by dim).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68723?vs=224447&id=224460#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68723

Files:
  lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h

Index: lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -183,8 +183,8 @@
 private:
   ProcessFreeBSD *m_process;
 
-  llvm::Expected m_operation_thread;
-  llvm::Expected m_monitor_thread;
+  llvm::Optional m_operation_thread;
+  llvm::Optional m_monitor_thread;
   lldb::pid_t m_pid;
 
   int m_terminal_fd;
Index: lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -703,7 +703,7 @@
 const lldb_private::ProcessLaunchInfo & /* launch_info */,
 lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   std::unique_ptr args(
@@ -730,20 +730,22 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process launch failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   sem_init(&m_operation_pending, 0, 0);
@@ -768,14 +770,16 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  llvm::Expected monitor_thread =
+Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process attach failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::~ProcessMonitor() { StopMonitor(); }
@@ -784,13 +788,15 @@
 void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread && m_operation_thread->IsJoinable())
 return;
 
-  m_operation_thread =
-  ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
-  if (!m_operation_thread)
- error = m_operation_thread.takeError();
+  llvm::Expected operation_thread =
+ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::LaunchOpThread(void *arg) {
@@ -952,14 +958,15 @@
  lldb_private::Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread && m_operation_thread->IsJoinable())
 return;
 
-  m_operation_thread =
-  ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
-
-  if (!m_operation_thread)
-	error = m_operation_thread.takeError();
+  llvm::Expected operation_thread =
+ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::AttachOpThread(void *arg) {
@@ -1374,7 +1381,7 @@
 }
 
 void ProcessMonitor::Sto

[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

tatyana-krasnukha wrote:
> This command produces an incorrect path for Visual Studio since it 
> concatenates the root build directory with 'bin/liblldb.dll' bypassing 
> configuration name.
Hmm understood. The origin change is reverted in rG958091c209d0. So I don't 
think this is relevant any more. I'll redo the change. Can you help test that 
time? I don't have a visual studio...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68770: [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

2019-10-10 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

On Windows, it _does_ rewrite `argv[0]`, but it looks like it tries to not 
change whether it was relative/absolute, so I think this is fine.

Thanks for the clean-up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68770



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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D68655#1700626 , @aprantl wrote:

> I had to revert this. Apparently for very small / gapless programs, clang 
> emits single-value DW_AT_low_pc/high_pc in the compile unit, and dsymutil 
> does not rewrite that into DW_AT_ranges. Would be a nice speedup though.


So is this a bug in dsymutil? It is also legal for compilers to do this. I have 
also seen a lot of DWARF that has issues where the DW_AT_ranges for a 
DW_TAG_compile_unit is not complete and is missing functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655



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


[Lldb-commits] [PATCH] D68096: ProcessMinidump: Suppress reporting stop for signal '0'

2019-10-10 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet updated this revision to Diff 224470.
JosephTremoulet added a comment.
Herald added a reviewer: jfb.

- Rebase
- Add testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68096

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp

Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -219,6 +219,9 @@
 
   m_thread_list = m_minidump_parser->GetThreads();
   m_active_exception = m_minidump_parser->GetExceptionStream();
+
+  SetUnixSignals(UnixSignals::Create(GetArchitecture()));
+
   ReadModuleList();
 
   llvm::Optional pid = m_minidump_parser->GetPid();
@@ -238,6 +241,7 @@
 Status ProcessMinidump::DoDestroy() { return Status(); }
 
 void ProcessMinidump::RefreshStateAfterStop() {
+
   if (!m_active_exception)
 return;
 
@@ -264,8 +268,15 @@
   ArchSpec arch = GetArchitecture();
 
   if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
+uint32_t signo = m_active_exception->ExceptionRecord.ExceptionCode;
+
+if (signo == 0) {
+  // No stop.
+  return;
+}
+
 stop_info = StopInfo::CreateStopReasonWithSignal(
-*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode);
+*stop_thread, signo);
   } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
 stop_info = StopInfoMachException::CreateStopReasonWithMachException(
 *stop_thread, m_active_exception->ExceptionRecord.ExceptionCode, 2,
Index: lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64_null_signal.yaml
@@ -0,0 +1,25 @@
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x2177
+Context: 
+Stack:
+  Start of Memory Range: 0x7FFE2F689000
+  Content: 
+  - Type:Exception
+Thread ID:   0x2177
+Exception Record:
+  Exception Code:  0x
+  Exception Address: 0x00400582
+Thread Context:  
+  - Type:SystemInfo
+Processor Arch:  AMD64
+Platform ID: Linux
+  - Type:LinuxProcStatus
+Text: |
+  Name:	busyloop
+  Umask:	0002
+  State:	t (tracing stop)
+  Pid:	8567
+...
Index: lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -153,9 +153,9 @@
 self.assertTrue(eip.IsValid())
 self.assertEqual(pc, eip.GetValueAsUnsigned())
 
-def test_snapshot_minidump(self):
+def test_snapshot_minidump_dump_requested(self):
 """Test that if we load a snapshot minidump file (meaning the process
-did not crash) there is no stop reason."""
+did not crash) with exception code "DUMP_REQUESTED" there is no stop reason."""
 # target create -c linux-x86_64_not_crashed.dmp
 self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
@@ -167,6 +167,17 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def test_snapshot_minidump_null_exn_code(self):
+"""Test that if we load a snapshot minidump file (meaning the process
+did not crash) with exception code zero there is no stop reason."""
+self.process_from_yaml("linux-x86_64_null_signal.yaml")
+self.check_state()
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+stop_description = thread.GetStopDescription(256)
+self.assertEqual(stop_description, "")
+
 def check_register_unsigned(self, set, name, expected):
 reg_value = set.GetChildMemberWithName(name)
 self.assertTrue(reg_value.IsValid(),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >