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

2019-10-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added subscribers: amccarth, zturner.
labath added a comment.

Thanks. I was just about to hit approve, but then I noticed one other thing... 
:/ It seems that somebody (I guess it was @zturner) spent a lot of time in 
creating the whole PythonObject hierarchy, and it's (worthwhile) goal seems to 
be to enable the rest of the to code to avoid dealing with the python APIs 
directly. However, here you're ignoring all of that, and jumping to the C 
python interface directly.

I'd like to know what's your take on that? Have you considered basing these 
file classes on the PythonDataObject stuff?

The main reason I mention that is your comment about PyErr_Occurred, and the 
resulting boiler plate it produced. This seems like something that would be 
nicely solved by some c++-like wrapper, which is exactly what the PythonObject 
stuff is AFAICT.

Most of your interactions seem to be about calling methods. Would it be 
possible to add a PythonDataObject wrapper for this (and any other frequently 
used python API)? I'm hoping that we could have something like:

  if (Expected i = m_py_obj.CallMethod(pybuffer))
l_bytes_written = i->GetInteger();
  else
return Status(i.takeError());

instead of stuff like

  auto bytes_written = Take(
  PyObject_CallMethod(m_py_obj, "write", "(O)", pybuffer.get()));
  if (PyErr_Occurred())
return Status(llvm::make_error("Write"));
  long l_bytes_written = PyLong_AsLong(bytes_written.get());
  if (PyErr_Occurred())
return Status(llvm::make_error("Write"));

It doesn't look like adding this should be too hard (including the 
template-based computation of the python signature), but it could go a long way 
towards improving the readability, and it might actually fix other issues too 
-- it seems that the PythonDataObjects currently completely ignore the 
`PyErr_Occurred` stuff, which seems to be wrong, and it could actually be the 
reason why @amccarth was unable to run the test suite with a debug python on 
windows. Improving that, even if it's just for the stuff that's needed for your 
work would be really helpful, as it would provide a pattern on how to fix the 
remaining issues.

I'm sorry that I'm bringing this up so late in the review, but I am also 
learning this stuff as we go along -- unfortunately, I don't think we have 
anyone really knowledgeable about the python stuff still active in the lldb 
community..




Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1165
+  bool IsValid() const override {
+GIL takeGIL;
+return IsPythonSideValid() && Base::IsValid();

Maybe this GIL-talking can be done inside `IsPythonSideValid` (instead of two 
IsValid methods)?



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1197
+   uint32_t options)
+  : OwnedPythonFile(file, borrowed, fd, options, false){};
+};

extra semicolon here too



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1369
+const char *utf8 = PyUnicode_AsUTF8AndSize(pystring.get(), &size);
+if (!utf8 || PyErr_Occurred())
+  return Status(llvm::make_error("Read"));

This is an example where _I think_ you may be using `PyErr_Occurred` 
incorrectly. If python really asserts that PyErr_Occurred is always called, 
then this is not right, as you will not call it if the result is null. There 
are a couple of other examples like that in the code too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [lldb] r373711 - [lldb][modern-type-lookup] No longer import temporary declarations into the persistent AST

2019-10-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct  4 01:26:17 2019
New Revision: 373711

URL: http://llvm.org/viewvc/llvm-project?rev=373711&view=rev
Log:
[lldb][modern-type-lookup] No longer import temporary declarations into the 
persistent AST

Summary:
As we figured out in D67803, importing declarations from a temporary ASTContext 
that were originally from a persistent ASTContext
causes a bunch of duplicated declarations where we end up having declarations 
in the target AST that have no associated ASTImporter that
can complete them.

I haven't figured out how/if we can solve this in the current way we do things 
in LLDB, but in the modern-type-lookup this is solvable
as we have a saner architecture with the ExternalASTMerger. As we can 
(hopefully) make modern-type-lookup the default mode in the future,
I would say we try fixing this issue here. As we don't use the hack that was 
reinstated in D67803 during modern-type-lookup, the test case for this
is essentially just printing any kind of container in `std::` as we would 
otherwise run into the issue that required a hack like D67803.

What this patch is doing in essence is that instead of importing a declaration 
from a temporary ASTContext, we instead check if the
declaration originally came from a persistent ASTContext (e.g. the debug 
information) and we directly import from there. The ExternalASTMerger
is already connected with ASTImporters to these different sources, so this 
patch is essentially just two parts:
1. Mark our temporary ASTContext/ImporterSource as temporary when we import 
from the expression AST.
2. If the ExternalASTMerger sees we import from the expression AST, instead of 
trying to import these temporary declarations, check if we
can instead import from the persistent ASTContext that is already connected. 
This ensures that all records from the persistent source actually
come from the persistent source and are minimally imported in a way that allows 
them to be completed later on in the target AST.

The next step is to run the ASTImporter for these temporary expressions with 
the MinimalImport mode disabled, but that's a follow up patch.

This patch fixes most test failures with modern-type-lookup enabled by default 
(down to 73 failing tests, which includes the 22 import-std-module tests
which need special treatment).

Reviewers: shafik, martong

Reviewed By: martong

Subscribers: aprantl, rnkovacs, christof, abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py?rev=373711&r1=373710&r2=373711&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
 Fri Oct  4 01:26:17 2019
@@ -18,3 +18,6 @@ class LibcxxModernTypeLookup(TestBase):
 
 # Test a few simple expressions that should still work with 
modern-type-lookup.
 self.expect("expr pair", substrs=["(std::", "pairhttp://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp?rev=373711&r1=373710&r2=373711&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
 Fri Oct  4 01:26:17 2019
@@ -1,6 +1,14 @@
 #include 
+#include 
+#include 
+#include 
 
 int main(int argc, char **argv) {
   std::pair pair = std::make_pair(1, 2L);
+  std::string foo = "bar";
+  std::map map;
+  map[1] = 2;
+  std::unordered_map umap;
+  umap[1] = 2;
   return pair.first; // Set break point at this line.
 }

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=373711&r1=373710&r2=373711&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
F

[Lldb-commits] [PATCH] D68326: [lldb][modern-type-lookup] No longer import temporary declarations into the persistent AST

2019-10-04 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373711: [lldb][modern-type-lookup] No longer import 
temporary declarations into the… (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68326?vs=223007&id=223168#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68326

Files:
  cfe/trunk/include/clang/AST/ExternalASTMerger.h
  cfe/trunk/lib/AST/ExternalASTMerger.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -180,108 +180,20 @@
   return ret;
 }
 
-namespace {
-/// This class walks an AST and ensures that all DeclContexts defined inside the
-/// current source file are properly complete.
-///
-/// This is used to ensure that persistent types defined in the current source
-/// file migrate completely to the persistent AST context before they are
-/// reused.  If that didn't happen, it would be impoossible to complete them
-/// because their origin would be gone.
-///
-/// The stragtegy used by this class is to check the SourceLocation (to be
-/// specific, the FileID) and see if it's the FileID for the current expression.
-/// Alternate strategies could include checking whether an ExternalASTMerger,
-/// set up to not have the current context as a source, can find an original for
-/// the type.
-class Completer : public clang::RecursiveASTVisitor {
-private:
-  /// Used to import Decl contents
-  clang::ASTImporter &m_exporter;
-  /// The file that's going away
-  clang::FileID m_file;
-  /// Visited Decls, to avoid cycles
-  llvm::DenseSet m_completed;
-
-  bool ImportAndCheckCompletable(clang::Decl *decl) {
-llvm::Expected imported_decl = m_exporter.Import(decl);
-if (!imported_decl) {
-  llvm::consumeError(imported_decl.takeError());
-  return false;
-}
-if (m_completed.count(decl))
-  return false;
-if (!llvm::isa(decl))
-  return false;
-const clang::SourceLocation loc = decl->getLocation();
-if (!loc.isValid())
-  return false;
-const clang::FileID file =
-m_exporter.getFromContext().getSourceManager().getFileID(loc);
-if (file != m_file)
-  return false;
-// We are assuming the Decl was parsed in this very expression, so it
-// should not have external storage.
-lldbassert(!llvm::cast(decl)->hasExternalLexicalStorage());
-return true;
-  }
-
-  void Complete(clang::Decl *decl) {
-m_completed.insert(decl);
-auto *decl_context = llvm::cast(decl);
-llvm::Expected imported_decl = m_exporter.Import(decl);
-if (!imported_decl) {
-  llvm::consumeError(imported_decl.takeError());
-  return;
-}
-m_exporter.CompleteDecl(decl);
-for (Decl *child : decl_context->decls())
-  if (ImportAndCheckCompletable(child))
-Complete(child);
-  }
-
-  void MaybeComplete(clang::Decl *decl) {
-if (ImportAndCheckCompletable(decl))
-  Complete(decl);
-  }
-
-public:
-  Completer(clang::ASTImporter &exporter, clang::FileID file)
-  : m_exporter(exporter), m_file(file) {}
-
-  // Implements the RecursiveASTVisitor's core API.  It is called on each Decl
-  // that the RecursiveASTVisitor encounters, and returns true if the traversal
-  // should continue.
-  bool VisitDecl(clang::Decl *decl) {
-MaybeComplete(decl);
-return true;
-  }
-};
-} // namespace
-
-static void CompleteAllDeclContexts(clang::ASTImporter &exporter,
-clang::FileID file, clang::QualType root) {
-  clang::QualType canonical_type = root.getCanonicalType();
-  if (clang::TagDecl *tag_decl = canonical_type->getAsTagDecl()) {
-Completer(exporter, file).TraverseDecl(tag_decl);
-  } else if (auto interface_type = llvm::dyn_cast(
- canonical_type.getTypePtr())) {
-Completer(exporter, file).TraverseDecl(interface_type->getDecl());
-  } else {
-Completer(exporter, file).TraverseType(canonical_type);
-  }
-}
-
 static clang::QualType ExportAllDeclaredTypes(
-clang::ExternalASTMerger &merger, clang::ASTContext &source,
-clang::FileManager &source_file_manager,
+clang::ExternalASTMerger &parent_merger, clang::ExternalASTMerger &merger,
+clang::ASTContext &source, clang::FileManager &source_file_manager,
 const clang::ExternalASTMerger::OriginMap &source_origin_map,
  

[Lldb-commits] [PATCH] D68433: SBFile: add a bunch of tests that should eventually work.

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

Makes sense. Would it make sense to use `@expectedFailure` instead of 
`@skipIf`? That way you'll get an notification once a test actually starts 
passing...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68433



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


[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

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



Comment at: lldb/source/Core/IOHandler.cpp:332
+  if (m_output_sp) {
+m_output_sp->GetFile().Printf("%s", prompt);
+m_output_sp->Flush();

It looks like this could actually use the `Stream` interface to write this 
stuff (*m_output_sp << prompt). Ideally, I guess we wouldn't even have 
formatted output capabilities on the File class, and things would always go 
through streams for stuff like this..



Comment at: lldb/source/Core/IOHandler.cpp:493
+if (m_output_sp) {
+  m_output_sp->GetFile().Printf(
+  "%u%s", m_base_line_number + (uint32_t)lines.GetSize(),

same here.



Comment at: lldb/source/Expression/REPL.cpp:426
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->GetFile().Printf("\n");
 }

and here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444



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


[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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



Comment at: lldb/include/lldb/Utility/ReproducerInstrumentation.h:19
 
+#include "lldb/API/SBFile.h"
+

This is definitely not right. `Utility` should never include other lldb 
libraries. I think this stuff should be defined in the API folder. Either in 
the SBFile.cpp directly, or some additional cpp file.



Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:38
 
+template <> lldb::SBFile Deserializer::Deserialize() {
+//@JDevlieghere I'm pretty sure this is not the right thing to

lawrence_danna wrote:
> @JDevlieghere advice please.
This is not totally surprising as SBDebugger::SetInputFile ignores the input 
SBFile when it's in replay mode. However, it still doesn't seem like the right 
fix. I am guessing that something special needs to happen in the record/replay 
logic of the SBFile constructor, but off-hand, it's not fully clear to me what 
would that be.

I think ideally, we'd have the reproducer shadowing that's currently done in 
SBDebugger::SetInputFileHandle kick in earlier (in the SBFile constructor) so 
that it covers all SBFiles, and not just those that later become the debugger 
input handles, but I don't think it should be on you to make all of that work. 
Maybe the appropriate fix would be to just make sure the SBFile constructor 
creates empty objects and acknowledge that reproducers won't work for all 
SBFiles until someone actually implements the appropriate support for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434



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


[Lldb-commits] [lldb] r373719 - [lldb] Fix typo in r373675

2019-10-04 Thread Sam McCall via lldb-commits
Author: sammccall
Date: Fri Oct  4 02:33:04 2019
New Revision: 373719

URL: http://llvm.org/viewvc/llvm-project?rev=373719&view=rev
Log:
[lldb] Fix typo in r373675

Modified:
lldb/trunk/scripts/Python/python-wrapper.swig

Modified: lldb/trunk/scripts/Python/python-wrapper.swig
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=373719&r1=373718&r2=373719&view=diff
==
--- lldb/trunk/scripts/Python/python-wrapper.swig (original)
+++ lldb/trunk/scripts/Python/python-wrapper.swig Fri Oct  4 02:33:04 2019
@@ -288,7 +288,7 @@ LLDBSwigPythonCreateScriptedThreadPlan
Py_RETURN_NONE;
 }
 result = pfunc(tp_arg, dict);
-} else if (init_num_args = 4) {
+} else if (init_num_args == 4) {
 lldb::SBStructuredData *args_value = new 
lldb::SBStructuredData(args_impl);
 PythonObject args_arg(PyRefType::Owned, 
SBTypeToSWIGWrapper(args_value));
 result = pfunc(tp_arg, args_arg, dict);


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


[Lldb-commits] [PATCH] D68069: Explicitly set entry point arch when it's thumb

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

Yea, I see what you mean. I wouldn't spend too much time on fixing that though. 
The ability for SymbolFiles to add symtab entries is a fairly new thing. Not 
all issues with it have been ironed out, and I don't think it's up to you to 
fix them. The same kind of conflict could have happened with any other 
synthetic symbol (e.g. the eh_frame stuff) being added by the object file, and 
you were just unlucky that I wrote that particular test to check for the entry 
point symbol. I think you can just tweak the test it doesn't trigger this issue 
(e.g. you can just delete the entry point from the yamlized elf file being used 
as input).




Comment at: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2714
+ArchSpec arch = GetArchitecture();
+auto entry_point_addr = GetEntryPointAddress().GetFileAddress();
+if (entry_point_addr != LLDB_INVALID_ADDRESS) {

When playing around with the test failure, I realized that you're creating this 
entry point symbol even if the entry point is empty/zero. I think you should 
only create it if is matching a known section (and maybe also only if this 
object is an executable file (not a library)). In fact, probably 
GetEntryPointAddress should check that, and not return anything in this case.



Comment at: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2719
+SectionSP section_sp =
+
GetSectionList()->FindSectionContainingFileAddress(entry_point_addr);
+Symbol symbol(

This actually shouldn't be needed if you saved the original Address object 
returned from `GetEntryPointAddress()` as the section should already be present 
there.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68069



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


[Lldb-commits] [lldb] r373721 - [lldb] Fix -Wreorder-ctor in r373673

2019-10-04 Thread Sam McCall via lldb-commits
Author: sammccall
Date: Fri Oct  4 02:41:43 2019
New Revision: 373721

URL: http://llvm.org/viewvc/llvm-project?rev=373721&view=rev
Log:
[lldb] Fix -Wreorder-ctor in r373673

Modified:
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=373721&r1=373720&r2=373721&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Oct  4 02:41:43 
2019
@@ -242,19 +242,18 @@ public:
 interpreter, "breakpoint set",
 "Sets a breakpoint or set of breakpoints in the executable.",
 "breakpoint set "),
-m_python_class_options("scripted breakpoint", 'P'),
-m_bp_opts(), m_options() {
-  // We're picking up all the normal options, commands and disable.
-  m_all_options.Append(&m_python_class_options, LLDB_OPT_SET_1,
-   LLDB_OPT_SET_11);
-  m_all_options.Append(&m_bp_opts, 
-   LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | 
LLDB_OPT_SET_4, 
-   LLDB_OPT_SET_ALL);
-  m_all_options.Append(&m_dummy_options, LLDB_OPT_SET_1, 
-   LLDB_OPT_SET_ALL);
-  m_all_options.Append(&m_options);
-  m_all_options.Finalize();
-}
+m_bp_opts(), m_python_class_options("scripted breakpoint", 'P'),
+m_options() {
+// We're picking up all the normal options, commands and disable.
+m_all_options.Append(&m_python_class_options, LLDB_OPT_SET_1,
+ LLDB_OPT_SET_11);
+m_all_options.Append(&m_bp_opts,
+ LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4,
+ LLDB_OPT_SET_ALL);
+m_all_options.Append(&m_dummy_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL);
+m_all_options.Append(&m_options);
+m_all_options.Finalize();
+  }
 
   ~CommandObjectBreakpointSet() override = default;
 


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


[Lldb-commits] [lldb] r373723 - [lldb] Fix that 'ninja clean' breaks the build by deleting debugserver_vers.c

2019-10-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct  4 02:52:26 2019
New Revision: 373723

URL: http://llvm.org/viewvc/llvm-project?rev=373723&view=rev
Log:
[lldb] Fix that 'ninja clean' breaks the build by deleting debugserver_vers.c

Summary:
We mark debugserver_vers.c as a generated file in CMake. This means that when 
we run `ninja clean` we end up deleting that file,
but any following `ninja` invocation will fail due to the file missing. The 
file can't be generated as `ninja` doesn't know it has to
rerun CMake to create the file. Turns out that marking the output of 
configure_file as generated is wrong as explained in this bug report:
https://gitlab.kitware.com/cmake/cmake/issues/18032

This patch just removes that property. The only side effect of this seems to be 
that this file maybe shows up in your IDE when
opening our CMake project, but that seems like a small sacrifice.

This patch can be quickly tested by running `ninja clean ; ninja 
lldbDebugserverCommon`. Before this patch the build will fail
due to debugserver_vers.c missing.

Reviewers: JDevlieghere, labath

Reviewed By: labath

Subscribers: mgorny, abidh, lldb-commits

Tags: #lldb

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

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

Modified: lldb/trunk/tools/debugserver/source/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/CMakeLists.txt?rev=373723&r1=373722&r2=373723&view=diff
==
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt Fri Oct  4 02:52:26 2019
@@ -136,7 +136,6 @@ add_custom_command(OUTPUT ${generated_ma
   )
 
 set(DEBUGSERVER_VERS_GENERATED_FILE 
${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES 
GENERATED 1)
 configure_file(debugserver_vers.c.in
${DEBUGSERVER_VERS_GENERATED_FILE} @ONLY)
 


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


[Lldb-commits] [PATCH] D68376: [lldb] Fix that 'ninja clean' breaks the build by deleting debugserver_vers.c

2019-10-04 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373723: [lldb] Fix that 'ninja clean' breaks the 
build by deleting debugserver_vers.c (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68376?vs=222972&id=223178#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68376

Files:
  lldb/trunk/tools/debugserver/source/CMakeLists.txt


Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -136,7 +136,6 @@
   )
 
 set(DEBUGSERVER_VERS_GENERATED_FILE 
${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES 
GENERATED 1)
 configure_file(debugserver_vers.c.in
${DEBUGSERVER_VERS_GENERATED_FILE} @ONLY)
 


Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -136,7 +136,6 @@
   )
 
 set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
 configure_file(debugserver_vers.c.in
${DEBUGSERVER_VERS_GENERATED_FILE} @ONLY)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r373725 - [lldb] Get the TargetAPI lock in SBProcess::IsInstrumentationRuntimePresent

2019-10-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Oct  4 02:54:58 2019
New Revision: 373725

URL: http://llvm.org/viewvc/llvm-project?rev=373725&view=rev
Log:
[lldb] Get the TargetAPI lock in SBProcess::IsInstrumentationRuntimePresent

Summary:
We should get the TargetAPI lock here to prevent the process of being destroyed 
while we are in the function. Thanks Jim for explaining what's going on.

Fixes rdar://54424754

Reviewers: jingham

Reviewed By: jingham

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/API/SBProcess.cpp

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=373725&r1=373724&r2=373725&view=diff
==
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Fri Oct  4 02:54:58 2019
@@ -1180,6 +1180,9 @@ bool SBProcess::IsInstrumentationRuntime
   if (!process_sp)
 return false;
 
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+
   InstrumentationRuntimeSP runtime_sp =
   process_sp->GetInstrumentationRuntime(type);
 


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


[Lldb-commits] [PATCH] D67831: [lldb] Get the TargetAPI lock in SBProcess::IsInstrumentationRuntimePresen

2019-10-04 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373725: [lldb] Get the TargetAPI lock in 
SBProcess::IsInstrumentationRuntimePresent (authored by teemperor, committed by 
).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67831?vs=221011&id=223179#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67831

Files:
  lldb/trunk/source/API/SBProcess.cpp


Index: lldb/trunk/source/API/SBProcess.cpp
===
--- lldb/trunk/source/API/SBProcess.cpp
+++ lldb/trunk/source/API/SBProcess.cpp
@@ -1180,6 +1180,9 @@
   if (!process_sp)
 return false;
 
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+
   InstrumentationRuntimeSP runtime_sp =
   process_sp->GetInstrumentationRuntime(type);
 


Index: lldb/trunk/source/API/SBProcess.cpp
===
--- lldb/trunk/source/API/SBProcess.cpp
+++ lldb/trunk/source/API/SBProcess.cpp
@@ -1180,6 +1180,9 @@
   if (!process_sp)
 return false;
 
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+
   InstrumentationRuntimeSP runtime_sp =
   process_sp->GetInstrumentationRuntime(type);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

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

Yeah, that's definitely python-related, but it's hard to say how exactly 
without knowing more details. Also note that there have been some changes in 
how the python stuff is used/built in the last couple of weeks so it's possible 
this was not caused by a change on your side...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

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

TBE, this happens when lldb is not able to find the python package files (which 
should normally be in `$BUILD/libXY/pythonA.B/site-packages`).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


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

2019-10-04 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68454

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

Index: lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -2199,6 +2199,97 @@
   EXPECT_EQ(-40, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestSpArithx86_64Augmented) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine64 = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x55, // pushq %rbp
+  0x48, 0x89, 0xe5, // movq %rsp, %rbp
+
+  // x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite
+  // has a bug where it can't augment a function that is just
+  // prologue+epilogue - it needs at least one other instruction
+  // in between.
+
+  0x90,// nop
+  0x48, 0x81, 0xec, 0x88, 0, 0, 0, // subq   $0x88, %rsp
+  0x90,// nop
+  0x48, 0x81, 0xc4, 0x88, 0, 0, 0, // addq   $0x88, %rsp
+
+  0x5d, // popq %rbp
+  0xc3  // retq
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  unwind_plan.SetSourceName("unit testing hand-created unwind plan");
+  unwind_plan.SetPlanValidAddressRange(sample_range);
+  unwind_plan.SetRegisterKind(eRegisterKindLLDB);
+
+  row_sp = std::make_shared();
+
+  // Describe offset 0
+  row_sp->SetOffset(0);
+  row_sp->GetCFAValue().SetIsRegisterPlusOffset(k_rsp, 8);
+
+  regloc.SetAtCFAPlusOffset(-8);
+  row_sp->SetRegisterInfo(k_rip, regloc);
+
+  unwind_plan.AppendRow(row_sp);
+
+  // Allocate a new Row, populate it with the existing Row contents.
+  UnwindPlan::Row *new_row = new UnwindPlan::Row;
+  *new_row = *row_sp.get();
+  row_sp.reset(new_row);
+
+  // Describe offset 1
+  row_sp->SetOffset(1);
+  row_sp->GetCFAValue().SetIsRegisterPlusOffset(k_rsp, 16);
+  regloc.SetAtCFAPlusOffset(-16);
+  row_sp->SetRegisterInfo(k_rbp, regloc);
+  unwind_plan.AppendRow(row_sp);
+
+  // Allocate a new Row, populate it with the existing Row contents.
+  new_row = new UnwindPlan::Row;
+  *new_row = *row_sp.get();
+  row_sp.reset(new_row);
+
+  // Describe offset 4
+  row_sp->SetOffset(4);
+  row_sp->GetCFAValue().SetIsRegisterPlusOffset(k_rsp, 16);
+  unwind_plan.AppendRow(row_sp);
+
+  RegisterContextSP reg_ctx_sp;
+  EXPECT_TRUE(engine64->AugmentUnwindPlanFromCallSite(
+  data, sizeof(data), sample_range, unwind_plan, reg_ctx_sp));
+
+  // Before we touch the stack pointer, we should still refer to the
+  // row from after the prologue.
+  row_sp = unwind_plan.GetRowForFunctionOffset(5);
+  EXPECT_EQ(4ull, row_sp->GetOffset());
+
+  // Check the first stack pointer update.
+  row_sp = unwind_plan.GetRowForFunctionOffset(12);
+  EXPECT_EQ(12ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_EQ(152, row_sp->GetCFAValue().GetOffset());
+
+  // After the nop, we should still refer to the same row.
+  row_sp = unwind_plan.GetRowForFunctionOffset(13);
+  EXPECT_EQ(12ull, row_sp->GetOffset());
+
+  // Check that the second stack pointer update is reflected in the
+  // unwind plan.
+  row_sp = unwind_plan.GetRowForFunctionOffset(20);
+  EXPECT_EQ(20ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestSimplex86_64Augmented) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
Index: lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
===
--- lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -1371,7 +1371,6 @@
   int row_id = 1;
   bool unwind_plan_updated = false;
   UnwindPlan::RowSP row(new UnwindPlan::Row(*first_row));
-  m_cur_insn =

[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, compnerd, phosek, beanz.

Link against clang-cpp dylib rather than split libs when
CLANG_LINK_CLANG_DYLIB is enabled.


https://reviews.llvm.org/D68456

Files:
  lldb/cmake/modules/AddLLDB.cmake
  lldb/source/Core/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/Language/ObjC/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
  lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
  lldb/source/Symbol/CMakeLists.txt
  lldb/tools/lldb-instr/CMakeLists.txt

Index: lldb/tools/lldb-instr/CMakeLists.txt
===
--- lldb/tools/lldb-instr/CMakeLists.txt
+++ lldb/tools/lldb-instr/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_lldb_tool(lldb-instr
   Instrument.cpp
 
-  LINK_LIBS
+  CLANG_LIBS
 clangAST
 clangBasic
 clangCodeGen
Index: lldb/source/Symbol/CMakeLists.txt
===
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -46,9 +46,6 @@
   ${PLATFORM_SOURCES}
 
   LINK_LIBS
-clangAST
-clangBasic
-clangFrontend
 lldbCore
 lldbExpression
 lldbHost
@@ -60,6 +57,11 @@
 lldbPluginObjCLanguage
 lldbPluginObjCRuntime
 
+  CLANG_LIBS
+clangAST
+clangBasic
+clangFrontend
+
   LINK_COMPONENTS
 Support
   )
Index: lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
===
--- lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
+++ lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -4,12 +4,13 @@
   SymbolFilePDB.cpp
 
   LINK_LIBS
-clangAST
-clangLex
 lldbCore
+lldbPluginSymbolFileNativePDB
 lldbSymbol
 lldbUtility
-  lldbPluginSymbolFileNativePDB
+  CLANG_LIBS
+clangAST
+clangLex
   LINK_COMPONENTS
 DebugInfoPDB
 Support
Index: lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
===
--- lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
+++ lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
@@ -11,11 +11,12 @@
   UdtRecordCompleter.cpp
 
   LINK_LIBS
-clangAST
-clangLex
 lldbCore
 lldbSymbol
 lldbUtility
+  CLANG_LIBS
+clangAST
+clangLex
   LINK_COMPONENTS
 DebugInfoCodeView
 DebugInfoPDB
Index: lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
===
--- lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -43,8 +43,6 @@
   UniqueDWARFASTType.cpp
 
   LINK_LIBS
-clangAST
-clangBasic
 lldbCore
 lldbExpression
 lldbHost
@@ -55,6 +53,9 @@
 lldbPluginObjCLanguage
 lldbPluginCPlusPlusLanguage
 lldbPluginExpressionParserClang
+  CLANG_LIBS
+clangAST
+clangBasic
   LINK_COMPONENTS
 DebugInfoDWARF
 Support
Index: lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -39,7 +39,6 @@
   ${PLUGIN_PLATFORM_MACOSX_SOURCES}
 
   LINK_LIBS
-clangBasic
 lldbBreakpoint
 lldbCore
 lldbHost
@@ -49,6 +48,8 @@
 lldbUtility
 lldbPluginPlatformPOSIX
 ${OBJC_LIBS}
+  CLANG_LIBS
+clangBasic
   LINK_COMPONENTS
 Support
 )
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
@@ -13,7 +13,6 @@
   ${tablegen_deps}
 
   LINK_LIBS
-clangBasic
 lldbBreakpoint
 lldbCore
 lldbDataFormatters
@@ -22,6 +21,8 @@
 lldbInterpreter
 lldbSymbol
 lldbTarget
+  CLANG_LIBS
+clangBasic
   LINK_COMPONENTS
 Core
 IRReader
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
@@ -9,7 +9,6 @@
   AppleObjCTypeEncodingParser.cpp
 
   LINK_LIBS
-clangAST
 lldbBreakpoint
 lldbCore
 lldbExpression
@@ -20,6 +19,8 @@
 lldbUtility
 lldbPluginExpressionParserClang
 lldbPluginCPPRuntime
+  CLANG_LIBS
+clangAST
   LINK

[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

FTR, I'm getting missing LD_LIBRARY_PATH problems when running `check-llvm` 
with dylibs. However, it also happens with plain `LLVM_LINK_LLVM_DYLIB`, so I 
don't think it needs to be addressed with this patch.


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

https://reviews.llvm.org/D68456



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


[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

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

Seems reasonable. Just one quick question about the implementation.




Comment at: lldb/cmake/modules/AddLLDB.cmake:94-99
+
+if(CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${name} PRIVATE clang-cpp)
+else()
+  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
+endif()

I don't know whether this makes any difference, but I am wondering if we should 
pass these (both clang-cpp and PARAM_CLANG_LIBS) as the LINK_LIBS argument to 
the llvm_add_library call above. Seems like it would be more consistent with 
the approach of letting the llvm function manage linking. WDYT?


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

https://reviews.llvm.org/D68456



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


[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lldb/cmake/modules/AddLLDB.cmake:94-99
+
+if(CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${name} PRIVATE clang-cpp)
+else()
+  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
+endif()

labath wrote:
> I don't know whether this makes any difference, but I am wondering if we 
> should pass these (both clang-cpp and PARAM_CLANG_LIBS) as the LINK_LIBS 
> argument to the llvm_add_library call above. Seems like it would be more 
> consistent with the approach of letting the llvm function manage linking. 
> WDYT?
I presumed it doesn't, so went for the simpler approach ;-). I can change it if 
you prefer.


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

https://reviews.llvm.org/D68456



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


[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 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/cmake/modules/AddLLDB.cmake:94-99
+
+if(CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${name} PRIVATE clang-cpp)
+else()
+  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
+endif()

mgorny wrote:
> labath wrote:
> > I don't know whether this makes any difference, but I am wondering if we 
> > should pass these (both clang-cpp and PARAM_CLANG_LIBS) as the LINK_LIBS 
> > argument to the llvm_add_library call above. Seems like it would be more 
> > consistent with the approach of letting the llvm function manage linking. 
> > WDYT?
> I presumed it doesn't, so went for the simpler approach ;-). I can change it 
> if you prefer.
Pfft.. I don't know.. We can leave that as is..


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

https://reviews.llvm.org/D68456



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


[Lldb-commits] [lldb] r373734 - [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Fri Oct  4 05:03:03 2019
New Revision: 373734

URL: http://llvm.org/viewvc/llvm-project?rev=373734&view=rev
Log:
[lldb] [cmake] Support linking against clang-cpp dylib

Link against clang-cpp dylib rather than split libs when
CLANG_LINK_CLANG_DYLIB is enabled.

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

Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/source/Core/CMakeLists.txt
lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
lldb/trunk/source/Symbol/CMakeLists.txt
lldb/trunk/tools/lldb-instr/CMakeLists.txt

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=373734&r1=373733&r2=373734&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Fri Oct  4 05:03:03 2019
@@ -37,7 +37,7 @@ function(add_lldb_library name)
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
 "INSTALL_PREFIX;ENTITLEMENTS"
-"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
+"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
@@ -91,6 +91,12 @@ function(add_lldb_library name)
   ${pass_ENTITLEMENTS}
   ${pass_NO_INSTALL_RPATH}
 )
+
+if(CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${name} PRIVATE clang-cpp)
+else()
+  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
+endif()
   endif()
 
   if(PARAM_SHARED)
@@ -136,7 +142,7 @@ function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "GENERATE_INSTALL"
 "INSTALL_PREFIX;ENTITLEMENTS"
-"LINK_LIBS;LINK_COMPONENTS"
+"LINK_LIBS;CLANG_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
@@ -156,6 +162,11 @@ function(add_lldb_executable name)
   )
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
+  if(CLANG_LINK_CLANG_DYLIB)
+target_link_libraries(${name} PRIVATE clang-cpp)
+  else()
+target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})
+  endif()
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if(ARG_GENERATE_INSTALL)

Modified: lldb/trunk/source/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CMakeLists.txt?rev=373734&r1=373733&r2=373734&view=diff
==
--- lldb/trunk/source/Core/CMakeLists.txt (original)
+++ lldb/trunk/source/Core/CMakeLists.txt Fri Oct  4 05:03:03 2019
@@ -69,7 +69,6 @@ add_lldb_library(lldbCore
 clang-tablegen-targets
 
   LINK_LIBS
-clangDriver
 lldbBreakpoint
 lldbDataFormatters
 lldbExpression
@@ -82,6 +81,9 @@ add_lldb_library(lldbCore
 lldbPluginObjCLanguage
 ${LLDB_CURSES_LIBS}
 
+  CLANG_LIBS
+clangDriver
+
   LINK_COMPONENTS
 Support
 Demangle

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt?rev=373734&r1=373733&r2=373734&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt Fri Oct  4 
05:03:03 2019
@@ -27,6 +27,16 @@ add_lldb_library(lldbPluginExpressionPar
   ${tablegen_deps}
 
   LINK_LIBS
+lldbCore
+lldbExpression
+lldbHost
+lldbInterpreter
+lldbSymbol
+lldbTarget
+lldbUtility
+lldbPluginCPlusPlusLanguage
+lldbPluginCPPRuntime
+  CLANG_LIBS
 clangAST
 clangCodeGen
 clangDriver
@@ -38,15 +48,6 @@ add_lldb_library(lldbPluginExpressionPar
 clangRewriteFrontend
 clangSema
 clangSerialization
-lldbCore
-lldbExpression
-lldbHost
-lldbInterpreter
-lldbSymbol
-lldbTarget
-lldbUtility
-lldbPluginCPlusPlusLanguage
-lldbPluginCPPRuntime
   LINK_COMPONENTS
 Core
 ExecutionEngine

Modified: lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt?rev=373734&r1=373733&r2=373734&view=diff
==
--- lldb

[Lldb-commits] [PATCH] D68456: [lldb] [cmake] Support linking against clang-cpp dylib

2019-10-04 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373734: [lldb] [cmake] Support linking against clang-cpp 
dylib (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68456?vs=223185&id=223190#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68456

Files:
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/source/Core/CMakeLists.txt
  lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
  lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
  lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
  lldb/trunk/source/Symbol/CMakeLists.txt
  lldb/trunk/tools/lldb-instr/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -37,7 +37,7 @@
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
 "INSTALL_PREFIX;ENTITLEMENTS"
-"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
+"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
@@ -91,6 +91,12 @@
   ${pass_ENTITLEMENTS}
   ${pass_NO_INSTALL_RPATH}
 )
+
+if(CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${name} PRIVATE clang-cpp)
+else()
+  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
+endif()
   endif()
 
   if(PARAM_SHARED)
@@ -136,7 +142,7 @@
   cmake_parse_arguments(ARG
 "GENERATE_INSTALL"
 "INSTALL_PREFIX;ENTITLEMENTS"
-"LINK_LIBS;LINK_COMPONENTS"
+"LINK_LIBS;CLANG_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
@@ -156,6 +162,11 @@
   )
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
+  if(CLANG_LINK_CLANG_DYLIB)
+target_link_libraries(${name} PRIVATE clang-cpp)
+  else()
+target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})
+  endif()
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if(ARG_GENERATE_INSTALL)
Index: lldb/trunk/source/Core/CMakeLists.txt
===
--- lldb/trunk/source/Core/CMakeLists.txt
+++ lldb/trunk/source/Core/CMakeLists.txt
@@ -69,7 +69,6 @@
 clang-tablegen-targets
 
   LINK_LIBS
-clangDriver
 lldbBreakpoint
 lldbDataFormatters
 lldbExpression
@@ -82,6 +81,9 @@
 lldbPluginObjCLanguage
 ${LLDB_CURSES_LIBS}
 
+  CLANG_LIBS
+clangDriver
+
   LINK_COMPONENTS
 Support
 Demangle
Index: lldb/trunk/source/Symbol/CMakeLists.txt
===
--- lldb/trunk/source/Symbol/CMakeLists.txt
+++ lldb/trunk/source/Symbol/CMakeLists.txt
@@ -46,9 +46,6 @@
   ${PLATFORM_SOURCES}
 
   LINK_LIBS
-clangAST
-clangBasic
-clangFrontend
 lldbCore
 lldbExpression
 lldbHost
@@ -60,6 +57,11 @@
 lldbPluginObjCLanguage
 lldbPluginObjCRuntime
 
+  CLANG_LIBS
+clangAST
+clangBasic
+clangFrontend
+
   LINK_COMPONENTS
 Support
   )
Index: lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -4,12 +4,13 @@
   SymbolFilePDB.cpp
 
   LINK_LIBS
-clangAST
-clangLex
 lldbCore
+lldbPluginSymbolFileNativePDB
 lldbSymbol
 lldbUtility
-  lldbPluginSymbolFileNativePDB
+  CLANG_LIBS
+clangAST
+clangLex
   LINK_COMPONENTS
 DebugInfoPDB
 Support
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -43,8 +43,6 @@
   UniqueDWARFASTType.cpp
 
   LINK_LIBS
-clangAST
-clangBasic
 lldbCore
 lldbExpression
 lldbHost
@@ -55,6 +53,9 @@
 lldbPluginObjCLanguage
 lldbPluginCPlusPlusLanguage
 lldbPluginExpressionParserClang
+  CLANG_LIBS
+clangAST
+clangBasic
   LINK_COMPONENTS
 DebugInfoDWARF
 Support
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/CMakeList

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

2019-10-04 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 223193.
labath added a comment.

Upload a new version of the patch.

This isn't fully ready for submission, but I am putting it up anyway, to get
some feedback on the direction I am taking this, and ask some questions.

First I tried to do a complete rewrite of the loclists class in a manner similar
to the rnglists parser, but then I ran into the problem called .debug_loc.dwo
(v4 extension vaguely similar to DWARF5 loclists). Right now, it is possible to
share the parsing code between this format and .debug_loclists. That would be
pretty tricky to do with the rnglists approach.

So, instead I went for a bottom-up approach and tried to rewrite/reuse/make
similar the lower level classes, which can be shared more easily with the
rnglists stuff. This patch creates a DWARFLocation class, which is based on the
existing DWARFAddressRange class. The next step would be (or maybe I'll land it
before this patch) a LocationListEntry class akin to the existing
RangeListEntry.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68270

Files:
  include/llvm/BinaryFormat/Dwarf.h
  include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
  lib/BinaryFormat/Dwarf.cpp
  lib/DebugInfo/DWARF/DWARFContext.cpp
  lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
  lib/DebugInfo/DWARF/DWARFDie.cpp
  test/CodeGen/X86/debug-loclists.ll
  test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s
  test/DebugInfo/X86/dwarfdump-debug-loclists.test
  test/DebugInfo/X86/fission-ranges.ll
  test/DebugInfo/X86/loclists-dwp.ll
  test/tools/llvm-dwarfdump/X86/debug_loc_dwo.s
  test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s

Index: test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
===
--- test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
+++ test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
@@ -8,7 +8,7 @@
 # CHECK: .debug_loclists contents:
 # CHECK-NEXT:0x: locations list header: length = 0x000e, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x
 # CHECK-NEXT:0x:
-# CHECK-NEXT:Addr idx 1 (w/ length 16): DW_OP_reg5 RDI
+# CHECK-NEXT:[DW_LLE_startx_length]: 0x0001, 0x0010[DW_LLE_startx_length]: 0x0001, 0x0010 =>  DW_OP_reg5 RDI
 
 .section .debug_loclists,"",@progbits
  .long  .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0
Index: test/tools/llvm-dwarfdump/X86/debug_loc_dwo.s
===
--- test/tools/llvm-dwarfdump/X86/debug_loc_dwo.s
+++ test/tools/llvm-dwarfdump/X86/debug_loc_dwo.s
@@ -6,7 +6,7 @@
 
 # CHECK: .debug_loc.dwo contents:
 # CHECK-NEXT:0x:
-# CHECK-NEXT:Addr idx 1 (w/ length 16): DW_OP_reg5 RDI
+# CHECK-NEXT:[DW_LLE_startx_length]: 0x0001, 0x0010 =>  DW_OP_reg5 RDI
 
 .section .debug_loc.dwo,"",@progbits
 # One location list. The pre-DWARF v5 implementation only recognizes
Index: test/DebugInfo/X86/loclists-dwp.ll
===
--- test/DebugInfo/X86/loclists-dwp.ll
+++ test/DebugInfo/X86/loclists-dwp.ll
@@ -19,10 +19,10 @@
 ; void b(int i) { asm("" : : : "rdi"); }
 
 ; CHECK:  DW_AT_location [DW_FORM_sec_offset]   (0x
-; CHECK-NEXT: Addr idx 0 (w/ length 6): DW_OP_reg5 RDI)
+; CHECK-NEXT: [DW_LLE_startx_length]: 0x, 0x0006 =>  DW_OP_reg5 RDI)
 
 ; CHECK:  DW_AT_location [DW_FORM_sec_offset]   (0x
-; CHECK-NEXT: Addr idx 0 (w/ length 0): DW_OP_reg5 RDI)
+; CHECK-NEXT: [DW_LLE_startx_length]: 0x, 0x =>  DW_OP_reg5 RDI)
 
 target triple = "x86_64-unknown-linux-gnu"
 
Index: test/DebugInfo/X86/fission-ranges.ll
===
--- test/DebugInfo/X86/fission-ranges.ll
+++ test/DebugInfo/X86/fission-ranges.ll
@@ -45,18 +45,18 @@
 ; if they've changed due to a bugfix, change in register allocation, etc.
 
 ; CHECK:  [[A]]:
-; CHECK-NEXT:   Addr idx 2 (w/ length 15): DW_OP_consts +0, DW_OP_stack_value
-; CHECK-NEXT:   Addr idx 3 (w/ length 15): DW_OP_reg0 RAX
-; CHECK-NEXT:   Addr idx 4 (w/ length 18): DW_OP_breg7 RSP-8
+; CHECK-NEXT:   [DW_LLE_startx_length]: 0x0002, 0x000f =>  DW_OP_consts +0, DW_OP_stack_value
+; CHECK-NEXT:   [DW_LLE_startx_length]: 0x0003, 0x000f =>  DW_OP_reg0 RAX
+; CHECK-NEXT:   [DW_LLE_startx_length]: 0x0004, 0x0012 =>  DW_OP_breg7 RSP-8
 ; CHECK:  [[E]]:
-; CHECK-NEXT:   Addr idx 5 (w/ length 9): DW_OP_reg0 RAX
-; CHECK-NEXT:   Addr idx 6 (w/ length 98): DW_OP_breg7 RSP-44
+; CHECK-NEXT:   [DW_LLE_startx_length]: 0x0005, 0x0009 =>  DW_OP_reg0 RAX
+; CHECK-NEXT:   [DW_LLE_startx_length]: 0x0006, 0x0062 =>  DW_OP_breg7 RSP-44
 ; CHECK:  [[B]]:
-; CHECK-NEXT:   Ad

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

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



Comment at: include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h:91
 
+  class EntryIterator {
+  public:

I went for an iterator-like approach (instead of a callback or direct 
materialization) because it's easier to use. In particular it makes it possible 
to reuse this stuff in the dumping code, which would have been pretty hard with 
callbacks.



Comment at: include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h:138
+llvm::Optional BaseAddr;
+std::function(uint32_t)>
+AddrOffsetResolver;

Using a callback is consistent with what rnglists code does. This uses a 
std::function instead of a function_ref because it's easier for iterators to 
escape out of scopes. However, I've wondered if we shouldn't define an 
AddrOffsetResolver interface that llvm, lldb DWARFUnits and anyone else who 
wishes so (unit tests ?) can implement.



Comment at: lib/DebugInfo/DWARF/DWARFDebugLoc.cpp:164
+if (!BaseAddr)
+  return createStringError(errc::invalid_argument,
+   "Cannot interpret DW_LLE_offset_pair entry due "

A significant deviation from the rnglists code: Here I return an error if it is 
not possible to compute the address range correctly. The rnglists parser cannot 
compute the value, it will just return something, which can be very far from 
the correct range -- for instance, it's happy to use the base_addressx index as 
the offset, if the index cannot be resolved correctly. And it doesn't provide 
any indication that it has done so, which doesn't seem like a very useful 
behavior.

If this is the behavior we want, I can also try to make the rnglists parser do 
something similar.



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

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.



Comment at: test/CodeGen/X86/debug-loclists.ll:16
 ; CHECK-NEXT: 0x:
-; CHECK-NEXT:  [0x, 0x0004): DW_OP_breg5 RDI+0
-; CHECK-NEXT:  [0x0004, 0x0012): DW_OP_breg3 RBX+0
-
-; There is no way to use llvm-dwarfdump atm (2018, october) to verify the 
DW_LLE_* codes emited,
-; because dumper is not yet implements that. Use asm code to do this check 
instead.
-;
-; RUN: llc -mtriple=x86_64-pc-linux -filetype=asm < %s -o - | FileCheck %s 
--check-prefix=ASM
-; ASM:  .section .debug_loclists,"",@progbits
-; ASM-NEXT: .long .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # 
Length
-; ASM-NEXT: .Ldebug_loclist_table_start0:
-; ASM-NEXT:  .short 5  # Version
-; ASM-NEXT:  .byte 8   # Address size
-; ASM-NEXT:  .byte 0   # Segment selector size
-; ASM-NEXT:  .long 0   # Offset entry count
-; ASM-NEXT: .Lloclists_table_base0:
-; ASM-NEXT: .Ldebug_loc0:
-; ASM-NEXT:  .byte 4   # DW_LLE_offset_pair
-; ASM-NEXT:  .uleb128 .Lfunc_begin0-.Lfunc_begin0  # starting offset
-; ASM-NEXT:  .uleb128 .Ltmp0-.Lfunc_begin0 # ending offset
-; ASM-NEXT:  .byte 2   # Loc expr size
-; ASM-NEXT:  .byte 117 # DW_OP_breg5
-; ASM-NEXT:  .byte 0   # 0
-; ASM-NEXT:  .byte 4   # DW_LLE_offset_pair
-; ASM-NEXT:  .uleb128 .Ltmp0-.Lfunc_begin0 # starting offset
-; ASM-NEXT:  .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset
-; ASM-NEXT:  .byte 2   # Loc expr size
-; ASM-NEXT:  .byte 115 # DW_OP_breg3
-; ASM-NEXT:  .byte 0   # 0
-; ASM-NEXT:  .byte 0   # DW_LLE_end_of_list
-; ASM-NEXT: .Ldebug_loclist_table_end0:
+; CHECK-NEXT:[DW_LLE_offset_pair ]: 0x, 0x0004 
=> [0x, 0x0004) DW_OP_breg5 RDI+0
+; CHECK-NEXT:[DW_LLE_offset_pair ]: 0x0004, 0x0012 
=> [0x0004, 0x0012) DW_OP_breg3 RBX+0

This tries to follow the RLE format as closely as possible, but I think 
something like
```
[DW_LLE_offset_pair,  0x, 0x0004] => 
[0x, 0x0004): DW_OP_breg5 RDI+0
```
would make more sense (both here and for RLE).



Comment at: test/DebugInfo/X86/fission-ranges.ll:48
 ; CHECK:  [[A]]:
-; CHECK-NEXT:   Addr idx 2 (w/ length 15): DW_OP_consts +0, DW_OP_stack_value
-; CHECK-NEXT

[Lldb-commits] [PATCH] D68464: [lldb][modern-type-lookup] Ask the ExternalASTMerger to lookup namespaces instead of using the old mechanism

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

With this patch LLDB starts querying the ExternalASTMerger when we look up a 
namespace in the translation unit context. Because
Clang's FindExternalVisibleDecls is returning a true/false on Lookup and LLDB 
instead uses a list of decls, this also adds some
glue code that passes this bool back to the caller when we have 
modern-type-lookup activated. We can't easily emulate
LLDB's API as Clang doesn't directly tell us what declarations it found in the 
DeclContext and querying the decl context for potential
declarations could have side-effects (like modifying the cached lookup in some 
way).

Note that this doesn't change any code for normal LLDB as we continue to ignore 
that return value in normal LLDB (mostly because
I don't know if there is a reason this was implemented this way).

The bigger change in ClangExpressionDeclMap.cpp is necessary as currently never 
query the ExternalASTSource when we don't
have a NamespaceMap (which we never have, as that's a non-modern-type-lookup 
thing). So instead we just ignore the NameSpaceMap
and continue to the actual ExternalASTSource in this case.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68464

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/namespace-lookup/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/namespace-lookup/TestNamespaceWithModernTypeLookup.py
  
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/namespace-lookup/main.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -279,7 +279,7 @@
   ///
   /// \return
   /// True on success; false otherwise.
-  void FindExternalVisibleDecls(NameSearchContext &context) override;
+  bool FindExternalVisibleDecls(NameSearchContext &context) override;
 
   /// Find all entities matching a given name in a given module/namespace,
   /// using a NameSearchContext to make Decls for them.
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -683,7 +683,7 @@
 
 // Interface for ClangASTSource
 
-void ClangExpressionDeclMap::FindExternalVisibleDecls(
+bool ClangExpressionDeclMap::FindExternalVisibleDecls(
 NameSearchContext &context) {
   assert(m_ast_context);
 
@@ -696,7 +696,7 @@
   if (GetImportInProgress()) {
 if (log && log->GetVerbose())
   LLDB_LOGF(log, "Ignoring a query during an import");
-return;
+return false;
   }
 
   static unsigned int invocation_id = 0;
@@ -732,32 +732,34 @@
 context.m_decl_context)));
   FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
current_id);
-  return;
+  return context.m_decls.size() != 0;
 }
 
-ClangASTImporter::NamespaceMapSP namespace_map =
-m_ast_importer_sp
-? m_ast_importer_sp->GetNamespaceMap(namespace_context)
-: ClangASTImporter::NamespaceMapSP();
+// Only do this when we have a ClangASTImporter.
+if (m_ast_importer_sp) {
+  ClangASTImporter::NamespaceMapSP namespace_map =
+  m_ast_importer_sp->GetNamespaceMap(namespace_context);
 
-if (!namespace_map)
-  return;
+  if (!namespace_map)
+return context.m_decls.size() != 0;
 
-if (log && log->GetVerbose())
-  log->Printf("  CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
-  current_id, static_cast(namespace_map.get()),
-  (int)namespace_map->size());
+  if (log && log->GetVerbose())
+log->Printf("  CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
+current_id, static_cast(namespace_map.get()),
+(int)namespace_map->size());
 
-for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
-  e = namespace_map->end();
- i != e; ++i) {
-  if (log)
-log->Printf("  CEDM::FEVD[%u] Searching namespace %s in module %s",
-current_id, i->second.GetName().AsCString(),
-i->first->GetFileSpec().GetFilename().Ge

[Lldb-commits] [PATCH] D68069: Explicitly set entry point arch when it's thumb

2019-10-04 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

Ok. Initially I thought that with the entry point we were making big 
assumptions there but after reading the parse unwind symbols I guess it's 
really no big difference. 
I guess my main concern is that the user can no longer create symbols within 
the span of the entry point symbol, even if they happen to know better (it's 
not even possible to manually remove symbols). But like you said, the same is 
true with the other synthetic symbols..


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68069



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


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

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

In D68188#1694276 , @labath wrote:

> Most of your interactions seem to be about calling methods. Would it be 
> possible to add a PythonDataObject wrapper for this (and any other frequently 
> used python API)? I'm hoping that we could have something like...


I think this is a good idea, but there's a //lot// of places in 
PythonDataObjects that need to be fixed to check for exceptions and return 
Expected<>. I really think it ought to be done in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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



Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:38
 
+template <> lldb::SBFile Deserializer::Deserialize() {
+//@JDevlieghere I'm pretty sure this is not the right thing to

labath wrote:
> lawrence_danna wrote:
> > @JDevlieghere advice please.
> This is not totally surprising as SBDebugger::SetInputFile ignores the input 
> SBFile when it's in replay mode. However, it still doesn't seem like the 
> right fix. I am guessing that something special needs to happen in the 
> record/replay logic of the SBFile constructor, but off-hand, it's not fully 
> clear to me what would that be.
> 
> I think ideally, we'd have the reproducer shadowing that's currently done in 
> SBDebugger::SetInputFileHandle kick in earlier (in the SBFile constructor) so 
> that it covers all SBFiles, and not just those that later become the debugger 
> input handles, but I don't think it should be on you to make all of that 
> work. Maybe the appropriate fix would be to just make sure the SBFile 
> constructor creates empty objects and acknowledge that reproducers won't work 
> for all SBFiles until someone actually implements the appropriate support for 
> them.
Thanks for the great explanation Pavel, I share your thoughts on this. So to 
make this work you'll want to remove the `LLDB_REGISTER_CONSTRUCTOR` for SBFile 
that take a file descriptor or a  `FILE*` (which looks like it's currently 
missing?) and have custom `doit` implementation  (similar to what I did in 
SBDebugger) that just returns and empty SBFile. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434



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


[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

2019-10-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM modulo the stream changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444



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


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

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

last nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68289

Files:
  lldb/source/Host/linux/Host.cpp

Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -144,68 +144,79 @@
   }
 }
 
-static bool GetProcessAndStatInfo(::pid_t pid,
-  ProcessInstanceInfo &process_info,
-  ProcessState &State, ::pid_t &tracerpid) {
-  tracerpid = 0;
-  process_info.Clear();
+static void GetProcessArgs(::pid_t pid, ProcessInstanceInfo &process_info) {
+  auto BufferOrError = getProcFile(pid, "cmdline");
+  if (!BufferOrError)
+return;
+  std::unique_ptr Cmdline = std::move(*BufferOrError);
 
+  llvm::StringRef Arg0, Rest;
+  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
+  process_info.SetArg0(Arg0);
+  while (!Rest.empty()) {
+llvm::StringRef Arg;
+std::tie(Arg, Rest) = Rest.split('\0');
+process_info.GetArguments().AppendArgument(Arg);
+  }
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  std::string ExePath(PATH_MAX, '\0');
 
   // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
   llvm::SmallString<64> ProcExe;
   (llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe);
-  std::string ExePath(PATH_MAX, '\0');
 
   ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
-  if (len <= 0) {
+  if (len > 0) {
+ExePath.resize(len);
+  } else {
 LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
  Status(errno, eErrorTypePOSIX));
-return false;
+ExePath.resize(0);
   }
-  ExePath.resize(len);
-
   // If the binary has been deleted, the link name has " (deleted)" appended.
   // Remove if there.
   llvm::StringRef PathRef = ExePath;
   PathRef.consume_back(" (deleted)");
 
-  process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  if (!PathRef.empty()) {
+process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
+process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  }
+}
 
+static void GetProcessEnviron(::pid_t pid, ProcessInstanceInfo &process_info) {
   // Get the process environment.
   auto BufferOrError = getProcFile(pid, "environ");
   if (!BufferOrError)
-return false;
+return;
+ 
   std::unique_ptr Environ = std::move(*BufferOrError);
-
-  // Get the command line used to start the process.
-  BufferOrError = getProcFile(pid, "cmdline");
-  if (!BufferOrError)
-return false;
-  std::unique_ptr Cmdline = std::move(*BufferOrError);
-
-  // Get User and Group IDs and get tracer pid.
-  if (!GetStatusInfo(pid, process_info, State, tracerpid))
-return false;
-
-  process_info.SetProcessID(pid);
-  process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
-
   llvm::StringRef Rest = Environ->getBuffer();
   while (!Rest.empty()) {
 llvm::StringRef Var;
 std::tie(Var, Rest) = Rest.split('\0');
 process_info.GetEnvironment().insert(Var);
   }
+}
 
-  llvm::StringRef Arg0;
-  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
-  process_info.SetArg0(Arg0);
-  while (!Rest.empty()) {
-llvm::StringRef Arg;
-std::tie(Arg, Rest) = Rest.split('\0');
-process_info.GetArguments().AppendArgument(Arg);
-  }
+static bool GetProcessAndStatInfo(::pid_t pid,
+  ProcessInstanceInfo &process_info,
+  ProcessState &State, ::pid_t &tracerpid) {
+  tracerpid = 0;
+  process_info.Clear();
+
+  process_info.SetProcessID(pid);
+
+  GetExePathAndArch(pid, process_info);
+  GetProcessArgs(pid, process_info);
+  GetProcessEnviron(pid, process_info);
+
+  // Get User and Group IDs and get tracer pid.
+  if (!GetStatusInfo(pid, process_info, State, tracerpid))
+return false;
 
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

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

minor fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.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/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
@@ -84,14 +84,19 @@
 
   PythonObject(const PythonObject &rhs) : m_py_obj(nullptr) { Reset(rhs); }
 
+  PythonObject(PythonObject &&rhs) {
+m_py_obj = rhs.m_py_obj;
+rhs.m_py_obj = nullptr;
+  }
+
   virtual ~PythonObject() { Reset(); }
 
   void Reset() {
 // Avoid calling the virtual method since it's not necessary
 // to actually validate the type of the PyObject if we're
 // just setting to null.
-if (Py_IsInitialized())
-  Py_XDECREF(m_py_obj);
+if (m_py_obj && Py_IsInitialized())
+  Py_DECREF(m_py_obj);
 m_py_obj = nullptr;
   }
 
@@ -123,7 +128,7 @@
 // an owned reference by incrementing it.  If it is an owned
 // reference (for example the caller allocated it with PyDict_New()
 // then we must *not* increment it.
-if (Py_IsInitialized() && type == PyRefType::Borrowed)
+if (m_py_obj && Py_IsInitialized() && type == PyRefType::Borrowed)
   Py_XINCREF(m_py_obj);
   }
 
@@ -467,8 +472,38 @@
   void Reset(File &file, const char *mode);
 
   lldb::FileUP GetUnderlyingFile() const;
+
+  llvm::Expected ConvertToFile(bool borrowed = false);
+  llvm::Expected
+  ConvertToFileForcingUseOfScriptingIOMethods(bool borrowed = false);
 };
 
+class PythonException : public llvm::ErrorInfo {
+private:
+  PyObject *m_exception_type, *m_exception, *m_traceback;
+  PyObject *m_repr_bytes;
+
+public:
+  static char ID;
+  const char *toCString() const;
+  PythonException(const char *caller);
+  void Restore();
+  ~PythonException();
+  void log(llvm::raw_ostream &OS) const override;
+  std::error_code convertToErrorCode() const override;
+};
+
+template  T unwrapOrSetPythonException(llvm::Expected expected) {
+  if (expected)
+return expected.get();
+  llvm::handleAllErrors(
+  expected.takeError(), [](PythonException &E) { E.Restore(); },
+  [](const llvm::ErrorInfoBase &E) {
+PyErr_SetString(PyExc_Exception, E.message().c_str());
+  });
+  return T();
+}
+
 } // namespace lldb_private
 
 #endif
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Host/File.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/ADT/StringSwitch.h"
@@ -33,6 +34,14 @@
   s.value(llvm::formatv("Python Obj: {0:X}", GetValue()).str());
 }
 
+template  static T Take(PyObject * obj) {
+return T(PyRefType::Owned, obj);
+}
+
+template  static T Retain(PyObject * obj) {
+  return T(PyRefType::Borrowed, obj);
+}
+
 // PythonObject
 
 void PythonObject::Dump(Stream &strm) const {
@@ -963,20 +972,19 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
+  // inherits from `io.IOBase`.
   PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
   PythonDictionary io_dict(PyRefType::Borrowed,
PyModule_GetDict(io_module.get()));
   PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
+  assert(!PyErr_Occurred());
 
   PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
 
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
-return false;
-  if (!object_type.HasAttribute("fileno"))
+  if (!PyObject_IsSubclass(object_type.get(), io_base_class.get())) {
+PyErr_Clear();
 return false;
+  }
 
   return true;
 #endif
@@ -1031,4 +1039,438 @@
   return file;
 }

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

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



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1369
+const char *utf8 = PyUnicode_AsUTF8AndSize(pystring.get(), &size);
+if (!utf8 || PyErr_Occurred())
+  return Status(llvm::make_error("Read"));

labath wrote:
> This is an example where _I think_ you may be using `PyErr_Occurred` 
> incorrectly. If python really asserts that PyErr_Occurred is always called, 
> then this is not right, as you will not call it if the result is null. There 
> are a couple of other examples like that in the code too.
I think it is correct.

Python doesn't assert that PyErr_Occured is called, it asserts that the error 
is cleared before you call back in to another thing that can cause an error.
PythonException will clear the error if there is one, or say "unknown error" if 
there isn't one (which should never happen if utf8==NULL, but i'm checking out 
of abundance of caution)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


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

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

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68289

Files:
  lldb/source/Host/linux/Host.cpp

Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -144,68 +144,79 @@
   }
 }
 
-static bool GetProcessAndStatInfo(::pid_t pid,
-  ProcessInstanceInfo &process_info,
-  ProcessState &State, ::pid_t &tracerpid) {
-  tracerpid = 0;
-  process_info.Clear();
+static void GetProcessArgs(::pid_t pid, ProcessInstanceInfo &process_info) {
+  auto BufferOrError = getProcFile(pid, "cmdline");
+  if (!BufferOrError)
+return;
+  std::unique_ptr Cmdline = std::move(*BufferOrError);
+
+  llvm::StringRef Arg0, Rest;
+  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
+  process_info.SetArg0(Arg0);
+  while (!Rest.empty()) {
+llvm::StringRef Arg;
+std::tie(Arg, Rest) = Rest.split('\0');
+process_info.GetArguments().AppendArgument(Arg);
+  }
+}
 
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  std::string ExePath(PATH_MAX, '\0');
 
   // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
   llvm::SmallString<64> ProcExe;
   (llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe);
-  std::string ExePath(PATH_MAX, '\0');
 
   ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
-  if (len <= 0) {
+  if (len > 0) {
+ExePath.resize(len);
+  } else {
 LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
  Status(errno, eErrorTypePOSIX));
-return false;
+ExePath.resize(0);
   }
-  ExePath.resize(len);
-
   // If the binary has been deleted, the link name has " (deleted)" appended.
   // Remove if there.
   llvm::StringRef PathRef = ExePath;
   PathRef.consume_back(" (deleted)");
 
-  process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  if (!PathRef.empty()) {
+process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
+process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  }
+}
 
+static void GetProcessEnviron(::pid_t pid, ProcessInstanceInfo &process_info) {
   // Get the process environment.
   auto BufferOrError = getProcFile(pid, "environ");
   if (!BufferOrError)
-return false;
-  std::unique_ptr Environ = std::move(*BufferOrError);
-
-  // Get the command line used to start the process.
-  BufferOrError = getProcFile(pid, "cmdline");
-  if (!BufferOrError)
-return false;
-  std::unique_ptr Cmdline = std::move(*BufferOrError);
-
-  // Get User and Group IDs and get tracer pid.
-  if (!GetStatusInfo(pid, process_info, State, tracerpid))
-return false;
-
-  process_info.SetProcessID(pid);
-  process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
+return;
 
+  std::unique_ptr Environ = std::move(*BufferOrError);
   llvm::StringRef Rest = Environ->getBuffer();
   while (!Rest.empty()) {
 llvm::StringRef Var;
 std::tie(Var, Rest) = Rest.split('\0');
 process_info.GetEnvironment().insert(Var);
   }
+}
 
-  llvm::StringRef Arg0;
-  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
-  process_info.SetArg0(Arg0);
-  while (!Rest.empty()) {
-llvm::StringRef Arg;
-std::tie(Arg, Rest) = Rest.split('\0');
-process_info.GetArguments().AppendArgument(Arg);
-  }
+static bool GetProcessAndStatInfo(::pid_t pid,
+  ProcessInstanceInfo &process_info,
+  ProcessState &State, ::pid_t &tracerpid) {
+  tracerpid = 0;
+  process_info.Clear();
+
+  process_info.SetProcessID(pid);
+
+  GetExePathAndArch(pid, process_info);
+  GetProcessArgs(pid, process_info);
+  GetProcessEnviron(pid, process_info);
+
+  // Get User and Group IDs and get tracer pid.
+  if (!GetStatusInfo(pid, process_info, State, tracerpid))
+return false;
 
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r373758 - [lldb-server/android] Show more processes and package name when necessary

2019-10-04 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct  4 09:35:59 2019
New Revision: 373758

URL: http://llvm.org/viewvc/llvm-project?rev=373758&view=rev
Log:
[lldb-server/android] Show more processes and package name when necessary

Summary:
By default `platform process list` only shows the processes of the current user 
that lldb-server can parse.
There are several problems:
- apk programs don't have an executable file. They instead use a package name 
as identifier.
- each apk also runs under a different user. That's how android works
- because of the user permission, some files like /proc//{environ,exe} 
can't be read.

This results in a very small process list.

This is a local run on my machine
```
(lldb) platform process list
2 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
23291  3177  aarch64-unknown-linux-android sh
23301  23291aarch64-unknown-linux-android lldb-server
```
However, I have 700 processes running at this time.

By implementing a few fallbacks for android, I've expanded this list to 202, 
filtering out kernel processes, which would presumably appear in this list if 
the device was rooted.

```
(lldb) platform process list
202 matching processes were found on "remote-android"
PIDPARENT USER   TRIPLE   NAME
== == ==  
...
12647  3208  aarch64-unknown-linux-android sh
12649  12647 aarch64-unknown-linux-android lldb-server
12653  982com.samsung.faceservice
13185  982com.samsung.vvm
15899  982com.samsung.android.spay
16220  982com.sec.spp.push
17126  982
com.sec.spp.push:RemoteDlcProcess
19772  983com.android.chrome
20209  982com.samsung.cmh:CMH
20380  982
com.google.android.inputmethod.latin
20879  982
com.samsung.android.oneconnect:Receiver
21212  983com.tencent.mm
24459  1 aarch64-unknown-linux-android wpa_supplicant
25974  982com.samsung.android.contacts
26293  982com.samsung.android.messaging
28714  982com.samsung.android.dialer
31605  982
com.samsung.android.MtpApplication
32256  982com.bezobidny
```

Something to notice is that the architecture is unkonwn for all apks. And 
that's fine, because run-as would be required to gather this information and 
that would make this entire functionality massively slow.

There are still several improvements to make here, like displaying actual user 
names, which I'll try to do in a following diff.

Note: Regarding overall apk debugging support from lldb. I'm planning on having 
lldb spawn lldb-server by itself with the correct user, so that everything 
works well. The initial lldb-server used for connecting to the remote platform 
can be reused for such purpose. Furthermore, eventually lldb could also launch 
that initial lldb-server on its own.

Reviewers: clayborg, aadsm, labath, xiaobai

Subscribers: srhines, krytarowski, kristof.beyls, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Host/linux/Host.cpp

Modified: lldb/trunk/source/Host/linux/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=373758&r1=373757&r2=373758&view=diff
==
--- lldb/trunk/source/Host/linux/Host.cpp (original)
+++ lldb/trunk/source/Host/linux/Host.cpp Fri Oct  4 09:35:59 2019
@@ -144,68 +144,79 @@ static ArchSpec GetELFProcessCPUType(llv
   }
 }
 
-static bool GetProcessAndStatInfo(::pid_t pid,
-  ProcessInstanceInfo &process_info,
-  ProcessState &State, ::pid_t &tracerpid) {
-  tracerpid = 0;
-  process_info.Clear();
+static void GetProcessArgs(::pid_t pid, ProcessInstanceInfo &process_info) {
+  auto BufferOrError = getProcFile(pid, "cmdline");
+  if (!BufferOrError)
+return;
+  std::unique_ptr Cmdline = std::move(*BufferOrError);
 
+  llvm::StringRef Arg0, Rest;
+  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
+  process_info.SetArg0(Arg0);
+  while (!Rest.empty()) {
+llvm::StringRef Arg;
+std::tie(Arg, Rest) = Rest.split('\0');
+process_info.GetArguments().AppendArgument(Arg);
+  }
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessIns

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

2019-10-04 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373758: [lldb-server/android] Show more processes and 
package name when necessary (authored by wallace, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68289?vs=223236&id=223237#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68289

Files:
  lldb/trunk/source/Host/linux/Host.cpp

Index: lldb/trunk/source/Host/linux/Host.cpp
===
--- lldb/trunk/source/Host/linux/Host.cpp
+++ lldb/trunk/source/Host/linux/Host.cpp
@@ -144,68 +144,79 @@
   }
 }
 
-static bool GetProcessAndStatInfo(::pid_t pid,
-  ProcessInstanceInfo &process_info,
-  ProcessState &State, ::pid_t &tracerpid) {
-  tracerpid = 0;
-  process_info.Clear();
+static void GetProcessArgs(::pid_t pid, ProcessInstanceInfo &process_info) {
+  auto BufferOrError = getProcFile(pid, "cmdline");
+  if (!BufferOrError)
+return;
+  std::unique_ptr Cmdline = std::move(*BufferOrError);
 
+  llvm::StringRef Arg0, Rest;
+  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
+  process_info.SetArg0(Arg0);
+  while (!Rest.empty()) {
+llvm::StringRef Arg;
+std::tie(Arg, Rest) = Rest.split('\0');
+process_info.GetArguments().AppendArgument(Arg);
+  }
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  std::string ExePath(PATH_MAX, '\0');
 
   // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
   llvm::SmallString<64> ProcExe;
   (llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe);
-  std::string ExePath(PATH_MAX, '\0');
 
   ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
-  if (len <= 0) {
+  if (len > 0) {
+ExePath.resize(len);
+  } else {
 LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
  Status(errno, eErrorTypePOSIX));
-return false;
+ExePath.resize(0);
   }
-  ExePath.resize(len);
-
   // If the binary has been deleted, the link name has " (deleted)" appended.
   // Remove if there.
   llvm::StringRef PathRef = ExePath;
   PathRef.consume_back(" (deleted)");
 
-  process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  if (!PathRef.empty()) {
+process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
+process_info.SetArchitecture(GetELFProcessCPUType(PathRef));
+  }
+}
 
+static void GetProcessEnviron(::pid_t pid, ProcessInstanceInfo &process_info) {
   // Get the process environment.
   auto BufferOrError = getProcFile(pid, "environ");
   if (!BufferOrError)
-return false;
+return;
+ 
   std::unique_ptr Environ = std::move(*BufferOrError);
-
-  // Get the command line used to start the process.
-  BufferOrError = getProcFile(pid, "cmdline");
-  if (!BufferOrError)
-return false;
-  std::unique_ptr Cmdline = std::move(*BufferOrError);
-
-  // Get User and Group IDs and get tracer pid.
-  if (!GetStatusInfo(pid, process_info, State, tracerpid))
-return false;
-
-  process_info.SetProcessID(pid);
-  process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
-
   llvm::StringRef Rest = Environ->getBuffer();
   while (!Rest.empty()) {
 llvm::StringRef Var;
 std::tie(Var, Rest) = Rest.split('\0');
 process_info.GetEnvironment().insert(Var);
   }
+}
 
-  llvm::StringRef Arg0;
-  std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
-  process_info.SetArg0(Arg0);
-  while (!Rest.empty()) {
-llvm::StringRef Arg;
-std::tie(Arg, Rest) = Rest.split('\0');
-process_info.GetArguments().AppendArgument(Arg);
-  }
+static bool GetProcessAndStatInfo(::pid_t pid,
+  ProcessInstanceInfo &process_info,
+  ProcessState &State, ::pid_t &tracerpid) {
+  tracerpid = 0;
+  process_info.Clear();
+
+  process_info.SetProcessID(pid);
+
+  GetExePathAndArch(pid, process_info);
+  GetProcessArgs(pid, process_info);
+  GetProcessEnviron(pid, process_info);
+
+  // Get User and Group IDs and get tracer pid.
+  if (!GetStatusInfo(pid, process_info, State, tracerpid))
+return false;
 
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68433: SBFile: add a bunch of tests that should eventually work.

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

use expectedFailure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68433

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig

Index: lldb/scripts/Python/python-typemaps.swig
===
--- lldb/scripts/Python/python-typemaps.swig
+++ lldb/scripts/Python/python-typemaps.swig
@@ -440,19 +440,19 @@
   $1 = nullptr;
else if (!lldb_private::PythonFile::Check($input)) {
   int fd = PyObject_AsFileDescriptor($input);
+  if (fd < 0 || PyErr_Occurred())
+return nullptr;
   PythonObject py_input(PyRefType::Borrowed, $input);
   PythonString py_mode = py_input.GetAttributeValue("mode").AsType();
-
-  if (-1 != fd && py_mode.IsValid()) {
- FILE *f;
- if ((f = fdopen(fd, py_mode.GetString().str().c_str(
-$1 = f;
- else
-PyErr_SetString(PyExc_TypeError, strerror(errno));
-  } else {
- PyErr_SetString(PyExc_TypeError,"not a file-like object");
- return nullptr;
-  }
+  if (!py_mode.IsValid() || PyErr_Occurred())
+return nullptr;
+FILE *f;
+if ((f = fdopen(fd, py_mode.GetString().str().c_str(
+  $1 = f;
+else {
+  PyErr_SetString(PyExc_TypeError, strerror(errno));
+  return nullptr;
+}
}
else
{
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
@@ -13,7 +13,7 @@
 import lldb
 from lldbsuite.test import  lldbtest
 from lldbsuite.test.decorators import (
-add_test_categories, skipIf, skipIfWindows)
+add_test_categories, skipIf, skipIfWindows, expectedFailure)
 
 class OhNoe(Exception):
 pass
@@ -180,6 +180,19 @@
 self.assertIn("is not a valid command", f.read())
 
 
+@add_test_categories(['pyapi'])
+def test_legacy_file_error(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+debugger.SetErrorFileHandle(f, False)
+self.handleCmd('lolwut', check=False, collect_result=False)
+debugger.GetErrorFileHandle().write('FOOBAR\n')
+with open(self.out_filename, 'r') as f:
+errors = f.read()
+self.assertTrue(re.search(r'error:.*lolwut', errors))
+self.assertTrue(re.search(r'FOOBAR', errors))
+
+
 @add_test_categories(['pyapi'])
 def test_sbfile_type_errors(self):
 sbf = lldb.SBFile()
@@ -269,6 +282,17 @@
 self.assertTrue(re.search(r'Show a list of all debugger commands', f.read()))
 
 
+@add_test_categories(['pyapi'])
+def test_help(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+status = debugger.SetOutputFile(lldb.SBFile(f))
+self.assertTrue(status.Success())
+self.handleCmd("help help", check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+self.assertIn('Show a list of all debugger commands', f.read())
+
+
 @add_test_categories(['pyapi'])
 def test_immediate(self):
 with open(self.out_filename, 'w') as f:
@@ -278,15 +302,44 @@
 interpreter.HandleCommand("help help", ret)
 # make sure the file wasn't closed early.
 f.write("\nQUUX\n")
-
 ret = None # call destructor and flush streams
-
 with open(self.out_filename, 'r') as f:
 output = f.read()
 self.assertTrue(re.search(r'Show a list of all debugger commands', output))
 self.assertTrue(re.search(r'QUUX', output))
 
 
+@add_test_categories(['pyapi'])
+@expectedFailure # FIXME need SBFile interfaces on SBCommandReturnObject
+def test_immediate_string(self):
+f = io.StringIO()
+ret = lldb.SBCommandReturnObject()
+ret.SetImmediateOutputFile(f)
+interpreter = self.debugger.GetCommandInterpreter()
+interpreter.HandleCommand("help help", ret)
+# make sure the file wasn't closed early.
+f.write("\nQUUX\n")
+ret = None # call destructor and flush streams
+output = f.getvalue()
+self.assertTrue(re.search(r'Show a list of all debugger commands', output))
+self.assertTrue(re.search(r'QUUX', output))
+
+
+@add_test_categories(['pyapi'])
+@expectedFailure # FIXME need SBFile interfaces on SBCommandReturnObject
+def test_immediate_sbfile_string(self):
+f = io.StringIO()
+ret = lldb.SBCommandReturnObject()
+

[Lldb-commits] [lldb] r373760 - [process info] Remove assert in DoGetGroupName

2019-10-04 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Fri Oct  4 09:56:23 2019
New Revision: 373760

URL: http://llvm.org/viewvc/llvm-project?rev=373760&view=rev
Log:
[process info] Remove assert in DoGetGroupName

Summary:
Disabling this assert prevents lldb-server from crashing, which prevents it 
from finding the user and group names of a given process list.

Before this change, the process list didn't contain names:

```
PIDPARENT USER   GROUP  EFF USER   EFF GROUP  TRIPLE
   ARGUMENTS
== == == == == == 
== 
27585  98210098  10098  10098  10098
 com.LogiaGroup.LogiaDeck
27623  98210098  10098  10098  10098
 com.digitalturbine.ignite.suspend.DataUsageRecorderService
28024  98210199  10199  10199  10199
 com.google.vr.vrcore
28061  98310353  10353  10353  10353
 com.instagram.android:videoplayer
28121  98210045  10045  10045  10045
 com.sec.spp.push
28325  98210247  10247  10247  10247
 com.facebook.orca
28714  98210367  10367  10367  10367
 com.samsung.android.dialer
29867  3208   2000   2000   2000   2000   
aarch64-unknown-linux-android  /system/bin/sh-c /data/local/tmp/lldb-server 
platform --listen *:5557 --server --log-file /data/local/tmp/logs 
--log-channels gdb-remote all --log-channels lldb all
```

After this change, the list looks much better

```
PIDPARENT USER   GROUP  EFF USER   EFF GROUP  TRIPLE
   ARGUMENTS
== == == == == == 
== 
24459  1  wifi   1010   wifi   1010   
aarch64-unknown-linux-android  
/vendor/bin/hw/wpa_supplicant-O/data/vendor/wifi/wpa/sockets 
-puse_p2p_group_interface=1 -g@android:wpa_wlan0
25098  982u0_a42 10042  u0_a42 10042
 com.samsung.android.messaging
25442  982u0_a65 10065  u0_a65 10065
 com.samsung.android.mobileservice
25974  982u0_a9  10009  u0_a9  10009
 com.samsung.android.contacts
26377  982radio  1001   radio  1001 
 com.samsung.android.incallui
26390  983u0_a26 10026  u0_a26 10026
 com.samsung.android.game.gametools
26876  983u0_a30610306  u0_a30610306
 com.tencent.mm:push
```

Reviewers: clayborg,aadsm,xiaobai,labath

Subscribers:

Modified:
lldb/trunk/source/Host/posix/HostInfoPosix.cpp

Modified: lldb/trunk/source/Host/posix/HostInfoPosix.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=373760&r1=373759&r2=373760&view=diff
==
--- lldb/trunk/source/Host/posix/HostInfoPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp Fri Oct  4 09:56:23 2019
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "lldb/Host/posix/HostInfoPosix.h"
-#include "lldb/Utility/UserIDResolver.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/UserIDResolver.h"
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
@@ -103,8 +103,6 @@ llvm::Optional PosixUserIDR
 if (group_info_ptr)
   return std::string(group_info_ptr->gr_name);
   }
-#else
-  assert(false && "getgrgid_r() not supported on Android");
 #endif
   return llvm::None;
 }


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


[Lldb-commits] [PATCH] D68314: [process info] Remove assert in DoGetGroupName

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

This has been committed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68314



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


[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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

a different deserializer fix for SBFile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434

Files:
  lldb/include/lldb/API/SBCommandReturnObject.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/Interpreter/CommandReturnObject.h
  lldb/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBCommandReturnObject.i
  lldb/source/API/SBCommandReturnObject.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -11,6 +11,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBReproducer.h"
@@ -499,16 +500,16 @@
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInHomeDirectory(result);
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
   // warning and instructions to load local lldbinit files.
   sb_interpreter.SourceInitFileInCurrentWorkingDirectory(result);
-  result.PutError(m_debugger.GetErrorFileHandle());
-  result.PutOutput(m_debugger.GetOutputFileHandle());
+  result.PutError(m_debugger.GetErrorFile());
+  result.PutOutput(m_debugger.GetOutputFile());
 
   // We allow the user to specify an exit code when calling quit which we will
   // return when exiting.
@@ -574,8 +575,8 @@
   }
 
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   const bool handle_events = true;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -893,8 +893,9 @@
   ::setbuf(outfile_handle, nullptr);
 
 result->SetImmediateOutputFile(
-debugger.GetOutputFile().GetStream());
-result->SetImmediateErrorFile(debugger.GetErrorFile().GetStream());
+debugger.GetOutputStream().GetFileSP());
+result->SetImmediateErrorFile(
+debugger.GetErrorStream().GetFileSP());
   }
 }
   }
Index: lldb/source/API/SBFile.cpp
===
--- lldb/source/API/SBFile.cpp
+++ lldb/source/API/SBFile.cpp
@@ -23,6 +23,7 @@
 SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
 
 SBFile::SBFile(FILE *file, bool transfer_ownership) {
+  LLDB_RECORD_CONSTRUCTOR(SBFile, (FILE *, bool), file, transfer_ownership);
   m_opaque_sp = std::make_shared(file, transfer_ownership);
 }
 
@@ -102,11 +103,21 @@
   return LLDB_RECORD_RESULT(!IsValid());
 }
 
+static SBFile *dummy() { return new SBFile(); }
+static SBFile *dummy(int, const char *, bool) { return new SBFile(); }
+static SBFile *dummy(FILE *, bool) { return new SBFile(); }
+
 namespace lldb_private {
 namespace repro {
+
 template <> void RegisterMethods(Registry &R) {
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, ());
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool));
+
+  R.Register(&dummy, "", "SBFile", "SBFile", "()");
+  R.Register(&dummy, "", "SBFile", "SBFile",
+"(int, const char *, bool)");
+  R.Register(&dummy, "", "SBFile", "SBFile",
+ "(FILE*, bool)");
+
   LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -468,9 +468,9 @@
 sb_interpreter.HandleCommand(command, result, false);
 
 if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFileHandle());

[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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



Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:38
 
+template <> lldb::SBFile Deserializer::Deserialize() {
+//@JDevlieghere I'm pretty sure this is not the right thing to

JDevlieghere wrote:
> labath wrote:
> > lawrence_danna wrote:
> > > @JDevlieghere advice please.
> > This is not totally surprising as SBDebugger::SetInputFile ignores the 
> > input SBFile when it's in replay mode. However, it still doesn't seem like 
> > the right fix. I am guessing that something special needs to happen in the 
> > record/replay logic of the SBFile constructor, but off-hand, it's not fully 
> > clear to me what would that be.
> > 
> > I think ideally, we'd have the reproducer shadowing that's currently done 
> > in SBDebugger::SetInputFileHandle kick in earlier (in the SBFile 
> > constructor) so that it covers all SBFiles, and not just those that later 
> > become the debugger input handles, but I don't think it should be on you to 
> > make all of that work. Maybe the appropriate fix would be to just make sure 
> > the SBFile constructor creates empty objects and acknowledge that 
> > reproducers won't work for all SBFiles until someone actually implements 
> > the appropriate support for them.
> Thanks for the great explanation Pavel, I share your thoughts on this. So to 
> make this work you'll want to remove the `LLDB_REGISTER_CONSTRUCTOR` for 
> SBFile that take a file descriptor or a  `FILE*` (which looks like it's 
> currently missing?) and have custom `doit` implementation  (similar to what I 
> did in SBDebugger) that just returns and empty SBFile. 
custom doits for the constructor aren't enough.   That won't stop the 
serializer from using reinterpret_cast on SBFiles that are passed by value to 
other recorder-instrumented functions.   I've updated the patch with a somewhat 
more reasonable solution that doesn't mess up the library dependencies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434



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


[Lldb-commits] [PATCH] D68370: Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS

2019-10-04 Thread António Afonso via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373768: Componentize lldb/scripts to use with 
LLVM_DISTRIBUTION_COMPONENTS (authored by aadsm, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68370?vs=223094&id=223251#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68370

Files:
  lldb/trunk/scripts/CMakeLists.txt


Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -69,5 +69,14 @@
 OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/
+DESTINATION ${SWIG_INSTALL_DIR}
+COMPONENT lldb-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
+  endif()
 endif()


Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -69,5 +69,14 @@
 OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/
+DESTINATION ${SWIG_INSTALL_DIR}
+COMPONENT lldb-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
+  endif()
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

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

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444



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


[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

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

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444

Files:
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -328,10 +328,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -490,10 +489,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + 
(uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -328,10 +328,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -490,10 +489,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());
___
lldb-commits mailing list
lldb-commits

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

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

I agree about the separate patch stuff, but it seems to be that this should be 
done before this one. After all, all (most?) of the existing code has already 
been DataObject-ized and this patch is the thing that's deviating from that 
practice. I don't think you should rewrite all of the existing code -- 
hopefully we can find a way to fit this in there. For instance, the CallMethod 
thingy would be a new api, so we can have that return expected independently of 
the other APIs. I guess the main part you will need is (and that already 
existing in the non-Expected form) is the type conversions, but maybe there we 
can introduce a new kind of conversion, which is more strict in checking for 
errors. Or possibly have the current form return Expected, but then have a 
helper function to suppress those errors and return a default-constructed T() 
for legacy uses (so legacy code would be sth like 
`suppressError(object.AsType())`)




Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1369
+const char *utf8 = PyUnicode_AsUTF8AndSize(pystring.get(), &size);
+if (!utf8 || PyErr_Occurred())
+  return Status(llvm::make_error("Read"));

lawrence_danna wrote:
> labath wrote:
> > This is an example where _I think_ you may be using `PyErr_Occurred` 
> > incorrectly. If python really asserts that PyErr_Occurred is always called, 
> > then this is not right, as you will not call it if the result is null. 
> > There are a couple of other examples like that in the code too.
> I think it is correct.
> 
> Python doesn't assert that PyErr_Occured is called, it asserts that the error 
> is cleared before you call back in to another thing that can cause an error.  
>   PythonException will clear the error if there is one, or say "unknown 
> error" if there isn't one (which should never happen if utf8==NULL, but i'm 
> checking out of abundance of caution)
> 
> 
Ok, thanks for the explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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



Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:38
 
+template <> lldb::SBFile Deserializer::Deserialize() {
+//@JDevlieghere I'm pretty sure this is not the right thing to

lawrence_danna wrote:
> JDevlieghere wrote:
> > labath wrote:
> > > lawrence_danna wrote:
> > > > @JDevlieghere advice please.
> > > This is not totally surprising as SBDebugger::SetInputFile ignores the 
> > > input SBFile when it's in replay mode. However, it still doesn't seem 
> > > like the right fix. I am guessing that something special needs to happen 
> > > in the record/replay logic of the SBFile constructor, but off-hand, it's 
> > > not fully clear to me what would that be.
> > > 
> > > I think ideally, we'd have the reproducer shadowing that's currently done 
> > > in SBDebugger::SetInputFileHandle kick in earlier (in the SBFile 
> > > constructor) so that it covers all SBFiles, and not just those that later 
> > > become the debugger input handles, but I don't think it should be on you 
> > > to make all of that work. Maybe the appropriate fix would be to just make 
> > > sure the SBFile constructor creates empty objects and acknowledge that 
> > > reproducers won't work for all SBFiles until someone actually implements 
> > > the appropriate support for them.
> > Thanks for the great explanation Pavel, I share your thoughts on this. So 
> > to make this work you'll want to remove the `LLDB_REGISTER_CONSTRUCTOR` for 
> > SBFile that take a file descriptor or a  `FILE*` (which looks like it's 
> > currently missing?) and have custom `doit` implementation  (similar to what 
> > I did in SBDebugger) that just returns and empty SBFile. 
> custom doits for the constructor aren't enough.   That won't stop the 
> serializer from using reinterpret_cast on SBFiles that are passed by value to 
> other recorder-instrumented functions.   I've updated the patch with a 
> somewhat more reasonable solution that doesn't mess up the library 
> dependencies.
> That won't stop the serializer from using reinterpret_cast on SBFiles that 
> are passed by value to other recorder-instrumented functions.

I find that surprising. At this level, what makes SBFile different from any 
other SB class that is passed around by value? I'd expect that the reproducer 
should be able to copy the (empty) SBFile object just like every other class 
(once we actually get it to construct an empty SBFile from a FileSP)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434



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


[Lldb-commits] [lldb] r361898 - Fix IPv6 support on lldb-server platform

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue May 28 16:26:32 2019
New Revision: 361898

URL: http://llvm.org/viewvc/llvm-project?rev=361898&view=rev
Log:
Fix IPv6 support on lldb-server platform

Summary:
This is a general fix for the ConnectionFileDescriptor class but my main 
motivation was to make lldb-server working with IPv6.
The connect URI can use square brackets ([]) to wrap the interface part of the 
URI (e.g.: ://[]:). For IPv6 addresses this is a must 
since its ip can include colons and it will overlap with the port colon 
otherwise. The URIParser class parses the square brackets correctly but the 
ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it 
impossible to connect to the gdb server when using this protocol.

How to reproduce the issue:
```
$ lldb-server p --server --listen [::1]:8080
...
$ lldb
(lldb) platform select remote-macosx
(lldb) platform connect connect://[::1]:8080
(lldb) platform process -p 
error: unable to launch a GDB server on 'computer'
```

The server was actually launched we were just not able to connect to it. With 
this fix lldb will correctly connect. I fixed this by wrapping the ip portion 
with [].

Reviewers: labath

Reviewed By: labath

Subscribers: xiaobai, mgorny, jfb, lldb-commits, labath

Tags: #lldb

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

Added:
lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp
lldb/trunk/unittests/Host/SocketTestUtilities.cpp
lldb/trunk/unittests/Host/SocketTestUtilities.h
Modified:
lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/trunk/unittests/Host/CMakeLists.txt
lldb/trunk/unittests/Host/SocketTest.cpp

Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp?rev=361898&r1=361897&r2=361898&view=diff
==
--- lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp Tue May 28 
16:26:32 2019
@@ -764,7 +764,7 @@ void ConnectionFileDescriptor::Initializ
   m_write_sp.reset(socket);
   m_read_sp = m_write_sp;
   StreamString strm;
-  strm.Printf("connect://%s:%u", tcp_socket->GetRemoteIPAddress().c_str(),
+  strm.Printf("connect://[%s]:%u", tcp_socket->GetRemoteIPAddress().c_str(),
   tcp_socket->GetRemotePortNumber());
   m_uri = strm.GetString();
 }

Modified: lldb/trunk/unittests/Host/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=361898&r1=361897&r2=361898&view=diff
==
--- lldb/trunk/unittests/Host/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Host/CMakeLists.txt Tue May 28 16:26:32 2019
@@ -1,4 +1,5 @@
 set (FILES
+  ConnectionFileDescriptorTest.cpp
   FileActionTest.cpp
   FileSystemTest.cpp
   HostInfoTest.cpp
@@ -8,6 +9,7 @@ set (FILES
   ProcessLaunchInfoTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
+  SocketTestUtilities.cpp
   TaskPoolTest.cpp
 )
 

Added: lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp?rev=361898&view=auto
==
--- lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp (added)
+++ lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp Tue May 28 
16:26:32 2019
@@ -0,0 +1,50 @@
+//===-- ConnectionFileDescriptorTest.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 "SocketTestUtilities.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
+#include "lldb/Utility/UriParser.h"
+
+using namespace lldb_private;
+
+class ConnectionFileDescriptorTest : public testing::Test {
+public:
+  void SetUp() override {
+ASSERT_THAT_ERROR(Socket::Initialize(), llvm::Succeeded());
+  }
+
+  void TearDown() override { Socket::Terminate(); }
+
+  void TestGetURI(std::string ip) {
+std::unique_ptr socket_a_up;
+std::unique_ptr socket_b_up;
+if (!IsAddressFamilySupported(ip)) {
+  GTEST_LOG_(WARNING) << "Skipping test due to missing IPv"
+  << (IsIPv4(ip) ? "4" : "6") << " support.";
+  return;
+}
+CreateTCPConnectedSockets(ip, &socket_a_up, &socket_b_up);
+auto socket = socket_a_up.release();
+ConnectionFileDescriptor connection_file_descriptor(socket);
+
+llvm::StringRef scheme;
+llvm::StringRef hostname;
+int port;
+llvm::StringRef pat

[Lldb-commits] [lldb] r351504 - Use llvm::VersionTuple instead of manual version marshalling

2019-10-04 Thread Brad Smith via lldb-commits
Author: brad
Date: Thu Jan 17 17:36:58 2019
New Revision: 351504

URL: http://llvm.org/viewvc/llvm-project?rev=351504&view=rev
Log:
Use llvm::VersionTuple instead of manual version marshalling

Modified:
lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h
lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp

Modified: lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h?rev=351504&r1=351503&r2=351504&view=diff
==
--- lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h (original)
+++ lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h Thu Jan 17 17:36:58 
2019
@@ -12,12 +12,13 @@
 
 #include "lldb/Host/posix/HostInfoPosix.h"
 #include "lldb/Utility/FileSpec.h"
+#include "llvm/Support/VersionTuple.h"
 
 namespace lldb_private {
 
 class HostInfoOpenBSD : public HostInfoPosix {
 public:
-  static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+  static llvm::VersionTuple GetOSVersion();
   static bool GetOSBuildString(std::string &s);
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();

Modified: lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp?rev=351504&r1=351503&r2=351504&view=diff
==
--- lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp (original)
+++ lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp Thu Jan 17 17:36:58 2019
@@ -17,16 +17,17 @@
 
 using namespace lldb_private;
 
-bool HostInfoOpenBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
-   uint32_t &update) {
+llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
   struct utsname un;
 
   ::memset(&un, 0, sizeof(utsname));
   if (uname(&un) < 0)
-return false;
+return llvm::VersionTuple();
 
-  int status = sscanf(un.release, "%u.%u", &major, &minor);
-  return status == 2;
+  unsigned major, minor;
+  if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+return llvm::VersionTuple(major, minor);
+  return llvm::VersionTuple();
 }
 
 bool HostInfoOpenBSD::GetOSBuildString(std::string &s) {


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


[Lldb-commits] [lldb] r361295 - Fix LLDB warnings when compiling with Clang 8.0

2019-10-04 Thread Alexandre Ganea via lldb-commits
Author: aganea
Date: Tue May 21 12:35:06 2019
New Revision: 361295

URL: http://llvm.org/viewvc/llvm-project?rev=361295&view=rev
Log:
Fix LLDB warnings when compiling with Clang 8.0

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

Modified:
lldb/trunk/source/Host/common/GetOptInc.cpp
lldb/trunk/source/Host/common/MainLoop.cpp
lldb/trunk/source/Host/common/Socket.cpp
lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp
lldb/trunk/source/Host/windows/Windows.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Modified: lldb/trunk/source/Host/common/GetOptInc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/GetOptInc.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Host/common/GetOptInc.cpp (original)
+++ lldb/trunk/source/Host/common/GetOptInc.cpp Tue May 21 12:35:06 2019
@@ -97,9 +97,9 @@ static void permute_args(int panonopt_st
 pos += nopts;
   swap = nargv[pos];
   /* LINTED const cast */
-  ((char **)nargv)[pos] = nargv[cstart];
+  const_cast(nargv)[pos] = nargv[cstart];
   /* LINTED const cast */
-  ((char **)nargv)[cstart] = swap;
+  const_cast(nargv)[cstart] = swap;
 }
   }
 }

Modified: lldb/trunk/source/Host/common/MainLoop.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MainLoop.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Host/common/MainLoop.cpp (original)
+++ lldb/trunk/source/Host/common/MainLoop.cpp Tue May 21 12:35:06 2019
@@ -61,10 +61,12 @@ using namespace lldb_private;
 
 static sig_atomic_t g_signal_flags[NSIG];
 
+#ifndef SIGNAL_POLLING_UNSUPPORTED
 static void SignalHandler(int signo, siginfo_t *info, void *) {
   assert(signo < NSIG);
   g_signal_flags[signo] = 1;
 }
+#endif
 
 class MainLoop::RunImpl {
 public:

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Tue May 21 12:35:06 2019
@@ -394,8 +394,8 @@ Status Socket::Close() {
 
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
   if (log)
-log->Printf("%p Socket::Close (fd = %i)", static_cast(this),
-m_socket);
+log->Printf("%p Socket::Close (fd = %" PRIu64 ")",
+static_cast(this), static_cast(m_socket));
 
 #if defined(_WIN32)
   bool success = !!closesocket(m_socket);

Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Tue May 21 
12:35:06 2019
@@ -30,8 +30,9 @@ void CreateEnvironmentBuffer(const Envir
   for (const auto &KV : env) {
 std::wstring warg;
 if (llvm::ConvertUTF8toWide(Environment::compose(KV), warg)) {
-  buffer.insert(buffer.end(), (char *)warg.c_str(),
-(char *)(warg.c_str() + warg.size() + 1));
+  buffer.insert(
+  buffer.end(), reinterpret_cast(warg.c_str()),
+  reinterpret_cast(warg.c_str() + warg.size() + 1));
 }
   }
   // One null wchar_t (to end the block) is two null bytes

Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Tue May 21 12:35:06 2019
@@ -84,7 +84,7 @@ char *strcasestr(const char *s, const ch
 } while (strncasecmp(s, find, len) != 0);
 s--;
   }
-  return ((char *)s);
+  return const_cast(s);
 }
 
 char *realpath(const char *name, char *resolved) {

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=361295&r1=361294&r2=361295&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common

[Lldb-commits] [lldb] r343810 - The Python 3 part of the script was missed when adding OpenBSD support.

2019-10-04 Thread Brad Smith via lldb-commits
Author: brad
Date: Thu Oct  4 13:34:58 2018
New Revision: 343810

URL: http://llvm.org/viewvc/llvm-project?rev=343810&view=rev
Log:
The Python 3 part of the script was missed when adding OpenBSD support.

Modified:
lldb/trunk/scripts/utilsOsType.py

Modified: lldb/trunk/scripts/utilsOsType.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/utilsOsType.py?rev=343810&r1=343809&r2=343810&view=diff
==
--- lldb/trunk/scripts/utilsOsType.py (original)
+++ lldb/trunk/scripts/utilsOsType.py Thu Oct  4 13:34:58 2018
@@ -35,8 +35,9 @@ if sys.version_info.major >= 3:
 FreeBSD = 2
 Linux = 3
 NetBSD = 4
-Windows = 5
-kFreeBSD = 6
+OpenBSD = 5
+Windows = 6
+kFreeBSD = 7
 else:
 class EnumOsType(object):
 values = ["Unknown",


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


[Lldb-commits] [lldb] r361531 - Test commit access by removing a empty line

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu May 23 11:35:54 2019
New Revision: 361531

URL: http://llvm.org/viewvc/llvm-project?rev=361531&view=rev
Log:
Test commit access by removing a empty line

Modified:
lldb/trunk/source/Core/ModuleList.cpp

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=361531&r1=361530&r2=361531&view=diff
==
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Thu May 23 11:35:54 2019
@@ -114,7 +114,6 @@ bool ModuleListProperties::SetClangModul
   nullptr, ePropertyClangModulesCachePath, path);
 }
 
-
 ModuleList::ModuleList()
 : m_modules(), m_modules_mutex(), m_notifier(nullptr) {}
 


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


[Lldb-commits] [lldb] r359966 - [lldb] Fix buildbot failure due to clang AST change.

2019-10-04 Thread Nicolas Lesser via lldb-commits
Author: rakete
Date: Sat May  4 03:21:50 2019
New Revision: 359966

URL: http://llvm.org/viewvc/llvm-project?rev=359966&view=rev
Log:
[lldb] Fix buildbot failure due to clang AST change.

In r359949 several AST node constructors were modified without the
corresponding change in lldb, which caused build failures.

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=359966&r1=359965&r2=359966&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sat May  4 03:21:50 2019
@@ -8167,6 +8167,10 @@ clang::CXXMethodDecl *ClangASTContext::A
   if (is_artificial)
 return nullptr; // skip everything artificial
 
+  const clang::ExplicitSpecifier explicit_spec(
+  nullptr /*expr*/, is_explicit
+? clang::ExplicitSpecKind::ResolvedTrue
+: clang::ExplicitSpecKind::ResolvedFalse);
   if (name[0] == '~') {
 cxx_dtor_decl = clang::CXXDestructorDecl::Create(
 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
@@ -8185,7 +8189,7 @@ clang::CXXMethodDecl *ClangASTContext::A
 clang::SourceLocation()),
 method_qual_type,
 nullptr, // TypeSourceInfo *
-is_explicit, is_inline, is_artificial, false /*is_constexpr*/);
+explicit_spec, is_inline, is_artificial, false /*is_constexpr*/);
 cxx_method_decl = cxx_ctor_decl;
   } else {
 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
@@ -8220,7 +8224,7 @@ clang::CXXMethodDecl *ClangASTContext::A
 clang::SourceLocation()),
 method_qual_type,
 nullptr, // TypeSourceInfo *
-is_inline, is_explicit, false /*is_constexpr*/,
+is_inline, explicit_spec, false /*is_constexpr*/,
 clang::SourceLocation());
   }
 }


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


[Lldb-commits] [lldb] r362173 - Make ConnectionFileDescription work with all sockets

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu May 30 16:30:35 2019
New Revision: 362173

URL: http://llvm.org/viewvc/llvm-project?rev=362173&view=rev
Log:
Make ConnectionFileDescription work with all sockets

Summary:
My main goal here is to make lldb-server work with Android Studio.

This is currently not the case because lldb-server is started in platform mode 
listening on a domain socket. When Android Studio connects to it lldb-server 
crashes because even though it's listening on a domain socket as soon as it 
gets a connection it asserts that it's a TCP connection, which will obviously 
fails for any non-tcp connection.

To do this I came up with a new method called GetConnectURI() in Socket that 
returns the URI needed to connect to the connected portion of the socket.

Reviewers: labath, clayborg, xiaobai

Reviewed By: labath

Subscribers: mgorny, jfb, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Host/Socket.h
lldb/trunk/include/lldb/Host/common/TCPSocket.h
lldb/trunk/include/lldb/Host/common/UDPSocket.h
lldb/trunk/include/lldb/Host/posix/DomainSocket.h
lldb/trunk/source/Host/common/TCPSocket.cpp
lldb/trunk/source/Host/common/UDPSocket.cpp
lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/trunk/source/Host/posix/DomainSocket.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/trunk/unittests/Host/SocketTest.cpp

Modified: lldb/trunk/include/lldb/Host/Socket.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Socket.h?rev=362173&r1=362172&r2=362173&view=diff
==
--- lldb/trunk/include/lldb/Host/Socket.h (original)
+++ lldb/trunk/include/lldb/Host/Socket.h Thu May 30 16:30:35 2019
@@ -102,6 +102,9 @@ public:
 std::string &host_str, std::string &port_str,
 int32_t &port, Status *error_ptr);
 
+  // If this Socket is connected then return the URI used to connect.
+  virtual std::string GetRemoteConnectionURI() const { return ""; };
+
 protected:
   Socket(SocketProtocol protocol, bool should_close,
  bool m_child_process_inherit);

Modified: lldb/trunk/include/lldb/Host/common/TCPSocket.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/TCPSocket.h?rev=362173&r1=362172&r2=362173&view=diff
==
--- lldb/trunk/include/lldb/Host/common/TCPSocket.h (original)
+++ lldb/trunk/include/lldb/Host/common/TCPSocket.h Thu May 30 16:30:35 2019
@@ -46,6 +46,8 @@ public:
 
   bool IsValid() const override;
 
+  std::string GetRemoteConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 

Modified: lldb/trunk/include/lldb/Host/common/UDPSocket.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/UDPSocket.h?rev=362173&r1=362172&r2=362173&view=diff
==
--- lldb/trunk/include/lldb/Host/common/UDPSocket.h (original)
+++ lldb/trunk/include/lldb/Host/common/UDPSocket.h Thu May 30 16:30:35 2019
@@ -19,6 +19,8 @@ public:
   static Status Connect(llvm::StringRef name, bool child_processes_inherit,
 Socket *&socket);
 
+  std::string GetRemoteConnectionURI() const override;
+
 private:
   UDPSocket(NativeSocket socket);
 

Modified: lldb/trunk/include/lldb/Host/posix/DomainSocket.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/DomainSocket.h?rev=362173&r1=362172&r2=362173&view=diff
==
--- lldb/trunk/include/lldb/Host/posix/DomainSocket.h (original)
+++ lldb/trunk/include/lldb/Host/posix/DomainSocket.h Thu May 30 16:30:35 2019
@@ -20,11 +20,14 @@ public:
   Status Listen(llvm::StringRef name, int backlog) override;
   Status Accept(Socket *&socket) override;
 
+  std::string GetRemoteConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol, bool child_processes_inherit);
 
   virtual size_t GetNameOffset() const;
   virtual void DeleteSocketFile(llvm::StringRef name);
+  std::string GetSocketName() const;
 
 private:
   DomainSocket(NativeSocket socket, const DomainSocket &listen_socket);

Modified: lldb/trunk/source/Host/common/TCPSocket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=362173&r1=362172&r2=362173&view=diff
==
--- lldb/trunk/source/Host/common/TCPSocket.cpp (original)
+++ lldb/trunk/source/Host/common/TCPSocket.cpp Thu May 30 16:30:35 2019
@@ -118,6 +118,14 @@ std::string TCPSocket::GetRemoteIPAddres
   return "";
 }
 
+std::string TCPSocket::GetRemoteConnectionURI(

[Lldb-commits] [lldb] r362619 - [DynamicLoader] Make sure we always set the rendezvous breakpoint

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Wed Jun  5 09:22:33 2019
New Revision: 362619

URL: http://llvm.org/viewvc/llvm-project?rev=362619&view=rev
Log:
[DynamicLoader] Make sure we always set the rendezvous breakpoint

Summary:
Once we've attached to the process we load all current modules and also set a 
breakpoint at the rendezvous break address.
However, we don't do this if we already have a load address for the image info 
address (e.g.: DT_DEBUG on ELF). This code was added 4 years ago when adding 
support for `$qXfer:Libraries:` packet (https://reviews.llvm.org/D9471) but its 
intention is not 100% clear to me. It seems to me we're using that check to 
know if the modules have already been loaded (which they have if 
`$qXfer:Libraries:` is supported by the gdb server) and skip loading the 
modules again in the following `if` block. The problem is that we also skip 
setting the Rendezvous breakpoint so we stop knowing when the process loads new 
modules.
I fix this by moving the call to set the breakpoint to the end of the function 
so we always call it as long as we have a valid executable.

Reviewers: ADodds, clayborg, eugene, labath

Reviewed By: eugene, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Modified: 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=362619&r1=362618&r2=362619&view=diff
==
--- 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
Wed Jun  5 09:22:33 2019
@@ -150,11 +150,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach()
  true);
 
 LoadAllCurrentModules();
-if (!SetRendezvousBreakpoint()) {
-  // If we cannot establish rendezvous breakpoint right now we'll try again
-  // at entry point.
-  ProbeEntry();
-}
 
 m_process->GetTarget().ModulesDidLoad(module_list);
 if (log) {
@@ -169,6 +164,14 @@ void DynamicLoaderPOSIXDYLD::DidAttach()
   }
 }
   }
+
+  if (executable_sp.get()) {
+if (!SetRendezvousBreakpoint()) {
+  // If we cannot establish rendezvous breakpoint right now we'll try again
+  // at entry point.
+  ProbeEntry();
+}
+  }
 }
 
 void DynamicLoaderPOSIXDYLD::DidLaunch() {


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


[Lldb-commits] [lldb] r362107 - Remove length modifier when using assignment suppression in TimerTest

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu May 30 08:38:05 2019
New Revision: 362107

URL: http://llvm.org/viewvc/llvm-project?rev=362107&view=rev
Log:
Remove length modifier when using assignment suppression in TimerTest

Summary:
This is useless and it's giving warnings in the build bots:
/home/motus/netbsd8/netbsd8/llvm/tools/lldb/unittests/Utility/TimerTest.cpp:67:43:
 warning: use of assignment suppression and length modifier together in 
gnu_scanf format [-Wformat=]

Reviewers: xiaobai

Subscribers: krytarowski, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/unittests/Utility/TimerTest.cpp

Modified: lldb/trunk/unittests/Utility/TimerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/TimerTest.cpp?rev=362107&r1=362106&r2=362107&view=diff
==
--- lldb/trunk/unittests/Utility/TimerTest.cpp (original)
+++ lldb/trunk/unittests/Utility/TimerTest.cpp Thu May 30 08:38:05 2019
@@ -62,7 +62,7 @@ TEST(TimerTest, CategoryTimes2) {
   Timer::DumpCategoryTimes(&ss);
   double seconds1, seconds2;
   ASSERT_EQ(2, sscanf(ss.GetData(),
-  "%lf sec (total: %*lfs; child: %*lfs; count: %*d) for "
+  "%lf sec (total: %*fs; child: %*fs; count: %*d) for "
   "CAT1%*[\n ]%lf sec for CAT2",
   &seconds1, &seconds2))
   << "String: " << ss.GetData();
@@ -98,7 +98,7 @@ TEST(TimerTest, CategoryTimesStats) {
   ASSERT_EQ(
   6, sscanf(ss.GetData(),
 "%lf sec (total: %lfs; child: %lfs; count: %d) for CAT1%*[\n ]"
-"%lf sec (total: %*lfs; child: %*lfs; count: %d) for CAT2",
+"%lf sec (total: %*fs; child: %*fs; count: %d) for CAT2",
 &seconds1, &total1, &child1, &count1, &seconds2, &count2))
   << "String: " << ss.GetData();
   EXPECT_NEAR(total1 - child1, seconds1, 0.002);


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


[Lldb-commits] [lldb] r361861 - Fix 'warning: format specifies type 'int' but the argument has type 'MIuint' (aka 'unsigned long long') [-Wformat]' with Clang 8.0

2019-10-04 Thread Alexandre Ganea via lldb-commits
Author: aganea
Date: Tue May 28 11:36:11 2019
New Revision: 361861

URL: http://llvm.org/viewvc/llvm-project?rev=361861&view=rev
Log:
Fix 'warning: format specifies type 'int' but the argument has type 'MIuint' 
(aka 'unsigned long long') [-Wformat]' with Clang 8.0

Modified:
lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp?rev=361861&r1=361860&r2=361861&view=diff
==
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Tue May 28 
11:36:11 2019
@@ -951,7 +951,7 @@ bool CMICmnLLDBDebuggerHandleEvents::Han
   } else {
 const MIuint nTargetIndex = rDebugger.GetIndexOfTarget(target);
 if (nTargetIndex != UINT_MAX)
-  streamOut.Printf("Target %d: (", nTargetIndex);
+  streamOut.Printf("Target %" PRIu64 ": (", (uint64_t)nTargetIndex);
 else
   streamOut.Printf("Target : (");
 target.GetDescription(streamOut, lldb::eDescriptionLevelBrief);


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


[Lldb-commits] [lldb] r363098 - Add support to read aux vector values

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jun 11 13:16:13 2019
New Revision: 363098

URL: http://llvm.org/viewvc/llvm-project?rev=363098&view=rev
Log:
Add support to read aux vector values

Summary:
This is the second patch to improve module loading in a series that started 
here (where I explain the motivation and solution): 
https://reviews.llvm.org/D62499

I need to read the aux vector to know where the r_debug map with the loaded 
libraries are.
The AuxVector class was made generic so it could be reused between the 
POSIX-DYLD plugin and NativeProcess*. The class itself ended up in the 
ProcessUtility plugin.

Reviewers: clayborg, xiaobai, labath, JDevlieghere

Reviewed By: clayborg, labath, JDevlieghere

Subscribers: emaste, JDevlieghere, mgorny, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/source/Plugins/Process/Utility/AuxVector.cpp
lldb/trunk/source/Plugins/Process/Utility/AuxVector.h
Removed:
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363098&r1=363097&r2=363098&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 11 
13:16:13 2019
@@ -133,6 +133,10 @@ public:
 return GetArchitecture().GetByteOrder();
   }
 
+  uint32_t GetAddressByteSize() const {
+return GetArchitecture().GetAddressByteSize();
+  }
+
   virtual llvm::ErrorOr>
   GetAuxvData() const = 0;
 

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=363098&r1=363097&r2=363098&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Jun 11 13:16:13 2019
@@ -670,8 +670,8 @@ public:
   // The default action is to return an empty data buffer.
   //
   // \return
-  //A data buffer containing the contents of the AUXV data.
-  virtual const lldb::DataBufferSP GetAuxvData();
+  //A data extractor containing the contents of the AUXV data.
+  virtual DataExtractor GetAuxvData();
 
   /// Sometimes processes know how to retrieve and load shared libraries. This
   /// is normally done by DynamicLoader plug-ins, but sometimes the connection

Removed: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp?rev=363097&view=auto
==
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp (removed)
@@ -1,141 +0,0 @@
-//===-- AuxVector.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 "AuxVector.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static bool GetMaxU64(DataExtractor &data, lldb::offset_t *offset_ptr,
-  uint64_t *value, unsigned int byte_size) {
-  lldb::offset_t saved_offset = *offset_ptr;
-  *value = data.GetMaxU64(offset_ptr, byte_size);
-  return *offset_ptr != saved_offset;
-}
-
-

[Lldb-commits] [lldb] r347721 - Remove dead code from IOHandler

2019-10-04 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Tue Nov 27 15:37:47 2018
New Revision: 347721

URL: http://llvm.org/viewvc/llvm-project?rev=347721&view=rev
Log:
Remove dead code from IOHandler

This has been dead since 2014 according to the blame

Modified:
lldb/trunk/source/Core/IOHandler.cpp

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=347721&r1=347720&r2=347721&view=diff
==
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Tue Nov 27 15:37:47 2018
@@ -1744,11 +1744,7 @@ public:
   void Initialize() {
 ::setlocale(LC_ALL, "");
 ::setlocale(LC_CTYPE, "");
-#if 0
-::initscr();
-#else
 m_screen = ::newterm(nullptr, m_out, m_in);
-#endif
 ::start_color();
 ::curs_set(0);
 ::noecho();


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


[Lldb-commits] [lldb] r361987 - Add more information to the log timer dump

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Wed May 29 09:31:32 2019
New Revision: 361987

URL: http://llvm.org/viewvc/llvm-project?rev=361987&view=rev
Log:
Add more information to the log timer dump

Summary:
The `log timer dump` is showing the time of the function itself minus any 
function that is called from this one that also happens to be timed. However, 
this is really not obvious and it also makes it hard to understand the time 
spent in total and also which children are actually taking the time.
To get a better reading of the timer dump I added the total, children (which I 
named child) and also the hit count. I used these timers to figure out a 
performance issue and only after adding this things were more clear to me.

It looks like this:
```
(lldb) log timer dump
35.447713617 sec (total: 35.449s; child: 0.001s; count: 1374) for void 
SymbolFileDWARF::Index()
29.717921481 sec (total: 29.718s; child: 0.000s; count: 8230500) for const 
lldb_private::ConstString 
&lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const
21.049508865 sec (total: 24.683s; child: 3.633s; count: 1399) for void 
lldb_private::Symtab::InitNameIndexes()
...
```

Reviewers: clayborg, teemperor, labath, espindola, xiaobai

Reviewed By: labath, xiaobai

Subscribers: emaste, mgorny, arichardson, eraman, MaskRay, jdoerfert, labath, 
davide, teemperor, aprantl, erik.pilkington, jfb, abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Utility/Timer.h
lldb/trunk/source/Utility/Timer.cpp
lldb/trunk/unittests/Utility/TimerTest.cpp

Modified: lldb/trunk/include/lldb/Utility/Timer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Timer.h?rev=361987&r1=361986&r2=361987&view=diff
==
--- lldb/trunk/include/lldb/Utility/Timer.h (original)
+++ lldb/trunk/include/lldb/Utility/Timer.h Wed May 29 09:31:32 2019
@@ -30,6 +30,8 @@ public:
 friend class Timer;
 const char *m_name;
 std::atomic m_nanos;
+std::atomic m_nanos_total;
+std::atomic m_count;
 std::atomic m_next;
 
 DISALLOW_COPY_AND_ASSIGN(Category);

Modified: lldb/trunk/source/Utility/Timer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Timer.cpp?rev=361987&r1=361986&r2=361987&view=diff
==
--- lldb/trunk/source/Utility/Timer.cpp (original)
+++ lldb/trunk/source/Utility/Timer.cpp Wed May 29 09:31:32 2019
@@ -41,6 +41,8 @@ static TimerStack &GetTimerStackForCurre
 
 Timer::Category::Category(const char *cat) : m_name(cat) {
   m_nanos.store(0, std::memory_order_release);
+  m_nanos_total.store(0, std::memory_order_release);
+  m_count.store(0, std::memory_order_release);
   Category *expected = g_categories;
   do {
 m_next = expected;
@@ -93,6 +95,8 @@ Timer::~Timer() {
 
   // Keep total results for each category so we can dump results.
   m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count();
+  m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count();
+  m_category.m_count++;
 }
 
 void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; }
@@ -100,25 +104,38 @@ void Timer::SetDisplayDepth(uint32_t dep
 /* binary function predicate:
  * - returns whether a person is less than another person
  */
-
-typedef std::pair TimerEntry;
-
-static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs,
- const TimerEntry &rhs) {
-  return lhs.second > rhs.second;
+namespace {
+struct Stats {
+  const char *name;
+  uint64_t nanos;
+  uint64_t nanos_total;
+  uint64_t count;
+};
+} // namespace
+
+static bool CategoryMapIteratorSortCriterion(const Stats &lhs,
+ const Stats &rhs) {
+  return lhs.nanos > rhs.nanos;
 }
 
 void Timer::ResetCategoryTimes() {
-  for (Category *i = g_categories; i; i = i->m_next)
+  for (Category *i = g_categories; i; i = i->m_next) {
 i->m_nanos.store(0, std::memory_order_release);
+i->m_nanos_total.store(0, std::memory_order_release);
+i->m_count.store(0, std::memory_order_release);
+  }
 }
 
 void Timer::DumpCategoryTimes(Stream *s) {
-  std::vector sorted;
+  std::vector sorted;
   for (Category *i = g_categories; i; i = i->m_next) {
 uint64_t nanos = i->m_nanos.load(std::memory_order_acquire);
-if (nanos)
-  sorted.push_back(std::make_pair(i->m_name, nanos));
+if (nanos) {
+  uint64_t nanos_total = i->m_nanos_total.load(std::memory_order_acquire);
+  uint64_t count = i->m_count.load(std::memory_order_acquire);
+  Stats stats{i->m_name, nanos, nanos_total, count};
+  sorted.push_back(stats);
+}
   }
   if (sorted.empty())
 return; // Later code will break without any elements.
@@ -126,6 +143,9 @@ void Timer::DumpCategoryTimes(Stream *s)
   // Sort by time
   llvm::sort(sorted.begin(

[Lldb-commits] [lldb] r363458 - Implement GetSharedLibraryInfoAddress

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Fri Jun 14 14:15:08 2019
New Revision: 363458

URL: http://llvm.org/viewvc/llvm-project?rev=363458&view=rev
Log:
Implement GetSharedLibraryInfoAddress

Summary:
This is the third patch to improve module loading in a series that started here 
(where I explain the motivation and solution): D62499

Add functions to read the r_debug location to know where the linked list of 
loaded libraries are so I can generate the `xfer:libraries-svr4` packet.
I'm also using this function to implement `GetSharedLibraryInfoAddress` that 
was "not implemented" for linux.
Most of this code was inspired by the current ds2 implementation here: 
https://github.com/facebook/ds2/blob/master/Sources/Target/POSIX/ELFProcess.cpp.

Reviewers: clayborg, xiaobai, labath

Reviewed By: clayborg, labath

Subscribers: emaste, krytarowski, mgorny, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h
lldb/trunk/unittests/Process/POSIX/
lldb/trunk/unittests/Process/POSIX/CMakeLists.txt
lldb/trunk/unittests/Process/POSIX/NativeProcessELFTest.cpp
lldb/trunk/unittests/TestingSupport/Host/
lldb/trunk/unittests/TestingSupport/Host/NativeProcessTestUtils.h
Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/trunk/source/Plugins/Process/POSIX/CMakeLists.txt
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
lldb/trunk/unittests/Process/CMakeLists.txt

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=363458&r1=363457&r2=363458&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Fri Jun 14 
14:15:08 2019
@@ -288,7 +288,7 @@ NativeProcessLinux::NativeProcessLinux(:
NativeDelegate &delegate,
const ArchSpec &arch, MainLoop 
&mainloop,
llvm::ArrayRef<::pid_t> tids)
-: NativeProcessProtocol(pid, terminal_fd, delegate), m_arch(arch) {
+: NativeProcessELF(pid, terminal_fd, delegate), m_arch(arch) {
   if (m_terminal_fd != -1) {
 Status status = EnsureFDFlags(m_terminal_fd, O_NONBLOCK);
 assert(status.Success());
@@ -1389,11 +1389,6 @@ Status NativeProcessLinux::DeallocateMem
   return Status("not implemented");
 }
 
-lldb::addr_t NativeProcessLinux::GetSharedLibraryInfoAddress() {
-  // punt on this for now
-  return LLDB_INVALID_ADDRESS;
-}
-
 size_t NativeProcessLinux::UpdateThreads() {
   // The NativeProcessLinux monitoring threads are always up to date with
   // respect to thread state and they keep the thread list populated properly.
@@ -2082,18 +2077,3 @@ Status NativeProcessLinux::StopProcessor
 
   return error;
 }
-
-llvm::Optional
-NativeProcessLinux::GetAuxValue(enum AuxVector::EntryType type) {
-  if (m_aux_vector == nullptr) {
-auto buffer_or_error = GetAuxvData();
-if (!buffer_or_error)
-  return llvm::None;
-DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(),
-buffer_or_error.get()->getBufferSize(),
-GetByteOrder(), GetAddressByteSize());
-m_aux_vector = llvm::make_unique(auxv_data);
-  }
-
-  return m_aux_vector->GetAuxValue(type);
-}

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h?rev=363458&r1=363457&r2=363458&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h Fri Jun 14 
14:15:08 2019
@@ -12,7 +12,6 @@
 #include 
 #include 
 
-#include "Plugins/Process/Utility/AuxVector.h"
 #include "lldb/Host/Debug.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/linux/Support.h"
@@ -22,8 +21,8 @@
 #include "lldb/lldb-types.h"
 
 #include "NativeThreadLinux.h"
+#include "Plugins/Process/POSIX/NativeProcessELF.h"
 #include "ProcessorTrace.h"
-#include "lldb/Host/common/NativeProcessProtocol.h"
 
 namespace lldb_private {
 class Status;
@@ -37,7 +36,7 @@ namespace process_linux {
 /// for debugging.
 ///
 /// Changes in the inferior process state are broadcasted.
-class NativeProcessLinux : public NativeProcessProtocol {
+class NativeProcessLinux : public NativeProcessELF {
 public:
   class Factory : public NativeProcessProtocol::Factory {
   public:
@@ -77,8 +76,6 @@ public:
 
   Status DeallocateMemory(l

[Lldb-commits] [lldb] r365059 - Add plugin.process.gdb-remote.use-libraries-svr4 option

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Wed Jul  3 10:30:07 2019
New Revision: 365059

URL: http://llvm.org/viewvc/llvm-project?rev=365059&view=rev
Log:
Add plugin.process.gdb-remote.use-libraries-svr4 option

Summary:
This option allow the toggling of the libraries-svr4 usage in ProcessGDBRemote. 
It's a follow up of https://reviews.llvm.org/D62503#1564296 and it's meant to 
test / tweak this new packet with, hopefully, minimum impact and in a faster 
way.

Enable it with `settings set plugin.process.gdb-remote.use-libraries-svr4 
true`. For now, by default it's false.

I didn't put tests up for this but I did test it manually.

Reviewers: labath, jankratochvil

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

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

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=365059&r1=365058&r2=365059&view=diff
==
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Jul  
3 10:30:07 2019
@@ -111,18 +111,40 @@ void DumpProcessGDBRemotePacketHistory(v
 namespace {
 
 static constexpr PropertyDefinition g_properties[] = {
-{"packet-timeout", OptionValue::eTypeUInt64, true, 5
+{"packet-timeout",
+ OptionValue::eTypeUInt64,
+ true,
+ 5
 #if defined(__has_feature)
 #if __has_feature(address_sanitizer)
  * 2
 #endif
 #endif
- , nullptr, {},
+ ,
+ nullptr,
+ {},
  "Specify the default packet timeout in seconds."},
-{"target-definition-file", OptionValue::eTypeFileSpec, true, 0, nullptr, 
{},
- "The file that provides the description for remote target registers."}};
-
-enum { ePropertyPacketTimeout, ePropertyTargetDefinitionFile };
+{"target-definition-file",
+ OptionValue::eTypeFileSpec,
+ true,
+ 0,
+ nullptr,
+ {},
+ "The file that provides the description for remote target registers."},
+{"use-libraries-svr4",
+ OptionValue::eTypeBoolean,
+ true,
+ false,
+ nullptr,
+ {},
+ "If true, the libraries-svr4 feature will be used to get a hold of the "
+ "process's loaded modules."}};
+
+enum {
+  ePropertyPacketTimeout,
+  ePropertyTargetDefinitionFile,
+  ePropertyUseSVR4
+};
 
 class PluginProperties : public Properties {
 public:
@@ -152,6 +174,12 @@ public:
 const uint32_t idx = ePropertyTargetDefinitionFile;
 return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
   }
+
+  bool GetUseSVR4() const {
+const uint32_t idx = ePropertyUseSVR4;
+return m_collection_sp->GetPropertyAtIndexAsBoolean(
+nullptr, idx, g_properties[idx].default_uint_value != 0);
+  }
 };
 
 typedef std::shared_ptr ProcessKDPPropertiesSP;
@@ -4681,9 +4709,10 @@ Status ProcessGDBRemote::GetLoadedModule
 log->Printf("ProcessGDBRemote::%s", __FUNCTION__);
 
   GDBRemoteCommunicationClient &comm = m_gdb_comm;
+  bool can_use_svr4 = GetGlobalPluginProperties()->GetUseSVR4();
 
   // check that we have extended feature read support
-  if (comm.GetQXferLibrariesSVR4ReadSupported()) {
+  if (can_use_svr4 && comm.GetQXferLibrariesSVR4ReadSupported()) {
 list.clear();
 
 // request the loaded library list


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


[Lldb-commits] [lldb] r362406 - [lldb-server unittest] Add missing teardown logic

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Mon Jun  3 08:18:15 2019
New Revision: 362406

URL: http://llvm.org/viewvc/llvm-project?rev=362406&view=rev
Log:
[lldb-server unittest] Add missing teardown logic

Summary:
This test base class is missing the teardown making the second set of tests 
extending it to fail in an assertion in the FileSystem::Initialize() (as it's 
being initialized twice).
Not sure why this isn't failing the build bots.. (unless they're running 
without asserts?).

With this fix `ninja LLDBServerTests && 
./tools/lldb/unittests/tools/lldb-server/tests/LLDBServerTests` successfully 
runs and passes all tests.

Reviewers: clayborg, xiaobai, labath

Reviewed By: xiaobai, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h

Modified: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h?rev=362406&r1=362405&r2=362406&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h Mon Jun  3 08:18:15 
2019
@@ -25,6 +25,11 @@ public:
 lldb_private::HostInfo::Initialize();
   }
 
+  static void TearDownTestCase() {
+lldb_private::HostInfo::Terminate();
+lldb_private::FileSystem::Terminate();
+  }
+
   static std::string getInferiorPath(llvm::StringRef Name) {
 llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH);
 llvm::sys::path::append(Path, Name + LLDB_TEST_INFERIOR_SUFFIX);


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


[Lldb-commits] [lldb] r362437 - Silence 'warning C4305: 'initializing': truncation from 'double' to 'float'' with MSVC 19.16.27021.1 (VS2017 15.9.12)

2019-10-04 Thread Alexandre Ganea via lldb-commits
Author: aganea
Date: Mon Jun  3 11:46:30 2019
New Revision: 362437

URL: http://llvm.org/viewvc/llvm-project?rev=362437&view=rev
Log:
Silence 'warning C4305: 'initializing': truncation from 'double' to 'float'' 
with MSVC 19.16.27021.1 (VS2017 15.9.12)

Modified:
lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp

Modified: lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp?rev=362437&r1=362436&r2=362437&view=diff
==
--- lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp (original)
+++ lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp Mon Jun  3 
11:46:30 2019
@@ -31,7 +31,7 @@ struct Pod {
   bool a = true;
   bool b = false;
   char c = 'a';
-  float d = 1.1;
+  float d = 1.1f;
   int e = 2;
   long long f = 3;
   long g = 4;
@@ -443,7 +443,7 @@ TEST(RecordReplayTest, InstrumentedFoo)
 
   {
 int b = 200;
-float c = 300.3;
+float c = 300.3f;
 double e = 400.4;
 
 InstrumentedFoo foo(0);
@@ -471,7 +471,7 @@ TEST(RecordReplayTest, InstrumentedFooSa
   g_serializer.emplace(os);
 
   int b = 200;
-  float c = 300.3;
+  float c = 300.3f;
   double e = 400.4;
 
   InstrumentedFoo *foo = new InstrumentedFoo(0);
@@ -517,7 +517,7 @@ TEST(RecordReplayTest, InstrumentedBar)
 #endif
 
 int b = 200;
-float c = 300.3;
+float c = 300.3f;
 double e = 400.4;
 
 foo.A(100);
@@ -552,7 +552,7 @@ TEST(RecordReplayTest, InstrumentedBarRe
 InstrumentedFoo &foo = bar.GetInstrumentedFooRef();
 
 int b = 200;
-float c = 300.3;
+float c = 300.3f;
 double e = 400.4;
 
 foo.A(100);
@@ -587,7 +587,7 @@ TEST(RecordReplayTest, InstrumentedBarPt
 InstrumentedFoo &foo = *(bar.GetInstrumentedFooPtr());
 
 int b = 200;
-float c = 300.3;
+float c = 300.3f;
 double e = 400.4;
 
 foo.A(100);


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


[Lldb-commits] [lldb] r364355 - Revert "Add ReadCStringFromMemory for faster string reads"

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jun 25 15:22:13 2019
New Revision: 364355

URL: http://llvm.org/viewvc/llvm-project?rev=364355&view=rev
Log:
Revert "Add ReadCStringFromMemory for faster string reads"

This reverts commit a7335393f50246b59db450dc6005f7c8f29e73a6.

It seems this is breaking a bunch of tests 
(https://reviews.llvm.org/D62503#1549874) so reverting until I find the time to 
repro and fix.

Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=364355&r1=364354&r2=364355&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 25 
15:22:13 2019
@@ -84,31 +84,6 @@ public:
   Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read);
 
-  /// Reads a null terminated string from memory.
-  ///
-  /// Reads up to \p max_size bytes of memory until it finds a '\0'.
-  /// If a '\0' is not found then it reads max_size-1 bytes as a string and a
-  /// '\0' is added as the last character of the \p buffer.
-  ///
-  /// \param[in] addr
-  /// The address in memory to read from.
-  ///
-  /// \param[in] buffer
-  /// An allocated buffer with at least \p max_size size.
-  ///
-  /// \param[in] max_size
-  /// The maximum number of bytes to read from memory until it reads the
-  /// string.
-  ///
-  /// \param[out] total_bytes_read
-  /// The number of bytes read from memory into \p buffer.
-  ///
-  /// \return
-  /// Returns a StringRef backed up by the \p buffer passed in.
-  llvm::Expected
-  ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size,
-size_t &total_bytes_read);
-
   virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
  size_t &bytes_written) = 0;
 

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=364355&r1=364354&r2=364355&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jun 25 15:22:13 
2019
@@ -16,8 +16,6 @@
 #include "lldb/Utility/State.h"
 #include "lldb/lldb-enumerations.h"
 
-#include "llvm/Support/Process.h"
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -661,58 +659,6 @@ Status NativeProcessProtocol::ReadMemory
   return Status();
 }
 
-llvm::Expected
-NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer,
- size_t max_size,
- size_t &total_bytes_read) {
-  static const size_t cache_line_size =
-  llvm::sys::Process::getPageSizeEstimate();
-  size_t bytes_read = 0;
-  size_t bytes_left = max_size;
-  addr_t curr_addr = addr;
-  size_t string_size;
-  char *curr_buffer = buffer;
-  total_bytes_read = 0;
-  Status status;
-
-  while (bytes_left > 0 && status.Success()) {
-addr_t cache_line_bytes_left =
-cache_line_size - (curr_addr % cache_line_size);
-addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left);
-status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer),
-bytes_to_read, bytes_read);
-
-if (bytes_read == 0)
-  break;
-
-void *str_end = std::memchr(curr_buffer, '\0', bytes_read);
-if (str_end != nullptr) {
-  total_bytes_read =
-  (size_t)(reinterpret_cast(str_end) - buffer + 1);
-  status.Clear();
-  break;
-}
-
-total_bytes_read += bytes_read;
-curr_buffer += bytes_read;
-curr_addr += bytes_read;
-bytes_left -= bytes_read;
-  }
-
-  string_size = total_bytes_read - 1;
-
-  // Make sure we return a null terminated string.
-  if (bytes_left == 0 && max_size > 0 && buffer[max_size - 1] != '\0') {
-buffer[max_size - 1] = '\0';
-total_bytes_read--;
-  }
-
-  if (!status.Success())
-return status.ToError();
-
-  return llvm::StringRef(buffer, string_size);
-}
-
 lldb::StateType NativeProcessProtocol::GetState() const {
   std::lock_guard guard(m_state_mutex);
   return m_state;

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cp

[Lldb-commits] [lldb] r363750 - Add ReadCStringFromMemory for faster string reads

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jun 18 16:27:57 2019
New Revision: 363750

URL: http://llvm.org/viewvc/llvm-project?rev=363750&view=rev
Log:
Add ReadCStringFromMemory for faster string reads

Summary:
This is the fifth patch to improve module loading in a series that started here 
(where I explain the motivation and solution): D62499

Reading strings with ReadMemory is really slow when reading the path of the 
shared library. This is because we don't know the length of the path so use 
PATH_MAX (4096) and these strings are actually super close to the boundary of 
an unreadable page. So even though we use process_vm_readv it will usually fail 
because the read size spans to the unreadable page and we then default to read 
the string word by word with ptrace.

This new function is very similar to another ReadCStringFromMemory that already 
exists in lldb that makes sure it never reads cross page boundaries and checks 
if we already read the entire string by finding '\0'.

I was able to reduce the GetLoadedSharedLibraries call from 30ms to 4ms (or 
something of that order).

Reviewers: clayborg, xiaobai, labath

Reviewed By: labath

Subscribers: emaste, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363750&r1=363749&r2=363750&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 18 
16:27:57 2019
@@ -84,6 +84,31 @@ public:
   Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read);
 
+  /// Reads a null terminated string from memory.
+  ///
+  /// Reads up to \p max_size bytes of memory until it finds a '\0'.
+  /// If a '\0' is not found then it reads max_size-1 bytes as a string and a
+  /// '\0' is added as the last character of the \p buffer.
+  ///
+  /// \param[in] addr
+  /// The address in memory to read from.
+  ///
+  /// \param[in] buffer
+  /// An allocated buffer with at least \p max_size size.
+  ///
+  /// \param[in] max_size
+  /// The maximum number of bytes to read from memory until it reads the
+  /// string.
+  ///
+  /// \param[out] total_bytes_read
+  /// The number of bytes read from memory into \p buffer.
+  ///
+  /// \return
+  /// Returns a StringRef backed up by the \p buffer passed in.
+  llvm::Expected
+  ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size,
+size_t &total_bytes_read);
+
   virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
  size_t &bytes_written) = 0;
 

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=363750&r1=363749&r2=363750&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jun 18 16:27:57 
2019
@@ -16,6 +16,8 @@
 #include "lldb/Utility/State.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/Support/Process.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -659,6 +661,58 @@ Status NativeProcessProtocol::ReadMemory
   return Status();
 }
 
+llvm::Expected
+NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer,
+ size_t max_size,
+ size_t &total_bytes_read) {
+  static const size_t cache_line_size =
+  llvm::sys::Process::getPageSizeEstimate();
+  size_t bytes_read = 0;
+  size_t bytes_left = max_size;
+  addr_t curr_addr = addr;
+  size_t string_size;
+  char *curr_buffer = buffer;
+  total_bytes_read = 0;
+  Status status;
+
+  while (bytes_left > 0 && status.Success()) {
+addr_t cache_line_bytes_left =
+cache_line_size - (curr_addr % cache_line_size);
+addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left);
+status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer),
+bytes_to_read, bytes_read);
+
+if (bytes_read == 0)
+  break;
+
+void *str_end = std::memchr(curr_buffer, '\0', bytes_read);
+if (str_end != nullptr) {
+  total_bytes_read =
+  (size_t)(reinterpret_cast(

[Lldb-commits] [lldb] r362982 - Create a generic handler for Xfer packets

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Mon Jun 10 13:59:58 2019
New Revision: 362982

URL: http://llvm.org/viewvc/llvm-project?rev=362982&view=rev
Log:
Create a generic handler for Xfer packets

Summary:
This is the first of a few patches I have to improve the performance of dynamic 
module loading on Android.

In this first diff I'll describe the context of my main motivation and will 
then link to it in the other diffs to avoid repeating myself.

## Motivation
I have a few scenarios where opening a specific feature on an Android app takes 
around 40s when lldb is attached to it. The reason for that is because 40 
modules are dynamicly loaded at that point in time and each one of them is 
taking ~1s.

## The problem
To learn about new modules we have a breakpoint on a linker function that is 
called twice whenever a module is loaded. One time just before it's loaded (so 
lldb can check which modules are loaded) and another right after it's loaded 
(so lldb can check again which ones are loaded and calculate the diference).
It's figuring out which modules are loaded that is taking quite some time. This 
is currently done by traversing the linked list of loaded shared libraries that 
the linker maintains in memory. Each item in the linked list requires its own 
`x` packet sent to the gdb server (this is android so the network also plays a 
part). In my scenario there are 400+ loaded libraries and even though we read 
0x800 worth of bytes at a time we still make ~180 requests that end up taking 
150-200ms.
We also do this twice, once before the module is loaded (state = eAdd) and 
another right after (state = eConsistent) which easly adds up to ~400ms per 
module.

## A solution

**Implement `xfer:libraries-svr4` in lldb-server:**
I noticed in the code that loads the new modules that it had support for the 
`xfer:libraries-svr4` packet (added ~4 years ago to support the ds2 debug 
server) but we didn't support it in lldb-server. This single packet returns an 
xml list of all the loaded modules by the process. The advantage is that 
there's no more need to make 180 requests to read the linked list. Additionally 
this new requests takes around 10ms.

**More efficient usage of the `xfer:libraries-svr4` packet in lldb:**
When `xfer:libraries-svr4` is available the Process class has a `LoadModules` 
function that requests this packet and then loads or unloads modules based on 
the current list of loaded modules by the process.
This is the function that is used by the DYLDRendezvous class to get the list 
of loaded modules before and after the module is loaded. However, this is 
really not needed since the LoadModules function already loaded or unloaded the 
modules accordingly. I changed this strategy to call LoadModules only once 
(after the process has loaded the module).

**Bugs**
I found a few issues in lldb while implementing this and have submitted 
independent patches for them.

I tried to devide this into multiple logical patches to make it easier to 
review and discuss.

## Tests

I wanted to put these set of diffs up before having all the tests up and 
running to start having them reviewed from a techical point of view. I'm also 
having some trouble making the tests running on linux so I need more time to 
make that happen.

# This diff

The `xfer` packages follow the same protocol, they are requested with 
`xfer` and a return that starts 
with `l` or `m` depending if the offset and length covers the entire data or 
not. Before implementing the `xfer:libraries-svr4` I refactored the `xfer:auxv` 
to generically handle xfer packets so we can easly add new ones.

The overall structure of the function ends up being:
* Parse the packet into its components: object, offset etc.
* Depending on the object do its own logic to generate the data.
* Return the data based on its size, the requested offset and length.

Reviewers: clayborg, xiaobai, labath

Reviewed By: labath

Subscribers: mgorny, krytarowski, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp
Modified:
lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h

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

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
lldb/trunk/unittests/Process/gdb-remote/CMakeLists.txt
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h

Modified: lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h?rev=362982&r1=362981&r2=362982&view=diff

[Lldb-commits] [lldb] r363707 - Implement xfer:libraries-svr4:read packet

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jun 18 10:51:56 2019
New Revision: 363707

URL: http://llvm.org/viewvc/llvm-project?rev=363707&view=rev
Log:
Implement xfer:libraries-svr4:read packet

Summary:
This is the fourth patch to improve module loading in a series that started 
here (where I explain the motivation and solution): D62499

Implement the `xfer:libraries-svr4` packet by adding a new function that 
generates the list and then in Handle_xfer I generate the XML for it. The XML 
is really simple so I'm just using string concatenation because I believe it's 
more readable than having to deal with a DOM api.

Reviewers: clayborg, xiaobai, labath

Reviewed By: labath

Subscribers: emaste, mgorny, srhines, krytarowski, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h

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

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

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363707&r1=363706&r2=363707&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 18 
10:51:56 2019
@@ -32,6 +32,14 @@ namespace lldb_private {
 class MemoryRegionInfo;
 class ResumeActionList;
 
+struct SVR4LibraryInfo {
+  std::string name;
+  lldb::addr_t link_map;
+  lldb::addr_t base_addr;
+  lldb::addr_t ld_addr;
+  lldb::addr_t next;
+};
+
 // NativeProcessProtocol
 class NativeProcessProtocol {
 public:
@@ -86,6 +94,12 @@ public:
 
   virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0;
 
+  virtual llvm::Expected>
+  GetLoadedSVR4Libraries() {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Not implemented");
+  }
+
   virtual bool IsAlive() const;
 
   virtual size_t UpdateThreads() = 0;

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=363707&r1=363706&r2=363707&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
 Tue Jun 18 10:51:56 2019
@@ -513,7 +513,8 @@ class GdbRemoteTestCaseBase(TestBase):
 self,
 inferior_args=None,
 inferior_sleep_seconds=3,
-inferior_exe_path=None):
+inferior_exe_path=None,
+inferior_env=None):
 """Prep the debug monitor, the inferior, and the expected packet 
stream.
 
 Handle the separate cases of using the debug monitor in 
attach-to-inferior mode
@@ -576,6 +577,9 @@ class GdbRemoteTestCaseBase(TestBase):
 
 # Build the expected protocol stream
 self.add_no_ack_remote_stream()
+if inferior_env:
+for name, value in inferior_env.items():
+self.add_set_environment_packets(name, value)
 if self._inferior_startup == self._STARTUP_LAUNCH:
 self.add_verified_launch_packets(launch_args)
 
@@ -656,6 +660,12 @@ class GdbRemoteTestCaseBase(TestBase):
  {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", 
"capture": {1: "process_info_raw"}}],
 True)
 
+def add_set_environment_packet

[Lldb-commits] [lldb] r367020 - Correctly use GetLoadedModuleList to take advantage of libraries-svr4

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu Jul 25 07:28:21 2019
New Revision: 367020

URL: http://llvm.org/viewvc/llvm-project?rev=367020&view=rev
Log:
Correctly use GetLoadedModuleList to take advantage of libraries-svr4

Summary:
Here's a replacement for D62504. I thought I could use LoadModules to implement 
this but in reality I can't because there are at few issues with it:
* The LoadModules assumes that the list returned by GetLoadedModuleList is 
comprehensive in the sense that reflects all the mapped segments, however, this 
is not true, for instance VDSO entry is not there since it's loaded manually by 
LoadVDSO using GetMemoryRegionInfo and it doesn't represent a specific shared 
object in disk. Because of this LoadModules will unload the VDSO module.
* The loader (interpreter) module might have also been loaded using 
GetMemoryRegionInfo, this is true when we launch the process and the rendezvous 
structure is not yet available (done through LoadInterpreterModule()). The 
problem here is that this entry will point to the same file name as the one 
found in /proc/pid/maps, however, when we read the same module from the 
r_debug.link_map structure it might be under a different name. This is true at 
least on CentOS where the loader is a symlink. Because of this LoadModules will 
unload and load the module in a way where the rendezvous breakpoint is 
unresolved but not resolved again (because we add the new module first and 
remove the old one after).

The symlink issue might be fixable by first unloading the old and loading the 
news (but sounds super brittle), however, I'm not sure how to fix the VDSO 
issue.
Since I can't trust it I'm just going to use GetLoadedModuleList directly with 
the same logic that we use today for when we read the linked list in lldb. The 
only safe thing to do here is to only calculate differences between different 
snapshots of the svr4 packet itself. This will also cut the dependency this 
plugin has from LoadModules.

I separated the 2 logics into 2 different functions (remote and not remote) 
because I don't like mixing 2 different logics in the same function with 
if/else's. Two different functions makes it easier to reason with I believe. 
However, I did abstract away the logic that decides if we should take a 
snapshot or add/remove modules so both functions could reuse it.

The other difference between the two is that on the UpdateSOEntriesFromRemote I 
take the snapshot only once when state = Consistent because I didn't find a 
good reason to always update that, as we already got the list from state = Add 
| Remove. I probably should use the same logic on UpdateSOEntries though I 
don't see a reason not to since it's really using the same data, just read in 
different places. Any thoughts here?

It might also be worthwhile to add a test to make sure we don't unload modules 
that were not actually "unloaded" like the vdso. I haven't done this yet though.
This diff is also missing the option for svr4 like proposed in 
https://reviews.llvm.org/D62503#1564296, I'll start working on this but wanted 
to have this up first.

Reviewers: labath, jankratochvil, clayborg, xiaobai

Reviewed By: labath

Subscribers: srhines, JDevlieghere, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=367020&r1=367019&r2=367020&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Jul 25 07:28:21 2019
@@ -680,10 +680,19 @@ public:
   /// shared library load state.
   ///
   /// \return
-  ///The number of shared libraries that were loaded
-  virtual size_t LoadModules() { return 0; }
+  ///A status object indicating if the operation was sucessful or not.
+  virtual llvm::Error LoadModules() {
+return llvm::make_error("Not implemented.",
+   llvm::inconvertibleErrorCode());
+  }
 
-  virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; }
+  /// Query remote GDBServer for a detailed loaded library list
+  /// \return
+  ///The list of modules currently loaded by the process, or an error.
+  virtual llvm::Expected GetLoadedModuleList() {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ 

[Lldb-commits] [lldb] r373687 - Revert "Explicitly set entry point arch when it's thumb"

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu Oct  3 18:45:58 2019
New Revision: 373687

URL: http://llvm.org/viewvc/llvm-project?rev=373687&view=rev
Log:
Revert "Explicitly set entry point arch when it's thumb"

Backing out because SymbolFile/Breakpad/symtab.test is failing and it seems to 
be a legit issue. Will investigate.

This reverts commit 72153f95ee4c1b52d2f4f483f0ea4f650ec863be.

Removed:
lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Removed: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s?rev=373686&view=auto
==
--- lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (original)
+++ lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (removed)
@@ -1,13 +0,0 @@
-# REQUIRES: lld, arm
-
-# RUN: llvm-mc -triple=thumbv7-eabi %s -filetype=obj -o %t.o
-# RUN: ld.lld %t.o -o %t --section-start=.text=0x8074 -e 0x8075 -s
-# RUN: %lldb -x -b -o 'dis -s 0x8074 -e 0x8080' -- %t | FileCheck %s
-# CHECK:  {{.*}}[0x8074] <+0>: movs   r0, #0x2a
-# CHECK-NEXT: {{.*}}[0x8076] <+2>: movs   r7, #0x1
-# CHECK-NEXT: {{.*}}[0x8078] <+4>: svc#0x0
-
-_start:
-movs r0, #0x2a
-movs r7, #0x1
-svc #0x0
\ No newline at end of file

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=373687&r1=373686&r2=373687&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Oct  3 
18:45:58 2019
@@ -2703,46 +2703,6 @@ Symtab *ObjectFileELF::GetSymtab() {
 if (m_symtab_up == nullptr)
   m_symtab_up.reset(new Symtab(this));
 
-// In the event that there's no symbol entry for the entry point we'll
-// artifically create one. We delegate to the symtab object the figuring
-// out of the proper size, this will usually make it span til the next
-// symbol it finds in the section. This means that if there are missing
-// symbols the entry point might span beyond its function definition.
-// We're fine with this as it doesn't make it worse than not having a
-// symbol entry at all.
-ArchSpec arch = GetArchitecture();
-auto entry_point_addr = GetEntryPointAddress().GetFileAddress();
-if (entry_point_addr != LLDB_INVALID_ADDRESS) {
-  if (!m_symtab_up->FindSymbolContainingFileAddress(entry_point_addr)) {
-uint64_t symbol_id = m_symtab_up->GetNumSymbols();
-SectionSP section_sp =
-
GetSectionList()->FindSectionContainingFileAddress(entry_point_addr);
-Symbol symbol(
-symbol_id,
-GetNextSyntheticSymbolName().GetCString(), // Symbol name.
-false,   // Is the symbol name mangled?
-eSymbolTypeCode, // Type of this symbol.
-true,// Is this globally visible?
-false,   // Is this symbol debug info?
-false,   // Is this symbol a trampoline?
-true,// Is this symbol artificial?
-section_sp, // Section in which this symbol is defined or null.
-0,  // Offset in section or symbol value.
-0,  // Size.
-false,  // Size is valid.
-false,  // Contains linker annotations?
-0); // Symbol flags.
-m_symtab_up->AddSymbol(symbol);
-// When the entry point is arm thumb we need to explicitly set its
-// class address to reflect that. This is important because expression
-// evaluation relies on correctly setting a breakpoint at this address.
-if (arch.GetMachine() == llvm::Triple::arm && (entry_point_addr & 1))
-  m_address_class_map[entry_point_addr ^ 1] = 
AddressClass::eCodeAlternateISA;
-else
-  m_address_class_map[entry_point_addr] = AddressClass::eCode;
-  }
-}
-
 m_symtab_up->CalculateSymbolSizes();
   }
 

Modified: lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp?rev=373687&r1=373686&r2=373687&view=diff
==
--- lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp (original)
+++ lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Thu Oct  3 
18:45:58 2019
@@ -172,129 +172,3 @@ TEST_F(ObjectFileELFTest, GetModuleSpeci
   Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20);
   EXPECT_EQ(Spec.GetUUID(), Uuid);
 }
-
-TEST_F(ObjectFileELFTest, GetSym

[Lldb-commits] [lldb] r367247 - Test load unloading of modules with libraries-svr4

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Mon Jul 29 11:12:55 2019
New Revision: 367247

URL: http://llvm.org/viewvc/llvm-project?rev=367247&view=rev
Log:
Test load unloading of modules with libraries-svr4

Summary:
This doubles the 3 tests running right now on linux by also executing each test 
with libraries-svr4 enabled.
Not sure if there's a better way to do this as I had to copy/paste all the 
decorators as well...

Reviewers: labath, clayborg, xiaobai

Reviewed By: labath

Subscribers: srhines, lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=367247&r1=367246&r2=367247&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
 Mon Jul 29 11:12:55 2019
@@ -93,6 +93,13 @@ class LoadUnloadTestCase(TestBase):
 "Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" %
 (wd, err.GetCString()))
 
+def setSvr4Support(self, enabled):
+self.runCmd(
+"settings set plugin.process.gdb-remote.use-libraries-svr4 
{enabled}".format(
+enabled="true" if enabled else "false"
+)
+)
+
 # libloadunload_d.so does not appear in the image list because executable
 # dependencies are resolved relative to the debuggers PWD. Bug?
 @expectedFailureAll(oslist=["linux"])
@@ -224,6 +231,20 @@ class LoadUnloadTestCase(TestBase):
 @skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
 @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic 
libraries work differently
 def test_lldb_process_load_and_unload_commands(self):
+self.setSvr4Support(False)
+self.run_lldb_process_load_and_unload_commands()
+
+@expectedFailureAll(
+bugnumber="llvm.org/pr25805",
+hostoslist=["windows"],
+triple='.*-android')
+@skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
+@skipIfWindows  # Windows doesn't have dlopen and friends, dynamic 
libraries work differently
+def test_lldb_process_load_and_unload_commands_with_svr4(self):
+self.setSvr4Support(True)
+self.run_lldb_process_load_and_unload_commands()
+
+def run_lldb_process_load_and_unload_commands(self):
 """Test that lldb process load/unload command work correctly."""
 self.copy_shlibs_to_remote()
 
@@ -295,6 +316,15 @@ class LoadUnloadTestCase(TestBase):
 
 @skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
 def test_load_unload(self):
+self.setSvr4Support(False)
+self.run_load_unload()
+
+@skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
+def test_load_unload_with_svr4(self):
+self.setSvr4Support(True)
+self.run_load_unload()
+
+def run_load_unload(self):
 """Test breakpoint by name works correctly with dlopen'ing."""
 self.copy_shlibs_to_remote()
 
@@ -335,6 +365,16 @@ class LoadUnloadTestCase(TestBase):
 @skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
 @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic 
libraries work differently
 def test_step_over_load(self):
+self.setSvr4Support(False)
+self.run_step_over_load()
+
+@skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase 
support
+@skipIfWindows  # Windows doesn't have dlopen and friends, dynamic 
libraries work differently
+def test_step_over_load_with_svr4(self):
+self.setSvr4Support(True)
+self.run_step_over_load()
+
+def run_step_over_load(self):
 """Test stepping over code that loads a shared library works 
correctly."""
 self.copy_shlibs_to_remote()
 


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


[Lldb-commits] [lldb] r367052 - [LLDB] Find debugserver in Command Line Tools as well

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu Jul 25 13:53:00 2019
New Revision: 367052

URL: http://llvm.org/viewvc/llvm-project?rev=367052&view=rev
Log:
[LLDB] Find debugserver in Command Line Tools as well

Summary:
This might be an edge case in regular use but if you're shipping an lldb 
version with no debugserver lldb will try to use the System one.
However, lldb only knows how to find the Xcode one and not the Command Line 
Tools one. This diff fixes that.

We try to find debugserver with 
`PlatformDarwin::LocateExecutable("debugserver")`, we call `xcode-select -p` to 
get the path and then assume this path is of Xcode.

The changes I did are:
* Change `PlatformDarwin::LocateExecutable` to also add the Command Line Tools 
directory to the list of paths to search for debugserver.
* Created a new function to find the Command Line Tools directory named 
`GetCommandLineToolsLibraryPath`.
* Refactored the code that calls `xcode-select -p` into its own function 
`GetXcodeSelectPath()`. There were 2 identical pieces of code for this so I 
reduced it to one and used this function everywhere instead.
* I also changed `PlatformDarwin::GetSDKDirectoryForModules` to use the `SDKs` 
directory that exists in the Command Line Tools installation.

I'm not sure how to create tests for this. PlatformDarwinTest is really limited 
and I couldn't find how to mock Filesystem::Instance() so I could create a 
virtual file system.

Reviewers: clayborg, JDevlieghere

Reviewed By: clayborg, JDevlieghere

Subscribers: jasonmolenda, lldb-commits

Tags: #lldb

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

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=367052&r1=367051&r2=367052&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Thu Jul 25 
13:53:00 2019
@@ -1102,6 +1102,34 @@ bool PlatformDarwin::ARMGetSupportedArch
   return false;
 }
 
+static FileSpec GetXcodeSelectPath() {
+  static FileSpec g_xcode_select_filespec;
+
+  if (!g_xcode_select_filespec) {
+FileSpec xcode_select_cmd("/usr/bin/xcode-select");
+if (FileSystem::Instance().Exists(xcode_select_cmd)) {
+  int exit_status = -1;
+  int signo = -1;
+  std::string command_output;
+  Status status =
+  Host::RunShellCommand("/usr/bin/xcode-select --print-path",
+nullptr, // current working directory
+&exit_status, &signo, &command_output,
+std::chrono::seconds(2), // short timeout
+false);  // don't run in a 
shell
+  if (status.Success() && exit_status == 0 && !command_output.empty()) {
+size_t first_non_newline = command_output.find_last_not_of("\r\n");
+if (first_non_newline != std::string::npos) {
+  command_output.erase(first_non_newline + 1);
+}
+g_xcode_select_filespec = FileSpec(command_output);
+  }
+}
+  }
+
+  return g_xcode_select_filespec;
+}
+
 // Return a directory path like /Applications/Xcode.app/Contents/Developer
 const char *PlatformDarwin::GetDeveloperDirectory() {
   std::lock_guard guard(m_mutex);
@@ -1159,34 +1187,10 @@ const char *PlatformDarwin::GetDeveloper
 }
 
 if (!developer_dir_path_valid) {
-  FileSpec xcode_select_cmd("/usr/bin/xcode-select");
-  if (FileSystem::Instance().Exists(xcode_select_cmd)) {
-int exit_status = -1;
-int signo = -1;
-std::string command_output;
-Status error =
-Host::RunShellCommand("/usr/bin/xcode-select --print-path",
-  nullptr, // current working directory
-  &exit_status, &signo, &command_output,
-  std::chrono::seconds(2), // short timeout
-  false); // don't run in a shell
-if (error.Success() && exit_status == 0 && !command_output.empty()) {
-  const char *cmd_output_ptr = command_output.c_str();
-  developer_dir_path[sizeof(developer_dir_path) - 1] = '\0';
-  size_t i;
-  for (i = 0; i < sizeof(developer_dir_path) - 1; i++) {
-if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' ||
-cmd_output_ptr[i] == '\0')
-  break;
-developer_dir_path[i] = cmd_output_ptr[i];
-  }
-  developer_dir_path[i] = '\0';
-
-  FileSpec devel_dir(developer_dir_path);
-  if (FileSystem::Instance().IsDirectory(devel_dir)) {
-developer_dir_path_valid = true;
-  }
-}
+  FileSpec devel_dir = GetXcodeSel

[Lldb-commits] [lldb] r373680 - Explicitly set entry point arch when it's thumb

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Thu Oct  3 17:11:22 2019
New Revision: 373680

URL: http://llvm.org/viewvc/llvm-project?rev=373680&view=rev
Log:
Explicitly set entry point arch when it's thumb

Summary:
I found a case where the main android binary (app_process32) had thumb code at 
its entry point but no entry in the symbol table indicating this. This made 
lldb set a 4 byte breakpoint at that address (we default to arm code) instead 
of a 2 byte one (like we should for thumb).
The big deal with this is that the expression evaluator uses the entry point as 
a way to know when a JITed expression has finished executing by putting a 
breakpoint there. Because of this, evaluating expressions on certain android 
devices (Google Pixel something) made the process crash.
This was fixed by checking this specific situation when we parse the symbol 
table and add an artificial symbol for this 2 byte range and indicating that 
it's arm thumb.

I created 2 unit tests for this, one to check that now we know that the entry 
point is arm thumb, and the other to make sure we didn't change the behaviour 
for arm code.

I also run the following on the command line with the `app_process32` where I 
found the issue:
**Before:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32[0x1640]: .long  0xf0004668; unknown opcode
```
**After:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32`:
app_process32[0x1640] <+0>: movr0, sp
app_process32[0x1642]:  andeq  r0, r0, r0
```

Reviewers: clayborg, labath, wallace, espindola

Subscribers: srhines, emaste, arichardson, kristof.beyls, MaskRay, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s?rev=373680&view=auto
==
--- lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (added)
+++ lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s Thu Oct  3 17:11:22 
2019
@@ -0,0 +1,13 @@
+# REQUIRES: lld, arm
+
+# RUN: llvm-mc -triple=thumbv7-eabi %s -filetype=obj -o %t.o
+# RUN: ld.lld %t.o -o %t --section-start=.text=0x8074 -e 0x8075 -s
+# RUN: %lldb -x -b -o 'dis -s 0x8074 -e 0x8080' -- %t | FileCheck %s
+# CHECK:  {{.*}}[0x8074] <+0>: movs   r0, #0x2a
+# CHECK-NEXT: {{.*}}[0x8076] <+2>: movs   r7, #0x1
+# CHECK-NEXT: {{.*}}[0x8078] <+4>: svc#0x0
+
+_start:
+movs r0, #0x2a
+movs r7, #0x1
+svc #0x0
\ No newline at end of file

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=373680&r1=373679&r2=373680&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Oct  3 
17:11:22 2019
@@ -2703,6 +2703,46 @@ Symtab *ObjectFileELF::GetSymtab() {
 if (m_symtab_up == nullptr)
   m_symtab_up.reset(new Symtab(this));
 
+// In the event that there's no symbol entry for the entry point we'll
+// artifically create one. We delegate to the symtab object the figuring
+// out of the proper size, this will usually make it span til the next
+// symbol it finds in the section. This means that if there are missing
+// symbols the entry point might span beyond its function definition.
+// We're fine with this as it doesn't make it worse than not having a
+// symbol entry at all.
+ArchSpec arch = GetArchitecture();
+auto entry_point_addr = GetEntryPointAddress().GetFileAddress();
+if (entry_point_addr != LLDB_INVALID_ADDRESS) {
+  if (!m_symtab_up->FindSymbolContainingFileAddress(entry_point_addr)) {
+uint64_t symbol_id = m_symtab_up->GetNumSymbols();
+SectionSP section_sp =
+
GetSectionList()->FindSectionContainingFileAddress(entry_point_addr);
+Symbol symbol(
+symbol_id,
+GetNextSyntheticSymbolName().GetCString(), // Symbol name.
+false,   // Is the symbol name mangled?
+eSymbolTypeCode, // Type of this symbol.
+true,// Is this globally visible?
+false,   // Is this symbol debug info?
+false,   // Is this symbol a trampoline?
+true,// Is this symbol artificial?
+section_sp, // Section in which this symbol is defined or null.
+0,  // Offset in section or symbol value.
+0,  // Size.
+false,  // Size is valid.
+false,  // Contains lin

[Lldb-commits] [lldb] r366956 - [Support] move FileCollector from LLDB to llvm/Support

2019-10-04 Thread Alex Lorenz via lldb-commits
Author: arphaman
Date: Wed Jul 24 15:59:20 2019
New Revision: 366956

URL: http://llvm.org/viewvc/llvm-project?rev=366956&view=rev
Log:
[Support] move FileCollector from LLDB to llvm/Support

The file collector class is useful for creating reproducers,
not just for LLDB, but for other tools as well in LLVM/Clang.

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

Removed:
lldb/trunk/source/Utility/FileCollector.cpp
lldb/trunk/unittests/Utility/FileCollectorTest.cpp
Modified:
lldb/trunk/include/lldb/Utility/FileCollector.h
lldb/trunk/source/Utility/CMakeLists.txt
lldb/trunk/unittests/Utility/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Utility/FileCollector.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/FileCollector.h?rev=366956&r1=366955&r2=366956&view=diff
==
--- lldb/trunk/include/lldb/Utility/FileCollector.h (original)
+++ lldb/trunk/include/lldb/Utility/FileCollector.h Wed Jul 24 15:59:20 2019
@@ -11,65 +11,29 @@
 
 #include "lldb/Utility/FileSpec.h"
 
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/VirtualFileSystem.h"
-
-#include 
+#include "llvm/Support/FileCollector.h"
 
 namespace lldb_private {
 
 /// Collects files into a directory and generates a mapping that can be used by
 /// the VFS.
-class FileCollector {
+class FileCollector : public llvm::FileCollector {
 public:
-  FileCollector(const FileSpec &root, const FileSpec &overlay);
-
-  void AddFile(const llvm::Twine &file);
-  void AddFile(const FileSpec &file) { return AddFile(file.GetPath()); }
+  FileCollector(const FileSpec &root, const FileSpec &overlay) :
+llvm::FileCollector(root.GetPath(), overlay.GetPath()) {}
 
-  /// Write the yaml mapping (for the VFS) to the given file.
-  std::error_code WriteMapping(const FileSpec &mapping_file);
+  using llvm::FileCollector::AddFile;
 
-  /// Copy the files into the root directory.
-  ///
-  /// When stop_on_error is true (the default) we abort as soon as one file
-  /// cannot be copied. This is relatively common, for example when a file was
-  /// removed after it was added to the mapping.
-  std::error_code CopyFiles(bool stop_on_error = true);
-
-protected:
-  void AddFileImpl(llvm::StringRef src_path);
-
-  bool MarkAsSeen(llvm::StringRef path) { return m_seen.insert(path).second; }
-
-  bool GetRealPath(llvm::StringRef src_path,
-   llvm::SmallVectorImpl &result);
-
-  void AddFileToMapping(llvm::StringRef virtual_path,
-llvm::StringRef real_path) {
-m_vfs_writer.addFileMapping(virtual_path, real_path);
+  void AddFile(const FileSpec &file) {
+  std::string path = file.GetPath();
+  llvm::FileCollector::AddFile(path);
   }
 
-  /// Synchronizes adding files.
-  std::mutex m_mutex;
-
-  /// The root directory where files are copied.
-  FileSpec m_root;
-
-  /// The root directory where the VFS overlay lives.
-  FileSpec m_overlay_root;
-
-  /// Tracks already seen files so they can be skipped.
-  llvm::StringSet<> m_seen;
-
-  /// The yaml mapping writer.
-  llvm::vfs::YAMLVFSWriter m_vfs_writer;
-
-  /// Caches real_path calls when resolving symlinks.
-  llvm::StringMap m_symlink_map;
+  /// Write the yaml mapping (for the VFS) to the given file.
+  std::error_code WriteMapping(const FileSpec &mapping_file) {
+std::string path = mapping_file.GetPath();
+return llvm::FileCollector::WriteMapping(path);
+  }
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=366956&r1=366955&r2=366956&view=diff
==
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Wed Jul 24 15:59:20 2019
@@ -23,7 +23,6 @@ add_lldb_library(lldbUtility
   DataEncoder.cpp
   DataExtractor.cpp
   Environment.cpp
-  FileCollector.cpp
   Event.cpp
   FileSpec.cpp
   IOObject.cpp

Removed: lldb/trunk/source/Utility/FileCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileCollector.cpp?rev=366955&view=auto
==
--- lldb/trunk/source/Utility/FileCollector.cpp (original)
+++ lldb/trunk/source/Utility/FileCollector.cpp (removed)
@@ -1,182 +0,0 @@
-//===-- FileCollector.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 "lldb/Utility/FileCollector.h"
-
-#include "llvm/ADT/S

[Lldb-commits] [lldb] r373768 - Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Fri Oct  4 11:10:42 2019
New Revision: 373768

URL: http://llvm.org/viewvc/llvm-project?rev=373768&view=rev
Log:
Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS

Summary:
I'd like to install lldb using the install-distribution target with 
LLVM_DISTRIBUTION_COMPONENTS but this is currently not possible as the 
lldb/scripts do not provide any component we can use and install the python 
scripts.
For this effect I created an lldb-python-scripts target and added the 
install-lldb-python-scripts llvm install target.

I tested with:
cmake ... -DLLVM_ENABLE_PROJECTS="clang;lldb" 
-DLLVM_DISTRIBUTION_COMPONENTS="lldb;liblldb;lldb-python-scripts" ...
DESTDIR=... ninja install-distribution

Then checked with bin/lldb -x -o 'script import lldb'

Reviewers: labath, xiaobai, clayborg, lanza

Subscribers: mgorny, lldb-commits, smeenai, wallace

Tags: #lldb

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

Modified:
lldb/trunk/scripts/CMakeLists.txt

Modified: lldb/trunk/scripts/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=373768&r1=373767&r2=373768&view=diff
==
--- lldb/trunk/scripts/CMakeLists.txt (original)
+++ lldb/trunk/scripts/CMakeLists.txt Fri Oct  4 11:10:42 2019
@@ -69,5 +69,14 @@ if(NOT LLDB_BUILD_FRAMEWORK)
 OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/
+DESTINATION ${SWIG_INSTALL_DIR}
+COMPONENT lldb-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
+  endif()
 endif()


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


[Lldb-commits] [lldb] r366848 - Revert "Revert "Add ReadCStringFromMemory for faster string reads""

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jul 23 13:40:37 2019
New Revision: 366848

URL: http://llvm.org/viewvc/llvm-project?rev=366848&view=rev
Log:
Revert "Revert "Add ReadCStringFromMemory for faster string reads""

This reverts commit 9c10b620c0619611dfe062216459431955ac4801.

Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=366848&r1=366847&r2=366848&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jul 23 
13:40:37 2019
@@ -84,6 +84,31 @@ public:
   Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read);
 
+  /// Reads a null terminated string from memory.
+  ///
+  /// Reads up to \p max_size bytes of memory until it finds a '\0'.
+  /// If a '\0' is not found then it reads max_size-1 bytes as a string and a
+  /// '\0' is added as the last character of the \p buffer.
+  ///
+  /// \param[in] addr
+  /// The address in memory to read from.
+  ///
+  /// \param[in] buffer
+  /// An allocated buffer with at least \p max_size size.
+  ///
+  /// \param[in] max_size
+  /// The maximum number of bytes to read from memory until it reads the
+  /// string.
+  ///
+  /// \param[out] total_bytes_read
+  /// The number of bytes read from memory into \p buffer.
+  ///
+  /// \return
+  /// Returns a StringRef backed up by the \p buffer passed in.
+  llvm::Expected
+  ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size,
+size_t &total_bytes_read);
+
   virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
  size_t &bytes_written) = 0;
 

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=366848&r1=366847&r2=366848&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jul 23 13:40:37 
2019
@@ -16,6 +16,8 @@
 #include "lldb/Utility/State.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/Support/Process.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -659,6 +661,58 @@ Status NativeProcessProtocol::ReadMemory
   return Status();
 }
 
+llvm::Expected
+NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer,
+ size_t max_size,
+ size_t &total_bytes_read) {
+  static const size_t cache_line_size =
+  llvm::sys::Process::getPageSizeEstimate();
+  size_t bytes_read = 0;
+  size_t bytes_left = max_size;
+  addr_t curr_addr = addr;
+  size_t string_size;
+  char *curr_buffer = buffer;
+  total_bytes_read = 0;
+  Status status;
+
+  while (bytes_left > 0 && status.Success()) {
+addr_t cache_line_bytes_left =
+cache_line_size - (curr_addr % cache_line_size);
+addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left);
+status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer),
+bytes_to_read, bytes_read);
+
+if (bytes_read == 0)
+  break;
+
+void *str_end = std::memchr(curr_buffer, '\0', bytes_read);
+if (str_end != nullptr) {
+  total_bytes_read =
+  (size_t)(reinterpret_cast(str_end) - buffer + 1);
+  status.Clear();
+  break;
+}
+
+total_bytes_read += bytes_read;
+curr_buffer += bytes_read;
+curr_addr += bytes_read;
+bytes_left -= bytes_read;
+  }
+
+  string_size = total_bytes_read - 1;
+
+  // Make sure we return a null terminated string.
+  if (bytes_left == 0 && max_size > 0 && buffer[max_size - 1] != '\0') {
+buffer[max_size - 1] = '\0';
+total_bytes_read--;
+  }
+
+  if (!status.Success())
+return status.ToError();
+
+  return llvm::StringRef(buffer, string_size);
+}
+
 lldb::StateType NativeProcessProtocol::GetState() const {
   std::lock_guard guard(m_state_mutex);
   return m_state;

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=366848&r1=366847&r2=366848&view=diff
==
--- lldb/t

[Lldb-commits] [lldb] r366847 - Revert "Revert "Implement xfer:libraries-svr4:read packet""

2019-10-04 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Jul 23 13:40:30 2019
New Revision: 366847

URL: http://llvm.org/viewvc/llvm-project?rev=366847&view=rev
Log:
Revert "Revert "Implement xfer:libraries-svr4:read packet""

This reverts commit 08c38f77c5fb4d3735ec215032fed8ee6730b3db.

Added:
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h

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

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

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=366847&r1=366846&r2=366847&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jul 23 
13:40:30 2019
@@ -32,6 +32,14 @@ namespace lldb_private {
 class MemoryRegionInfo;
 class ResumeActionList;
 
+struct SVR4LibraryInfo {
+  std::string name;
+  lldb::addr_t link_map;
+  lldb::addr_t base_addr;
+  lldb::addr_t ld_addr;
+  lldb::addr_t next;
+};
+
 // NativeProcessProtocol
 class NativeProcessProtocol {
 public:
@@ -86,6 +94,12 @@ public:
 
   virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0;
 
+  virtual llvm::Expected>
+  GetLoadedSVR4Libraries() {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Not implemented");
+  }
+
   virtual bool IsAlive() const;
 
   virtual size_t UpdateThreads() = 0;

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=366847&r1=366846&r2=366847&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
 Tue Jul 23 13:40:30 2019
@@ -513,7 +513,8 @@ class GdbRemoteTestCaseBase(TestBase):
 self,
 inferior_args=None,
 inferior_sleep_seconds=3,
-inferior_exe_path=None):
+inferior_exe_path=None,
+inferior_env=None):
 """Prep the debug monitor, the inferior, and the expected packet 
stream.
 
 Handle the separate cases of using the debug monitor in 
attach-to-inferior mode
@@ -576,6 +577,9 @@ class GdbRemoteTestCaseBase(TestBase):
 
 # Build the expected protocol stream
 self.add_no_ack_remote_stream()
+if inferior_env:
+for name, value in inferior_env.items():
+self.add_set_environment_packets(name, value)
 if self._inferior_startup == self._STARTUP_LAUNCH:
 self.add_verified_launch_packets(launch_args)
 
@@ -656,6 +660,12 @@ class GdbRemoteTestCaseBase(TestBase):
  {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", 
"capture": {1: "process_info_raw"}}],
 True)
 
+def add_set_environment_packets(self, name, value):
+self.test_sequence.add_log_lines(
+["read packet: $QEnvironment:" + name + "=" + value + "#00",
+ "send packet: $OK#00",
+ ], True)
+
 _KNOWN_PROCESS_INFO_KEYS = [
 "pid",
 "parent-pid",
@@ -816,6 +826,7 @@ class GdbRemoteTestCaseBase(TestBase):
 "error"])
 self.assertIsNotNone(val)
 
+mem_region_dict["name"] = seven.unhexlify(mem_region_dict.get("name", 
""))
 # Return the dictionary of key-value pairs 

[Lldb-commits] [lldb] r341320 - [PseudoTerminal][NFC] Use llvm errno helpers

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Mon Sep  3 07:59:57 2018
New Revision: 341320

URL: http://llvm.org/viewvc/llvm-project?rev=341320&view=rev
Log:
[PseudoTerminal][NFC] Use llvm errno helpers

Summary:
LLVM provide (str)errno helpers, so convert code to use it.

Also fixes warning:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Host/common/PseudoTerminal.cpp:248:25:
 warning: ignoring return value of ‘char* strerror_r(int, char*, size_t)’, 
declared with attribute warn_unused_result [-Wunused-result]
 ::strerror_r(errno, error_str, error_len);

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: abidh, lldb-commits

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

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

Modified: lldb/trunk/source/Host/common/PseudoTerminal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/PseudoTerminal.cpp?rev=341320&r1=341319&r2=341320&view=diff
==
--- lldb/trunk/source/Host/common/PseudoTerminal.cpp (original)
+++ lldb/trunk/source/Host/common/PseudoTerminal.cpp Mon Sep  3 07:59:57 2018
@@ -10,7 +10,8 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/Config.h"
 
-#include 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 #include 
@@ -27,6 +28,14 @@ int posix_openpt(int flags);
 using namespace lldb_private;
 
 //--
+// Write string describing error number
+//--
+static void ErrnoToStr(char *error_str, size_t error_len) {
+  std::string strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
+
+//--
 // PseudoTerminal constructor
 //--
 PseudoTerminal::PseudoTerminal()
@@ -88,14 +97,14 @@ bool PseudoTerminal::OpenFirstAvailableM
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 return false;
   }
 
   // Grant access to the slave pseudo terminal
   if (::grantpt(m_master_fd) < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 CloseMasterFileDescriptor();
 return false;
   }
@@ -103,7 +112,7 @@ bool PseudoTerminal::OpenFirstAvailableM
   // Clear the lock flag on the slave pseudo terminal
   if (::unlockpt(m_master_fd) < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 CloseMasterFileDescriptor();
 return false;
   }
@@ -143,7 +152,7 @@ bool PseudoTerminal::OpenSlave(int oflag
 
   if (m_slave_fd < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 return false;
   }
 
@@ -175,7 +184,7 @@ const char *PseudoTerminal::GetSlaveName
   const char *slave_name = ::ptsname(m_master_fd);
 
   if (error_str && slave_name == nullptr)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 
   return slave_name;
 }
@@ -213,7 +222,7 @@ lldb::pid_t PseudoTerminal::Fork(char *e
 if (pid < 0) {
   // Fork failed
   if (error_str)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 } else if (pid == 0) {
   // Child Process
   ::setsid();
@@ -229,23 +238,23 @@ lldb::pid_t PseudoTerminal::Fork(char *e
 // Acquire the controlling terminal
 if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
   if (error_str)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 #endif
 // Duplicate all stdio file descriptors to the slave pseudo terminal
 if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 
 if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 
 if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
   }
 } else {


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


[Lldb-commits] [lldb] r341340 - [NFC] Fixed enum constant in boolean context error

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Mon Sep  3 15:09:08 2018
New Revision: 341340

URL: http://llvm.org/viewvc/llvm-project?rev=341340&view=rev
Log:
[NFC] Fixed enum constant in boolean context error

Summary:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:656:59:
 warning: enum constant in boolean context [-Wint-in-bool-context]
 if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
   ^~~~
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:658:62:
 warning: enum constant in boolean context [-Wint-in-bool-context]
 if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)

Reviewers: JDevlieghere, teemperor

Reviewed By: teemperor

Subscribers: abidh, lldb-commits

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

Modified:

lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Modified: 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=341340&r1=341339&r2=341340&view=diff
==
--- 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
 Mon Sep  3 15:09:08 2018
@@ -652,11 +652,12 @@ bool DynamicLoaderDarwinKernel::KextImag
 
   llvm::MachO::mach_header mh;
   size_t size_to_read = 512;
-  if (ReadMachHeader (m_load_address, process, mh)) {
-if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
-  size_to_read = sizeof (llvm::MachO::mach_header) + mh.sizeofcmds;
-if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)
-  size_to_read = sizeof (llvm::MachO::mach_header_64) + mh.sizeofcmds;
+  if (ReadMachHeader(m_load_address, process, mh)) {
+if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
+  size_to_read = sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
+if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
+mh.magic == llvm::MachO::MH_MAGIC_64)
+  size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
   }
 
   ModuleSP memory_module_sp =


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


[Lldb-commits] [lldb] r341339 - [NFC] Use llvm_unreachable instead of lldb::assert

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Mon Sep  3 15:08:30 2018
New Revision: 341339

URL: http://llvm.org/viewvc/llvm-project?rev=341339&view=rev
Log:
[NFC] Use llvm_unreachable instead of lldb::assert 

Summary: Fixes implicit fall through warnings

Reviewers: JDevlieghere, teemperor

Reviewed By: teemperor

Subscribers: lldb-commits

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

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

Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=341339&r1=341338&r2=341339&view=diff
==
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Mon Sep  3 15:08:30 2018
@@ -526,7 +526,7 @@ int Editline::GetCharacter(EditLineGetCh
 break;
 
   case lldb::eConnectionStatusInterrupted:
-lldbassert(0 && "Interrupts should have been handled above.");
+llvm_unreachable("Interrupts should have been handled above.");
 
   case lldb::eConnectionStatusError:// Check GetError() for details
   case lldb::eConnectionStatusTimedOut: // Request timed out


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


[Lldb-commits] [lldb] r341334 - [ClangUserExpression][NFC] Removed unused code

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Mon Sep  3 11:21:21 2018
New Revision: 341334

URL: http://llvm.org/viewvc/llvm-project?rev=341334&view=rev
Log:
[ClangUserExpression][NFC] Removed unused code

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

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=341334&r1=341333&r2=341334&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
Mon Sep  3 11:21:21 2018
@@ -655,10 +655,6 @@ bool ClangUserExpression::Complete(Execu
   if (!PrepareForParsing(diagnostic_manager, exe_ctx))
 return false;
 
-  lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown;
-  if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx))
-lang_type = new_lang.getValue();
-
   if (log)
 log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
 


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


[Lldb-commits] [lldb] r341387 - Terminate debugger if an assert was hit

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Tue Sep  4 10:19:15 2018
New Revision: 341387

URL: http://llvm.org/viewvc/llvm-project?rev=341387&view=rev
Log:
Terminate debugger if an assert was hit

Reviewers: JDevlieghere, teemperor, #lldb

Reviewed By: JDevlieghere

Subscribers: clayborg, lemo, lldb-commits

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

Modified:
lldb/trunk/source/Utility/LLDBAssert.cpp

Modified: lldb/trunk/source/Utility/LLDBAssert.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/LLDBAssert.cpp?rev=341387&r1=341386&r2=341387&view=diff
==
--- lldb/trunk/source/Utility/LLDBAssert.cpp (original)
+++ lldb/trunk/source/Utility/LLDBAssert.cpp Tue Sep  4 10:19:15 2018
@@ -19,14 +19,14 @@ using namespace lldb_private;
 void lldb_private::lldb_assert(bool expression, const char *expr_text,
const char *func, const char *file,
unsigned int line) {
-  if (expression)
-;
-  else {
-errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
- expr_text, func, file, line);
-errs() << "backtrace leading to the failure:\n";
-llvm::sys::PrintStackTrace(errs());
-errs() << "please file a bug report against lldb reporting this failure "
-  "log, and as many details as possible\n";
-  }
+  if (LLVM_LIKELY(expression))
+return;
+
+  errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
+   expr_text, func, file, line);
+  errs() << "backtrace leading to the failure:\n";
+  llvm::sys::PrintStackTrace(errs());
+  errs() << "please file a bug report against lldb reporting this failure "
+"log, and as many details as possible\n";
+  abort();
 }


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


[Lldb-commits] [lldb] r341746 - Check if a terminal supports colors on Windows properly

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Sat Sep  8 00:15:56 2018
New Revision: 341746

URL: http://llvm.org/viewvc/llvm-project?rev=341746&view=rev
Log:
Check if a terminal supports colors on Windows properly

Summary:
Previously we SetUseColor(true) wrongly when output was not a terminal so it 
broken some (not public) bots.

Thanks for issue report, @stella.stamenova

Reviewers: stella.stamenova, zturner

Reviewed By: stella.stamenova

Subscribers: abidh, lldb-commits, stella.stamenova

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

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

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=341746&r1=341745&r2=341746&view=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Sat Sep  8 00:15:56 2018
@@ -812,7 +812,6 @@ Debugger::Debugger(lldb::LogOutputCallba
   // Enabling use of ANSI color codes because LLDB is using them to highlight
   // text.
   llvm::sys::Process::UseANSIEscapeCodes(true);
-  SetUseColor(true);
 #endif
 }
 

Modified: lldb/trunk/source/Host/common/File.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=341746&r1=341745&r2=341746&view=diff
==
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Sat Sep  8 00:15:56 2018
@@ -806,6 +806,9 @@ void File::CalculateInteractiveAndTermin
 if (_isatty(fd)) {
   m_is_interactive = eLazyBoolYes;
   m_is_real_terminal = eLazyBoolYes;
+#if defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+  m_supports_colors = eLazyBoolYes;
+#endif
 }
 #else
 if (isatty(fd)) {


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


[Lldb-commits] [lldb] r357336 - [CMake] Add missing test dep

2019-10-04 Thread David Zarzycki via lldb-commits
Author: davezarzycki
Date: Fri Mar 29 17:00:19 2019
New Revision: 357336

URL: http://llvm.org/viewvc/llvm-project?rev=357336&view=rev
Log:
[CMake] Add missing test dep

lit/SymbolFile/NativePDB/globals-bss.cpp needs llvm-readobj

Modified:
lldb/trunk/lit/CMakeLists.txt

Modified: lldb/trunk/lit/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=357336&r1=357335&r2=357336&view=diff
==
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Fri Mar 29 17:00:19 2019
@@ -26,6 +26,7 @@ list(APPEND LLDB_TEST_DEPS
   llvm-config
   llvm-mc
   llvm-objcopy
+  llvm-readobj
   )
 
 if(TARGET lld)


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


[Lldb-commits] [lldb] r341315 - [Symtab][NFC] Added llvm_unreachable to supress compiler warning

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Mon Sep  3 05:57:54 2018
New Revision: 341315

URL: http://llvm.org/viewvc/llvm-project?rev=341315&view=rev
Log:
[Symtab][NFC] Added llvm_unreachable to supress compiler warning

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

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

Modified:
lldb/trunk/source/Symbol/Symtab.cpp

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=341315&r1=341314&r2=341315&view=diff
==
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Mon Sep  3 05:57:54 2018
@@ -249,6 +249,7 @@ static bool lldb_skip_name(llvm::StringR
   case Mangled::eManglingSchemeNone:
 return true;
   }
+  llvm_unreachable("unknown scheme!");
 }
 
 void Symtab::InitNameIndexes() {


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


[Lldb-commits] [lldb] r345637 - NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)

2019-10-04 Thread Erik Pilkington via lldb-commits
Author: epilk
Date: Tue Oct 30 13:31:30 2018
New Revision: 345637

URL: http://llvm.org/viewvc/llvm-project?rev=345637&view=rev
Log:
NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)

We haven't supported compiling ObjC1 for a long time (and never will again), so
there isn't any reason to keep these separate. This patch replaces
LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC.

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

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
lldb/trunk/source/Symbol/ClangASTContext.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=345637&r1=345636&r2=345637&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Tue Oct 30 13:31:30 2018
@@ -381,8 +381,7 @@ ClangExpressionParser::ClangExpressionPa
 m_compiler->getLangOpts().CPlusPlus = true;
 break;
   case lldb::eLanguageTypeObjC:
-m_compiler->getLangOpts().ObjC1 = true;
-m_compiler->getLangOpts().ObjC2 = true;
+m_compiler->getLangOpts().ObjC = true;
 // FIXME: the following language option is a temporary workaround,
 // to "ask for ObjC, get ObjC++" (see comment above).
 m_compiler->getLangOpts().CPlusPlus = true;
@@ -406,13 +405,12 @@ ClangExpressionParser::ClangExpressionPa
 // FIXME: the following language option is a temporary workaround,
 // to "ask for C++, get ObjC++".  Apple hopes to remove this requirement on
 // non-Apple platforms, but for now it is needed.
-m_compiler->getLangOpts().ObjC1 = true;
+m_compiler->getLangOpts().ObjC = true;
 break;
   case lldb::eLanguageTypeObjC_plus_plus:
   case lldb::eLanguageTypeUnknown:
   default:
-m_compiler->getLangOpts().ObjC1 = true;
-m_compiler->getLangOpts().ObjC2 = true;
+m_compiler->getLangOpts().ObjC = true;
 m_compiler->getLangOpts().CPlusPlus = true;
 m_compiler->getLangOpts().CPlusPlus11 = true;
 m_compiler->getHeaderSearchOpts().UseLibcxx = true;
@@ -436,7 +434,7 @@ ClangExpressionParser::ClangExpressionPa
   // long time parsing and importing debug information.
   m_compiler->getLangOpts().SpellChecking = false;
 
-  if (process_sp && m_compiler->getLangOpts().ObjC1) {
+  if (process_sp && m_compiler->getLangOpts().ObjC) {
 if (process_sp->GetObjCLanguageRuntime()) {
   if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() ==
   ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)

Modified: lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp?rev=345637&r1=345636&r2=345637&view=diff
==
--- lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp 
(original)
+++ lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp Tue Oct 
30 13:31:30 2018
@@ -155,7 +155,8 @@ void ClangHighlighter::Highlight(const H
   // Let's just enable the latest ObjC and C++ which should get most tokens
   // right.
   LangOptions Opts;
-  Opts.ObjC2 = true;
+  Opts.ObjC = true;
+  // FIXME: This should probably set CPlusPlus, CPlusPlus11, ... too
   Opts.CPlusPlus17 = true;
   Opts.LineComment = true;
 

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=345637&r1=345636&r2=345637&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct 30 13:31:30 2018
@@ -459,7 +459,7 @@ static void ParseLangArgs(LangOptions &O
   if (IK.getLanguage() == InputKind::Asm) {
 Opts.AsmPreprocessor = 1;
   } else if (IK.isObjectiveC()) {
-Opts.ObjC1 = Opts.ObjC2 = 1;
+Opts.ObjC = 1;
   }
 
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;


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


[Lldb-commits] [lldb] r342075 - Do not create new terminals when launching process on Windows with --no-stdio

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Wed Sep 12 12:50:45 2018
New Revision: 342075

URL: http://llvm.org/viewvc/llvm-project?rev=342075&view=rev
Log:
Do not create new terminals when launching process on Windows with --no-stdio

Summary: Partially fixes PR38222

Reviewers: teemperor, zturner, stella.stamenova

Reviewed By: zturner, stella.stamenova

Subscribers: JDevlieghere, clayborg, labath, abidh, lldb-commits

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

Modified:
lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp

Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=342075&r1=342074&r2=342075&view=diff
==
--- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Wed Sep 12 
12:50:45 2018
@@ -76,6 +76,9 @@ ProcessLauncherWindows::LaunchProcess(co
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
 flags |= DEBUG_ONLY_THIS_PROCESS;
 
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO))
+flags &= ~CREATE_NEW_CONSOLE;
+
   LPVOID env_block = nullptr;
   ::CreateEnvironmentBuffer(launch_info.GetEnvironment(), environment);
   if (!environment.empty())


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


[Lldb-commits] [lldb] r341497 - Set Windows console mode to enable support for ansi escape codes

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Wed Sep  5 15:06:58 2018
New Revision: 341497

URL: http://llvm.org/viewvc/llvm-project?rev=341497&view=rev
Log:
Set Windows console mode to enable support for ansi escape codes

Summary:
Windows console now supports supports ANSI escape codes, but we need to enable 
it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences.

Syntax hightlighting now works fine on Windows:
https://i.imgur.com/P0i04A7.png

Reviewers: JDevlieghere, teemperor, zturner

Reviewed By: zturner

Subscribers: abidh, lldb-commits

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

Modified:
lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=341497&r1=341496&r2=341497&view=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Sep  5 15:06:58 2018
@@ -50,6 +50,7 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#include "lldb/Host/windows/windows.h"
 #endif
 
 #include "llvm/ADT/None.h"  // for None
@@ -58,6 +59,7 @@
 #include "llvm/ADT/iterator.h" // for iterator_facade_...
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h" // for raw_fd_ostream
 
@@ -804,6 +806,13 @@ Debugger::Debugger(lldb::LogOutputCallba
   // Turn off use-color if we don't write to a terminal with color support.
   if (!m_output_file_sp->GetFile().GetIsTerminalWithColors())
 SetUseColor(false);
+
+#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+  // Enabling use of ANSI color codes because LLDB is using them to highlight
+  // text.
+  llvm::sys::Process::UseANSIEscapeCodes(true);
+  SetUseColor(true);
+#endif
 }
 
 Debugger::~Debugger() { Clear(); }


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


[Lldb-commits] [lldb] r366912 - [AIX][lit] Don't depend on psutil on AIX

2019-10-04 Thread David Tenty via lldb-commits
Author: daltenty
Date: Wed Jul 24 08:04:27 2019
New Revision: 366912

URL: http://llvm.org/viewvc/llvm-project?rev=366912&view=rev
Log:
[AIX][lit] Don't depend on psutil on AIX

Summary:
On AIX psutil can run into problems with permissions to read the process
tree, which causes problems for python timeout tests which need to kill off
a test and it's children.

This patch adds a workaround by invoking shell via subprocess and using a
platform specific option to ps to list all the descendant processes so we can
kill them. We add some checks so lit can tell whether timeout tests are
supported with out exposing whether we are utilizing the psutil
implementation or the alternative.

Reviewers: hubert.reinterpretcast, andusy, davide, delcypher

Reviewed By: delcypher

Subscribers: davide, delcypher, christof, lldb-commits, libcxx-commits, 
llvm-commits

Tags: #lldb, #libc, #llvm

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

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

Modified: lldb/trunk/lit/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/lit.cfg.py?rev=366912&r1=366911&r2=366912&view=diff
==
--- lldb/trunk/lit/lit.cfg.py (original)
+++ lldb/trunk/lit/lit.cfg.py Wed Jul 24 08:04:27 2019
@@ -1,6 +1,7 @@
 # -*- Python -*-
 
 import os
+import platform
 import re
 import shutil
 import site
@@ -75,13 +76,14 @@ for i in ['module-cache-clang', 'module-
 shutil.rmtree(cachedir)
 
 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
-# requires the psutil module and lit complains if the value is set but the
-# module can't be found.
-try:
-import psutil  # noqa: F401
+# requires that killProcessAndChildren() is supported on the platform and
+# lit complains if the value is set but it is not supported.
+supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
+if supported:
 lit_config.maxIndividualTestTime = 600
-except ImportError:
-pass
+else:
+lit_config.warning("Could not set a default per-test timeout. " + errormsg)
+
 
 # If running tests natively, check for CPU features needed for some tests.
 


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


[Lldb-commits] [lldb] r373074 - [lldb] Disable testing entry values as memory location

2019-10-04 Thread Djordje Todorovic via lldb-commits
Author: djtodoro
Date: Fri Sep 27 05:16:29 2019
New Revision: 373074

URL: http://llvm.org/viewvc/llvm-project?rev=373074&view=rev
Log:
[lldb] Disable testing entry values as memory location

The D67717 excludes such locations for now.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp?rev=373074&r1=373073&r2=373074&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp
 Fri Sep 27 05:16:29 2019
@@ -152,7 +152,10 @@ int main() {
   func2(sink, 123);
 
   // Test evaluation of "DW_OP_fbreg -24, DW_OP_deref" in the parent frame.
+  // Disabled for now, see: llvm.org/PR43343
+#if 0
   func3(sink, s1.field2);
+#endif
 
   // The sequences `main -> func4 -> func{5,6}_amb -> sink` are both plausible.
   // Test that lldb doesn't attempt to guess which one occurred: entry value


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


[Lldb-commits] [lldb] r345755 - [NFC] Fixed -Wsign-compare warning

2019-10-04 Thread David Bolvansky via lldb-commits
Author: xbolva00
Date: Wed Oct 31 11:03:36 2018
New Revision: 345755

URL: http://llvm.org/viewvc/llvm-project?rev=345755&view=rev
Log:
[NFC] Fixed -Wsign-compare warning

Modified:

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Modified: 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=345755&r1=345754&r2=345755&view=diff
==
--- 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
Wed Oct 31 11:03:36 2018
@@ -1547,7 +1547,7 @@ lldb::ValueObjectListSP ScriptInterprete
   if (py_return.get()) {
 PythonList result_list(PyRefType::Borrowed, py_return.get());
 ValueObjectListSP result = ValueObjectListSP(new ValueObjectList());
-for (int i = 0; i < result_list.GetSize(); i++) {
+for (size_t i = 0; i < result_list.GetSize(); i++) {
   PyObject *item = result_list.GetItemAtIndex(i).get();
   lldb::SBValue *sb_value_ptr =
   (lldb::SBValue *)g_swig_cast_to_sbvalue(item);


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


[Lldb-commits] [lldb] r373775 - [lldb] Fix crash on SBCommandReturnObject & assignment

2019-10-04 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Fri Oct  4 12:32:57 2019
New Revision: 373775

URL: http://llvm.org/viewvc/llvm-project?rev=373775&view=rev
Log:
[lldb] Fix crash on SBCommandReturnObject & assignment

I was writing an SB API client and it was crashing on:
bool DoExecute(SBDebugger dbg, char **command, SBCommandReturnObject 
&result) {
  result = subcommand(dbg, "help");

That is because SBCommandReturnObject &result gets initialized inside LLDB by:
bool DoExecute(Args &command, CommandReturnObject &result) override {
  // std::unique_ptr gets initialized here from `&result`!!!
  SBCommandReturnObject sb_return(&result);
  DoExecute(...);
  sb_return.Release();

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile

lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
Modified:
lldb/trunk/include/lldb/API/SBCommandReturnObject.h
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/API/SBCommandReturnObject.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=373775&r1=373774&r2=373775&view=diff
==
--- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Fri Oct  4 12:32:57 2019
@@ -15,23 +15,27 @@
 
 #include "lldb/API/SBDefines.h"
 
+namespace lldb_private {
+class SBCommandReturnObjectImpl;
+};
+
 namespace lldb {
 
 class LLDB_API SBCommandReturnObject {
 public:
   SBCommandReturnObject();
 
+  SBCommandReturnObject(lldb_private::CommandReturnObject &ref);
+
+  // rvalue ctor+assignment are incompatible with Reproducers.
+
   SBCommandReturnObject(const lldb::SBCommandReturnObject &rhs);
 
   ~SBCommandReturnObject();
 
-  const lldb::SBCommandReturnObject &
+  lldb::SBCommandReturnObject &
   operator=(const lldb::SBCommandReturnObject &rhs);
 
-  SBCommandReturnObject(lldb_private::CommandReturnObject *ptr);
-
-  lldb_private::CommandReturnObject *Release();
-
   explicit operator bool() const;
 
   bool IsValid() const;
@@ -86,6 +90,9 @@ public:
 
   void SetError(const char *error_cstr);
 
+  // ref() is internal for LLDB only.
+  lldb_private::CommandReturnObject &ref() const;
+
 protected:
   friend class SBCommandInterpreter;
   friend class SBOptions;
@@ -96,10 +103,8 @@ protected:
 
   lldb_private::CommandReturnObject &operator*() const;
 
-  lldb_private::CommandReturnObject &ref() const;
-
 private:
-  std::unique_ptr m_opaque_up;
+  std::unique_ptr m_opaque_up;
 };
 
 } // namespace lldb

Added: 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile?rev=373775&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile 
Fri Oct  4 12:32:57 2019
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py?rev=373775&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
 Fri Oct  4 12:32:57 2019
@@ -0,0 +1,31 @@
+"""Test the lldb public C++ api for returning SBCommandReturnObject."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSBCommandReturnObject(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfNoSBHeaders
+def test_sb_command_return_object(self):
+env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+
+self.driver_exe = self.getBuildArtifact("command-return-object")
+self.buildDriver('main.cpp', self.driver_exe)
+self.addTearDownHook(lambda: os.remove(self.driver_exe))
+self.signBinary(self.driver_exe)
+
+if self.TraceOn():
+print("Running test %s" % sel

[Lldb-commits] [PATCH] D67589: Fix crash on SBCommandReturnObject & assignment

2019-10-04 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373775: [lldb] Fix crash on SBCommandReturnObject & 
assignment (authored by jankratochvil, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67589?vs=222114&id=223263#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67589

Files:
  lldb/trunk/include/lldb/API/SBCommandReturnObject.h
  lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
  lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
  lldb/trunk/scripts/Python/python-wrapper.swig
  lldb/trunk/source/API/SBCommandInterpreter.cpp
  lldb/trunk/source/API/SBCommandReturnObject.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
@@ -0,0 +1,35 @@
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBDebugger.h"
+
+using namespace lldb;
+
+static SBCommandReturnObject subcommand(SBDebugger &dbg, const char *cmd) {
+  SBCommandReturnObject Result;
+  dbg.GetCommandInterpreter().HandleCommand(cmd, Result);
+  return Result;
+}
+
+class CommandCrasher : public SBCommandPluginInterface {
+public:
+  bool DoExecute(SBDebugger dbg, char **command,
+ SBCommandReturnObject &result) {
+// Test assignment from a different SBCommandReturnObject instance.
+result = subcommand(dbg, "help");
+// Test also whether self-assignment is handled correctly.
+result = result;
+if (!result.Succeeded())
+  return false;
+return true;
+  }
+};
+
+int main() {
+  SBDebugger::Initialize();
+  SBDebugger dbg = SBDebugger::Create(false /*source_init_files*/);
+  SBCommandInterpreter interp = dbg.GetCommandInterpreter();
+  static CommandCrasher crasher;
+  interp.AddCommand("crasher", &crasher, nullptr /*help*/);
+  SBCommandReturnObject Result;
+  dbg.GetCommandInterpreter().HandleCommand("crasher", Result);
+}
Index: lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
+++ lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
@@ -0,0 +1,31 @@
+"""Test the lldb public C++ api for returning SBCommandReturnObject."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSBCommandReturnObject(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfNoSBHeaders
+def test_sb_command_return_object(self):
+env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+
+self.driver_exe = self.getBuildArtifact("command-return-object")
+self.buildDriver('main.cpp', self.driver_exe)
+self.addTearDownHook(lambda: os.remove(self.driver_exe))
+self.signBinary(self.driver_exe)
+
+if self.TraceOn():
+print("Running test %s" % self.driver_exe)
+check_call([self.driver_exe, self.driver_exe], env=env)
+else:
+with open(os.devnull, 'w') as fnull:
+check_call([self.driver_exe, self.driver_exe],
+   env=env, stdout=fnull, stderr=fnull)
Index: lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/api/command-return-object/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/trunk/source/API/SBCommandReturnObject.cpp
===
--- lldb/trunk/source/API/SBCommandReturnObject.cpp
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp
@@ -18,11 +18,43 @@
 using namespace lldb;
 using namespace lldb_private;
 
+class lldb_private::SBCommandReturnObjectImpl {
+public:
+  SBCommandReturnObjectImpl()
+  : m_ptr(new CommandReturnObject()), m_owned(true) {}
+  SBCommandReturnObjectImpl(CommandReturnObject &ref)
+  : m_ptr(&ref), m_owned(false) {}
+  SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs)
+  : m_ptr(new CommandReturnObject(*rhs.m_ptr)), m_owned(rhs.m_owned) {}
+  SBCommandRe

[Lldb-commits] [lldb] r373777 - [MachO] Reformat before making changes to this file (NFC)

2019-10-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Oct  4 12:37:52 2019
New Revision: 373777

URL: http://llvm.org/viewvc/llvm-project?rev=373777&view=rev
Log:
[MachO] Reformat before making changes to this file (NFC)

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=373777&r1=373776&r2=373777&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Oct  4 
12:37:52 2019
@@ -109,8 +109,8 @@ struct lldb_copy_dyld_cache_local_symbol
 };
 
 static void PrintRegisterValue(RegisterContext *reg_ctx, const char *name,
-  const char *alt_name, size_t reg_byte_size,
-  Stream &data) {
+   const char *alt_name, size_t reg_byte_size,
+   Stream &data) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
   if (reg_info == nullptr)
 reg_info = reg_ctx->GetRegisterInfoByName(alt_name);
@@ -121,8 +121,7 @@ static void PrintRegisterValue(RegisterC
 data.Write(reg_value.GetBytes(), reg_byte_size);
   else {
 data.Write(reg_value.GetBytes(), reg_info->byte_size);
-for (size_t i = 0, n = reg_byte_size - reg_info->byte_size; i < n;
- ++i)
+for (size_t i = 0, n = reg_byte_size - reg_info->byte_size; i < n; ++i)
   data.PutChar(0);
   }
   return;
@@ -1434,7 +1433,7 @@ static lldb::SectionType GetSectionType(
   if (section_name == g_sect_name_dwarf_debug_pubtypes)
 return eSectionTypeDWARFDebugPubTypes;
   if (section_name == g_sect_name_dwarf_debug_ranges)
-return eSectionTypeDWARFDebugRanges; 
+return eSectionTypeDWARFDebugRanges;
   if (section_name == g_sect_name_dwarf_debug_str)
 return eSectionTypeDWARFDebugStr;
   if (section_name == g_sect_name_dwarf_debug_types)
@@ -1597,7 +1596,7 @@ void ObjectFileMachO::ProcessSegmentComm
 // the file
 load_cmd.filesize, // Size in bytes of this section as found
 // in the file
-0,// Segments have no alignment information
+0,   // Segments have no alignment information
 load_cmd.flags); // Flags for this section
 
 segment_sp->SetIsEncrypted(segment_is_encrypted);
@@ -2228,14 +2227,15 @@ size_t ObjectFileMachO::ParseSymtab() {
 
   UUID lldb_shared_cache;
   addr_t lldb_shared_cache_addr;
-  GetLLDBSharedCacheUUID (lldb_shared_cache_addr, lldb_shared_cache);
+  GetLLDBSharedCacheUUID(lldb_shared_cache_addr, lldb_shared_cache);
   UUID process_shared_cache;
   addr_t process_shared_cache_addr;
-  GetProcessSharedCacheUUID(process, process_shared_cache_addr, 
process_shared_cache);
+  GetProcessSharedCacheUUID(process, process_shared_cache_addr,
+process_shared_cache);
   bool use_lldb_cache = true;
   if (lldb_shared_cache.IsValid() && process_shared_cache.IsValid() &&
-  (lldb_shared_cache != process_shared_cache
-   || process_shared_cache_addr != lldb_shared_cache_addr)) {
+  (lldb_shared_cache != process_shared_cache ||
+   process_shared_cache_addr != lldb_shared_cache_addr)) {
 use_lldb_cache = false;
   }
 
@@ -2282,26 +2282,26 @@ size_t ObjectFileMachO::ParseSymtab() {
 indirect_symbol_index_data.SetData(
 indirect_syms_data_sp, 0,
 indirect_syms_data_sp->GetByteSize());
-  // If this binary is outside the shared cache, 
+  // If this binary is outside the shared cache,
   // cache the string table.
-  // Binaries in the shared cache all share a giant string table, 
and
-  // we can't share the string tables across multiple 
ObjectFileMachO's,
-  // so we'd end up re-reading this mega-strtab for every binary
-  // in the shared cache - it would be a big perf problem.
-  // For binaries outside the shared cache, it's faster to read the
-  // entire strtab at once instead of piece-by-piece as we process
-  // the nlist records.
+  // Binaries in the shared cache all share a giant string table,
+  // and we can't share the string tables across multiple
+  // ObjectFileMachO's, so we'd end up re-reading this mega-strtab
+  // for every binary in the shared cache - it would be a big perf
+  // problem. For binaries outside the shared cache, it's faster to
+  // read the entire strtab at once ins

[Lldb-commits] [lldb] r373776 - [Host] Don't discard return value from RunShellCommand

2019-10-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Oct  4 12:37:46 2019
New Revision: 373776

URL: http://llvm.org/viewvc/llvm-project?rev=373776&view=rev
Log:
[Host] Don't discard return value from RunShellCommand

The recent change to expand arguments with the user's shell sometimes
caused a timeout and the error was not propagated.

Modified:
lldb/trunk/source/Host/macosx/objcxx/Host.mm
lldb/trunk/source/Host/windows/Host.cpp

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=373776&r1=373775&r2=373776&view=diff
==
--- lldb/trunk/source/Host/macosx/objcxx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/objcxx/Host.mm Fri Oct  4 12:37:46 2019
@@ -1366,9 +1366,14 @@ Status Host::ShellExpandArguments(Proces
 }
 bool run_in_default_shell = true;
 bool hide_stderr = true;
-RunShellCommand(expand_command, cwd, &status, nullptr, &output,
-std::chrono::seconds(10), run_in_default_shell,
-hide_stderr);
+Status e = RunShellCommand(expand_command, cwd, &status, nullptr, &output,
+   std::chrono::seconds(10), run_in_default_shell,
+   hide_stderr);
+
+if (e.Fail()) {
+  error.SetErrorString(e.AsCString());
+  return error;
+}
 
 if (status != 0) {
   error.SetErrorStringWithFormat("lldb-argdumper exited with error %d",

Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=373776&r1=373775&r2=373776&view=diff
==
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Fri Oct  4 12:37:46 2019
@@ -226,8 +226,14 @@ Status Host::ShellExpandArguments(Proces
 int status;
 std::string output;
 std::string command = expand_command.GetString();
-RunShellCommand(command.c_str(), launch_info.GetWorkingDirectory(), 
&status,
-nullptr, &output, std::chrono::seconds(10));
+Status e =
+RunShellCommand(command.c_str(), launch_info.GetWorkingDirectory(),
+&status, nullptr, &output, std::chrono::seconds(10));
+
+if (e.Fail()) {
+  error.SetErrorString(e.AsCString());
+  return error;
+}
 
 if (status != 0) {
   error.SetErrorStringWithFormat("lldb-argdumper exited with error %d",


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


Re: [Lldb-commits] [lldb] r373776 - [Host] Don't discard return value from RunShellCommand

2019-10-04 Thread Pavel Labath via lldb-commits

On 04/10/2019 21:37, Jonas Devlieghere via lldb-commits wrote:

+  error.SetErrorString(e.AsCString());
+  return error;
+}


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


[Lldb-commits] [lldb] r344119 - [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2019-10-04 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Oct 10 01:11:15 2018
New Revision: 344119

URL: http://llvm.org/viewvc/llvm-project?rev=344119&view=rev
Log:
[LLDB] - Add basic support for .debug_rnglists section (DWARF5)

This adds a basic support of the .debug_rnglists section.
Only the DW_RLE_start_length and DW_RLE_end_of_list entries are supported.

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

Added:
lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
lldb/trunk/lit/Breakpoint/debug_rnglist_basic.test
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=344119&r1=344118&r2=344119&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Oct 10 01:11:15 2018
@@ -675,6 +675,7 @@ enum SectionType {
   eSectionTypeDWARFDebugNames, // DWARF v5 .debug_names
   eSectionTypeOther,
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
+  eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Added: lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml?rev=344119&view=auto
==
--- lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml Wed Oct 10 
01:11:15 2018
@@ -0,0 +1,50 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 
31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445DC3660F1F44BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF20204000FFE00F1F005DC3660F1F44803D391B007517554889E5E87EFFC605271B015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89900F1F8400554889E5B801005DC30F1F44554889E54883EC10C745FCE8DCFF4883C4105DC3660F1F44415741564189FF415541544C8D25A61855488D2DA618534989F64989D54C29E54883EC0848C1FD03E86FFE4885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
250023002C005D00650069006D00
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
636C616E672076657273696F6E20382E302E3020287472756E6B203334333438372900746573742E637070002F686F6D652F756D622F74657374735F323031382F313033726E676C697374732F6C6C64622F63726561746574657374005F5A337A656476007A656400696E74006D61696E00
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
011101252513050325721710171B25110155177417022E001101120640186E2503253A0B3B0B49133F19032E0011011206401803253A0B3B0B49133F1904240003253E0B0B0B00
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
58000500010801000400010800020C000C000220054B00015603040101570003300540001A00015606010557000405050400
+  - Name:.debug_rnglists
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
1D00050008000720054B07300540001A00
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+ 

[Lldb-commits] [lldb] r336846 - [FileCheck] Add -allow-deprecated-dag-overlap to failing lldb tests

2019-10-04 Thread Joel E. Denny via lldb-commits
Author: jdenny
Date: Wed Jul 11 13:27:05 2018
New Revision: 336846

URL: http://llvm.org/viewvc/llvm-project?rev=336846&view=rev
Log:
[FileCheck] Add -allow-deprecated-dag-overlap to failing lldb tests

See https://reviews.llvm.org/D47106 for details.

Reviewed By: probinson

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

Modified:
lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp

Modified: lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp?rev=336846&r1=336845&r2=336846&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp Wed Jul 11 13:27:05 
2018
@@ -7,7 +7,7 @@
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method 
%t | \
 // RUN:   FileCheck --check-prefix=METHOD %s
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t 
| \
-// RUN:   FileCheck --check-prefix=FULL %s
+// RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=FULL %s
 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full 
%t | \
 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
 // RUN: lldb-test symbols --name=foo --context=context --find=function 
--function-flags=base %t | \
@@ -21,7 +21,7 @@
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method 
%t | \
 // RUN:   FileCheck --check-prefix=METHOD %s
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t 
| \
-// RUN:   FileCheck --check-prefix=FULL %s
+// RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=FULL %s
 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full 
%t | \
 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
 // RUN: lldb-test symbols --name=foo --context=context --find=function 
--function-flags=base %t | \
@@ -36,7 +36,7 @@
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method 
%t | \
 // RUN:   FileCheck --check-prefix=METHOD %s
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t 
| \
-// RUN:   FileCheck --check-prefix=FULL %s
+// RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=FULL %s
 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full 
%t | \
 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
 // RUN: lldb-test symbols --name=foo --context=context --find=function 
--function-flags=base %t | \


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


[Lldb-commits] [lldb] r345016 - [LLDB] - Implement the support for the .debug_loclists section.

2019-10-04 Thread George Rimar via lldb-commits
Author: grimar
Date: Tue Oct 23 02:46:15 2018
New Revision: 345016

URL: http://llvm.org/viewvc/llvm-project?rev=345016&view=rev
Log:
[LLDB] - Implement the support for the .debug_loclists section.

This implements the support for .debug_loclists section, which is
DWARF 5 version of .debug_loc.

Currently, clang is able to emit it with the use of D53365.

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

Modified:
lldb/trunk/include/lldb/Expression/DWARFExpression.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=345016&r1=345015&r2=345016&view=diff
==
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Tue Oct 23 02:46:15 
2018
@@ -41,6 +41,7 @@ public:
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
 SplitDwarfLocationList, // Location list format used in split dwarf files
+LocLists,   // Location list format used in DWARF v5 
(.debug_loclists).
   };
 
   //--

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=345016&r1=345015&r2=345016&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Tue Oct 23 02:46:15 2018
@@ -676,6 +676,7 @@ enum SectionType {
   eSectionTypeOther,
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
+  eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Modified: lldb/trunk/source/Core/Section.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=345016&r1=345015&r2=345016&view=diff
==
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Tue Oct 23 02:46:15 2018
@@ -77,6 +77,8 @@ const char *Section::GetTypeAsCString()
 return "dwarf-line-str";
   case eSectionTypeDWARFDebugLoc:
 return "dwarf-loc";
+  case eSectionTypeDWARFDebugLocLists:
+return "dwarf-loclists";
   case eSectionTypeDWARFDebugMacInfo:
 return "dwarf-macinfo";
   case eSectionTypeDWARFDebugMacro:

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=345016&r1=345015&r2=345016&view=diff
==
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Oct 23 02:46:15 2018
@@ -3037,6 +3037,7 @@ bool DWARFExpression::AddressRangeForLoc
 high_pc = debug_loc_data.GetAddress(offset_ptr);
 return true;
   case SplitDwarfLocationList:
+  case LocLists:
 switch (debug_loc_data.GetU8(offset_ptr)) {
 case DW_LLE_end_of_list:
   return false;
@@ -3054,8 +3055,19 @@ bool DWARFExpression::AddressRangeForLoc
   high_pc = low_pc + length;
   return true;
 }
+case DW_LLE_start_length: {
+  low_pc = debug_loc_data.GetAddress(offset_ptr);
+  high_pc = low_pc + debug_loc_data.GetULEB128(offset_ptr);
+  return true;
+}
+case DW_LLE_start_end: {
+  low_pc = debug_loc_data.GetAddress(offset_ptr);
+  high_pc = debug_loc_data.GetAddress(offset_ptr);
+  return true;
+}
 default:
   // Not supported entry type
+  lldbassert(false && "Not supported location list type");
   return false;
 }
   }

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=345016&r1=345015&r2=345016&view=diff
==
--- lldb/trunk/sou

[Lldb-commits] [lldb] r344674 - [LLDB] - Add support for DW_RLE_start_end entries (.debug_rnglists)

2019-10-04 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Oct 17 00:37:26 2018
New Revision: 344674

URL: http://llvm.org/viewvc/llvm-project?rev=344674&view=rev
Log:
[LLDB] - Add support for DW_RLE_start_end entries (.debug_rnglists)

DWARF5 describes DW_RLE_start_end as:

This is a form of bounded range entry that has two target address operands.
Each operand is the same size as used in DW_FORM_addr. These indicate
the starting and ending addresses, respectively, that define the address range
for which the following location is valid.

The patch implements the support.

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

Added:
lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp

Added: lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml?rev=344674&view=auto
==
--- lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml Wed Oct 17 
00:37:26 2018
@@ -0,0 +1,49 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00201000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00201000
+AddressAlign:0x0010
+Content: 
31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C7F0102000E89701F455B810202000483D102020004889E57417B84885C0740D5DBF10202000FFE00F1F445DC3660F1F44BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF10202000FFE00F1F005DC3660F1F44803D592F007517554889E5E87EFFC605472F015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89CC554889E5B801005DC3CC554889E54883EC10C745FCE8DCFF4883C4105DC3415741564189FF415541544C8D25E61E55488D2DE61E534989F64989D54C29E54883EC0848C1FD03E843004885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
250004002B003900620027003400
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
696E7400636C616E672076657273696F6E20382E302E3020287472756E6B2033343430333529007A656400746573742E637070006D61696E002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E64005F5A337A65647600
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
011101252513050325721710171B25110155177417022E001101120640186E2503253A0B3B0B49133F19032E0011011206401803253A0B3B0B49133F1904240003253E0B0B0B00
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
58000500010801000400010800020C000C0002E0102B00015603040101570003F01020001A00015606010557000405050400
+  - Name:.debug_rnglists
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
2B000500080006E0102000EB1026F0102A1120
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: '00'
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
8200050008004C00010101FB0E0D000101010100010101011F01090003011F020F051E0200C404455D157064301CF8C713A4AC4CEE00C404455D157064301CF8C713A4AC4CEE000902E0102105030A4B0207000101000902F010200016050A0AE5050306580206000101
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
746573742E637070002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E6400
+Symbols:

Added: lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test?rev=344674&view=auto
===

[Lldb-commits] [lldb] r344122 - [LLDB] - Simplify. NFC.

2019-10-04 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Oct 10 01:49:17 2018
New Revision: 344122

URL: http://llvm.org/viewvc/llvm-project?rev=344122&view=rev
Log:
[LLDB] - Simplify. NFC.

There are several places that call `FindRanges`,
all of them use `Slide` to adjust the ranges found
by the base address. 
All except one, which does the same manually in a loop.
Patch updates it to use `Slide` for consistency.


Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

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=344122&r1=344121&r2=344122&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Oct 10 
01:49:17 2018
@@ -3336,14 +3336,7 @@ VariableSP SymbolFileDWARF::ParseVariabl
   // All DW_AT_start_scope are relative to the base address of the
   // compile unit. We add the compile unit base address to make
   // sure all the addresses are properly fixed up.
-  for (size_t i = 0, count = dwarf_scope_ranges.GetSize();
-   i < count; ++i) {
-const DWARFRangeList::Entry &range =
-dwarf_scope_ranges.GetEntryRef(i);
-scope_ranges.Append(range.GetRangeBase() +
-die.GetCU()->GetBaseAddress(),
-range.GetByteSize());
-  }
+  dwarf_scope_ranges.Slide(die.GetCU()->GetBaseAddress());
 } else {
   // TODO: Handle the case when DW_AT_start_scope have form
   // constant. The


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


  1   2   3   4   >