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

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



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:440
+
+os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
 

So, what's the reason for passing this around through environment? Couldn't the 
"builder" module just fetch that from the configuration object? Using the 
environment to communicate between two python functions is just wrong...


Repository:
  rG LLVM Github Monorepo

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] D68861: [lldb] Add nodebug attribute to import-std-module/sysroot test

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

So far we rely on the default argument and the fact that we don't call this
inline function in our actual `main.cpp` to make sure that this function can 
only
be called if LLDB loads this header as a C++ module. This patch just adds
the nodebug attribute as yet another measure to make sure LLDB can't call this
function without the standard module loaded. Note that the test is already
requiring clang for the sysroot setup, so its fine that this is a Clang 
specific attribute.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68861

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


Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
===
--- 
lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
@@ -4,6 +4,7 @@
   // Makes sure we get a support file for this header.
   struct vector { int i; };
 
+  __attribute__((__nodebug__))
   inline int myabs(int i = -123) {
 double nil;
 return i < 0 ? -i : i;


Index: lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
+++ lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
@@ -4,6 +4,7 @@
   // Makes sure we get a support file for this header.
   struct vector { int i; };
 
+  __attribute__((__nodebug__))
   inline int myabs(int i = -123) {
 double nil;
 return i < 0 ? -i : i;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-11 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Core/IOHandler.cpp:308-310
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;

Please move these to the beginning of the file, next to all the "using 
namespace" stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622



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


[Lldb-commits] [PATCH] D68856: convert SBDebugger::***FileHandle() wrappers to native files.

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



Comment at: 
lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py:827-835
+self.assertRaises(TypeError, self.debugger.SetOutputFile, None)
+self.assertRaises(TypeError, self.debugger.SetOutputFile, "ham 
sandwich")
+self.assertRaises(TypeError, self.debugger.SetOutputFileHandle, "ham 
sandwich")
+self.assertRaises(TypeError, self.debugger.SetInputFile, None)
+self.assertRaises(TypeError, self.debugger.SetInputFile, "ham 
sandwich")
+self.assertRaises(TypeError, self.debugger.SetInputFileHandle, "ham 
sandwich")
+self.assertRaises(TypeError, self.debugger.SetErrorFile, None)

I think these will fail with swig<=3. See my r374322. I personally don't think 
you need these checks for _every_ api taking accepting a file object, but if 
you do want to have them, you'll need to account for the differences in swig 
versions somehow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68856



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


[Lldb-commits] [lldb] r374525 - [lldb] Fix crash in CxxModuleHandler when std module is empty

2019-10-11 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct 11 01:42:22 2019
New Revision: 374525

URL: http://llvm.org/viewvc/llvm-project?rev=374525&view=rev
Log:
[lldb] Fix crash in CxxModuleHandler when std module is empty

We currently don't handle the error in the Expected we get
when searching for an equal local DeclContext. Usually this can't
happen as this would require that we have a STL container and
we can find libc++'s std module, but when we load the module in
the expression parser the module doesn't even contain the 'std'
namespace. The only way I see to test this is by having a fake
'std' module that requires a special define to actually provide
its contents, while it will just be empty (that is, it doesn't
even contain the 'std' namespace) without that define. LLDB currently
doesn't know about that define in the expression parser, so it
will load the wrong 'empty' module which should trigger this error.

Also removed the 'auto' for that variable as the function name
doesn't make it obvious that this is an expected and not just
a optional/ptr (which is how this slipped in from the start).

Added:

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

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

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py

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

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/root/

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/root/usr/

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/root/usr/include/

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

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

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

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

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/root/usr/include/libc_header.h
Modified:
lldb/trunk/source/Symbol/CxxModuleHandler.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/Makefile?rev=374525&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/Makefile
 Fri Oct 11 01:42:22 2019
@@ -0,0 +1,9 @@
+# We don't have any standard include directories, so we can't
+# parse the test_common.h header we usually inject as it includes
+# system headers.
+NO_TEST_COMMON_H := 1
+
+CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++ -DENABLE_STD_CONTENT=1
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py?rev=374525&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
 Fri Oct 11 01:42:22 2019
@@ -0,0 +1,35 @@
+"""
+Test that LLDB doesn't crash if the std module we load is empty.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import os
+
+class ImportStdModule(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(compiler=no_match("clang"))
+def test(self):
+self.build()
+
+sysroot = os.path.join(os.getcwd(), "root")
+
+# Set the sysroot.
+self.runCmd("platform select --sysroot '" + sysroot + "' host", 
CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_to_source_breakpoint(self,
+"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("settings set target.import-std-module true")
+self.runCmd("lo

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

2019-10-11 Thread Martin Storsjo via lldb-commits
Author: mstorsjo
Date: Fri Oct 11 01:44:51 2019
New Revision: 374526

URL: http://llvm.org/viewvc/llvm-project?rev=374526&view=rev
Log:
[LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

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

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

Modified:
lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=374526&r1=374525&r2=374526&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Oct 11 01:44:51 2019
@@ -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 @@ llvm::Optional InitializeReproducer
   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] D68737: SBFile::GetFile: convert SBFile back into python native files.

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



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

lawrence_danna wrote:
> labath wrote:
> > 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..
> Are you sure that's the right thing to do?   `eOpenOptionRead | 
> eOpenOptionWrite` has type `unsigned int`, not `OpenOptions`.
Ah, right, that was the reason... Regardless, I do thing that's right -- I'll 
continue the discussion on the other patch.



Comment at: lldb/include/lldb/Host/File.h:331-335
+  static char ID;
+
+  virtual bool isA(const void *classID) const { return classID == &ID; }
+
+  static bool classof(const File *file) { return file->isA(&ID); }

Please move this somewhere else -- somewhere near the top or bottom of the 
class maybe.. It does not make sense to have it in the middle of the open 
options stuff.



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,)])

lawrence_danna wrote:
> 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.
Right, sorry, that came out a bit wrong. While I think it would be cool to have 
the other direction be an "identity" too, I don't think that is really 
necessary. Nevertheless, taking a File out of lldb and then back in will do 
_something_ right now, and that "something" could probably use a test. I 
suppose you could construct an SBFile from a path, convert it to a python file 
and back, and then ensure that reading/writing on those two SBFiles does 
something reasonable.



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

lawrence_danna wrote:
> 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.
Cool, thanks. This description is very helpful.



Comment at: lldb/scripts/interface/SBFile.i:93
+If there is no underlying python file to unwrap, GetFile will
+use the file descirptor, if availble to create a new python
+file object using `open(fd, mode=..., closefd=False)`

s/descirptor/descriptor



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1553-1554
+
+  auto *simple = llvm::dyn_cast(&file);
+  if (simple)
+return Retain(simple->GetPythonObject());

if (auto *simple = ...)



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());

lawrence_danna wrote:
> labath wrote:
> > 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?
> It's also called in some parts of ScriptInterpreterPython that are broken for 
> other reasons, and are

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

2019-10-11 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4778f40f782f: [LLDB] [Driver] Use llvm::InitLLVM to do 
unicode argument conversion on Windows (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

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] [lldb] r374528 - [Windows] Use information from the PE32 exceptions directory to construct unwind plans

2019-10-11 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Fri Oct 11 02:03:29 2019
New Revision: 374528

URL: http://llvm.org/viewvc/llvm-project?rev=374528&view=rev
Log:
[Windows] Use information from the PE32 exceptions directory to construct 
unwind plans

This patch adds an implementation of unwinding using PE EH info. It allows to
get almost ideal call stacks on 64-bit Windows systems (except some epilogue
cases, but I believe that they can be fixed with unwind plan disassembly
augmentation in the future).

To achieve the goal the CallFrameInfo abstraction was made. It is based on the
DWARFCallFrameInfo class interface with a few changes to make it less
DWARF-specific.

To implement the new interface for PECOFF object files the class PECallFrameInfo
was written. It uses the next helper classes:

- UnwindCodesIterator helps to iterate through UnwindCode structures (and
  processes chained infos transparently);
- EHProgramBuilder with the use of UnwindCodesIterator constructs EHProgram;
- EHProgram is, by fact, a vector of EHInstructions. It creates an abstraction
  over the low-level unwind codes and simplifies work with them. It contains
  only the information that is relevant to unwinding in the unified form. Also
  the required unwind codes are read from the object file only once with it;
- EHProgramRange allows to take a range of EHProgram and to build an unwind row
  for it.

So, PECallFrameInfo builds the EHProgram with EHProgramBuilder, takes the ranges
corresponding to every offset in prologue and builds the rows of the resulted
unwind plan. The resulted plan covers the whole range of the function except the
epilogue.

Reviewers: jasonmolenda, asmith, amccarth, clayborg, JDevlieghere, 
stella.stamenova, labath, espindola

Reviewed By: jasonmolenda

Subscribers: leonid.mashinskiy, emaste, mgorny, aprantl, arichardson, MaskRay, 
lldb-commits, llvm-commits

Tags: #lldb

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

Added:
lldb/trunk/include/lldb/Symbol/CallFrameInfo.h
lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.h
lldb/trunk/unittests/ObjectFile/PECOFF/
lldb/trunk/unittests/ObjectFile/PECOFF/CMakeLists.txt
lldb/trunk/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
Modified:
lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/include/lldb/Symbol/UnwindTable.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Symbol/FuncUnwinders.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp
lldb/trunk/unittests/ObjectFile/CMakeLists.txt

Added: lldb/trunk/include/lldb/Symbol/CallFrameInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CallFrameInfo.h?rev=374528&view=auto
==
--- lldb/trunk/include/lldb/Symbol/CallFrameInfo.h (added)
+++ lldb/trunk/include/lldb/Symbol/CallFrameInfo.h Fri Oct 11 02:03:29 2019
@@ -0,0 +1,28 @@
+//===-- CallFrameInfo.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_CallFrameInfo_h_
+#define liblldb_CallFrameInfo_h_
+
+#include "lldb/Core/Address.h"
+
+namespace lldb_private {
+
+class CallFrameInfo {
+public:
+  virtual ~CallFrameInfo() = default;
+
+  virtual bool GetAddressRange(Address addr, AddressRange &range) = 0;
+
+  virtual bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan) = 0;
+  virtual bool GetUnwindPlan(const AddressRange &range, UnwindPlan 
&unwind_plan) = 0;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CallFrameInfo_h_

Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=374528&r1=374527&r2=374528&view=diff
==
--- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original)
+++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Fri Oct 11 02:03:29 2019
@@ -76,6 +76,11 @@ public:
 
   lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread);
 
+  lldb::UnwindPlanSP GetObjectFileUnwindPlan(Target &target);
+
+  lldb::UnwindPlanSP GetObjectFileAugmentedUnwindPlan(Target &target,
+  

[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

2019-10-11 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG30c2441a3262: [Windows] Use information from the PE32 
exceptions directory to construct… (authored by aleksandr.urakov).

Changed prior to commit:
  https://reviews.llvm.org/D67347?vs=220144&id=224554#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347

Files:
  lldb/include/lldb/Symbol/CallFrameInfo.h
  lldb/include/lldb/Symbol/FuncUnwinders.h
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Symbol/UnwindTable.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.h
  lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/source/Symbol/FuncUnwinders.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/source/Symbol/UnwindTable.cpp
  lldb/unittests/ObjectFile/CMakeLists.txt
  lldb/unittests/ObjectFile/PECOFF/CMakeLists.txt
  lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
  llvm/include/llvm/Support/Win64EH.h

Index: llvm/include/llvm/Support/Win64EH.h
===
--- llvm/include/llvm/Support/Win64EH.h
+++ llvm/include/llvm/Support/Win64EH.h
@@ -30,7 +30,9 @@
   UOP_SetFPReg,
   UOP_SaveNonVol,
   UOP_SaveNonVolBig,
-  UOP_SaveXMM128 = 8,
+  UOP_Epilog,
+  UOP_SpareCode,
+  UOP_SaveXMM128,
   UOP_SaveXMM128Big,
   UOP_PushMachFrame,
   // The following set of unwind opcodes is for ARM64.  They are documented at
Index: lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
===
--- /dev/null
+++ lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
@@ -0,0 +1,336 @@
+//===-- TestPECallFrameInfo.cpp --*- C++ -*-===//
+//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/CallFrameInfo.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "llvm/Testing/Support/Error.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+class PECallFrameInfoTest : public testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+ObjectFilePECOFF::Initialize();
+  }
+
+  void TearDown() override {
+ObjectFilePECOFF::Terminate();
+FileSystem::Terminate();
+  }
+
+protected:
+  void GetUnwindPlan(addr_t file_addr, UnwindPlan &plan) const;
+};
+
+void PECallFrameInfoTest::GetUnwindPlan(addr_t file_addr, UnwindPlan &plan) const {
+  llvm::Expected ExpectedFile = TestFile::fromYaml(
+  R"(
+--- !COFF
+OptionalHeader:  
+  AddressOfEntryPoint: 0
+  ImageBase:   16777216
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable: 
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable: 
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:   
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:  
+RelativeVirtualAddress: 12288
+Size:60
+  CertificateTable: 
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable: 
+RelativeVirtualAddress: 0
+Size:0
+  Debug:   
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:   
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable: 
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport: 
+RelativeVirtualAddress: 0
+Size:0
+  IAT: 
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor: 
+RelativeVirtualAddress: 0
+Size

[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

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

Quick question here; will unwinding using DWARF debug info still work like 
before after this, for binaries that don't use SEH for exception unwinding?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347



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


[Lldb-commits] [PATCH] D68853: uint32_t options -> File::OpenOptions options

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

I originally thought you would do something local, but changing this across the 
board is definitely better, and it doesn't seem the patch is that big. LLVM 
already has a utility to work out the kinks in the bitmask enum use case. 
Please take a look at `llvm/ADT/BitmaskEnum.h` on how to make use of that.




Comment at: lldb/include/lldb/Host/File.h:56
+(1u << 8),   // Close the file when executing a new process
+eOpenOptionMax = 0xu // avoid undefined behavior
   };

A better way to handle that is to make this a typed enum (`enum OpenOptions : 
uint16_t`). Then you can add something like ` 
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/0xu)` to make sure the bitmask 
operators also work well.




Comment at: lldb/source/Host/common/File.cpp:42
 
-static const char *GetStreamOpenModeFromOptions(uint32_t options) {
+static Expected GetStreamOpenModeFromOptions(uint32_t options) {
   if (options & File::eOpenOptionAppend) {

I'd consider leaving the static function as `const char *` -- the function 
doesn't do anything complex, and there's only one way it can fail (which can be 
signalled by a nullptr), so having the Expected wrapper around that does not 
seem all that useful -- I'll leave it up to you though.



Comment at: lldb/source/Host/common/File.cpp:74
+
+Expected File::GetOptionsFromMode(llvm::StringRef mode) {
+  OpenOptions opts =

For similar reasons, I'd make this an Optional.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1093
   auto options = File::GetOptionsFromMode(py_mode.GetString());
-  auto file = std::unique_ptr(
-  new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
+  if (!options)
+return nullptr;

If `GetOptionsFromMode` stays as `Expected` then this is not correct, as it 
does not handle the error case. Overall, I'd say we shouldn't use `auto` here..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68853



___
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-11 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

What lldb does not like the most is a stop info with a signal "0" -- that 
causes a resume. Having no stop info whatsoever seems to work just fine -- and 
this is already what happens when there is no exception record around. I was 
surprised by that distinction, but we already have tests with minidumps like 
those, and they seem to work ok, so I thought it'd make sense to do the same 
for the case where we have an exception record, but it contains no signal (as 
opposed to e.g. inventing a SIGSTOP out of thin air). We already have a test 
for that in this patch.




Comment at: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp:264
+
 stop_info = StopInfo::CreateStopReasonWithSignal(
+*stop_thread, signo);

clayborg wrote:
> Are exceptions on linux always just a signal number? Mac can be a mach 
> exception or a signal. Might be worth looking at the breakpad sources to see 
> if they ever fill in anything else for linux other than a signal. 
> 
> Also, there is more info in the exception record that needs to be passed 
> along. Like for a SIGSEGV, the address should be in the exception info 
> somewhere.
Having the address (if it is there) would be nice, but I think that's a 
separate bug/feature, as this patch is about what happens when there is no 
exception record around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68096



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


[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

2019-10-11 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

In D67347#1705563 , @mstorsjo wrote:

> Quick question here; will unwinding using DWARF debug info still work like 
> before after this, for binaries that don't use SEH for exception unwinding?


Hi Martin!

Do I understand the question correctly: you mean x64 Windows binaries with an 
additional DWARF unwind info inside, right? In that case the info from PE32+ 
directory should be used, it has a higher priority than the debug info. I think 
it should have a higher priority because it is used by the system during an 
unwind and is always presented in x64 binaries, so we have stronger guarantees 
with it.

In all other cases, when the info in PE32+ directory is not presented, all 
things should work as usual (then, the DWARF info will be used).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347



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


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

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

Thanks. IIUC, all the existing tests just cover the yaml2obj direction. Could 
you add something for the other direction too? Maybe add an exception stream to 
`test/tools/obj2yaml/basic-minidump.yaml`?




Comment at: llvm/include/llvm/ObjectYAML/MinidumpYAML.h:162-181
+/// ExceptionStream minidump stream.
+struct ExceptionStream : public Stream {
+  minidump::ExceptionStream MDExceptionStream;
+  yaml::BinaryRef ThreadContext;
+
+  explicit ExceptionStream(const minidump::ExceptionStream &MDExceptionStream,
+   ArrayRef ThreadContext)

I've been trying to keep this somewhat sorted. Could you move this before the 
`MemoryInfoListStream` class? Also, in the previous patch we've moved the 
default constructors to front. It would be good to make this consistent with 
that.



Comment at: llvm/lib/ObjectYAML/MinidumpYAML.cpp:394
+  mapOptionalHex(IO, "Exception Address", Exception.ExceptionAddress, 0);
+  IO.mapOptional("Number Parameters", Exception.NumberParameters,
+ support::ulittle32_t(0u));

This file has a helper function for this (`mapOptional(IO, "name", value, 0)`. 
I'd consider changing the field name to "Number of Parameters" even though it 
does not match the field name, as it reads weird without that. I'm not sure why 
the microsoft naming is inconsistent here -- most of the other minidump structs 
have "of" in their name already (BaseOfImage, SizeOfImage, etc.), but at least 
we can be consistent.



Comment at: llvm/lib/ObjectYAML/MinidumpYAML.cpp:408-414
+StringRef yaml::MappingTraits::validate(
+yaml::IO &IO, minidump::Exception &Exception) {
+  if (Exception.NumberParameters > Exception::MaxParameters)
+return "Exception reports too many parameters";
+  return "";
+}
+

Could you remove this bit too? While it is technically invalid, this is not 
something that yaml2obj needs to care about (as it does not prevent successful 
serialization), and it would be nice to be able to use it to generate a test 
case with an invalid number (because that is something lldb should care about 
and expect/handle)..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657



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


[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

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

In D67347#1705563 , @mstorsjo wrote:

> Quick question here; will unwinding using DWARF debug info still work like 
> before after this, for binaries that don't use SEH for exception unwinding?


Do you mean debug_frame or eh_frame? debug_frame should be completely 
unaffected by this. the interaction between eh_frame and SEH is more tricky, 
but I don't know if that's ever used/emitted on windows (since presumably the 
system libraries don't know how to read it)...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347



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


[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

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

Yeah, I think that's the best we can do right now. Could you just drop the 
gdb_remote_offset from the `GetPtraceOffset`. It can be recovered from the 
`index` argument, and I don't want people to think that they _have to_ 
implement the ptrace offset computation via the gdb offset. I mean ideally, I 
hope the two things will be the same everywhere else, and x86 is just weird, 
but conceptually, I'd like the individual architectures to be free to compute 
the ptrace offset any way they like. Also, could you put that into a separate 
patch, as it functionally independent of this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931



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


[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

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

In D67347#1705611 , @labath wrote:

> In D67347#1705563 , @mstorsjo wrote:
>
> > Quick question here; will unwinding using DWARF debug info still work like 
> > before after this, for binaries that don't use SEH for exception unwinding?
>
>
> Do you mean debug_frame or eh_frame? debug_frame should be completely 
> unaffected by this. the interaction between eh_frame and SEH is more tricky, 
> but I don't know if that's ever used/emitted on windows (since presumably the 
> system libraries don't know how to read it)...


I meant debug_frame. Ok, good if that's unaffected.

In MinGW setups, you can have a number of different combinations of both unwind 
and debug info. The debug info normally is DWARF (i.e. debug_frame), but it can 
also (in pure clang/lld based environments, not with GCC/binutils) optionally 
use codeview/PDB.

For unwind info, on x64, SEH is normally used, but it can also optionally use 
SjLj or DWARF (i.e. eh_frame). For i686 (and armv7), DWARF is the default.

And for the cases where it does use SEH for C++ exception unwinding, it doesn't 
do it exactly like MSVC does, but it uses a special gcc personality function 
which unwinds one step at a time with RtlVirtualUnwind. So it still does use 
the system unwinder facility, but slightly differently.

In D67347#1705573 , @aleksandr.urakov 
wrote:

> In D67347#1705563 , @mstorsjo wrote:
>
> > Quick question here; will unwinding using DWARF debug info still work like 
> > before after this, for binaries that don't use SEH for exception unwinding?
>
>
> Do I understand the question correctly: you mean x64 Windows binaries with an 
> additional DWARF unwind info inside, right? In that case the info from PE32+ 
> directory should be used, it has a higher priority than the debug info. I 
> think it should have a higher priority because it is used by the system 
> during an unwind and is always presented in x64 binaries, so we have stronger 
> guarantees with it.


No, I meant DWARF debug info.

> In all other cases, when the info in PE32+ directory is not presented, all 
> things should work as usual (then, the DWARF info will be used).

Ok, that's good.

If I build an environment for x86_64 that uses DWARF for exception handling, 
ExceptionTableRVA/ExceptionTableSize are zero in the data directory, so I would 
presume this would be skipped then, and use the DWARF info instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347



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


[Lldb-commits] [PATCH] D68864: [LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of arguments for windows

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

This should allow lldb-server to operate on files with non-ascii pathnames.

I tried looking around in lldb/tools, and this seemed like the only other tool 
(other than the main lldb driver itself) that would be used (implicitly) by an 
end user (which could be working in non-ascii paths).

This does the same as for D68770  (where the 
main driver earlier was using custom code in the driver to convert unicode to 
utf8), while lldb-server didn't have any unicode handling at all before (where 
the main arguments would be given in the native local codepage, while the rest 
of llvm internals expect utf8).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68864

Files:
  lldb/tools/lldb-server/lldb-server.cpp


Index: lldb/tools/lldb-server/lldb-server.cpp
===
--- lldb/tools/lldb-server/lldb-server.cpp
+++ lldb/tools/lldb-server/lldb-server.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -48,6 +49,7 @@
 
 // main
 int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);


Index: lldb/tools/lldb-server/lldb-server.cpp
===
--- lldb/tools/lldb-server/lldb-server.cpp
+++ lldb/tools/lldb-server/lldb-server.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -48,6 +49,7 @@
 
 // main
 int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

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

In D68546#1700273 , @lawrence_danna 
wrote:

> So what's the conclusion here?   Should `HandleProcessEvent` get a SBStream 
> variant as well?   I say "as well", because the `FileSP` variant is 
> required in order to remove the python binding to the `FILE*` variant, and 
> once we have the `FileSP` it seems like it would be really strange to leave 
> out the `SBFile`.


Well... if we agree that SBStream is the future for APIs like this, then I 
don't think that would be too strange. The FileSP and FILE* variants would both 
be "legacy/deprecated" and present only to support legacy c++/python uses, and 
the SBStream would be the thing which we expect new users to use.

That said, I don't think that having an SBFile-based API is that bad either 
(though I would still like if it is used via an SBStream internally).. The main 
advantage of the "higher level" stream interface I see is that it is easier to 
provide your own implementation of it (less methods to override). However, 
given that we've just went through the exercise of making the file API 
overridable externally, I don't think we'll want to create an overridable 
stream abstraction any time soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546



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


[Lldb-commits] [lldb] r374529 - ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested, take 2

2019-10-11 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Oct 11 03:56:54 2019
New Revision: 374529

URL: http://llvm.org/viewvc/llvm-project?rev=374529&view=rev
Log:
ProcessInstanceInfoMatch: Don't match processes with no name if a name match 
was requested, take 2

Summary:
The previous attempt at making nameless process not match when searching for a
given name failed because the macos implementation was depending on this detail
in its partial matching strategy. Doing partial matching to avoid expensive
lookups is a perfectly valid thing to do, the way it was implemented seems
somewhat unexpected.

This patch implements it differently by providing special
methods in the ProcessInstanceInfoMatch which match only a subset of fields,
and changes mac host code to use those instead.

Then, it re-applies r373925 to get make the ProcessInstanceInfoMatch with a
name *not* match a nameless process.

Reviewers: JDevlieghere, teemperor, jingham

Subscribers: wallace, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Utility/ProcessInfo.h
lldb/trunk/source/Host/macosx/objcxx/Host.mm
lldb/trunk/source/Utility/ProcessInfo.cpp
lldb/trunk/unittests/Utility/ProcessInstanceInfoTest.cpp

Modified: lldb/trunk/include/lldb/Utility/ProcessInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessInfo.h?rev=374529&r1=374528&r2=374529&view=diff
==
--- lldb/trunk/include/lldb/Utility/ProcessInfo.h (original)
+++ lldb/trunk/include/lldb/Utility/ProcessInfo.h Fri Oct 11 03:56:54 2019
@@ -223,8 +223,20 @@ public:
 m_name_match_type = name_match_type;
   }
 
+  /// Return true iff the architecture in this object matches arch_spec.
+  bool ArchitectureMatches(const ArchSpec &arch_spec) const;
+
+  /// Return true iff the process name in this object matches process_name.
   bool NameMatches(const char *process_name) const;
 
+  /// Return true iff the process ID and parent process IDs in this object 
match
+  /// the ones in proc_info.
+  bool ProcessIDsMatch(const ProcessInstanceInfo &proc_info) const;
+
+  /// Return true iff the (both effective and real) user and group IDs in this
+  /// object match the ones in proc_info.
+  bool UserIDsMatch(const ProcessInstanceInfo &proc_info) const;
+
   bool Matches(const ProcessInstanceInfo &proc_info) const;
 
   bool MatchAllProcesses() const;

Modified: lldb/trunk/source/Host/macosx/objcxx/Host.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/objcxx/Host.mm?rev=374529&r1=374528&r2=374529&view=diff
==
--- lldb/trunk/source/Host/macosx/objcxx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/objcxx/Host.mm Fri Oct 11 03:56:54 2019
@@ -677,14 +677,16 @@ uint32_t Host::FindProcesses(const Proce
   process_info.SetEffectiveGroupID(UINT32_MAX);
 
 // Make sure our info matches before we go fetch the name and cpu type
-if (match_info.Matches(process_info)) {
-  // Get CPU type first so we can know to look for iOS simulator is we have
-  // x86 or x86_64
-  if (GetMacOSXProcessCPUType(process_info)) {
-if (GetMacOSXProcessArgs(&match_info, process_info)) {
-  if (match_info.Matches(process_info))
-process_infos.Append(process_info);
-}
+if (!match_info.UserIDsMatch(process_info) ||
+!match_info.ProcessIDsMatch(process_info))
+  continue;
+
+// Get CPU type first so we can know to look for iOS simulator is we have
+// x86 or x86_64
+if (GetMacOSXProcessCPUType(process_info)) {
+  if (GetMacOSXProcessArgs(&match_info, process_info)) {
+if (match_info.Matches(process_info))
+  process_infos.Append(process_info);
   }
 }
   }

Modified: lldb/trunk/source/Utility/ProcessInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ProcessInfo.cpp?rev=374529&r1=374528&r2=374529&view=diff
==
--- lldb/trunk/source/Utility/ProcessInfo.cpp (original)
+++ lldb/trunk/source/Utility/ProcessInfo.cpp Fri Oct 11 03:56:54 2019
@@ -243,8 +243,14 @@ void ProcessInstanceInfo::DumpAsTableRow
   }
 }
 
+bool ProcessInstanceInfoMatch::ArchitectureMatches(
+const ArchSpec &arch_spec) const {
+  return !m_match_info.GetArchitecture().IsValid() ||
+ m_match_info.GetArchitecture().IsCompatibleMatch(arch_spec);
+}
+
 bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
-  if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
+  if (m_name_match_type == NameMatch::Ignore)
 return true;
   const char *match_name = m_match_info.GetName();
   if (!match_name)
@@ -253,11 +259,8 @@ bool ProcessInstanceInfoMatch::NameMatch
   return lldb_private::NameMatches(process_name, m_name_match_type, 
match_name);
 }
 
-bool ProcessI

[Lldb-commits] [PATCH] D68631: ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested, take 2

2019-10-11 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8b18baa0f9e: ProcessInstanceInfoMatch: Don't match 
processes with no name if a name match… (authored by labath).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68631?vs=223822&id=224560#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68631

Files:
  lldb/include/lldb/Utility/ProcessInfo.h
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Utility/ProcessInfo.cpp
  lldb/unittests/Utility/ProcessInstanceInfoTest.cpp

Index: lldb/unittests/Utility/ProcessInstanceInfoTest.cpp
===
--- lldb/unittests/Utility/ProcessInstanceInfoTest.cpp
+++ lldb/unittests/Utility/ProcessInstanceInfoTest.cpp
@@ -91,3 +91,20 @@
 )",
   s.GetData());
 }
+
+TEST(ProcessInstanceInfoMatch, Name) {
+  ProcessInstanceInfo info_bar, info_empty;
+  info_bar.GetExecutableFile().SetFile("/foo/bar", FileSpec::Style::posix);
+
+  ProcessInstanceInfoMatch match;
+  match.SetNameMatchType(NameMatch::Equals);
+  match.GetProcessInfo().GetExecutableFile().SetFile("bar",
+ FileSpec::Style::posix);
+
+  EXPECT_TRUE(match.Matches(info_bar));
+  EXPECT_FALSE(match.Matches(info_empty));
+
+  match.GetProcessInfo().GetExecutableFile() = FileSpec();
+  EXPECT_TRUE(match.Matches(info_bar));
+  EXPECT_TRUE(match.Matches(info_empty));
+}
Index: lldb/source/Utility/ProcessInfo.cpp
===
--- lldb/source/Utility/ProcessInfo.cpp
+++ lldb/source/Utility/ProcessInfo.cpp
@@ -243,8 +243,14 @@
   }
 }
 
+bool ProcessInstanceInfoMatch::ArchitectureMatches(
+const ArchSpec &arch_spec) const {
+  return !m_match_info.GetArchitecture().IsValid() ||
+ m_match_info.GetArchitecture().IsCompatibleMatch(arch_spec);
+}
+
 bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
-  if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
+  if (m_name_match_type == NameMatch::Ignore)
 return true;
   const char *match_name = m_match_info.GetName();
   if (!match_name)
@@ -253,11 +259,8 @@
   return lldb_private::NameMatches(process_name, m_name_match_type, match_name);
 }
 
-bool ProcessInstanceInfoMatch::Matches(
+bool ProcessInstanceInfoMatch::ProcessIDsMatch(
 const ProcessInstanceInfo &proc_info) const {
-  if (!NameMatches(proc_info.GetName()))
-return false;
-
   if (m_match_info.ProcessIDIsValid() &&
   m_match_info.GetProcessID() != proc_info.GetProcessID())
 return false;
@@ -265,7 +268,11 @@
   if (m_match_info.ParentProcessIDIsValid() &&
   m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())
 return false;
+  return true;
+}
 
+bool ProcessInstanceInfoMatch::UserIDsMatch(
+const ProcessInstanceInfo &proc_info) const {
   if (m_match_info.UserIDIsValid() &&
   m_match_info.GetUserID() != proc_info.GetUserID())
 return false;
@@ -281,13 +288,14 @@
   if (m_match_info.EffectiveGroupIDIsValid() &&
   m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())
 return false;
-
-  if (m_match_info.GetArchitecture().IsValid() &&
-  !m_match_info.GetArchitecture().IsCompatibleMatch(
-  proc_info.GetArchitecture()))
-return false;
   return true;
 }
+bool ProcessInstanceInfoMatch::Matches(
+const ProcessInstanceInfo &proc_info) const {
+  return ArchitectureMatches(proc_info.GetArchitecture()) &&
+ ProcessIDsMatch(proc_info) && UserIDsMatch(proc_info) &&
+ NameMatches(proc_info.GetName());
+}
 
 bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
   if (m_name_match_type != NameMatch::Ignore)
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -677,14 +677,16 @@
   process_info.SetEffectiveGroupID(UINT32_MAX);
 
 // Make sure our info matches before we go fetch the name and cpu type
-if (match_info.Matches(process_info)) {
-  // Get CPU type first so we can know to look for iOS simulator is we have
-  // x86 or x86_64
-  if (GetMacOSXProcessCPUType(process_info)) {
-if (GetMacOSXProcessArgs(&match_info, process_info)) {
-  if (match_info.Matches(process_info))
-process_infos.Append(process_info);
-}
+if (!match_info.UserIDsMatch(process_info) ||
+!match_info.ProcessIDsMatch(process_info))
+  continue;
+
+// Get CPU type first so we can know to look for iOS simulator is we have
+// x86 or x86_64
+if (GetMacOSXProcessCPUType(process_info)) {
+  if (GetMacOSXProcessArgs(&match_info, process_info)) {
+if (match_info.Matches(process_info))
+  process_infos.Append(pr

[Lldb-commits] [lldb] r374532 - minidump: Use llvm memory info list parser

2019-10-11 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Oct 11 04:23:40 2019
New Revision: 374532

URL: http://llvm.org/viewvc/llvm-project?rev=374532&view=rev
Log:
minidump: Use llvm memory info list parser

Modified:
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=374532&r1=374531&r2=374532&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Fri Oct 11 
04:23:40 2019
@@ -427,23 +427,35 @@ CreateRegionsCacheFromLinuxMaps(Minidump
 static bool
 CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
  std::vector ®ions) {
-  auto data = parser.GetStream(StreamType::MemoryInfoList);
-  if (data.empty())
-return false;
-  auto mem_info_list = MinidumpMemoryInfo::ParseMemoryInfoList(data);
-  if (mem_info_list.empty())
+  Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
+  auto ExpectedInfo = parser.GetMinidumpFile().getMemoryInfoList();
+  if (!ExpectedInfo) {
+LLDB_LOG_ERROR(log, ExpectedInfo.takeError(),
+   "Failed to read memory info list: {0}");
 return false;
+  }
   constexpr auto yes = MemoryRegionInfo::eYes;
   constexpr auto no = MemoryRegionInfo::eNo;
-  regions.reserve(mem_info_list.size());
-  for (const auto &entry : mem_info_list) {
+  for (const MemoryInfo &entry : *ExpectedInfo) {
 MemoryRegionInfo region;
-region.GetRange().SetRangeBase(entry->base_address);
-region.GetRange().SetByteSize(entry->region_size);
-region.SetReadable(entry->isReadable() ? yes : no);
-region.SetWritable(entry->isWritable() ? yes : no);
-region.SetExecutable(entry->isExecutable() ? yes : no);
-region.SetMapped(entry->isMapped() ? yes : no);
+region.GetRange().SetRangeBase(entry.BaseAddress);
+region.GetRange().SetByteSize(entry.RegionSize);
+
+MemoryProtection prot = entry.Protect;
+region.SetReadable(bool(prot & MemoryProtection::NoAccess) ? no : yes);
+region.SetWritable(
+bool(prot & (MemoryProtection::ReadWrite | MemoryProtection::WriteCopy 
|
+ MemoryProtection::ExecuteReadWrite |
+ MemoryProtection::ExeciteWriteCopy))
+? yes
+: no);
+region.SetExecutable(
+bool(prot & (MemoryProtection::Execute | MemoryProtection::ExecuteRead 
|
+ MemoryProtection::ExecuteReadWrite |
+ MemoryProtection::ExeciteWriteCopy))
+? yes
+: no);
+region.SetMapped(entry.State != MemoryState::Free ? yes : no);
 regions.push_back(region);
   }
   return !regions.empty();

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp?rev=374532&r1=374531&r2=374532&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp Fri Oct 11 
04:23:40 2019
@@ -87,29 +87,3 @@ MinidumpMemoryDescriptor64::ParseMemory6
   *mem_ranges_count),
   *base_rva);
 }
-
-std::vector
-MinidumpMemoryInfo::ParseMemoryInfoList(llvm::ArrayRef &data) {
-  const MinidumpMemoryInfoListHeader *header;
-  Status error = consumeObject(data, header);
-  if (error.Fail() ||
-  header->size_of_header < sizeof(MinidumpMemoryInfoListHeader) ||
-  header->size_of_entry < sizeof(MinidumpMemoryInfo))
-return {};
-
-  data = data.drop_front(header->size_of_header -
- sizeof(MinidumpMemoryInfoListHeader));
-
-  if (header->size_of_entry * header->num_of_entries > data.size())
-return {};
-
-  std::vector result;
-  result.reserve(header->num_of_entries);
-
-  for (uint64_t i = 0; i < header->num_of_entries; ++i) {
-result.push_back(reinterpret_cast(
-data.data() + i * header->size_of_entry));
-  }
-
-  return result;
-}

Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h?rev=374532&r1=374531&r2=374532&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h Fri Oct 11 
04:23:40 2019
@@ -85,90 +85,6 @@ struct MinidumpMemoryDescriptor64 {
 static_asser

[Lldb-commits] [PATCH] D68289: [lldb-server/android] Show more processes by relaxing some checks

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

I've committed my ProcessInstanceInfoMatch fix now. Feel free to recommit when 
you're able to check the bots for failure.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68289



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


[Lldb-commits] [PATCH] D68662: Redo D68354 - [platform process list] add a flag for showing the processes of all users

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

Sorry for taking a while, this got burried in my stack. Still looks good, but 
please do keep an eye out on the bots. BTW, it would make it easier to figure 
out what changed if you just re-opened the old revision  (you can do that via 
the drop-down menu at the bottom of the page) and re-uploaded a new diff over 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68662



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


[Lldb-commits] [lldb] r374537 - [LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of arguments for windows

2019-10-11 Thread Martin Storsjo via lldb-commits
Author: mstorsjo
Date: Fri Oct 11 04:47:07 2019
New Revision: 374537

URL: http://llvm.org/viewvc/llvm-project?rev=374537&view=rev
Log:
[LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of 
arguments for windows

This should allow lldb-server to operate on files with non-ascii
pathnames.

I tried looking around in lldb/tools, and this seemed like the only
other tool (other than the main lldb driver itself) that would be
used (implicitly) by an end user (which could be working in
non-ascii paths).

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

Modified:
lldb/trunk/tools/lldb-server/lldb-server.cpp

Modified: lldb/trunk/tools/lldb-server/lldb-server.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-server.cpp?rev=374537&r1=374536&r2=374537&view=diff
==
--- lldb/trunk/tools/lldb-server/lldb-server.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp Fri Oct 11 04:47:07 2019
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -48,6 +49,7 @@ static void terminate_debugger() { g_deb
 
 // main
 int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);


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


[Lldb-commits] [PATCH] D68864: [LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of arguments for windows

2019-10-11 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG807dbee36679: [LLDB] [lldb-server] Use llvm::InitLLVM for 
doing unicode conversion of… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68864

Files:
  lldb/tools/lldb-server/lldb-server.cpp


Index: lldb/tools/lldb-server/lldb-server.cpp
===
--- lldb/tools/lldb-server/lldb-server.cpp
+++ lldb/tools/lldb-server/lldb-server.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -48,6 +49,7 @@
 
 // main
 int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);


Index: lldb/tools/lldb-server/lldb-server.cpp
===
--- lldb/tools/lldb-server/lldb-server.cpp
+++ lldb/tools/lldb-server/lldb-server.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -48,6 +49,7 @@
 
 // main
 int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

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

Fixed by reverting the initial commit.




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

hhb wrote:
> hhb wrote:
> > 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...
> Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
Yes, now it works well


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] [lldb] r374545 - [lldb] Insert break to avoid unannotated fall-through

2019-10-11 Thread Kadir Cetinkaya via lldb-commits
Author: kadircet
Date: Fri Oct 11 05:33:47 2019
New Revision: 374545

URL: http://llvm.org/viewvc/llvm-project?rev=374545&view=rev
Log:
[lldb] Insert break to avoid unannotated fall-through

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp?rev=374545&r1=374544&r2=374545&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp Fri Oct 11 
05:33:47 2019
@@ -425,6 +425,7 @@ int32_t EHProgramRange::GetCFAFrameOffse
 case EHInstruction::Type::PUSH_REGISTER:
 case EHInstruction::Type::ALLOCATE:
   result += it->frame_offset;
+  break;
 default:
   break;
 }


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


[Lldb-commits] [PATCH] D68270: DWARFDebugLoc: Add a function to get the address range of an entry

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



Comment at: lib/DebugInfo/DWARF/DWARFDebugLoc.cpp:291-295
+  EntryIterator Absolute =
+  getAbsoluteLocations(
+  SectionedAddress{BaseAddr, SectionedAddress::UndefSection},
+  LookupPooledAddress)
+  .begin();

dblaikie wrote:
> labath wrote:
> > dblaikie wrote:
> > > labath wrote:
> > > > dblaikie wrote:
> > > > > labath wrote:
> > > > > > This parallel iteration is not completely nice, but I think it's 
> > > > > > worth being able to reuse the absolute range computation code. I'm 
> > > > > > open to ideas for improvement though.
> > > > > Ah, I see - this is what you meant about "In particular it makes it 
> > > > > possible to reuse this stuff in the dumping code, which would have 
> > > > > been pretty hard with callbacks.".
> > > > > 
> > > > > I'm wondering if that might be worth revisiting somewhat. A full 
> > > > > iterator abstraction for one user here (well, two once you include 
> > > > > lldb - but I assume it's likely going to build its own data structure 
> > > > > from the iteration anyway, right? (it's not going to keep the 
> > > > > iterator around, do anything interesting like partial iterations, 
> > > > > re-iterate/etc - such that a callback would suffice))
> > > > > 
> > > > > I could imagine two callback APIs for this - one that gets entries 
> > > > > and locations and one that only gets locations by filtering on the 
> > > > > entry version.
> > > > > 
> > > > > eg:
> > > > > 
> > > > >   // for non-verbose output:
> > > > >   LL.forEachEntry([&](const Entry &E, Expected L) {
> > > > > if (Verbose && actually dumping debug_loc)
> > > > >   print(E) // print any LLE_*, raw parameters, etc
> > > > > if (L)
> > > > >   print(*L) // print the resulting address range, section name 
> > > > > (if verbose), 
> > > > > else
> > > > >   print(error stuff)
> > > > >   });
> > > > > 
> > > > > One question would be "when/where do we print the DWARF expression" - 
> > > > > if there's an error computing the address range, we can still print 
> > > > > the expression, so maybe that happens unconditionally at the end of 
> > > > > the callback, using the expression in the Entry? (then, arguably, the 
> > > > > expression doesn't need to be in the DWARFLocation - and I'd say make 
> > > > > the DWARFLocation a sectioned range, exactly the same type as for 
> > > > > ranges so that part of the dumping code, etc, can be maximally reused)
> > > > Actually, what lldb currently does is that it does not build any data 
> > > > structures at all (except storing the pointer to the right place in the 
> > > > debug_loc section. Then, whenever it wants to do something to the 
> > > > loclist, it parses it afresh. I don't know why it does this exactly, 
> > > > but I assume it has something to do with most locations never being 
> > > > used, or being only a couple of times, and the actual parsing being 
> > > > fairly fast. What this means is that lldb is not really a single 
> > > > "user", but there are like four or five places where it iterates 
> > > > through the list, depending on what does it actually want to do with 
> > > > it. It also does partial iteration where it stops as soon as it find 
> > > > the entry it was interested in.
> > > > Now, all of that is possible with a callback (though I am generally 
> > > > trying to avoid them), but it does resurface the issue of what should 
> > > > be the value of the second argument for DW_LLE_base_address entries 
> > > > (the thing which I originally used a error type for).
> > > > Maybe this should be actually one callback API, taking two callback 
> > > > functions, with one of them being invoked for base_address entries, and 
> > > > one for others? However, if we stick to the current approaches in both 
> > > > LLE and RLE of making the address pool resolution function a parameter 
> > > > (which I'd like to keep, as it makes my job in lldb easier), then this 
> > > > would actually be three callbacks, which starts to get unwieldy. Though 
> > > > one of those callbacks could be removed with the "DWARFUnit 
> > > > implementing a AddrOffsetResolver interface" idea, which I really like. 
> > > > :)
> > > Ah, thanks for the details on LLDB's location parsing logic. That's 
> > > interesting indeed!
> > > 
> > > I can appreciate an iterator-based API if that's the sort of usage we've 
> > > got, though I expect it doesn't have any interest in the low-level 
> > > encoding & just wants the fully processed address ranges/locations - it 
> > > doesn't want base_address or end_of_list entries? & I think the 
> > > dual-iteration is a fairly awkward API design, trying to iterate them in 
> > > lock-step, etc. I'd rather avoid that if reasonably possible.
> > > 
> > > Either having an iterator API that gives only the fully processed 
> > > data/semantic view & a completely different API if you w

[Lldb-commits] [PATCH] D68868: Fix build under musl

2019-10-11 Thread David Demelier via Phabricator via lldb-commits
markand created this revision.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

This fixes the build under musl because of missing definitions.

  In file included from 
/src/vanilla/dev/lldb/lldb-9.0.0.src/source/API/SBReproducerPrivate.h:18:
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:567:58:
 error: invalid application of 'sizeof'
to an incomplete type '_IO_FILE'
m_stream.write(reinterpret_cast(&t), sizeof(T));
   ^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:555:7:
 note: in instantiation of function
template specialization 
'lldb_private::repro::Serializer::Serialize<_IO_FILE>' requested here
Serialize(*t);
^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:541:5:
 note: in instantiation of function
template specialization 
'lldb_private::repro::Serializer::Serialize<_IO_FILE>' requested here
  Serialize(head);
  ^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:542:5:
 note: in instantiation of function
template specialization 
'lldb_private::repro::Serializer::SerializeAll<_IO_FILE *>' requested here
  SerializeAll(tail...);
  ^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:639:16:
 note: in instantiation of function
template specialization 
'lldb_private::repro::Serializer::SerializeAll' requested
here
  serializer.SerializeAll(args...);
 ^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/source/API/SBCommandReturnObject.cpp:109:3:
 note: in instantiation of function template
specialization 'lldb_private::repro::Recorder::Record' requested here
LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
^
  
/src/vanilla/dev/lldb/lldb-9.0.0.src/include/lldb/Utility/ReproducerInstrumentation.h:112:17:
 note: expanded from macro
'LLDB_RECORD_METHOD'
  sb_recorder.Record(   
 \
  ^
  //include/bits/alltypes.h:356:16: note: forward declaration of '_IO_FILE'
  typedef struct _IO_FILE FILE;
 ^
  1 error generated.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68868

Files:
  include/lldb/Utility/ReproducerInstrumentation.h.orig


Index: include/lldb/Utility/ReproducerInstrumentation.h.orig
===
--- include/lldb/Utility/ReproducerInstrumentation.h.orig
+++ include/lldb/Utility/ReproducerInstrumentation.h.orig
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"

+#include 
 #include 
 #include 
 #include 


Index: include/lldb/Utility/ReproducerInstrumentation.h.orig
===
--- include/lldb/Utility/ReproducerInstrumentation.h.orig
+++ include/lldb/Utility/ReproducerInstrumentation.h.orig
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"

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


[Lldb-commits] [PATCH] D68868: Fix build under musl

2019-10-11 Thread David Demelier via Phabricator via lldb-commits
markand added a comment.

Wait, actually the patch isn't working entirely.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68868



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


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

2019-10-11 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))

tatyana-krasnukha wrote:
> hhb wrote:
> > hhb wrote:
> > > 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...
> > Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
> Yes, now it works well
> Can you help test that time? I don't have a visual studio...

Yes, of course!

BTW, I suppose that '--cmakeBuildConfiguration' option can fix the issue for 
XCode too. 




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] D68868: Fix build under musl

2019-10-11 Thread David Demelier via Phabricator via lldb-commits
markand added a comment.

In fact, in musl, the content of the structure FILE isn't exposed. But anyway, 
I don't understand why the code tries to write the content of the structure 
directly.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68868



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


Re: [Lldb-commits] LLDB finish_swig and Python module installation broken for multi-configuration generators

2019-10-11 Thread Tatyana Krasnukha via lldb-commits
I had that issue since r373668 and the commit was already reverted today 
(r374226). Now finish_swig works for me. Cannot say anything about installation 
steps.

From: lldb-dev  On Behalf Of Ted Woodward via 
lldb-dev
Sent: Friday, October 11, 2019 2:11 AM
To: LLDB ; h...@google.com; antonio.afo...@gmail.com; 
mgo...@gentoo.org
Subject: [lldb-dev] LLDB finish_swig and Python module installation broken for 
multi-configuration generators

Starting in r372835 (Fix installing Python modules on systems using /usr/lib), 
the finish_swig and installation steps using multi-configuration generators 
(like Visual Studio or XCode) are broken.

The problem is the symlink and install steps look for liblldb and site-packages 
the wrong directories.

For the symlink, I get this output:
 Making symlink from ..\..\..\bin\liblldb.dll to 
i:\obj\lib\site-packages\lldb\_lldb.pyd
...
 WindowsError: [Error 2] The system cannot find the file specified: 
'..\\..\\..\\bin\\liblldb.dll'

Because the cwd is I:\obj\Lib\site-packages\lldb, not the correct 
I:\obj\Release\Lib\site-packages\lldb. liblldb.dll is in i:\obj\Release\bin, 
not i:\obj\bin. Also, the link itself should be in i:\obj\Release\lib, not 
i:\obj\lib.

The problem is the cmake code went from using LLVM_LIBRARY_OUTPUT_INTDIR to 
CMAKE_BINARY_DIR. CMAKE_BINARY_DIR is not complete for multi-configuration 
generators - you need to specify the configuration as well.

To fix it, in lldb/CMakeLists.txt change
if(LLDB_BUILD_FRAMEWORK)
  set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
else()
  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
endif()

to:
if(LLDB_BUILD_FRAMEWORK)
  set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
else()
  if(CMAKE_CFG_INTDIR)
   # use CMAKE_BUILD_TYPE here because CMAKE_CFG_INTDIR is ${Configuration}
# using Visual Studio, which won't work in cmake_install.cmake
# because it is a VS variable, not a cmake variable
install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${LLDB_PYTHON_RELATIVE_PATH}/
DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
COMPONENT lldb-scripts)
  else()
install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
COMPONENT lldb-scripts)
  endif()
endif()


In the install step we have a similar failure. The install in 
lldb/CMakeLists.txt again uses CMAKE_BINARY_DIR. To fix it, change:
  install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
  DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
  COMPONENT lldb-scripts)
to:
  if(CMAKE_CFG_INTDIR)
install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
COMPONENT lldb-scripts)
  else()
install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
COMPONENT lldb-scripts)
  endif()


Michal, please try this and see if it still works for the issue you fixed in 
r372835.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

2019-10-11 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet marked 4 inline comments as done.
JosephTremoulet added a comment.

Added Exception stream to minidump-basic.yaml as suggested.




Comment at: llvm/lib/ObjectYAML/MinidumpYAML.cpp:394
+  mapOptionalHex(IO, "Exception Address", Exception.ExceptionAddress, 0);
+  IO.mapOptional("Number Parameters", Exception.NumberParameters,
+ support::ulittle32_t(0u));

labath wrote:
> This file has a helper function for this (`mapOptional(IO, "name", value, 
> 0)`. I'd consider changing the field name to "Number of Parameters" even 
> though it does not match the field name, as it reads weird without that. I'm 
> not sure why the microsoft naming is inconsistent here -- most of the other 
> minidump structs have "of" in their name already (BaseOfImage, SizeOfImage, 
> etc.), but at least we can be consistent.
Updated to use the helper, and changed the name in the YAML to "Number of 
Parameters".  Let me know if it's important to you to also change the name of 
the field in the llvm::minidump::Exception type to `NumberOfParameters` -- I 
wasn't sure if you were suggesting that, and regardless my preference would be 
to leave that as-is to match breakpad aside from casing, as otherwise it's hard 
to know where to stop (e.g. change "ExceptionInformation" to "Parameters" to 
match "NumberOfParameters" and the YAML?  Reconcile the several different ways 
that alignment padding fields are named?  etc.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657



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


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

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

  Address review feedback
  
- Add Exception stream to minidump-basic.yaml to test obj2yaml
  direction
- Reorder ExceptionStream definition and constructors
- Use the mapOptional helper
- Replace "Number Parameters" with "Number of Parameters" in YAML
- Stop using mapping traits validation for number of parameters,
  update test to ensure correctly de-yamlizing an exception record
  with an out-of-bounds number of parameters


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-x86_64.yaml
  llvm/include/llvm/ObjectYAML/MinidumpYAML.h
  llvm/lib/ObjectYAML/MinidumpEmitter.cpp
  llvm/lib/ObjectYAML/MinidumpYAML.cpp
  llvm/test/tools/obj2yaml/basic-minidump.yaml
  llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp

Index: llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
+++ llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
@@ -139,3 +139,218 @@
   (ArrayRef{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
   makeArrayRef(SysInfo.CPU.Other.ProcessorFeatures));
 }
+
+TEST(MinidumpYAML, ExceptionStream) {
+  SmallString<0> Storage;
+  auto ExpectedFile = toBinary(Storage, R"(
+--- !minidump
+Streams:
+  - Type:Exception
+Thread ID:  0x7
+Exception Record:
+  Exception Code:  0x23
+  Exception Flags: 0x5
+  Exception Record: 0x0102030405060708
+  Exception Address: 0x0a0b0c0d0e0f1011
+  Number of Parameters: 2
+  Parameter 0: 0x22
+  Parameter 1: 0x24
+Thread Context:  3DeadBeefDefacedABadCafe)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  object::MinidumpFile &File = **ExpectedFile;
+
+  ASSERT_EQ(1u, File.streams().size());
+
+  Expected ExpectedStream =
+  File.getExceptionStream();
+
+  ASSERT_THAT_EXPECTED(ExpectedStream, Succeeded());
+
+  const minidump::ExceptionStream &Stream = *ExpectedStream;
+  EXPECT_EQ(0x7u, Stream.ThreadId);
+  const minidump::Exception &Exception = Stream.ExceptionRecord;
+  EXPECT_EQ(0x23u, Exception.ExceptionCode);
+  EXPECT_EQ(0x5u, Exception.ExceptionFlags);
+  EXPECT_EQ(0x0102030405060708u, Exception.ExceptionRecord);
+  EXPECT_EQ(0x0a0b0c0d0e0f1011u, Exception.ExceptionAddress);
+  EXPECT_EQ(2u, Exception.NumberParameters);
+  EXPECT_EQ(0x22u, Exception.ExceptionInformation[0]);
+  EXPECT_EQ(0x24u, Exception.ExceptionInformation[1]);
+
+  Expected> ExpectedContext =
+  File.getRawData(Stream.ThreadContext);
+  ASSERT_THAT_EXPECTED(ExpectedContext, Succeeded());
+  EXPECT_EQ((ArrayRef{0x3d, 0xea, 0xdb, 0xee, 0xfd, 0xef, 0xac, 0xed,
+   0xab, 0xad, 0xca, 0xfe}),
+*ExpectedContext);
+}
+
+TEST(MinidumpYAML, ExceptionStream_NoParameters) {
+  SmallString<0> Storage;
+  auto ExpectedFile = toBinary(Storage, R"(
+--- !minidump
+Streams:
+  - Type:Exception
+Thread ID:  0x7
+Exception Record:
+  Exception Code:  0x23
+  Exception Flags: 0x5
+  Exception Record: 0x0102030405060708
+  Exception Address: 0x0a0b0c0d0e0f1011
+Thread Context:  3DeadBeefDefacedABadCafe)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  object::MinidumpFile &File = **ExpectedFile;
+
+  ASSERT_EQ(1u, File.streams().size());
+
+  Expected ExpectedStream =
+  File.getExceptionStream();
+
+  ASSERT_THAT_EXPECTED(ExpectedStream, Succeeded());
+
+  const minidump::ExceptionStream &Stream = *ExpectedStream;
+  EXPECT_EQ(0x7u, Stream.ThreadId);
+  const minidump::Exception &Exception = Stream.ExceptionRecord;
+  EXPECT_EQ(0x23u, Exception.ExceptionCode);
+  EXPECT_EQ(0x5u, Exception.ExceptionFlags);
+  EXPECT_EQ(0x0102030405060708u, Exception.ExceptionRecord);
+  EXPECT_EQ(0x0a0b0c0d0e0f1011u, Exception.ExceptionAddress);
+  EXPECT_EQ(0u, Exception.NumberParameters);
+
+  Expected> ExpectedContext =
+  File.getRawData(Stream.ThreadContext);
+  ASSERT_THAT_EXPECTED(ExpectedContext, Succeeded());
+  EXPECT_EQ((ArrayRef{0x3d, 0xea, 0xdb, 0xee, 0xfd, 0xef, 0xac, 0xed,
+   0xab, 0xad, 0xca, 0xfe}),
+*ExpectedContext);
+}
+
+TEST(MinidumpYAML, ExceptionStream_TooManyParameters) {
+  SmallString<0> Storage;
+  auto ExpectedFile = toBinary(Storage, R"(
+--- !minidump
+Streams:
+  - Type:Exception
+Thread ID:  0x8
+Exception Record:
+  Exception Code: 0
+  Number of Parameters: 16
+  Parameter 0: 0x0
+  Parameter 1: 0xff
+  Parameter 2: 0xee
+  Parameter 3: 0xdd
+  Parameter 4: 0xcc
+  Parameter 5: 0xbb
+  Parameter 6: 0xaa
+  Parameter 7: 0x99
+  Parameter 8: 0x88
+  Parameter 9: 0x77
+  Parameter 10: 0x66
+  Parameter 11: 0x5

[Lldb-commits] [PATCH] D66795: [Mips] Use appropriate private label prefix based on Mips ABI

2019-10-11 Thread Mirko Brkusanin via Phabricator via lldb-commits
mbrkusanin updated this revision to Diff 224603.
mbrkusanin added a comment.

- Rebase
- Ping

@echristo @craig.topper @tstellar @dylanmckay @petecoup
If there are no objections then I'll split this into llvm, clang and lldb 
patches and commit them next week.


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

https://reviews.llvm.org/D66795

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.h
  llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
  llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp
  llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.h
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
  llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
  llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCAsmInfo.cpp
  llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCAsmInfo.h
  llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp
  llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h
  llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
  llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h
  llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
  llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp
  llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
  llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
  llvm/test/CodeGen/Mips/compactbranches/no-beqzc-bnezc.ll
  llvm/test/MC/Mips/macro-li.d.s
  llvm/test/MC/Mips/macro-li.s.s
  llvm/test/MC/Mips/private-prefix.s
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/Disassembler.cpp
  llvm/tools/llvm-mc/Disassembler.h
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/MCInstPrinter.cpp

Index: llvm/unittests/MC/MCInstPrinter.cpp
===
--- llvm/unittests/MC/MCInstPrinter.cpp
+++ llvm/unittests/MC/MCInstPrinter.cpp
@@ -9,6 +9,7 @@
 #include "llvm/MC/MCInstPrinter.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCTargetOptions.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Target/TargetMachine.h"
@@ -40,7 +41,8 @@
   return;
 
 MRI.reset(TheTarget->createMCRegInfo(TripleName));
-MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName));
+MCTargetOptions MCOptions;
+MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 MII.reset(TheTarget->createMCInstrInfo());
 Printer.reset(TheTarget->createMCInstPrinter(
 Triple(TripleName), MAI->getAssemblerDialect(), *MAI, *MII, *MRI));
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -12,6 +12,7 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCDwarf.h"
 #include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCTargetOptions.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "gtest/gtest.h"
@@ -37,7 +38,8 @@
   return;
 
 MRI.reset(TheTarget->createMCRegInfo(Triple));
-MAI.reset(TheTarget->createMCAsmInfo(*MRI, Triple));
+MCTargetOptions MCOptions;
+MAI.reset(TheTarget->createMCAsmInfo(*MRI, Triple, MCOptions));
 Ctx = std::make_unique(MAI.get(), MRI.get(), nullptr);
   }
 
Index: llvm/unittests/Exe

[Lldb-commits] [PATCH] D68874: [lldb] Fix offset intersection bug between MPX and AVX registers

2019-10-11 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade created this revision.
guiandrade added a reviewer: labath.
guiandrade added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.

This change increases the offset of MPX registers (by 128) so they
do not overlap with the offset associated with AVX registers. That was
causing MPX data in GDBRemoteRegisterContext::m_reg_data to get overwritten.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68874

Files:
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/TestMPXOffsetIntersection.py
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/main.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
@@ -25,15 +25,18 @@
LLVM_EXTENSION offsetof(FPR, xsave) +   \
LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
 
+// Guarantees BNDR/BNDC offsets do not overlap with YMM offsets.
+#define GDB_REMOTE_OFFSET 128
+
 #define BNDR_OFFSET(reg_index) \
   (LLVM_EXTENSION offsetof(UserArea, fpr) +\
LLVM_EXTENSION offsetof(FPR, xsave) +   \
-   LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
+   LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]) + GDB_REMOTE_OFFSET)
 
 #define BNDC_OFFSET(reg_index) \
   (LLVM_EXTENSION offsetof(UserArea, fpr) +\
LLVM_EXTENSION offsetof(FPR, xsave) +   \
-   LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
+   LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]) + GDB_REMOTE_OFFSET)
 
 #ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT
 
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
@@ -75,6 +75,8 @@
 
   Status WriteFPR() override;
 
+  uint32_t GetPtraceOffset(uint32_t reg_index) override;
+
 private:
   // Private member types.
   enum class XStateType { Invalid, FXSAVE, XSAVE };
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -1213,4 +1213,11 @@
   return 4;
 }
 
+uint32_t
+NativeRegisterContextLinux_x86_64::GetPtraceOffset(uint32_t reg_index) {
+  // If register is MPX, remove extra factor from gdb offset
+  return GetRegisterInfoAtIndex(reg_index)->byte_offset -
+ (IsMPX(reg_index) ? 128 : 0);
+}
+
 #endif // defined(__i386__) || defined(__x86_64__)
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -60,6 +60,10 @@
 
   virtual size_t GetFPRSize() = 0;
 
+  virtual uint32_t GetPtraceOffset(uint32_t reg_index) {
+return GetRegisterInfoAtIndex(reg_index)->byte_offset;
+  }
+
   // The Do*** functions are executed on the privileged thread and can perform
   // ptrace
   // operations directly.
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -34,7 +34,7 @@
   if (!reg_info)
 return Status("register %" PRIu32 " not found", reg_index);
 
-  return DoReadRegisterValue(reg_info->byte_offset, reg_info->name,
+  return DoReadRegisterValue(GetPtraceOffset(reg_index), reg_info->name,
  reg_info->byte_size, reg_value);
 }
 
@@ -91,7 +91,8 @@
   "for write register index %" PRIu32,
   __FUNCTION__, reg_to_write);
 
-  return DoWriteRegisterValue(reg_info->byte_offset, reg_info->name, reg_

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

2019-10-11 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added a comment.

Just to make sure I'm understanding the feedback correctly, I'll try to 
summarize.  Please let me know if this is off track:

- When one uses breakpad to generate a minidump for a process that *hasn't* 
crashed, depending which of its methods one calls to write the dump, the 
generated dump's exception stream's exception code is either the "dump 
requested" sentinel or zero.
- We have a bug, which this patch is meant to fix, wherein loading one of those 
dumps with exception code zero creates a stop with signal zero, resulting in 
lldb hanging.
- We have some "prior art" in ProcessElfCore, which is how we successfully load 
the core dump you get by running a zero-exception-code minidump through 
breakpad's minidump-2-core, which is to artificially report SIGSTOP.  @labath, 
your feedback is that this is a hack that we shouldn't extend and should 
ideally/eventually remove from ProcessElfCore
- We also have some "prior art" in ProcessMinidump, which is how we 
successfully load a minidump with the "dump requested" sentinel, which is to 
create no stop at all.  That's what this patch currently does when it sees 
signal zero.  @clayborg, your feedback is that simply checking that the error 
code is zero is insufficient grounds to suppress stop creation, that we should 
probably check other fields in the exception stream and create a stop if *any* 
of them are reporting anything non-null, and/or verify that the only way 
breakpad/crashpad will produce a linux minidump with null signal is if there's 
no exception whatsoever

I may need to set this aside for a while and come back to it to address 
@clayborg's concerns (if I've understood them correctly), but I can live with 
my downstream changes in the meantime, so that's seeming like the best path 
forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68096



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


[Lldb-commits] [lldb] r374570 - [lldb-test] Modify lldb-test to print out ASTs from symbol file

2019-10-11 Thread Shafik Yaghmour via lldb-commits
Author: shafik
Date: Fri Oct 11 09:36:20 2019
New Revision: 374570

URL: http://llvm.org/viewvc/llvm-project?rev=374570&view=rev
Log:
[lldb-test] Modify lldb-test to print out ASTs from symbol file

Summary:
Currently when invoking lldb-test symbols -dump-ast it parses all the debug 
symbols and calls print(...) on the TranslationUnitDecl.
While useful the TranslationUnitDecl::print(...) method gives us a higher level 
view then the dump from ASTDumper which is what we get when we invoke dump() on 
a specific AST node.
The main motivation for this change is allow us to verify that the AST nodes we 
create when we parse DWARF. For example in order to verify we are correctly 
using DIFlagExportSymbols added by D7

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

Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=374570&r1=374569&r2=374570&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Oct 11 09:36:20 2019
@@ -886,6 +886,14 @@ public:
 
   void Dump(Stream &s);
 
+  /// Dump clang AST types from the symbol file.
+  ///
+  /// \param[in] s
+  ///   A stream to send the dumped AST node(s) to
+  /// \param[in] symbol_name
+  ///   The name of the symbol to dump, if it is empty dump all the symbols
+  void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
+
   void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
  Stream *s, lldb::Format format, const DataExtractor &data,
  lldb::offset_t data_offset, size_t data_byte_size,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=374570&r1=374569&r2=374570&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct 11 
09:36:20 2019
@@ -3024,12 +3024,21 @@ size_t SymbolFileDWARF::ParseTypes(const
bool parse_siblings, bool parse_children) {
   size_t types_added = 0;
   DWARFDIE die = orig_die;
+
   while (die) {
+const dw_tag_t tag = die.Tag();
 bool type_is_new = false;
-if (ParseType(sc, die, &type_is_new).get()) {
-  if (type_is_new)
-++types_added;
-}
+
+Tag dwarf_tag = static_cast(tag);
+
+// TODO: Currently ParseTypeFromDWARF(...) which is called by 
ParseType(...)
+// does not handle DW_TAG_subrange_type. It is not clear if this is a bug 
or
+// not.
+if (isType(dwarf_tag) && tag != DW_TAG_subrange_type)
+  ParseType(sc, die, &type_is_new);
+
+if (type_is_new)
+  ++types_added;
 
 if (parse_children && die.HasChildren()) {
   if (die.Tag() == DW_TAG_subprogram) {

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=374570&r1=374569&r2=374570&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct 11 09:36:20 2019
@@ -8973,6 +8973,39 @@ void ClangASTContext::Dump(Stream &s) {
   tu->dump(s.AsRawOstream());
 }
 
+void ClangASTContext::DumpFromSymbolFile(Stream &s,
+ llvm::StringRef symbol_name) {
+  SymbolFile *symfile = GetSymbolFile();
+
+  if (!symfile)
+return;
+
+  lldb_private::TypeList type_list;
+  symfile->GetTypes(nullptr, eTypeClassAny, type_list);
+  size_t ntypes = type_list.GetSize();
+
+  for (size_t i = 0; i < ntypes; ++i) {
+TypeSP type = type_list.GetTypeAtIndex(i);
+
+if (!symbol_name.empty())
+  if (symbol_name.compare(type->GetName().GetStringRef()) != 0)
+continue;
+
+s << type->GetName().AsCString() << "\n";
+
+if (clang::TagDecl *tag_decl =
+ GetAsTagDecl(type->GetFullCompilerType()))
+  tag_decl->dump(s.AsRawOstream());
+else if (clang::TypedefNameDecl *typedef_decl =
+ GetAsTypedefDecl(type->GetFullCompilerType()))
+  typedef_decl->dump(s.AsRawOstream());
+else {
+  GetCanonicalQualType(type->GetFullCompilerType().GetOpaqueQualType())
+  .dump(s.AsRawOstream());
+}
+  }
+}
+
 void ClangASTContext::DumpValue(
 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s,
 l

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

2019-10-11 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This is failing on the windows bot. There was already another failure, so you 
probably didn't get an email:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9727
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9760


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] D67994: Modify lldb-test to print out ASTs from symbol file

2019-10-11 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f46982b452b: [lldb-test] Modify lldb-test to print out ASTs 
from symbol file (authored by shafik).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D67994?vs=224479&id=224617#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67994

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -42,6 +42,7 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
+
 #include 
 #include 
 
@@ -168,6 +169,10 @@
 static cl::opt DumpAST("dump-ast",
  cl::desc("Dump AST restored from symbols."),
  cl::sub(SymbolsSubcommand));
+static cl::opt
+DumpClangAST("dump-clang-ast",
+ cl::desc("Dump clang AST restored from symbols."),
+ cl::sub(SymbolsSubcommand));
 
 static cl::opt Verify("verify", cl::desc("Verify symbol information."),
 cl::sub(SymbolsSubcommand));
@@ -187,6 +192,7 @@
 static Error findVariables(lldb_private::Module &Module);
 static Error dumpModule(lldb_private::Module &Module);
 static Error dumpAST(lldb_private::Module &Module);
+static Error dumpClangAST(lldb_private::Module &Module);
 static Error verify(lldb_private::Module &Module);
 
 static Expected getAction();
@@ -580,11 +586,11 @@
 Error opts::symbols::dumpAST(lldb_private::Module &Module) {
   Module.ParseAllDebugSymbols();
 
-  auto symfile = Module.GetSymbolFile();
+  SymbolFile *symfile = Module.GetSymbolFile();
   if (!symfile)
 return make_string_error("Module has no symbol file.");
 
-  auto type_system_or_err =
+  llvm::Expected type_system_or_err =
   symfile->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
   if (!type_system_or_err)
 return make_string_error("Can't retrieve ClangASTContext");
@@ -598,7 +604,7 @@
   if (!ast_ctx)
 return make_string_error("Can't retrieve AST context.");
 
-  auto tu = ast_ctx->getTranslationUnitDecl();
+  clang::TranslationUnitDecl *tu = ast_ctx->getTranslationUnitDecl();
   if (!tu)
 return make_string_error("Can't retrieve translation unit declaration.");
 
@@ -607,6 +613,30 @@
   return Error::success();
 }
 
+Error opts::symbols::dumpClangAST(lldb_private::Module &Module) {
+  Module.ParseAllDebugSymbols();
+
+  SymbolFile *symfile = Module.GetSymbolFile();
+  if (!symfile)
+return make_string_error("Module has no symbol file.");
+
+  llvm::Expected type_system_or_err =
+  symfile->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
+  if (!type_system_or_err)
+return make_string_error("Can't retrieve ClangASTContext");
+
+  auto *clang_ast_ctx =
+  llvm::dyn_cast_or_null(&type_system_or_err.get());
+  if (!clang_ast_ctx)
+return make_string_error("Retrieved TypeSystem was not a ClangASTContext");
+
+  StreamString Stream;
+  clang_ast_ctx->DumpFromSymbolFile(Stream, Name);
+  outs() << Stream.GetData() << "\n";
+
+  return Error::success();
+}
+
 Error opts::symbols::verify(lldb_private::Module &Module) {
   SymbolFile *symfile = Module.GetSymbolFile();
   if (!symfile)
@@ -685,6 +715,16 @@
 return dumpAST;
   }
 
+  if (DumpClangAST) {
+if (Find != FindType::None)
+  return make_string_error("Cannot both search and dump clang AST.");
+if (Regex || !Context.empty() || !File.empty() || Line != 0)
+  return make_string_error(
+  "-regex, -context, -name, -file and -line options are not "
+  "applicable for dumping clang AST.");
+return dumpClangAST;
+  }
+
   if (Regex && !Context.empty())
 return make_string_error(
 "Cannot search using both regular expressions and context.");
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -8973,6 +8973,39 @@
   tu->dump(s.AsRawOstream());
 }
 
+void ClangASTContext::DumpFromSymbolFile(Stream &s,
+ llvm::StringRef symbol_name) {
+  SymbolFile *symfile = GetSymbolFile();
+
+  if (!symfile)
+return;
+
+  lldb_private::TypeList type_list;
+  symfile->GetTypes(nullptr, eTypeClassAny, type_list);
+  size_t ntypes = type_list.GetSize();
+
+  for (size_t i = 0; i < ntypes; ++i) {
+TypeSP type = type_list.GetTypeAtIndex(i);
+
+if (!symbol_name.empty())
+  if (symbol_name.compare(type->GetName().GetStringRef()) != 0)
+continue;
+
+s << type->GetName().As

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-10-11 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade updated this revision to Diff 224615.
guiandrade edited the summary of this revision.
guiandrade added a comment.

Moving MPX fix to a parent change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931

Files:
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/TestMPXOffsetIntersection.py
  
lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -128,6 +128,11 @@
   ASSERT_EQ(0,
 memcmp(buffer_sp->GetBytes(), one_register, sizeof one_register));
 
+  async_result = std::async(std::launch::async,
+[&] { return client.GetgPacketSupported(tid); });
+  HandlePacket(server, "g;thread:0047;", all_registers_hex);
+  ASSERT_TRUE(async_result.get());
+
   read_result = std::async(std::launch::async,
[&] { return client.ReadAllRegisters(tid); });
   HandlePacket(server, "g;thread:0047;", all_registers_hex);
Index: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -301,13 +301,15 @@
 if (process_sp) {
   ProcessGDBRemote *gdb_process =
   static_cast(process_sp.get());
-  // read_all_registers_at_once will be true if 'p' packet is not
-  // supported.
   bool read_all_registers_at_once =
-  !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
+  gdb_process->GetGDBRemote().GetgPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_reading;
+  bool write_all_registers_at_once =
+  gdb_process->GetGDBRemote().GetGPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_writing;
   reg_ctx_sp = std::make_shared(
   *this, concrete_frame_idx, gdb_process->m_register_info,
-  read_all_registers_at_once);
+  read_all_registers_at_once, write_all_registers_at_once);
 }
   } else {
 Unwind *unwinder = GetUnwinder();
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
@@ -13,4 +13,12 @@
 Global,
 DefaultFalse,
 Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules.">;
+  def UseGPacketForReading: Property<"use-g-packet-for-reading", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Specify if the server should use 'g' packets to read registers.">;
+  def UseGPacketForWriting: Property<"use-g-packet-for-writing", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"Specify if the server should use 'g' packets to write registers.">;
 }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -284,6 +284,8 @@
   lldb::CommandObjectSP m_command_sp;
   int64_t m_breakpoint_pc_offset;
   lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+  bool m_use_g_p

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-10-11 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade updated this revision to Diff 224626.
guiandrade added a comment.

Properly separating MPX fix from this change (I guess)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -128,6 +128,11 @@
   ASSERT_EQ(0,
 memcmp(buffer_sp->GetBytes(), one_register, sizeof one_register));
 
+  async_result = std::async(std::launch::async,
+[&] { return client.GetgPacketSupported(tid); });
+  HandlePacket(server, "g;thread:0047;", all_registers_hex);
+  ASSERT_TRUE(async_result.get());
+
   read_result = std::async(std::launch::async,
[&] { return client.ReadAllRegisters(tid); });
   HandlePacket(server, "g;thread:0047;", all_registers_hex);
Index: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -301,13 +301,15 @@
 if (process_sp) {
   ProcessGDBRemote *gdb_process =
   static_cast(process_sp.get());
-  // read_all_registers_at_once will be true if 'p' packet is not
-  // supported.
   bool read_all_registers_at_once =
-  !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
+  gdb_process->GetGDBRemote().GetgPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_reading;
+  bool write_all_registers_at_once =
+  gdb_process->GetGDBRemote().GetGPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_writing;
   reg_ctx_sp = std::make_shared(
   *this, concrete_frame_idx, gdb_process->m_register_info,
-  read_all_registers_at_once);
+  read_all_registers_at_once, write_all_registers_at_once);
 }
   } else {
 Unwind *unwinder = GetUnwinder();
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
@@ -13,4 +13,12 @@
 Global,
 DefaultFalse,
 Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules.">;
+  def UseGPacketForReading: Property<"use-g-packet-for-reading", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Specify if the server should use 'g' packets to read registers.">;
+  def UseGPacketForWriting: Property<"use-g-packet-for-writing", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"Specify if the server should use 'g' packets to write registers.">;
 }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -284,6 +284,8 @@
   lldb::CommandObjectSP m_command_sp;
   int64_t m_breakpoint_pc_offset;
   lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+  bool m_use_g_packet_for_reading;
+  bool m_use_g_packet_for_writing;
 
   bool m_replay_mode;
   bool m_allow_flash_writes;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -154,6 +154,16 @@
 nullptr, idx,
 g_processgdbremote_properties[idx].default_uint_value != 0);
   }
+
+  bool GetUseGPacketForReading() const {
+const uint32_t idx = ePropertyUseGPacketForReading;
+return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true);
+  }
+
+  bool GetUseGPacketForWriting() const {
+const uint32_t idx = eProperty

[Lldb-commits] [PATCH] D68878: [lldb] Fix python packages install path

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: mgorny.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68878

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374572 - [lldb] Add import-std-module/sysroot to the libc++ test category.

2019-10-11 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct 11 10:17:58 2019
New Revision: 374572

URL: http://llvm.org/viewvc/llvm-project?rev=374572&view=rev
Log:
[lldb] Add import-std-module/sysroot to the libc++ test category.

We essentially test libc++ in a sysroot here so let's make sure
that we actually only run this test on platforms where libc++
testing is enabled.

Modified:

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

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=374572&r1=374571&r2=374572&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
 Fri Oct 11 10:17:58 2019
@@ -11,6 +11,10 @@ class ImportStdModule(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
+# We only emulate a fake libc++ in this test and don't use the real libc++,
+# but we still add the libc++ category so that this test is only run in
+# test configurations where libc++ is actually supposed to be tested.
+@add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
 def test(self):
 self.build()


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


[Lldb-commits] [lldb] r374574 - [lldb] Mark import-std-module/empty-module as libc++ test

2019-10-11 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct 11 10:34:44 2019
New Revision: 374574

URL: http://llvm.org/viewvc/llvm-project?rev=374574&view=rev
Log:
[lldb] Mark import-std-module/empty-module as libc++ test

Same as with the import-std-module/sysroot test before.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py?rev=374574&r1=374573&r2=374574&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
 Fri Oct 11 10:34:44 2019
@@ -11,6 +11,10 @@ class ImportStdModule(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
+# We only emulate a fake libc++ in this test and don't use the real libc++,
+# but we still add the libc++ category so that this test is only run in
+# test configurations where libc++ is actually supposed to be tested.
+@add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
 def test(self):
 self.build()


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


[Lldb-commits] [PATCH] D68878: [lldb] Fix python packages install path

2019-10-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68878



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


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224630.
lawrence_danna added a comment.

move using declarations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/IOHandler.cpp

Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -70,6 +70,10 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
 
 IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
 : IOHandler(debugger, type,
@@ -306,94 +310,119 @@
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string &line_buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string &line_buffer) {
+  if (llvm::all_of(line_buffer, isspace))
+return None;
+  std::string line = std::move(line_buffer);
+  line_buffer.clear();
+  return line;
+}
+
 bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_up) {
 bool b = m_editline_up->GetLine(line, interrupted);
-if (m_data_recorder)
+if (b && m_data_recorder)
   m_data_recorder->Record(line, true);
 return b;
-  } else {
+  }
 #endif
-line.clear();
 
-FILE *in = GetInputFILE();
-if (in) {
-  if (GetIsInteractive()) {
-const char *prompt = nullptr;
+  line.clear();
 
-if (m_multi_line && m_curr_line_idx > 0)
-  prompt = GetContinuationPrompt();
+  if (GetIsInteractive()) {
+const char *prompt = nullptr;
 
-if (prompt == nullptr)
-  prompt = GetPrompt();
+if (m_multi_line && m_curr_line_idx > 0)
+  prompt = GetContinuationPrompt();
 
-if (prompt && prompt[0]) {
-  if (m_output_sp) {
-m_output_sp->Printf("%s", prompt);
-m_output_sp->Flush();
-  }
-}
+if (prompt == nullptr)
+  prompt = GetPrompt();
+
+if (prompt && prompt[0]) {
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
+  }
+}
+  }
+
+  Optional got_line = SplitLine(m_line_buffer);
+
+  if (!got_line && !m_input_sp) {
+// No more input file, we are done...
+SetIsDone(true);
+return false;
+  }
+
+  FILE *in = GetInputFILE();
+  char buffer[256];
+
+  if (!got_line && !in && m_input_sp) {
+// there is no FILE*, fall back on just reading bytes from the stream.
+while (!got_line) {
+  size_t bytes_read = sizeof(buffer);
+  Status error = m_input_sp->Read((void *)buffer, bytes_read);
+  if (error.Success() && !bytes_read) {
+got_line = SplitLineEOF(m_line_buffer);
+break;
   }
-  char buffer[256];
-  bool done = false;
-  bool got_line = false;
-  m_editing = true;
-  while (!done) {
+  if (error.Fail())
+break;
+  m_line_buffer += StringRef(buffer, bytes_read);
+  got_line = SplitLine(m_line_buffer);
+}
+  }
+
+  if (!got_line && in) {
+m_editing = true;
+while (!got_line) {
+  char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
-// ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
-// according to the docs on MSDN. However, this has evidently been a
-// known bug since Windows 8. Therefore, we can't detect if a signal
-// interrupted in the fgets. So pressing ctrl-c causes the repl to end
-// and the process to exit. A temporary workaround is just to attempt to
-// fgets twice until this bug is fixed.
-if (fgets(buffer, sizeof(buffer), in) == nullptr &&
-fgets(buffer, sizeof(buffer), in) == nullptr) {
-  // this is the equivalent of EINTR for Windows
-  if (GetLastError() == ERROR_OPERATION_ABORTED)
-continue;
-#else
-  if (fgets(buffer, sizeof(buffer), in) == nullptr) {
+  // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
+  // according to the docs on MSDN. However, this has evidently been a
+  // known bug since Windows 8. Therefore, we can't detect if a signal
+  // interrupted in the fgets. So pressing ctrl-c causes the repl to end
+  // and the process to exit. A temporary workaround is just to attempt to
+  // fgets twice until this bug is fixed.
+  if (r == nullptr)
+  

[Lldb-commits] [PATCH] D68853: uint32_t options -> File::OpenOptions options

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224631.
lawrence_danna marked 5 inline comments as done.
lawrence_danna added a comment.

review fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68853

Files:
  lldb/include/lldb/Core/StreamFile.h
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/FileCache.h
  lldb/include/lldb/Host/FileSystem.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Target/RemoteAwarePlatform.h
  lldb/source/API/SBFile.cpp
  lldb/source/API/SBStream.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Core/StreamFile.cpp
  lldb/source/Host/common/File.cpp
  lldb/source/Host/common/FileCache.cpp
  lldb/source/Host/common/FileSystem.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/RemoteAwarePlatform.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -996,10 +996,9 @@
   }
 
   StreamFile out_file(path.c_str(),
-  File::OpenOptions::eOpenOptionTruncate |
-  File::OpenOptions::eOpenOptionWrite |
-  File::OpenOptions::eOpenOptionCanCreate |
-  File::OpenOptions::eOpenOptionCloseOnExec,
+  File::eOpenOptionTruncate | File::eOpenOptionWrite |
+  File::eOpenOptionCanCreate |
+  File::eOpenOptionCloseOnExec,
   lldb::eFilePermissionsFileDefault);
   if (!out_file.GetFile().IsValid()) {
 error.SetErrorStringWithFormat("Unable to open output file: %s.",
Index: lldb/source/Target/RemoteAwarePlatform.cpp
===
--- lldb/source/Target/RemoteAwarePlatform.cpp
+++ lldb/source/Target/RemoteAwarePlatform.cpp
@@ -61,8 +61,8 @@
 }
 
 lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
-  uint32_t flags, uint32_t mode,
-  Status &error) {
+  File::OpenOptions flags,
+  uint32_t mode, Status &error) {
   if (IsHost())
 return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
   if (m_remote_platform_sp)
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1220,7 +1220,7 @@
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
   LLDB_LOGF(log, "[PutFile] Using block by block transfer\n");
 
-  uint32_t source_open_options =
+  auto source_open_options =
   File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
   namespace fs = llvm::sys::fs;
   if (fs::is_symlink_file(source.GetPath()))
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1090,8 +1090,12 @@
   // File object knows about that.
   PythonString py_mode = GetAttributeValue("mode").AsType();
   auto options = File::GetOptionsFromMode(py_mode.GetString());
-  auto file = std::unique_ptr(
-  new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
+  if (!options) {
+llvm::consumeError(options.takeError());
+return nullptr;
+  }
+  auto file = std::unique_ptr(new NativeFile(
+  PyObject_AsFileDescriptor(m_py_obj), options.get(), false));
   if (!file->IsValid())
 return nullptr;
   return file;
@@ -1165,8 +1169,9 @@
 
 char PythonException::ID = 0;
 
-llvm::Expected GetOptionsForPyObject(const PythonObject &obj) {
-  uint32_t options = 0;
+llvm::Expected
+GetOptionsForPyObject(const PythonObject &obj) {
+  auto options = File::OpenOptions(0);
 #if PY_MAJOR_VERSION >= 3
   auto readable = As(obj.CallMethod("readable"));
   if (!readable)
@@ -1245,7 +1250,7 @@
 class SimplePythonFile : public OwnedPythonFile {
 public:
   SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
-   uint32_t options)
+  

[Lldb-commits] [lldb] r374576 - IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-11 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Fri Oct 11 10:43:32 2019
New Revision: 374576

URL: http://llvm.org/viewvc/llvm-project?rev=374576&view=rev
Log:
IOHandler: fall back on File::Read if a FILE* isn't available.

Summary:
IOHandler needs to read lines of input from a lldb::File.
The way it currently does this using, FILE*, which is something
we want to avoid now.   I'd prefer to just replace the FILE* code
with calls to File::Read, but it contains an awkward and
delicate workaround specific to ctrl-C handling on windows, and
it's not clear if or how that workaround would translate to
lldb::File.

So in this patch, we use use the FILE* if it's available, and only
fall back on File::Read if that's the only option.

I think this is a reasonable approach here for two reasons.  First
is that interactive terminal support is the one area where FILE*
can't be avoided.   We need them for libedit and curses anyway,
and using them here as well is consistent with that pattern.

The second reason is that the comments express a hope that the
underlying windows bug that's being worked around will be fixed one
day, so hopefully when that happens, that whole path can be deleted.

Reviewers: JDevlieghere, jasonmolenda, labath, lanza

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Core/IOHandler.h

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
lldb/trunk/source/Core/IOHandler.cpp

Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=374576&r1=374575&r2=374576&view=diff
==
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Fri Oct 11 10:43:32 2019
@@ -431,6 +431,7 @@ protected:
   bool m_interrupt_exits;
   bool m_editing; // Set to true when fetching a line manually (not using
   // libedit)
+  std::string m_line_buffer;
 };
 
 // The order of base classes is important. Look at the constructor of

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=374576&r1=374575&r2=374576&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
 Fri Oct 11 10:43:32 2019
@@ -399,9 +399,9 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME IOHandler still using FILE*
+@skipIf(py_version=['<', (3,)])
 def test_string_inout(self):
-inf = io.StringIO("help help\n")
+inf = io.StringIO("help help\np/x ~0\n")
 outf = io.StringIO()
 status = self.debugger.SetOutputFile(lldb.SBFile(outf))
 self.assertTrue(status.Success())
@@ -412,10 +412,11 @@ class FileHandleTestCase(lldbtest.TestBa
 self.debugger.GetOutputFile().Flush()
 output = outf.getvalue()
 self.assertIn('Show a list of all debugger commands', output)
+self.assertIn('0xfff', output)
 
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll() # FIXME IOHandler still using FILE*
+@skipIf(py_version=['<', (3,)])
 def test_bytes_inout(self):
 inf = io.BytesIO(b"help help\nhelp b\n")
 outf = io.BytesIO()

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=374576&r1=374575&r2=374576&view=diff
==
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Fri Oct 11 10:43:32 2019
@@ -70,6 +70,10 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
 
 IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
 : IOHandler(debugger, type,
@@ -306,94 +310,119 @@ void IOHandlerEditline::Deactivate() {
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string &line_buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string &line_buffer) {
+  if (llvm::all_of(line_buffer, isspace))
+return None;
+  s

[Lldb-commits] [lldb] r374577 - [lldb] Fix python packages install path

2019-10-11 Thread Haibo Huang via lldb-commits
Author: hhb
Date: Fri Oct 11 10:44:14 2019
New Revision: 374577

URL: http://llvm.org/viewvc/llvm-project?rev=374577&view=rev
Log:
[lldb] Fix python packages install path

Reviewers: mgorny

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=374577&r1=374576&r2=374577&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Oct 11 10:44:14 2019
@@ -235,7 +235,7 @@ if (NOT LLDB_DISABLE_PYTHON)
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)


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


[Lldb-commits] [PATCH] D68853: uint32_t options -> File::OpenOptions options

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added inline comments.



Comment at: lldb/source/Host/common/File.cpp:42
 
-static const char *GetStreamOpenModeFromOptions(uint32_t options) {
+static Expected GetStreamOpenModeFromOptions(uint32_t options) {
   if (options & File::eOpenOptionAppend) {

labath wrote:
> I'd consider leaving the static function as `const char *` -- the function 
> doesn't do anything complex, and there's only one way it can fail (which can 
> be signalled by a nullptr), so having the Expected wrapper around that does 
> not seem all that useful -- I'll leave it up to you though.
If I do that I'd still just have to convert it to Error in the callers, so I 
think I'll leave it this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68853



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


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3faa01ff962: IOHandler: fall back on File::Read if a FILE* 
isn't available. (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/IOHandler.cpp

Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -70,6 +70,10 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
 
 IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
 : IOHandler(debugger, type,
@@ -306,94 +310,119 @@
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string &line_buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string &line_buffer) {
+  if (llvm::all_of(line_buffer, isspace))
+return None;
+  std::string line = std::move(line_buffer);
+  line_buffer.clear();
+  return line;
+}
+
 bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_up) {
 bool b = m_editline_up->GetLine(line, interrupted);
-if (m_data_recorder)
+if (b && m_data_recorder)
   m_data_recorder->Record(line, true);
 return b;
-  } else {
+  }
 #endif
-line.clear();
 
-FILE *in = GetInputFILE();
-if (in) {
-  if (GetIsInteractive()) {
-const char *prompt = nullptr;
+  line.clear();
 
-if (m_multi_line && m_curr_line_idx > 0)
-  prompt = GetContinuationPrompt();
+  if (GetIsInteractive()) {
+const char *prompt = nullptr;
 
-if (prompt == nullptr)
-  prompt = GetPrompt();
+if (m_multi_line && m_curr_line_idx > 0)
+  prompt = GetContinuationPrompt();
 
-if (prompt && prompt[0]) {
-  if (m_output_sp) {
-m_output_sp->Printf("%s", prompt);
-m_output_sp->Flush();
-  }
-}
+if (prompt == nullptr)
+  prompt = GetPrompt();
+
+if (prompt && prompt[0]) {
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
+  }
+}
+  }
+
+  Optional got_line = SplitLine(m_line_buffer);
+
+  if (!got_line && !m_input_sp) {
+// No more input file, we are done...
+SetIsDone(true);
+return false;
+  }
+
+  FILE *in = GetInputFILE();
+  char buffer[256];
+
+  if (!got_line && !in && m_input_sp) {
+// there is no FILE*, fall back on just reading bytes from the stream.
+while (!got_line) {
+  size_t bytes_read = sizeof(buffer);
+  Status error = m_input_sp->Read((void *)buffer, bytes_read);
+  if (error.Success() && !bytes_read) {
+got_line = SplitLineEOF(m_line_buffer);
+break;
   }
-  char buffer[256];
-  bool done = false;
-  bool got_line = false;
-  m_editing = true;
-  while (!done) {
+  if (error.Fail())
+break;
+  m_line_buffer += StringRef(buffer, bytes_read);
+  got_line = SplitLine(m_line_buffer);
+}
+  }
+
+  if (!got_line && in) {
+m_editing = true;
+while (!got_line) {
+  char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
-// ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
-// according to the docs on MSDN. However, this has evidently been a
-// known bug since Windows 8. Therefore, we can't detect if a signal
-// interrupted in the fgets. So pressing ctrl-c causes the repl to end
-// and the process to exit. A temporary workaround is just to attempt to
-// fgets twice until this bug is fixed.
-if (fgets(buffer, sizeof(buffer), in) == nullptr &&
-fgets(buffer, sizeof(buffer), in) == nullptr) {
-  // this is the equivalent of EINTR for Windows
-  if (GetLastError() == ERROR_OPERATION_ABORTED)
-continue;
-#else
-  if (fgets(buffer, sizeof(buffer), in) == nullptr) {
+  // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
+  // according to the docs on MSDN. However, this has evidently been a
+  // known bug since Windows 8. Therefore, we can't detect if a signal
+  // interrupted in the fgets. So pressing ctrl-c causes the repl to end
+  // and the process to exit. A temporary workaround is just to 

[Lldb-commits] [PATCH] D68878: [lldb] Fix python packages install path

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6aacd9687543: [lldb] Fix python packages install path 
(authored by hhb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68878

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)
___
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-11 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.

In D68096#1706076 , @JosephTremoulet 
wrote:

> Just to make sure I'm understanding the feedback correctly, I'll try to 
> summarize.  Please let me know if this is off track:
>
> - When one uses breakpad to generate a minidump for a process that *hasn't* 
> crashed, depending which of its methods one calls to write the dump, the 
> generated dump's exception stream's exception code is either the "dump 
> requested" sentinel or zero.


I believe so.

> - We have a bug, which this patch is meant to fix, wherein loading one of 
> those dumps with exception code zero creates a stop with signal zero, 
> resulting in lldb hanging.

If this patch is solely meant to fix this issue, then I remove my "Requires 
Changes" and this patch is good to go if it no longer hangs LLDB.

> - We have some "prior art" in ProcessElfCore, which is how we successfully 
> load the core dump you get by running a zero-exception-code minidump through 
> breakpad's minidump-2-core, which is to artificially report SIGSTOP.  
> @labath, your feedback is that this is a hack that we shouldn't extend and 
> should ideally/eventually remove from ProcessElfCore

I agree on this as long as no hang happens!

> - We also have some "prior art" in ProcessMinidump, which is how we 
> successfully load a minidump with the "dump requested" sentinel, which is to 
> create no stop at all.  That's what this patch currently does when it sees 
> signal zero.  @clayborg, your feedback is that simply checking that the error 
> code is zero is insufficient grounds to suppress stop creation, that we 
> should probably check other fields in the exception stream and create a stop 
> if *any* of them are reporting anything non-null, and/or verify that the only 
> way breakpad/crashpad will produce a linux minidump with null signal is if 
> there's no exception whatsoever

As Pavel mentioned, I was asking for other fields in the exception info to be 
passed along for other signals, like SIGSEGV. After reading his comments, I 
agree this can be done in another patch if it isn't already being done.

> I may need to set this aside for a while and come back to it to address 
> @clayborg's concerns (if I've understood them correctly), but I can live with 
> my downstream changes in the meantime, so that's seeming like the best path 
> forward.

If this patch fixes the hang, then it is good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68096



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


[Lldb-commits] [PATCH] D68856: convert SBDebugger::***FileHandle() wrappers to native files.

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224638.
lawrence_danna added a comment.

fix for swig 3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68856

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBDebugger.i

Index: lldb/scripts/interface/SBDebugger.i
===
--- lldb/scripts/interface/SBDebugger.i
+++ lldb/scripts/interface/SBDebugger.i
@@ -165,29 +165,44 @@
 void
 SkipLLDBInitFiles (bool b);
 
-%feature("autodoc", "DEPRECATED, use SetInputFile");
-void
-SetInputFileHandle (FILE *f, bool transfer_ownership);
+%pythoncode %{
+def SetOutputFileHandle(self, file, transfer_ownership):
+"DEPRECATED, use SetOutputFile"
+if file is None:
+import sys
+file = sys.stdout
+self.SetOutputFile(SBFile.Create(file, borrow=True))
+
+def SetInputFileHandle(self, file, transfer_ownership):
+"DEPRECATED, use SetInputFile"
+if file is None:
+import sys
+file = sys.stdin
+self.SetInputFile(SBFile.Create(file, borrow=True))
+
+def SetErrorFileHandle(self, file, transfer_ownership):
+"DEPRECATED, use SetErrorFile"
+if file is None:
+import sys
+file = sys.stderr
+self.SetErrorFile(SBFile.Create(file, borrow=True))
+%}
 
-%feature("autodoc", "DEPRECATED, use SetOutputFile");
-void
-SetOutputFileHandle (FILE *f, bool transfer_ownership);
 
-%feature("autodoc", "DEPRECATED, use SetErrorFile");
-void
-SetErrorFileHandle (FILE *f, bool transfer_ownership);
+%extend {
 
-%feature("autodoc", "DEPRECATED, use GetInputFile");
-FILE *
-GetInputFileHandle ();
+lldb::FileSP GetInputFileHandle() {
+return self->GetInputFile().GetFile();
+}
 
-%feature("autodoc", "DEPRECATED, use GetOutputFile");
-FILE *
-GetOutputFileHandle ();
+lldb::FileSP GetOutputFileHandle() {
+return self->GetOutputFile().GetFile();
+}
 
-%feature("autodoc", "DEPRECATED, use GetErrorFile");
-FILE *
-GetErrorFileHandle ();
+lldb::FileSP GetErrorFileHandle() {
+return self->GetErrorFile().GetFile();
+}
+}
 
 SBError
 SetInputFile (SBFile file);
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
@@ -129,8 +129,6 @@
 
 
 @add_test_categories(['pyapi'])
-@skipIfWindows # FIXME pre-existing bug, should be fixed
-   # when we delete the FILE* typemaps.
 def test_legacy_file_out_script(self):
 with open(self.out_filename, 'w') as f:
 self.debugger.SetOutputFileHandle(f, False)
@@ -155,8 +153,6 @@
 self.assertIn('deadbeef', f.read())
 
 @add_test_categories(['pyapi'])
-@skipIfWindows # FIXME pre-existing bug, should be fixed
-   # when we delete the FILE* typemaps.
 def test_legacy_file_err_with_get(self):
 with open(self.out_filename, 'w') as f:
 self.debugger.SetErrorFileHandle(f, False)
@@ -194,11 +190,11 @@
 @add_test_categories(['pyapi'])
 def test_sbfile_type_errors(self):
 sbf = lldb.SBFile()
-self.assertRaises(TypeError, sbf.Write, None)
-self.assertRaises(TypeError, sbf.Read, None)
-self.assertRaises(TypeError, sbf.Read, b'this bytes is not mutable')
-self.assertRaises(TypeError, sbf.Write, u"ham sandwich")
-self.assertRaises(TypeError, sbf.Read, u"ham sandwich")
+self.assertRaises(Exception, sbf.Write, None)
+self.assertRaises(Exception, sbf.Read, None)
+self.assertRaises(Exception, sbf.Read, b'this bytes is not mutable')
+self.assertRaises(Exception, sbf.Write, u"ham sandwich")
+self.assertRaises(Exception, sbf.Read, u"ham sandwich")
 
 
 @add_test_categories(['pyapi'])
@@ -825,3 +821,40 @@
 
 with open(self.out_filename, 'r') as f:
 self.assertEqual("foobar", f.read().strip())
+
+@add_test_categories(['pyapi'])
+def test_set_filehandle_none(self):
+self.assertRaises(Exception, self.debugger.SetOutputFile, None)
+self.assertRaises(Exception, self.debugger.SetOutputFile, "ham sandwich")
+self.assertRaises(Exception, self.debugger.SetOutputFileHandle, "ham sandwich")
+self.assertRaises(Exception, self.debugger.SetInputFile, None)
+self.assertRaises(Exception, self.debugger.SetInputFile, "ham sandwich")
+self.as

[Lldb-commits] [PATCH] D68671: Add the ability to pass extra args to a Python breakpoint command function

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

> The only place where I treat the extra_args as a Dictionary is when I use as 
> a way to tell whether the extra_args is empty, which I need to write the 
> right wrapper function in GenerateBreakpointCommandCallbackData. That 
> function is little annoying because it doesn't know whether it is calling a 
> function or some text gotten from the I/O handler, so I can't count the 
> function arguments there to decide which signature to use.
> 
> Let me see if I can make this cleaner so I don't have to rely on that. I 
> really don't intend to limit fancier uses of the extra args.

Let me know if you are going to look into making this cleaner for this patch. 
If so, I will hold off, else I can accept if you are out of time


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68671



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


[Lldb-commits] [PATCH] D68662: Redo D68354 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Good suggestion! I'll do that next time

Thank you so much. I'm getting more used to all the llvm infrastructure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68662



___
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-11 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added a comment.

In D68096#1706258 , @clayborg wrote:

> If this patch is solely meant to fix this issue, then I remove my "Requires 
> Changes" and this patch is good to go if it no longer hangs LLDB.


Great, thanks.  And just to confirm on the testing:

- test/functionalities/postmortem/minidump-new/linux-x86_64_not_crashed.cpp is 
an example program that uses breakpad to generate a dump that uses the sentinel 
signal, and we have a test checked in that uses a reduced yaml-ized copy of its 
minidump
- https://gist.github.com/JosephTremoulet/2689c5ed21d7be5543cfcb70d548e0bc is 
an example program that uses breakpad to generate a dump that uses null signal, 
and in this patch I'm adding a test that uses a reduced yaml-ized copy of its 
minidump, which lldb hangs on loading without this fix and successfully loads 
with this fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68096



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


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

2019-10-11 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:
> tatyana-krasnukha wrote:
> > hhb wrote:
> > > hhb wrote:
> > > > 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...
> > > Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
> > Yes, now it works well
> > Can you help test that time? I don't have a visual studio...
> 
> Yes, of course!
> 
> BTW, I suppose that '--cmakeBuildConfiguration' option can fix the issue for 
> XCode too. 
> 
> 
It does. But we have some other issue when LLDB_BUILD_FRAMEWORK is enabled.

Sent D68858. Wish it goes well this me. 😊


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] D68662: Redo D68354 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace closed this revision.
wallace added a comment.

will update the previous diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68662



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


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224648.
hhb added a comment.

Fix file copy path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224649.
hhb added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - (R) P

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224647.
hhb added a comment.

Fix file copy path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 224656.
wallace added a comment.

now it should work, the test pass


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,9 +160,34 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+raise "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +196,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -425,7 +450,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -0,0 +1,35 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+class MyResponder(MockGDBServerResponder):
+def qfProcessInfo(self, packet):
+if "all_users:1" in 

[Lldb-commits] [PATCH] D68549: make ConstString allocate memory in non-tiny chunks

2019-10-11 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2ca7cb504a8: make ConstString allocate memory in non-tiny 
chunks (authored by llunak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68549

Files:
  lldb/source/Utility/ConstString.cpp


Index: lldb/source/Utility/ConstString.cpp
===
--- lldb/source/Utility/ConstString.cpp
+++ lldb/source/Utility/ConstString.cpp
@@ -31,7 +31,10 @@
 class Pool {
 public:
   typedef const char *StringPoolValueType;
-  typedef llvm::StringMap
+  // BumpPtrAllocator allocates in 4KiB chunks, any larger C++ project is going
+  // to have megabytes of symbols, so allocate in larger chunks.
+  typedef llvm::BumpPtrAllocatorImpl Allocator;
+  typedef llvm::StringMap
   StringPool;
   typedef llvm::StringMapEntry StringPoolEntryType;
 
@@ -152,7 +155,9 @@
 
   struct PoolEntry {
 mutable llvm::sys::SmartRWMutex m_mutex;
-StringPool m_string_map;
+// StringMap by default starts with 16 buckets, any larger project is
+// going to have many symbols, so start with a larger value.
+StringPool m_string_map = StringPool( 65536 );
   };
 
   std::array m_string_pools;


Index: lldb/source/Utility/ConstString.cpp
===
--- lldb/source/Utility/ConstString.cpp
+++ lldb/source/Utility/ConstString.cpp
@@ -31,7 +31,10 @@
 class Pool {
 public:
   typedef const char *StringPoolValueType;
-  typedef llvm::StringMap
+  // BumpPtrAllocator allocates in 4KiB chunks, any larger C++ project is going
+  // to have megabytes of symbols, so allocate in larger chunks.
+  typedef llvm::BumpPtrAllocatorImpl Allocator;
+  typedef llvm::StringMap
   StringPool;
   typedef llvm::StringMapEntry StringPoolEntryType;
 
@@ -152,7 +155,9 @@
 
   struct PoolEntry {
 mutable llvm::sys::SmartRWMutex m_mutex;
-StringPool m_string_map;
+// StringMap by default starts with 16 buckets, any larger project is
+// going to have many symbols, so start with a larger value.
+StringPool m_string_map = StringPool( 65536 );
   };
 
   std::array m_string_pools;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374584 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 12:41:12 2019
New Revision: 374584

URL: http://llvm.org/viewvc/llvm-project?rev=374584&view=rev
Log:
[platform process list] add a flag for showing the processes of all users

Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same 
user as the user that launched lldb-server. However, it's quite useful to see 
all the processes, though, and it will lay a foundation for full apk debugging 
support from lldb.

Before:
```
PIDPARENT USER   TRIPLE   NAME
== == ==  
3234   1 aarch64-unknown-linux-android adbd
8034   3234  aarch64-unknown-linux-android sh
9096   3234  aarch64-unknown-linux-android sh
9098   9096  aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
1  0  init
5241  init
5251  init
5311  ueventd
5681  logd
5691 aarch64-unknown-linux-android servicemanager
5701 aarch64-unknown-linux-android hwservicemanager
5711 aarch64-unknown-linux-android vndservicemanager
5771 aarch64-unknown-linux-android qseecomd
580577   aarch64-unknown-linux-android qseecomd
...
23816  979com.android.providers.calendar
24600  979com.verizon.mips.services
27888  979com.hualai
28043  2378   
com.android.chrome:sandboxed_process0
31449  979com.att.shm
31779  979com.samsung.android.authfw
31846  979
com.samsung.android.server.iris
32014  979
com.samsung.android.MtpApplication
32045  979com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374584&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 Fri Oct 11 12:41:12 2019
@@ -0,0 +1,35 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+class MyResponder(MockGDBServerResponder):
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
+else:
+return "E04"
+
+self.server.responder = MyResponder()
+
+self.runCmd("platform select remote-linux")
+
+try:
+self.runCmd("platform connect connect://localhost:%d" %
+self.server.port)
+self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+self.expect("platform process list -x",
+substrs=["1 matching process was found", 
"test_process"])
+self.expect("platform process list",
+error=True,
+substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
+finally:
+self.dbg.GetSelectedPlatform().DisconnectRemote()

Modified: 
lldb/trunk/packages/P

[Lldb-commits] [PATCH] D67347: [Windows] Use information from the PE32 exceptions directory to construct unwind plans

2019-10-11 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It looks like this changed fixed at least one of the XFAILed tests on Windows:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9751

So now the test results would be red because of the unexpectedly passing test 
(if there wasn't another failure). Could you have a look at whether any of the 
other tests that were XFAILed for the same bug are also now passing and remove 
the expected failure tags as appropriate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67347



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


[Lldb-commits] [lldb] r374585 - Add -fgnuc-version to ClangModuleCompilationOptions on Darwin.

2019-10-11 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Fri Oct 11 12:54:09 2019
New Revision: 374585

URL: http://llvm.org/viewvc/llvm-project?rev=374585&view=rev
Log:
Add -fgnuc-version to ClangModuleCompilationOptions on Darwin.

This adapts LLDB for https://reviews.llvm.org/D68055.

Darwin's libC headers expect the GNUC macro to be set.

Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=374585&r1=374584&r2=374585&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Oct 11 
12:54:09 2019
@@ -1506,7 +1506,8 @@ void PlatformDarwin::AddClangModuleCompi
 Target *target, std::vector &options, SDKType sdk_type) {
   const std::vector apple_arguments = {
   "-x",   "objective-c++", "-fobjc-arc",
-  "-fblocks", "-D_ISO646_H",   "-D__ISO646_H"};
+  "-fblocks", "-D_ISO646_H",   "-D__ISO646_H",
+  "-fgnuc-version=4.2.1"};
 
   options.insert(options.end(), apple_arguments.begin(), 
apple_arguments.end());
 


___
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-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224659.
lawrence_danna marked 8 inline comments as done.
lawrence_danna added a comment.

review fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68737

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/Host/File.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Host/common/File.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -638,7 +638,7 @@
   void Reset(PyRefType type, PyObject *py_obj) override;
 
   ArgInfo GetNumArguments() const;
-  
+
   // If the callable is a Py_Class, then find the number of arguments
   // of the __init__ method.
   ArgInfo GetNumInitArguments() const;
@@ -658,7 +658,6 @@
 class PythonFile : public PythonObject {
 public:
   PythonFile();
-  PythonFile(File &file, const char *mode);
   PythonFile(PyRefType type, PyObject *o);
 
   ~PythonFile() override;
@@ -668,7 +667,21 @@
   using PythonObject::Reset;
 
   void Reset(PyRefType type, PyObject *py_obj) override;
-  void Reset(File &file, const char *mode);
+
+  static llvm::Expected FromFile(File &file,
+ const char *mode = nullptr);
+
+  // FIXME delete this after FILE* typemaps are deleted
+  // and ScriptInterpreterPython is fixed
+  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());
+}
+  }
 
   lldb::FileUP GetUnderlyingFile() const;
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -22,6 +22,7 @@
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Errno.h"
 
@@ -1012,8 +1013,6 @@
 
 PythonFile::PythonFile() : PythonObject() {}
 
-PythonFile::PythonFile(File &file, const char *mode) { Reset(file, mode); }
-
 PythonFile::PythonFile(PyRefType type, PyObject *o) { Reset(type, o); }
 
 PythonFile::~PythonFile() {}
@@ -1063,25 +1062,6 @@
   PythonObject::Reset(PyRefType::Borrowed, result.get());
 }
 
-void PythonFile::Reset(File &file, const char *mode) {
-  if (!file.IsValid()) {
-Reset();
-return;
-  }
-
-  char *cmode = const_cast(mode);
-#if PY_MAJOR_VERSION >= 3
-  Reset(PyRefType::Owned, PyFile_FromFd(file.GetDescriptor(), nullptr, cmode,
--1, nullptr, "ignore", nullptr, 0));
-#else
-  // Read through the Python source, doesn't seem to modify these strings
-  Reset(PyRefType::Owned,
-PyFile_FromFile(file.GetStream(), const_cast(""), cmode,
-nullptr));
-#endif
-}
-
-
 FileUP PythonFile::GetUnderlyingFile() const {
   if (!IsValid())
 return nullptr;
@@ -1238,6 +1218,13 @@
 return base_error;
   };
 
+  PyObject *GetPythonObject() const {
+assert(m_py_obj.IsValid());
+return m_py_obj.get();
+  }
+
+  static bool classof(const File *file) = delete;
+
 protected:
   PythonFile m_py_obj;
   bool m_borrowed;
@@ -1252,7 +1239,14 @@
   SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
File::OpenOptions options)
   : OwnedPythonFile(file, borrowed, fd, options, false) {}
+
+  static char ID;
+  bool isA(const void *classID) const override {
+return classID == &ID || NativeFile::isA(classID);
+  }
+  static bool classof(const File *file) { return file->isA(&ID); }
 };
+char SimplePythonFile::ID = 0;
 } // namespace
 
 #if PY_MAJOR_VERSION >= 3
@@ -1321,7 +1315,18 @@
 return Status();
   }
 
+  Expected GetOptions() const override {
+GIL takeGIL;
+return GetOptionsForPyObject(m_py_obj);
+  }
+
+  static char ID;
+  bool isA(const void *classID) const override {
+return classID == &ID || File::isA(classID);
+  }
+  static bool classof(const File *file) { return file->isA(&ID); }
 };
+char PythonIOFile::ID = 0;
 } // namespace
 
 namespace {
@@ -1542,4 +1547,42 @@
 #endif
 }
 
+Expected PythonFile::FromFile(File &file, const char *mode) {
+  if (!file.IsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid file

[Lldb-commits] [PATCH] D68853: uint32_t options -> File::OpenOptions options

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224658.
lawrence_danna added a comment.

fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68853

Files:
  lldb/include/lldb/Core/StreamFile.h
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/FileCache.h
  lldb/include/lldb/Host/FileSystem.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Target/RemoteAwarePlatform.h
  lldb/source/API/SBFile.cpp
  lldb/source/API/SBStream.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Core/StreamFile.cpp
  lldb/source/Host/common/File.cpp
  lldb/source/Host/common/FileCache.cpp
  lldb/source/Host/common/FileSystem.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/RemoteAwarePlatform.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -996,10 +996,9 @@
   }
 
   StreamFile out_file(path.c_str(),
-  File::OpenOptions::eOpenOptionTruncate |
-  File::OpenOptions::eOpenOptionWrite |
-  File::OpenOptions::eOpenOptionCanCreate |
-  File::OpenOptions::eOpenOptionCloseOnExec,
+  File::eOpenOptionTruncate | File::eOpenOptionWrite |
+  File::eOpenOptionCanCreate |
+  File::eOpenOptionCloseOnExec,
   lldb::eFilePermissionsFileDefault);
   if (!out_file.GetFile().IsValid()) {
 error.SetErrorStringWithFormat("Unable to open output file: %s.",
Index: lldb/source/Target/RemoteAwarePlatform.cpp
===
--- lldb/source/Target/RemoteAwarePlatform.cpp
+++ lldb/source/Target/RemoteAwarePlatform.cpp
@@ -61,8 +61,8 @@
 }
 
 lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
-  uint32_t flags, uint32_t mode,
-  Status &error) {
+  File::OpenOptions flags,
+  uint32_t mode, Status &error) {
   if (IsHost())
 return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
   if (m_remote_platform_sp)
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1220,7 +1220,7 @@
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
   LLDB_LOGF(log, "[PutFile] Using block by block transfer\n");
 
-  uint32_t source_open_options =
+  auto source_open_options =
   File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
   namespace fs = llvm::sys::fs;
   if (fs::is_symlink_file(source.GetPath()))
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1090,8 +1090,12 @@
   // File object knows about that.
   PythonString py_mode = GetAttributeValue("mode").AsType();
   auto options = File::GetOptionsFromMode(py_mode.GetString());
-  auto file = std::unique_ptr(
-  new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
+  if (!options) {
+llvm::consumeError(options.takeError());
+return nullptr;
+  }
+  auto file = std::unique_ptr(new NativeFile(
+  PyObject_AsFileDescriptor(m_py_obj), options.get(), false));
   if (!file->IsValid())
 return nullptr;
   return file;
@@ -1165,9 +1169,10 @@
 
 char PythonException::ID = 0;
 
-llvm::Expected GetOptionsForPyObject(const PythonObject &obj) {
-  uint32_t options = 0;
+llvm::Expected
+GetOptionsForPyObject(const PythonObject &obj) {
 #if PY_MAJOR_VERSION >= 3
+  auto options = File::OpenOptions(0);
   auto readable = As(obj.CallMethod("readable"));
   if (!readable)
 return readable.takeError();
@@ -1178,11 +1183,11 @@
 options |= File::eOpenOptionRead;
   if (writable.get())
 options |= File::eOpenOptionWrite;
+  return options;
 #else
   PythonString py_mode = obj.GetAttributeValue("mode").AsType();

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

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
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:
> lawrence_danna wrote:
> > 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.
> Right, sorry, that came out a bit wrong. While I think it would be cool to 
> have the other direction be an "identity" too, I don't think that is really 
> necessary. Nevertheless, taking a File out of lldb and then back in will do 
> _something_ right now, and that "something" could probably use a test. I 
> suppose you could construct an SBFile from a path, convert it to a python 
> file and back, and then ensure that reading/writing on those two SBFiles does 
> something reasonable.
I was gonna say that this test already covers it, but then I thought, "oh 
whatever I'll just write another test".  And the test I wrote uncovered a 
bug 😐.


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] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D68546#1705684 , @labath wrote:

> Well... if we agree that SBStream is the future for APIs like this, then I 
> don't think that would be too strange. The FileSP and FILE* variants would 
> both be "legacy/deprecated" and present only to support legacy c++/python 
> uses, and the SBStream would be the thing which we expect new users to use.
>
> That said, I don't think that having an SBFile-based API is that bad either 
> (though I would still like if it is used via an SBStream internally).. The 
> main advantage of the "higher level" stream interface I see is that it is 
> easier to provide your own implementation of it (less methods to override). 
> However, given that we've just went through the exercise of making the file 
> API overridable externally, I don't think we'll want to create an overridable 
> stream abstraction any time soon.


Ok I'll just update it to go though `StreamFile` internally and leave the 
decision of whether a `SBStream` version should be added to a later patch 
and/or someone else to decide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546



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


[Lldb-commits] [PATCH] D68883: Revert "[platform process list] add a flag for showing the processes of all users"

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: labath, aadsm, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This reverts commit e4ac611cd787f3f0e727a394e96fb1a5c3b19ccb.

There's a failure according to 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2538/testReport/junit/lldb-api/functionalities_gdb_remote_client/TestPlatformClient_py/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68883

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,7 +2176,8 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
+packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,9 +591,6 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
-  def platform_process_list_all_users: Option<"all-users", "x">,
-GroupRange<1,6>,
-Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,10 +1264,6 @@
 verbose = true;
 break;
 
-  case 'x':
-match_info.SetMatchAllUsers(true);
-break;
-
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,34 +160,9 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-raise "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -196,7 +171,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -450,6 +425,7 @@
 class InvalidPacketException(Exception):
 pass
 
+
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_li

[Lldb-commits] [lldb] r374587 - [NativePDB] Remove unused references to ClangASTImporter

2019-10-11 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Fri Oct 11 13:12:29 2019
New Revision: 374587

URL: http://llvm.org/viewvc/llvm-project?rev=374587&view=rev
Log:
[NativePDB] Remove unused references to ClangASTImporter

Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=374587&r1=374586&r2=374587&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Fri 
Oct 11 13:12:29 2019
@@ -20,7 +20,6 @@
 #include "lldb/Core/StreamBuffer.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
 #include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/CompileUnit.h"

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h?rev=374587&r1=374586&r2=374587&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Fri 
Oct 11 13:12:29 2019
@@ -9,7 +9,6 @@
 #ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
 #define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
 
-#include "lldb/Symbol/ClangASTImporter.h"
 #include "lldb/Symbol/SymbolFile.h"
 
 #include "llvm/ADT/DenseMap.h"
@@ -35,7 +34,6 @@ struct UnionRecord;
 } // namespace llvm
 
 namespace lldb_private {
-class ClangASTImporter;
 
 namespace npdb {
 class PdbAstBuilder;


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


[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224668.
lawrence_danna added a comment.

swig 3 fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/API/SBProcess.h
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_process.py
  lldb/scripts/interface/SBDebugger.i
  lldb/scripts/interface/SBProcess.i
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBProcess.cpp

Index: lldb/source/API/SBProcess.cpp
===
--- lldb/source/API/SBProcess.cpp
+++ lldb/source/API/SBProcess.cpp
@@ -29,11 +29,11 @@
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
-
 #include "lldb/API/SBBroadcaster.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEvent.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBMemoryRegionInfo.h"
 #include "lldb/API/SBMemoryRegionInfoList.h"
@@ -331,23 +331,34 @@
   return LLDB_RECORD_RESULT(trace_instance);
 }
 
+void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, SBFile), event, out);
+
+  return ReportEventState(event, out.m_opaque_sp);
+}
+
 void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
   LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *), event, out);
+  FileSP outfile = std::make_shared(out, false);
+  return ReportEventState(event, outfile);
+}
+
+void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
 
-  if (out == nullptr)
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, FileSP), event, out);
+
+  if (!out || !out->IsValid())
 return;
 
   ProcessSP process_sp(GetSP());
   if (process_sp) {
+StreamFile stream(out);
 const StateType event_state = SBProcess::GetStateFromEvent(event);
-char message[1024];
-int message_len = ::snprintf(
-message, sizeof(message), "Process %" PRIu64 " %s\n",
+stream.Printf("Process %" PRIu64 " %s\n",
 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
-
-if (message_len > 0)
-  ::fwrite(message, 1, message_len, out);
   }
 }
 
@@ -1310,6 +1321,10 @@
(lldb::SBTraceOptions &, lldb::SBError &));
   LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
  (const lldb::SBEvent &, FILE *));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FileSP));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, SBFile));
   LLDB_REGISTER_METHOD(
   void, SBProcess, AppendEventStateReport,
   (const lldb::SBEvent &, lldb::SBCommandReturnObject &));
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -494,8 +494,7 @@
 while (lldb_listener_sp->GetEventForBroadcaster(
 process_sp.get(), event_sp, std::chrono::seconds(0))) {
   SBEvent event(event_sp);
-  HandleProcessEvent(process, event, GetOutputFileHandle(),
- GetErrorFileHandle());
+  HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
 }
   }
 }
@@ -512,6 +511,17 @@
   return LLDB_RECORD_RESULT(sb_listener);
 }
 
+void SBDebugger::HandleProcessEvent(const SBProcess &process,
+const SBEvent &event, SBFile out,
+SBFile err) {
+  LLDB_RECORD_METHOD(
+  void, SBDebugger, HandleProcessEvent,
+  (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process,
+  event, out, err);
+
+  return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
+}
+
 void SBDebugger::HandleProcessEvent(const SBProcess &process,
 const SBEvent &event, FILE *out,
 FILE *err) {
@@ -520,6 +530,20 @@
   (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
   event, out, err);
 
+  FileSP outfile = std::make_shared(out, false);
+  FileSP errfile = std::make_shared(err, false);
+  return HandleProcessEvent(process, event, outfile, errfile);
+}
+
+void SBDebugger::HandleProcessEvent(const SBProcess &process,
+const SBEvent &event, FileSP out_sp,
+   

[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224666.
lawrence_danna added a comment.

use stream


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/API/SBProcess.h
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_process.py
  lldb/scripts/interface/SBDebugger.i
  lldb/scripts/interface/SBProcess.i
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBProcess.cpp

Index: lldb/source/API/SBProcess.cpp
===
--- lldb/source/API/SBProcess.cpp
+++ lldb/source/API/SBProcess.cpp
@@ -29,11 +29,11 @@
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
-
 #include "lldb/API/SBBroadcaster.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEvent.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBMemoryRegionInfo.h"
 #include "lldb/API/SBMemoryRegionInfoList.h"
@@ -331,23 +331,34 @@
   return LLDB_RECORD_RESULT(trace_instance);
 }
 
+void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, SBFile), event, out);
+
+  return ReportEventState(event, out.m_opaque_sp);
+}
+
 void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
   LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *), event, out);
+  FileSP outfile = std::make_shared(out, false);
+  return ReportEventState(event, outfile);
+}
+
+void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
 
-  if (out == nullptr)
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, FileSP), event, out);
+
+  if (!out || !out->IsValid())
 return;
 
   ProcessSP process_sp(GetSP());
   if (process_sp) {
+StreamFile stream(out);
 const StateType event_state = SBProcess::GetStateFromEvent(event);
-char message[1024];
-int message_len = ::snprintf(
-message, sizeof(message), "Process %" PRIu64 " %s\n",
+stream.Printf("Process %" PRIu64 " %s\n",
 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
-
-if (message_len > 0)
-  ::fwrite(message, 1, message_len, out);
   }
 }
 
@@ -1310,6 +1321,10 @@
(lldb::SBTraceOptions &, lldb::SBError &));
   LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
  (const lldb::SBEvent &, FILE *));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FileSP));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, SBFile));
   LLDB_REGISTER_METHOD(
   void, SBProcess, AppendEventStateReport,
   (const lldb::SBEvent &, lldb::SBCommandReturnObject &));
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -494,8 +494,7 @@
 while (lldb_listener_sp->GetEventForBroadcaster(
 process_sp.get(), event_sp, std::chrono::seconds(0))) {
   SBEvent event(event_sp);
-  HandleProcessEvent(process, event, GetOutputFileHandle(),
- GetErrorFileHandle());
+  HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
 }
   }
 }
@@ -512,6 +511,17 @@
   return LLDB_RECORD_RESULT(sb_listener);
 }
 
+void SBDebugger::HandleProcessEvent(const SBProcess &process,
+const SBEvent &event, SBFile out,
+SBFile err) {
+  LLDB_RECORD_METHOD(
+  void, SBDebugger, HandleProcessEvent,
+  (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process,
+  event, out, err);
+
+  return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
+}
+
 void SBDebugger::HandleProcessEvent(const SBProcess &process,
 const SBEvent &event, FILE *out,
 FILE *err) {
@@ -520,6 +530,20 @@
   (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
   event, out, err);
 
+  FileSP outfile = std::make_shared(out, false);
+  FileSP errfile = std::make_shared(err, false);
+  return HandleProcessEvent(process, event, outfile, errfile);
+}
+
+void SBDebugger::HandleProcessEvent(const SBProcess &process,
+const SBEvent &event, FileSP out_sp,
+   

[Lldb-commits] [lldb] r374591 - Set GNUC version in the LLDB expression parser.

2019-10-11 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Fri Oct 11 13:27:51 2019
New Revision: 374591

URL: http://llvm.org/viewvc/llvm-project?rev=374591&view=rev
Log:
Set GNUC version in the LLDB expression parser.

This adapts LLDB for https://reviews.llvm.org/D68055.

Darwin's libC headers expect the GNUC macro to be set.

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

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=374591&r1=374590&r2=374591&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Fri Oct 11 13:27:51 2019
@@ -515,6 +515,9 @@ ClangExpressionParser::ClangExpressionPa
 lang_opts.DoubleSquareBracketAttributes = true;
 lang_opts.CPlusPlus11 = true;
 
+// The Darwin libc expects this macro to be set.
+lang_opts.GNUCVersion = 40201;
+
 SetupModuleHeaderPaths(m_compiler.get(), m_include_directories,
target_sp);
   }


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


[Lldb-commits] [PATCH] D68270: DWARFDebugLoc: Add a function to get the address range of an entry

2019-10-11 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added inline comments.



Comment at: lib/DebugInfo/DWARF/DWARFDebugLoc.cpp:291-295
+  EntryIterator Absolute =
+  getAbsoluteLocations(
+  SectionedAddress{BaseAddr, SectionedAddress::UndefSection},
+  LookupPooledAddress)
+  .begin();

labath wrote:
> dblaikie wrote:
> > labath wrote:
> > > dblaikie wrote:
> > > > labath wrote:
> > > > > dblaikie wrote:
> > > > > > labath wrote:
> > > > > > > This parallel iteration is not completely nice, but I think it's 
> > > > > > > worth being able to reuse the absolute range computation code. 
> > > > > > > I'm open to ideas for improvement though.
> > > > > > Ah, I see - this is what you meant about "In particular it makes it 
> > > > > > possible to reuse this stuff in the dumping code, which would have 
> > > > > > been pretty hard with callbacks.".
> > > > > > 
> > > > > > I'm wondering if that might be worth revisiting somewhat. A full 
> > > > > > iterator abstraction for one user here (well, two once you include 
> > > > > > lldb - but I assume it's likely going to build its own data 
> > > > > > structure from the iteration anyway, right? (it's not going to keep 
> > > > > > the iterator around, do anything interesting like partial 
> > > > > > iterations, re-iterate/etc - such that a callback would suffice))
> > > > > > 
> > > > > > I could imagine two callback APIs for this - one that gets entries 
> > > > > > and locations and one that only gets locations by filtering on the 
> > > > > > entry version.
> > > > > > 
> > > > > > eg:
> > > > > > 
> > > > > >   // for non-verbose output:
> > > > > >   LL.forEachEntry([&](const Entry &E, Expected L) {
> > > > > > if (Verbose && actually dumping debug_loc)
> > > > > >   print(E) // print any LLE_*, raw parameters, etc
> > > > > > if (L)
> > > > > >   print(*L) // print the resulting address range, section name 
> > > > > > (if verbose), 
> > > > > > else
> > > > > >   print(error stuff)
> > > > > >   });
> > > > > > 
> > > > > > One question would be "when/where do we print the DWARF expression" 
> > > > > > - if there's an error computing the address range, we can still 
> > > > > > print the expression, so maybe that happens unconditionally at the 
> > > > > > end of the callback, using the expression in the Entry? (then, 
> > > > > > arguably, the expression doesn't need to be in the DWARFLocation - 
> > > > > > and I'd say make the DWARFLocation a sectioned range, exactly the 
> > > > > > same type as for ranges so that part of the dumping code, etc, can 
> > > > > > be maximally reused)
> > > > > Actually, what lldb currently does is that it does not build any data 
> > > > > structures at all (except storing the pointer to the right place in 
> > > > > the debug_loc section. Then, whenever it wants to do something to the 
> > > > > loclist, it parses it afresh. I don't know why it does this exactly, 
> > > > > but I assume it has something to do with most locations never being 
> > > > > used, or being only a couple of times, and the actual parsing being 
> > > > > fairly fast. What this means is that lldb is not really a single 
> > > > > "user", but there are like four or five places where it iterates 
> > > > > through the list, depending on what does it actually want to do with 
> > > > > it. It also does partial iteration where it stops as soon as it find 
> > > > > the entry it was interested in.
> > > > > Now, all of that is possible with a callback (though I am generally 
> > > > > trying to avoid them), but it does resurface the issue of what should 
> > > > > be the value of the second argument for DW_LLE_base_address entries 
> > > > > (the thing which I originally used a error type for).
> > > > > Maybe this should be actually one callback API, taking two callback 
> > > > > functions, with one of them being invoked for base_address entries, 
> > > > > and one for others? However, if we stick to the current approaches in 
> > > > > both LLE and RLE of making the address pool resolution function a 
> > > > > parameter (which I'd like to keep, as it makes my job in lldb 
> > > > > easier), then this would actually be three callbacks, which starts to 
> > > > > get unwieldy. Though one of those callbacks could be removed with the 
> > > > > "DWARFUnit implementing a AddrOffsetResolver interface" idea, which I 
> > > > > really like. :)
> > > > Ah, thanks for the details on LLDB's location parsing logic. That's 
> > > > interesting indeed!
> > > > 
> > > > I can appreciate an iterator-based API if that's the sort of usage 
> > > > we've got, though I expect it doesn't have any interest in the 
> > > > low-level encoding & just wants the fully processed address 
> > > > ranges/locations - it doesn't want base_address or end_of_list entries? 
> > > > & I think the dual-iteration is a fairly awkward API design, trying to 
> > > > iterate them in lock-step, etc. I'd rather avoid that if reasonably 
> > > > p

[Lldb-commits] [PATCH] D68890: remove FILE* bindings from SBInstruction.

2019-10-11 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: LLDB.

This patch replaces the FILE* python bindings for SBInstruction and
SBInstructionList and replaces them with the new, safe SBFile and FileSP
bindings.

I also re-enable `Test_Disassemble_VST1_64`, because now we can use
the file bindings as an additional test of the disassembler, and we
can use the disassembler test as a test of the file bindings.

The bugs referred to in the comments appear to have been fixed.   The
radar is closed now and the bugzilla bug does not reproduce with the
instructions given.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68890

Files:
  lldb/include/lldb/API/SBInstruction.h
  lldb/include/lldb/API/SBInstructionList.h
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_instruction.py
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_instructionlist.py
  
lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
  lldb/scripts/interface/SBInstruction.i
  lldb/scripts/interface/SBInstructionList.i
  lldb/source/API/SBInstruction.cpp
  lldb/source/API/SBInstructionList.cpp

Index: lldb/source/API/SBInstructionList.cpp
===
--- lldb/source/API/SBInstructionList.cpp
+++ lldb/source/API/SBInstructionList.cpp
@@ -11,8 +11,10 @@
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Utility/Stream.h"
 
@@ -118,21 +120,41 @@
 
 void SBInstructionList::Print(FILE *out) {
   LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FILE *), out);
-
   if (out == nullptr)
 return;
+  StreamFile stream(out, false);
+  GetDescription(stream);
 }
 
-bool SBInstructionList::GetDescription(lldb::SBStream &description) {
+void SBInstructionList::Print(SBFile out) {
+  LLDB_RECORD_METHOD(void, SBInstructionList, Print, (SBFile), out);
+  if (!out.IsValid())
+return;
+  StreamFile stream(out.GetFile());
+  GetDescription(stream);
+}
+
+void SBInstructionList::Print(FileSP out_sp) {
+  LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FileSP), out_sp);
+  if (!out_sp || !out_sp->IsValid())
+return;
+  StreamFile stream(out_sp);
+  GetDescription(stream);
+}
+
+bool SBInstructionList::GetDescription(lldb::SBStream &stream) {
   LLDB_RECORD_METHOD(bool, SBInstructionList, GetDescription,
- (lldb::SBStream &), description);
+ (lldb::SBStream &), stream);
+  return GetDescription(stream.ref());
+}
+
+bool SBInstructionList::GetDescription(Stream &sref) {
 
   if (m_opaque_sp) {
 size_t num_instructions = GetSize();
 if (num_instructions) {
   // Call the ref() to make sure a stream is created if one deesn't exist
   // already inside description...
-  Stream &sref = description.ref();
   const uint32_t max_opcode_byte_size =
   m_opaque_sp->GetInstructionList().GetMaxOpcocdeByteSize();
   FormatEntity::Entry format;
@@ -200,6 +222,8 @@
   LLDB_REGISTER_METHOD(void, SBInstructionList, AppendInstruction,
(lldb::SBInstruction));
   LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FILE *));
+  LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (SBFile));
+  LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FileSP));
   LLDB_REGISTER_METHOD(bool, SBInstructionList, GetDescription,
(lldb::SBStream &));
   LLDB_REGISTER_METHOD(bool, SBInstructionList,
Index: lldb/source/API/SBInstruction.cpp
===
--- lldb/source/API/SBInstruction.cpp
+++ lldb/source/API/SBInstruction.cpp
@@ -11,6 +11,7 @@
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFrame.h"
+#include "lldb/API/SBFile.h"
 
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBStream.h"
@@ -255,10 +256,21 @@
   return false;
 }
 
-void SBInstruction::Print(FILE *out) {
-  LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), out);
+void SBInstruction::Print(FILE *outp) {
+  LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), outp);
+  FileSP out = std::make_shared(outp, /*take_ownership=*/false);
+  Print(out);
+}
+
+void SBInstruction::Print(SBFile out) {
+  LLDB_RECORD_METHOD(void, SBInstruction, Print, (SBFile), out);
+  Print(out.GetFile());
+}
+
+void SBInstruction::Print(FileSP out_sp) {
+  LLDB_RECORD_METHOD(void, SBInstruction, Print, (FileSP), out_sp);
 
-  if (out == nullptr)
+  if (!out_sp || !out_sp->IsValid())
 return;
 
   lldb::InstructionSP inst_sp(GetOpaque());
@@ -269,7 +281,7 @@
 if (module_sp)
   module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything,
  

[Lldb-commits] [PATCH] D68293: [android/process list] support showing process arguments

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

This test fails on green dragon:

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/2538/changes#detail0
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/2538/testReport/junit/lldb-api/functionalities_gdb_remote_client/TestPlatformClient_py/

  lldb-api.functionalities/gdb_remote_client.TestPlatformClient.py (from 
lldb-api)
  
  Failing for the past 1 build (Since Failed#2538 )
  Took 0.66 sec.
  add description
  Stacktrace
  
  lldb version 10.0.99 (http://labmaster3.local/git/llvm-project.git revision 
1edb7e0b6f390b066f5218208a7c8ac974ee243c)
clang revision 089a334c39d06e958607e1e8e0c9796f9387f512
llvm revision 089a334c39d06e958607e1e8e0c9796f9387f512
  LLDB library dir: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
  LLDB import library dir: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
  libstdcxx tests will not be run because: Don't know how to build with 
libstdcxx on macosx
  Skipping following debug info categories: ['dwo']
  
  Session logs for test failures/errors/unexpected successes will go into 
directory '/Users/buildslave/jenkins/workspace/lldb-cmake/test/logs'
  Command invoked: 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/dotest.py
 --arch=x86_64 -s 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-traces -S 
nm -u CXXFLAGS -u CFLAGS --executable 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/lldb --dsymutil 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/dsymutil 
--filecheck 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/FileCheck -C 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/clang 
--codesign-identity lldb_codesign --server 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/debugserver 
--arch x86_64 --build-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex
 -s=/Users/buildslave/jenkins/workspace/lldb-cmake/test/logs -t --env 
TERM=vt100 --env 
LLVM_LIBS_DIR=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./lib 
--build-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex
 --lldb-module-cache-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-clang/lldb-api
 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client
 -p TestPlatformClient.py
  Change dir to: 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client
  runCmd: settings set symbols.enable-external-lookup false
  output: 
  
  runCmd: settings set plugin.process.gdb-remote.packet-timeout 60
  output: 
  
  runCmd: settings set symbols.clang-modules-cache-path 
"/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-lldb/lldb-api"
  output: 
  
  runCmd: settings set use-color false
  output: 
  
  runCmd: platform select remote-linux
  output:   Platform: remote-linux
   Connected: no
  
  
  runCmd: platform connect connect://localhost:52264
  output:   Platform: remote-linux
Hostname: (null)
   Connected: yes
  WorkingDir: /
  
  
  runCmd: platform process list -x
  runCmd failed!
  error: no processes were found on the "remote-linux" platform
  
  
  FAIL: LLDB 
(/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-10-x86_64) 
:: test_process_list_with_all_users (TestPlatformClient.TestPlatformClient)
  Restore dir to: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/test
  ==
  FAIL: test_process_list_with_all_users (TestPlatformClient.TestPlatformClient)
 Test connecting to a remote linux platform
  --
  Traceback (most recent call last):
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py",
 line 30, in test_process_list_with_all_users
  substrs=["1 matching process was found", "test_process"])
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2309, in expect
  inHistory=inHistory)
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2068, in runCmd
  msg if (msg) else CMD_MSG(cmd))
  AssertionError: False is not True : Command 'platform process list -x
  Error output:
  error: no processes were found on the "remote-linux" platform
  ' returns successfully
  
Config=

Re: [Lldb-commits] [lldb] r374584 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Adrian Prantl via lldb-commits
This test fails on green dragon:

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/2538/changes#detail0 

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/2538/testReport/junit/lldb-api/functionalities_gdb_remote_client/TestPlatformClient_py/
 


 lldb-api.functionalities/gdb_remote_client.TestPlatformClient.py (from 
lldb-api)

 Failing for the past 1 build (Since Failed#2538 )
 Took 0.66 sec.
 add description
 Stacktrace

 lldb version 10.0.99 (http://labmaster3.local/git/llvm-project.git 
 revision 
1edb7e0b6f390b066f5218208a7c8ac974ee243c)
   clang revision 089a334c39d06e958607e1e8e0c9796f9387f512
   llvm revision 089a334c39d06e958607e1e8e0c9796f9387f512
 LLDB library dir: /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
 LLDB import library dir: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
 libstdcxx tests will not be run because: Don't know how to build with 
libstdcxx on macosx
 Skipping following debug info categories: ['dwo']

 Session logs for test failures/errors/unexpected successes will go into 
directory '/Users/buildslave/jenkins/workspace/lldb-cmake/test/logs'
 Command invoked: 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/dotest.py
 --arch=x86_64 -s 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-traces -S 
nm -u CXXFLAGS -u CFLAGS --executable 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/lldb --dsymutil 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/dsymutil 
--filecheck 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/FileCheck -C 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/clang 
--codesign-identity lldb_codesign --server 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./bin/debugserver 
--arch x86_64 --build-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex
 -s=/Users/buildslave/jenkins/workspace/lldb-cmake/test/logs -t --env 
TERM=vt100 --env 
LLVM_LIBS_DIR=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/./lib 
--build-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex
 --lldb-module-cache-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-clang/lldb-api
 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client
 -p TestPlatformClient.py
 Change dir to: 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client
 runCmd: settings set symbols.enable-external-lookup false
 output: 

 runCmd: settings set plugin.process.gdb-remote.packet-timeout 60
 output: 

 runCmd: settings set symbols.clang-modules-cache-path 
"/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/lldb-test-build.noindex/module-cache-lldb/lldb-api"
 output: 

 runCmd: settings set use-color false
 output: 

 runCmd: platform select remote-linux
 output:   Platform: remote-linux
  Connected: no


 runCmd: platform connect connect://localhost:52264 
 output:   Platform: remote-linux
   Hostname: (null)
  Connected: yes
 WorkingDir: /


 runCmd: platform process list -x
 runCmd failed!
 error: no processes were found on the "remote-linux" platform


 FAIL: LLDB 
(/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-10-x86_64) 
:: test_process_list_with_all_users (TestPlatformClient.TestPlatformClient)
 Restore dir to: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/test
 ==
 FAIL: test_process_list_with_all_users (TestPlatformClient.TestPlatformClient)
Test connecting to a remote linux platform
 --
 Traceback (most recent call last):
   File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py",
 line 30, in test_process_list_with_all_users
 substrs=["1 matching process was found", "test_process"])
   File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2309, in expect
 inHistory=inHistory)
   File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2068, in runCmd
 msg if (msg) else CMD_MSG(cmd))
 Asserti

[Lldb-commits] [lldb] r374603 - Revert "[platform process list] add a flag for showing the processes of all users"

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 14:58:49 2019
New Revision: 374603

URL: http://llvm.org/viewvc/llvm-project?rev=374603&view=rev
Log:
Revert "[platform process list] add a flag for showing the processes of all 
users"

Summary:
This reverts commit e4ac611cd787f3f0e727a394e96fb1a5c3b19ccb.

There's a failure according to 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2538/testReport/junit/lldb-api/functionalities_gdb_remote_client/TestPlatformClient_py/

Reviewers: labath, aadsm, clayborg

Subscribers: lldb-commits

Tags: #lldb

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

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374602&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (removed)
@@ -1,35 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_list_with_all_users(self):
-"""Test connecting to a remote linux platform"""
-
-class MyResponder(MockGDBServerResponder):
-def qfProcessInfo(self, packet):
-if "all_users:1" in packet:
-return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
-else:
-return "E04"
-
-self.server.responder = MyResponder()
-
-self.runCmd("platform select remote-linux")
-
-try:
-self.runCmd("platform connect connect://localhost:%d" %
-self.server.port)
-self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
-self.expect("platform process list -x",
-substrs=["1 matching process was found", 
"test_process"])
-self.expect("platform process list",
-error=True,
-substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
-finally:
-self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374603&r1=374602&r2=374603&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
 Fri Oct 11 14:58:49 2019
@@ -160,34 +160,9 @@ class MockGDBServerResponder:
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-raise "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -196,7 +171,7 @@ class MockGDBServerResponder:
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -450,6 +425,7 @@ class MockGDBServer:
 class InvalidPacketException(Exception):
 pass
 
+
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.

Modified: lldb/trunk/so

[Lldb-commits] [PATCH] D68293: [android/process list] support showing process arguments

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

i'm reverting it, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68293



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


[Lldb-commits] [lldb] r374609 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 16:10:34 2019
New Revision: 374609

URL: http://llvm.org/viewvc/llvm-project?rev=374609&view=rev
Log:
[platform process list] add a flag for showing the processes of all users

Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same 
user as the user that launched lldb-server. However, it's quite useful to see 
all the processes, though, and it will lay a foundation for full apk debugging 
support from lldb.

Before:
```
PIDPARENT USER   TRIPLE   NAME
== == ==  
3234   1 aarch64-unknown-linux-android adbd
8034   3234  aarch64-unknown-linux-android sh
9096   3234  aarch64-unknown-linux-android sh
9098   9096  aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
1  0  init
5241  init
5251  init
5311  ueventd
5681  logd
5691 aarch64-unknown-linux-android servicemanager
5701 aarch64-unknown-linux-android hwservicemanager
5711 aarch64-unknown-linux-android vndservicemanager
5771 aarch64-unknown-linux-android qseecomd
580577   aarch64-unknown-linux-android qseecomd
...
23816  979com.android.providers.calendar
24600  979com.verizon.mips.services
27888  979com.hualai
28043  2378   
com.android.chrome:sandboxed_process0
31449  979com.att.shm
31779  979com.samsung.android.authfw
31846  979
com.samsung.android.server.iris
32014  979
com.samsung.android.MtpApplication
32045  979com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 374584

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374609&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 Fri Oct 11 16:10:34 2019
@@ -0,0 +1,39 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+class MyResponder(MockGDBServerResponder):
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
+else:
+return "E04"
+
+self.server.responder = MyResponder()
+
+self.runCmd("log enable gdb-remote all")
+self.runCmd("platform select remote-linux")
+
+try:
+url = "connect://localhost:%d" % self.server.port
+
+
#self.gdb.GetSelectedPlatform().ConnectRemote(lldb.SBPlatformConnectOptions(url))
+self.runCmd("platform connect connect://localhost:%d" %
+self.server.port)
+self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+self.expect("platform process list -x",
+substrs=["1 matching process was found", 
"test_process"])
+self.expect("platform process list",
+

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 224703.
wallace added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,9 +160,34 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+raise "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +196,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -425,7 +450,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -0,0 +1,39 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+class MyResponder(MockGDBServerResponder):
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224707.
hhb added a comment.

Adds VERBATIM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - 

[Lldb-commits] [PATCH] D68293: [android/process list] support showing process arguments

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

The re-committed variant still doesn't work :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68293



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


[Lldb-commits] [lldb] r374616 - Temporarily Revert [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Fri Oct 11 17:03:40 2019
New Revision: 374616

URL: http://llvm.org/viewvc/llvm-project?rev=374616&view=rev
Log:
Temporarily Revert [platform process list] add a flag for showing the processes 
of all users

as it breaks the bots.

This reverts r374609 (git commit 696d3cf8ad6f3a0b3019c87526d561bb77ad538e)

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374615&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (removed)
@@ -1,39 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_list_with_all_users(self):
-"""Test connecting to a remote linux platform"""
-
-class MyResponder(MockGDBServerResponder):
-def qfProcessInfo(self, packet):
-if "all_users:1" in packet:
-return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
-else:
-return "E04"
-
-self.server.responder = MyResponder()
-
-self.runCmd("log enable gdb-remote all")
-self.runCmd("platform select remote-linux")
-
-try:
-url = "connect://localhost:%d" % self.server.port
-
-
#self.gdb.GetSelectedPlatform().ConnectRemote(lldb.SBPlatformConnectOptions(url))
-self.runCmd("platform connect connect://localhost:%d" %
-self.server.port)
-self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
-self.expect("platform process list -x",
-substrs=["1 matching process was found", 
"test_process"])
-self.expect("platform process list",
-error=True,
-substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
-finally:
-self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374616&r1=374615&r2=374616&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
 Fri Oct 11 17:03:40 2019
@@ -160,34 +160,9 @@ class MockGDBServerResponder:
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-raise "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -196,7 +171,7 @@ class MockGDBServerResponder:
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -450,6 +425,7 @@ class MockGDBServer:
 class InvalidPacketException(Exception):
 pass
 
+
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org

[Lldb-commits] [lldb] r374620 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 17:44:50 2019
New Revision: 374620

URL: http://llvm.org/viewvc/llvm-project?rev=374620&view=rev
Log:
[platform process list] add a flag for showing the processes of all users

Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same 
user as the user that launched lldb-server. However, it's quite useful to see 
all the processes, though, and it will lay a foundation for full apk debugging 
support from lldb.

Before:
```
PIDPARENT USER   TRIPLE   NAME
== == ==  
3234   1 aarch64-unknown-linux-android adbd
8034   3234  aarch64-unknown-linux-android sh
9096   3234  aarch64-unknown-linux-android sh
9098   9096  aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
1  0  init
5241  init
5251  init
5311  ueventd
5681  logd
5691 aarch64-unknown-linux-android servicemanager
5701 aarch64-unknown-linux-android hwservicemanager
5711 aarch64-unknown-linux-android vndservicemanager
5771 aarch64-unknown-linux-android qseecomd
580577   aarch64-unknown-linux-android qseecomd
...
23816  979com.android.providers.calendar
24600  979com.verizon.mips.services
27888  979com.hualai
28043  2378   
com.android.chrome:sandboxed_process0
31449  979com.att.shm
31779  979com.samsung.android.authfw
31846  979
com.samsung.android.server.iris
32014  979
com.samsung.android.MtpApplication
32045  979com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 374584

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374620&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 Fri Oct 11 17:44:50 2019
@@ -0,0 +1,27 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+self.runCmd("log enable gdb-remote all")
+self.runCmd("platform select remote-linux")
+
+try:
+self.runCmd("platform connect connect://localhost:%d" %
+self.server.port)
+self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+self.expect("platform process list -x",
+substrs=["1 matching process was found", 
"test_process"])
+self.expect("platform process list",
+error=True,
+substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
+finally:
+self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374620&r1=374619&r2=374620&view=diff
==

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 224716.
wallace added a comment.

another try


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,9 +160,37 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + binascii.hexlify("/a/test_process") + ";"
+else:
+return "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +199,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -425,7 +453,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -0,0 +1,27 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux pl

[Lldb-commits] [lldb] r374621 - Revert "[platform process list] add a flag for showing the processes of all users"

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 18:08:50 2019
New Revision: 374621

URL: http://llvm.org/viewvc/llvm-project?rev=374621&view=rev
Log:
Revert "[platform process list] add a flag for showing the processes of all 
users"

This reverts commit 08781f4c53a177662c029d3da9c407ba65ae6747.

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374620&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (removed)
@@ -1,27 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_list_with_all_users(self):
-"""Test connecting to a remote linux platform"""
-
-self.runCmd("log enable gdb-remote all")
-self.runCmd("platform select remote-linux")
-
-try:
-self.runCmd("platform connect connect://localhost:%d" %
-self.server.port)
-self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
-self.expect("platform process list -x",
-substrs=["1 matching process was found", 
"test_process"])
-self.expect("platform process list",
-error=True,
-substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
-finally:
-self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374621&r1=374620&r2=374621&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
 Fri Oct 11 18:08:50 2019
@@ -160,37 +160,9 @@ class MockGDBServerResponder:
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-if "all_users:1" in packet:
-return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
-else:
-return "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -199,7 +171,7 @@ class MockGDBServerResponder:
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -453,6 +425,7 @@ class MockGDBServer:
 class InvalidPacketException(Exception):
 pass
 
+
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=374621&r1=374620&r2=374621&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Fri Oct 11 18:08:50 
2019
@@ -1264,10 +1264,6 @@ protected:
 verbose = true;
 

[Lldb-commits] [lldb] r374622 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 18:33:21 2019
New Revision: 374622

URL: http://llvm.org/viewvc/llvm-project?rev=374622&view=rev
Log:
[platform process list] add a flag for showing the processes of all users

Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same 
user as the user that launched lldb-server. However, it's quite useful to see 
all the processes, though, and it will lay a foundation for full apk debugging 
support from lldb.

Before:
```
PIDPARENT USER   TRIPLE   NAME
== == ==  
3234   1 aarch64-unknown-linux-android adbd
8034   3234  aarch64-unknown-linux-android sh
9096   3234  aarch64-unknown-linux-android sh
9098   9096  aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
1  0  init
5241  init
5251  init
5311  ueventd
5681  logd
5691 aarch64-unknown-linux-android servicemanager
5701 aarch64-unknown-linux-android hwservicemanager
5711 aarch64-unknown-linux-android vndservicemanager
5771 aarch64-unknown-linux-android qseecomd
580577   aarch64-unknown-linux-android qseecomd
...
23816  979com.android.providers.calendar
24600  979com.verizon.mips.services
27888  979com.hualai
28043  2378   
com.android.chrome:sandboxed_process0
31449  979com.att.shm
31779  979com.samsung.android.authfw
31846  979
com.samsung.android.server.iris
32014  979
com.samsung.android.MtpApplication
32045  979com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 374584

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374622&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 Fri Oct 11 18:33:21 2019
@@ -0,0 +1,27 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+self.runCmd("log enable gdb-remote all")
+self.runCmd("platform select remote-linux")
+
+try:
+self.runCmd("platform connect connect://localhost:%d" %
+self.server.port)
+self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+self.expect("platform process list -x",
+substrs=["1 matching process was found", 
"test_process"])
+self.expect("platform process list",
+error=True,
+substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
+finally:
+self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374622&r1=374621&r2=374622&view=diff
==

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 224717.
wallace added a comment.

adding some logging for exceptions in the mock server


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -3,6 +3,8 @@
 import threading
 import socket
 import lldb
+import binascii
+import traceback
 from lldbsuite.support import seven
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbtest_config
@@ -160,9 +162,37 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + binascii.hexlify("/a/test_process") + ";"
+else:
+return "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +201,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -315,6 +345,8 @@
 break
 self._receive(data)
 except Exception as e:
+print("An exception happened when receiving the response from the gdb server. Closing the client...")
+traceback.print_exc()
 self._client.close()
 break
 
@@ -425,7 +457,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client t

[Lldb-commits] [PATCH] D68671: Add the ability to pass extra args to a Python breakpoint command function

2019-10-11 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 224719.
jingham added a comment.

I added ScriptInterpreter::GetNumArgumentsForCallable, so I can base all the 
decisions on how to call the function on whether I was passed a function with 3 
or 4 arguments.  That's cleaner.  I also plumbed an error through the callback 
setting, so I can report an error if you pass me a function with the wrong 
number of arguments, or provide extra_args when you are passing a function that 
doesn't take 4 arguments.

I added a check in the extant test to ensure that a function that takes 
extra_args will work with empty extra_args, since there's no reason to disallow 
that.

I also added a test for the error handling when you pass a function with the 
wrong number of arguments.

Now we don't depend on the SBStructuredData handed across the SB API's being 
any particular structure.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68671

Files:
  lldb/include/lldb/API/SBBreakpoint.h
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/include/lldb/API/SBBreakpointName.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py
  lldb/scripts/Python/python-wrapper.swig
  lldb/scripts/interface/SBBreakpoint.i
  lldb/scripts/interface/SBBreakpointLocation.i
  lldb/scripts/interface/SBBreakpointName.i
  lldb/source/API/SBBreakpoint.cpp
  lldb/source/API/SBBreakpointLocation.cpp
  lldb/source/API/SBBreakpointName.cpp
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -62,7 +62,8 @@
 extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
 const char *python_function_name, const char *session_dictionary_name,
 const lldb::StackFrameSP &sb_frame,
-const lldb::BreakpointLocationSP &sb_bp_loc) {
+const lldb::BreakpointLocationSP &sb_bp_loc,
+StructuredDataImpl *args_impl) {
   return false;
 }
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -179,8 +179,10 @@
   Status GenerateFunction(const char *signature,
   const StringList &input) override;
 
-  Status GenerateBreakpointCommandCallbackData(StringList &input,
-   std::string &output) override;
+  Status GenerateBreakpointCommandCallbackData(
+  StringList &input,
+  std::string &output,
+  bool has_extra_args) override;
 
   bool GenerateWatchpointCommandCallbackData(StringList &input,
  std::string &output) override;
@@ -244,14 +246,22 @@
   Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
   const char *callback_body) override;
 
-  void SetBreakpointCommandCallbackFunction(BreakpointOptions *bp_options,
-const char *function_name) override;
+  Status SetBreakpointCommandCallbackFunction(
+  BreakpointOptions *bp_options,
+  const char *function_name,
+  StructuredData::ObjectSP extra_args_sp) override;
 
   /// This one is for deserialization:
   Status SetBreakpointCommandCallback(
   BreakpointOptions *bp_options,
   std::unique_ptr &data_up) override;
 
+  Status SetBreakpointCommandCallback(
+  BreakpointOptions *bp_options, 
+   const char *command_body_text,
+   StructuredData::ObjectSP extra_args_sp,
+   bool uses_extra_args);
+
   /// Set a one-liner as the callback for the watchpoint.
   void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
 const char *oneliner) override;
@@ -366,6 +376,8 @@
   PythonDictionary &GetSessionDicti

[Lldb-commits] [lldb] r374625 - Revert "[platform process list] add a flag for showing the processes of all users"

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 19:01:33 2019
New Revision: 374625

URL: http://llvm.org/viewvc/llvm-project?rev=374625&view=rev
Log:
Revert "[platform process list] add a flag for showing the processes of all 
users"

This reverts commit 90d0de4999354a5223f08ad714222b0a5dca3cad.

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374624&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (removed)
@@ -1,27 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_list_with_all_users(self):
-"""Test connecting to a remote linux platform"""
-
-self.runCmd("log enable gdb-remote all")
-self.runCmd("platform select remote-linux")
-
-try:
-self.runCmd("platform connect connect://localhost:%d" %
-self.server.port)
-self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
-self.expect("platform process list -x",
-substrs=["1 matching process was found", 
"test_process"])
-self.expect("platform process list",
-error=True,
-substrs=["error: no processes were found on the 
\"remote-linux\" platform"])
-finally:
-self.dbg.GetSelectedPlatform().DisconnectRemote()

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=374625&r1=374624&r2=374625&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
 Fri Oct 11 19:01:33 2019
@@ -3,8 +3,6 @@ import os.path
 import threading
 import socket
 import lldb
-import binascii
-import traceback
 from lldbsuite.support import seven
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbtest_config
@@ -162,37 +160,9 @@ class MockGDBServerResponder:
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-if "all_users:1" in packet:
-return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process") + ";"
-else:
-return "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -201,7 +171,7 @@ class MockGDBServerResponder:
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -345,8 +315,6 @@ class MockGDBServer:
 break
 self._receive(data)
 except Exception as e:
-print("An exception happened when receiving the response from 
the gdb server. Closing the client...")
-traceback.print_exc()
 self._client.close()
 break
 
@@ -457,6 +425,7 @@ class MockGDBServer:
 class InvalidPacketException(Exception):

[Lldb-commits] [lldb] r374626 - [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct 11 19:08:35 2019
New Revision: 374626

URL: http://llvm.org/viewvc/llvm-project?rev=374626&view=rev
Log:
[platform process list] add a flag for showing the processes of all users

Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same 
user as the user that launched lldb-server. However, it's quite useful to see 
all the processes, though, and it will lay a foundation for full apk debugging 
support from lldb.

Before:
```
PIDPARENT USER   TRIPLE   NAME
== == ==  
3234   1 aarch64-unknown-linux-android adbd
8034   3234  aarch64-unknown-linux-android sh
9096   3234  aarch64-unknown-linux-android sh
9098   9096  aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
1  0  init
5241  init
5251  init
5311  ueventd
5681  logd
5691 aarch64-unknown-linux-android servicemanager
5701 aarch64-unknown-linux-android hwservicemanager
5711 aarch64-unknown-linux-android vndservicemanager
5771 aarch64-unknown-linux-android qseecomd
580577   aarch64-unknown-linux-android qseecomd
...
23816  979com.android.providers.calendar
24600  979com.verizon.mips.services
27888  979com.hualai
28043  2378   
com.android.chrome:sandboxed_process0
31449  979com.att.shm
31779  979com.samsung.android.authfw
31846  979
com.samsung.android.server.iris
32014  979
com.samsung.android.MtpApplication
32045  979com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 374584

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374626&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 Fri Oct 11 19:08:35 2019
@@ -0,0 +1,39 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def test_process_list_with_all_users(self):
+"""Test connecting to a remote linux platform"""
+
+class MyResponder(MockGDBServerResponder):
+def qfProcessInfo(self, packet):
+if "all_users:1" in packet:
+return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + 
binascii.hexlify("/a/test_process").decode() + ";"
+else:
+return "E04"
+
+self.server.responder = MyResponder()
+
+self.runCmd("log enable gdb-remote all")
+self.runCmd("platform select remote-linux")
+
+try:
+url = "connect://localhost:%d" % self.server.port
+
+# 
self.gdb.GetSelectedPlatform().ConnectRemote(lldb.SBPlatformConnectOptions(url))
+self.runCmd("platform connect connect://localhost:%d" %
+self.server.port)
+self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+self.expect("platform process list -x",
+substrs=["1 matching process was found", 
"test_process"])
+self.expect("platform process list",
+  

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 224721.
wallace added a comment.

after the logging finally found the bug, it's was an encoding issue due to a 
different python version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec &match_arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -3,6 +3,8 @@
 import threading
 import socket
 import lldb
+import binascii
+import traceback
 from lldbsuite.support import seven
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbtest_config
@@ -160,9 +162,34 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+return "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +198,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -315,6 +342,8 @@
 break
 self._receive(data)
 except Exception as e:
+print("An exception happened when receiving the response from the gdb server. Closing the client...")
+traceback.print_exc()
 self._client.close()
 break
 
@@ -425,7 +454,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
==

  1   2   >