[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Thanks for the information, Greg!

In https://reviews.llvm.org/D48393#1243588, @clayborg wrote:

> A little background might help here: The lldb_private::Module lock is used to 
> prevent multiple queries into the DWARF from stomping on each other.
>
> Multi-threaded DWARF parsing was primarily added to speed up indexing and the 
> only place it is used. Is that not true? Indexing is just creating name 
> tables and the accelerator tables we need so that we can partially parse the 
> DWARF later. No type parsing should be happening when indexing. All other 
> accesses to the DWARF must be done via a SymbolFile API that takes the module 
> lock to stop multiple threads from stomping on each other. So my main point 
> is we need to use the module lock to avoid having multiple threads doing 
> important work that will cause crashes.


Looking at `SymbolFileDWARF`, we only have two methods that take the module 
lock: `PreloadSymbols` and `CompleteType`.

> The only multi-threaded access to DWARF currently should be in the indexing 
> only and no important parsing stuff should be going on.

Surely there can be a lot more going on, like two debuggers executing an 
expression at the same time?

> If we discover places where multiple threads are making accesses, we just 
> need to ensure they take the module lock and everything should just work.

So what you're saying is that we should add the module lock to every endpoint 
in `SymbolFileDWARF` that can potentially modify our internal data structures 
(i.e. parsing)?


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D52376: [Swig] Merge typemaps with same bodies

2018-09-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342959: [Swig] Merge typemaps with same bodies (authored by 
tkrasnukha, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52376?vs=166719&id=166838#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52376

Files:
  lldb/trunk/scripts/Python/python-typemaps.swig

Index: lldb/trunk/scripts/Python/python-typemaps.swig
===
--- lldb/trunk/scripts/Python/python-typemaps.swig
+++ lldb/trunk/scripts/Python/python-typemaps.swig
@@ -139,30 +139,9 @@
 
 // typemap for an outgoing buffer
 // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len).
-%typemap(in) (const char *cstr, uint32_t cstr_len) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (char*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (char*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (char*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a string");
-  return NULL;
-   }
-}
 // Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len).
-%typemap(in) (const char *src, size_t src_len) {
+%typemap(in) (const char *cstr, uint32_t cstr_len),
+ (const char *src, size_t src_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -184,32 +163,9 @@
   return NULL;
}
 }
-// And SBProcess::WriteMemory.
-%typemap(in) (const void *buf, size_t size) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (void*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (void*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (void*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a buffer");
-  return NULL;
-   }
-}
-
-// For SBDebugger::DispatchInput
-%typemap(in) (const void *data, size_t data_len) {
+// For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput.
+%typemap(in) (const void *buf, size_t size),
+ (const void *data, size_t data_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -264,142 +220,70 @@
free($1);
 }
 
-// these typemaps allow Python users to pass list objects
-// and have them turn into C++ arrays (this is useful, for instance
-// when creating SBData objects from lists of numbers)
-%typemap(in) (uint64_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint64_t*) malloc(size * sizeof(uint64_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLongLong(o);
-  }
-  else {
-PyErr_SetString(PyExc_TypeError,"list must contain numbers");
-free($1);
-return NULL;
-  }
-
-  if (PyErr_Occurred()) {
-free($1);
-return NULL;
-  }
-}
-  } else if ($input == Py_None) {
-$1 =  NULL;
-$2 = 0;
-  } else {
-PyErr_SetString(PyExc_TypeError,"not a list");
-return NULL;
-  }
+%{
+namespace {
+template 
+T PyLongAsT(PyObject *obj) {
+  static_assert(true, "unsupported type"); 
 }
 
-%typemap(freearg) (uint64_t* array, size_t array_len) {
-  free($1);
+template <> uint64_t PyLongAsT(PyObject *obj) {
+  return static_cast(PyLong_AsUnsignedLongLong(obj));
 }
 
-%typemap(in) (uint32_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint32_t*) malloc(size * sizeof(uint32_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLong(o);
-  }
-  else {
-PyErr_SetString(PyExc_TypeError,"list must contain

[Lldb-commits] [lldb] r342959 - [Swig] Merge typemaps with same bodies

2018-09-25 Thread Tatyana Krasnukha via lldb-commits
Author: tkrasnukha
Date: Tue Sep 25 03:30:32 2018
New Revision: 342959

URL: http://llvm.org/viewvc/llvm-project?rev=342959&view=rev
Log:
[Swig] Merge typemaps with same bodies

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

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

Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=342959&r1=342958&r2=342959&view=diff
==
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Tue Sep 25 03:30:32 2018
@@ -139,30 +139,9 @@
 
 // typemap for an outgoing buffer
 // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t 
cstr_len).
-%typemap(in) (const char *cstr, uint32_t cstr_len) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (char*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (char*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (char*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a string");
-  return NULL;
-   }
-}
 // Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len).
-%typemap(in) (const char *src, size_t src_len) {
+%typemap(in) (const char *cstr, uint32_t cstr_len),
+ (const char *src, size_t src_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -184,32 +163,9 @@
   return NULL;
}
 }
-// And SBProcess::WriteMemory.
-%typemap(in) (const void *buf, size_t size) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (void*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (void*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (void*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a buffer");
-  return NULL;
-   }
-}
-
-// For SBDebugger::DispatchInput
-%typemap(in) (const void *data, size_t data_len) {
+// For SBProcess::WriteMemory, SBTarget::GetInstructions and 
SBDebugger::DispatchInput.
+%typemap(in) (const void *buf, size_t size),
+ (const void *data, size_t data_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -264,142 +220,70 @@
free($1);
 }
 
-// these typemaps allow Python users to pass list objects
-// and have them turn into C++ arrays (this is useful, for instance
-// when creating SBData objects from lists of numbers)
-%typemap(in) (uint64_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint64_t*) malloc(size * sizeof(uint64_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLongLong(o);
-  }
-  else {
-PyErr_SetString(PyExc_TypeError,"list must contain numbers");
-free($1);
-return NULL;
-  }
-
-  if (PyErr_Occurred()) {
-free($1);
-return NULL;
-  }
-}
-  } else if ($input == Py_None) {
-$1 =  NULL;
-$2 = 0;
-  } else {
-PyErr_SetString(PyExc_TypeError,"not a list");
-return NULL;
-  }
+%{
+namespace {
+template 
+T PyLongAsT(PyObject *obj) {
+  static_assert(true, "unsupported type"); 
 }
 
-%typemap(freearg) (uint64_t* array, size_t array_len) {
-  free($1);
+template <> uint64_t PyLongAsT(PyObject *obj) {
+  return static_cast(PyLong_AsUnsignedLongLong(obj));
 }
 
-%typemap(in) (uint32_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint32_t*) malloc(size * sizeof(uint32_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLong(o);
-  }
-  else {
- 

[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-25 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Thanks for all the comments!

In https://reviews.llvm.org/D52403#1243127, @clayborg wrote:

> So the main questions is: do we need a new section enum called 
> eSectionTypeDWARFDebugInfoDWO? If so, then this patch changes. I think I 
> would prefer adding a new enum.


Yeah, that is what I thought at the first place too. I found that when code 
looks for some section, it seems sometimes assumes it can find .dwo section by 
regular section enum value.
I thought that time that much more changes might be required (for example, 
introducing enum values for each .dwo section and perhaps fixing callers)
and so selected the simplest solution (this patch), because original code 
already used filtering by section name "dwo" suffix.

I'll try to investigate it again, want to check a few ideas I have in mind.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D48393#1243195, @JDevlieghere wrote:

> In https://reviews.llvm.org/D48393#1139327, @labath wrote:
>
> > The only sane algorithm I can come up right now is to make the list of 
> > parsed dies local to each thread/parsing entity (e.g. via a "visited" 
> > list), and only update the global map once the parsing has completed 
> > (successfully or not). This can potentially duplicate some effort where one 
> > thread parses a type only to find out that it has already been parsed, but 
> > hopefully that is not going to be the common case. The alternative is some 
> > complicated resource cycle detection scheme.
>
>
> I gave this a shot in https://reviews.llvm.org/D52406 but I'm afraid it's too 
> simple to be correct. Pavel, could you give it a look and let me know whether 
> that was what you had in mind?


Yeah, I don't think this will make things fully correct. This avoids the 
problem when two threads are misinterpreting the DIE_IS_BEING_PARSED markers 
left by the other thread. However, it is still not correct when two threads are 
parsing the same DIE concurrently. Imagine the following sequence of events:

- thread A starts parsing DIE 1, checks that it still hasn't been parsed, 
inserts the DIE_IS_BEING_PARSED into the local map.
- thread B does the same
- thread A finishes parsing DIE 1. constructs a clang AST (C1) for it sets it 
as the map value
- thread B does the same overwrites the value with C2
- thread A carries on using C1
- thread B carries on using C2

This sounds like something that is not supposed to happen, though I don't 
really know what the consequences of that are. Also I am not entirely convinced 
that the mere construction of C1 and C2 does not touch some global structures 
(which would not be protected by a lock).

I agree with Greg that it would be best to restrict things such that there is 
only one instance of parsing going on at any given time for a single module. I 
think this was pretty much the state we reached when this thread fizzled out 
the last time (there are some extra emails that are not showing in phabricator 
history, the interesting ones start around here: 
http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180618/041937.html). 
I think the main part that needed to be resolved is whether we need to go 
anything special when resolving debug info references *between* modules (e.g. 
to prevent A/B deadlocks).


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D52461: [PDB] Introduce `PDBNameParser`

2018-09-25 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, asmith, labath.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor, mgorny.

This patch introduces the simple `PDBNameParser`. It is needed for parsing 
names of PDB symbols corresponding to template instantiations. For example, for 
the name `N0::N1::Template` we can't just split the name with 
`::` (as it is implemented for now) to retrieve its scopes. This parser 
processes such names in a more correct way.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52461

Files:
  lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
  lit/SymbolFile/PDB/ast-restore.test
  source/Plugins/SymbolFile/PDB/CMakeLists.txt
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.h
  source/Plugins/SymbolFile/PDB/PDBNameParser.cpp
  source/Plugins/SymbolFile/PDB/PDBNameParser.h
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -9,6 +9,10 @@
 
 #include "SymbolFilePDB.h"
 
+#include "PDBASTParser.h"
+#include "PDBLocationToDWARFExpression.h"
+#include "PDBNameParser.h"
+
 #include "clang/Lex/Lexer.h"
 
 #include "lldb/Core/Module.h"
@@ -46,8 +50,6 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" // For IsCPPMangledName
-#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
-#include "Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h"
 
 #include 
 
@@ -1058,7 +1060,7 @@
   continue;
 
 if (!name.GetStringRef().equals(
-PDBASTParser::PDBNameDropScope(pdb_data->getName(
+PDBNameParser::DropScope(pdb_data->getName(
   continue;
 
 auto actual_parent_decl_ctx =
@@ -1166,16 +1168,7 @@
 // its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does
 // not have inforamtion of this, we extract base names and cache them
 // by our own effort.
-llvm::StringRef basename;
-CPlusPlusLanguage::MethodName cpp_method(cstr_name);
-if (cpp_method.IsValid()) {
-  llvm::StringRef context;
-  basename = cpp_method.GetBasename();
-  if (basename.empty())
-CPlusPlusLanguage::ExtractContextAndIdentifier(name.c_str(),
-   context, basename);
-}
-
+auto basename = PDBNameParser::DropScope(name);
 if (!basename.empty())
   m_func_base_names.Append(ConstString(basename), uid);
 else {
@@ -1188,11 +1181,12 @@
   } else {
 // Handle not-method symbols.
 
-// The function name might contain namespace, or its lexical scope. It
-// is not safe to get its base name by applying same scheme as we deal
-// with the method names.
-// FIXME: Remove namespace if function is static in a scope.
-m_func_base_names.Append(ConstString(name), uid);
+// The function name might contain namespace, or its lexical scope.
+auto basename = PDBNameParser::DropScope(name);
+if (!basename.empty())
+  m_func_base_names.Append(ConstString(basename), uid);
+else
+  m_func_base_names.Append(ConstString(name), uid);
 
 if (name == "main") {
   m_func_full_names.Append(ConstString(name), uid);
@@ -1420,8 +1414,7 @@
 if (max_matches > 0 && matches >= max_matches)
   break;
 
-if (PDBASTParser::PDBNameDropScope(result->getRawSymbol().getName()) !=
-name)
+if (PDBNameParser::DropScope(result->getRawSymbol().getName()) != name)
   continue;
 
 switch (result->getSymTag()) {
Index: source/Plugins/SymbolFile/PDB/PDBNameParser.h
===
--- /dev/null
+++ source/Plugins/SymbolFile/PDB/PDBNameParser.h
@@ -0,0 +1,47 @@
+//===-- PDBNameParser.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SYMBOLFILE_PDB_PDBNAMEPARSER_H
+#define LLDB_PLUGINS_SYMBOLFILE_PDB_PDBNAMEPARSER_H
+
+#include 
+
+#include "llvm/ADT/StringRef.h"
+
+class PDBNameSpecifier {
+public:
+  PDBNameSpecifier(llvm::StringRef full_name, llvm::StringRef base_name)
+  : m_full_name(full_name), m_base_name(base_name) {}
+
+  llvm::StringRef GetFullName() const { return m_full_name; }
+  llvm::StringRef GetBaseName() const { return m_base_name; }
+
+private:
+  llvm::StringRef m_full_name;
+  llvm::StringRef m_base_name;
+};
+
+class PDBNameParser {
+pub

[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test

2018-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D52139#1243170, @teemperor wrote:

> Anyway, the actual issue is related Python 3: Arch Linux (and probably
>  some other distributions that "already" upgraded to Python 3 as
>  default) will launch Python 3 when the test script calls `python ...`.
>  And for some reason in Python 3.7, we will not inherit our FD from our
>  pipe to the subprocess, which causes this strange behavior when write
>  to the unrelated FD number in ConnectToRemote. When I explicitly call
>  Python 2.7 from the test, everything runs as expected.
>
> The python docs don't see to mention this change (and it seems like a
>  bug to me), so I'm open for ideas how to fix this properly. In any
>  case this problem doesn't block this review.


It's more like python 2 had a bug where it always inherited the file 
descriptor, and then python3 fixed that and introduced a special popen argument 
to control the inheriting behavior.

Back when we were designing this test, I demonstrated the necessary 
incantations for this to work on both python2 and 3 
https://reviews.llvm.org/D49739?id=157310#inline-438290. It seems that did not 
make it into the final version..


Repository:
  rL LLVM

https://reviews.llvm.org/D52139



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


[Lldb-commits] [PATCH] D52468: [PDB] Treat `char`, `signed char` and `unsigned char` as three different types

2018-09-25 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: asmith, zturner, labath.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor.

`char`, `signed char` and `unsigned char` are three different types, and they 
are mangled differently:

  void __declspec(dllexport) /* ?foo@@YAXD@Z */ foo(char c) { } 
  void __declspec(dllexport) /* ?foo@@YAXE@Z */ foo(unsigned char c) { }
  void __declspec(dllexport) /* ?foo@@YAXC@Z */ foo(signed char c) { }


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52468

Files:
  lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
  lit/SymbolFile/PDB/ast-restore.test
  lit/SymbolFile/PDB/func-symbols.test
  lit/SymbolFile/PDB/typedefs.test
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp


Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -113,6 +113,8 @@
 return CompilerType();
   case PDB_BuiltinType::Void:
 return clang_ast.GetBasicType(eBasicTypeVoid);
+  case PDB_BuiltinType::Char:
+return clang_ast.GetBasicType(eBasicTypeChar);
   case PDB_BuiltinType::Bool:
 return clang_ast.GetBasicType(eBasicTypeBool);
   case PDB_BuiltinType::Long:
Index: lit/SymbolFile/PDB/typedefs.test
===
--- lit/SymbolFile/PDB/typedefs.test
+++ lit/SymbolFile/PDB/typedefs.test
@@ -46,9 +46,10 @@
 CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long
 CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = 
{{.*}} unsigned short
 CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = 
{{.*}} unsigned int
+CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char
 CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} 
signed char
-CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} signed char (void *, long, 
unsigned short, unsigned int, ...)
-CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} signed char (*)(void 
*, long, unsigned short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned 
short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, 
long, unsigned short, unsigned int, ...)
 CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} 
typedef VarArgsFuncTypedef
 
 CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float
Index: lit/SymbolFile/PDB/func-symbols.test
===
--- lit/SymbolFile/PDB/func-symbols.test
+++ lit/SymbolFile/PDB/func-symbols.test
@@ -14,7 +14,7 @@
 CHECK-ONE-DAG: [[TY1:.*]]:   Type{[[UID1:.*]]} , name = "Func_arg_void", decl 
= FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void)
 CHECK-ONE-DAG: [[TY2:.*]]:   Type{[[UID2:.*]]} , name = "Func_arg_none", decl 
= FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void)
 CHECK-ONE-DAG: [[TY3:.*]]:   Type{[[UID3:.*]]} , name = "Func_varargs", decl = 
FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...)
-CHECK-ONE-DAG: [[TY4:.*]]:   Type{[[UID4:.*]]} , name = "Func", decl = 
FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (signed char, int)
+CHECK-ONE-DAG: [[TY4:.*]]:   Type{[[UID4:.*]]} , name = "Func", decl = 
FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (char, int)
 CHECK-ONE-DAG: [[TY5:.*]]:   Type{[[UID5:.*]]} , name = "main", decl = 
FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void)
 CHECK-ONE-DAG: [[TY6:.*]]:   Type{[[UID6:.*]]} , name = "Func", decl = 
FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, 
volatile _Bool, ...)
 CHECK-ONE-DAG: [[TY7:.*]]:   Type{[[UID7:.*]]} , name = "StaticFunction", decl 
= FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int)
Index: lit/SymbolFile/PDB/ast-restore.test
===
--- lit/SymbolFile/PDB/ast-restore.test
+++ lit/SymbolFile/PDB/ast-restore.test
@@ -58,7 +58,7 @@
 INNER: namespace N1 {
 INNER: class Class : public N0::N1::Base {
 INNER: struct Inner {
-INNER: signed char x;
+INNER: char x;
 INNER: short y;
 INNER: int z;
 INNER: };
Index: lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
===
--- lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
+++ lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
@@ -35,6 +35,9 @@
 enum struct EnumStruct { red, blue, black };
 EnumStruct EnumStructVar;
 
+typedef signed char SCharTypedef;
+SCharTypedef SCVar;
+
 typedef char16_t WChar16Typedef;
 WChar16Typedef WC16Var;
 


Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
==

[Lldb-commits] [PATCH] D52461: [PDB] Introduce `PDBNameParser`

2018-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think you should look at CPlusPlusLanguage::MethodName. It already contains a 
parser (in fact, two of them) of c++ names, and I think it should be easy to 
extend it to do what you want.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52461



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


[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D48393#1244426, @JDevlieghere wrote:

> Thanks for the information, Greg!
>
> In https://reviews.llvm.org/D48393#1243588, @clayborg wrote:
>
> > A little background might help here: The lldb_private::Module lock is used 
> > to prevent multiple queries into the DWARF from stomping on each other.
> >
> > Multi-threaded DWARF parsing was primarily added to speed up indexing and 
> > the only place it is used. Is that not true? Indexing is just creating name 
> > tables and the accelerator tables we need so that we can partially parse 
> > the DWARF later. No type parsing should be happening when indexing. All 
> > other accesses to the DWARF must be done via a SymbolFile API that takes 
> > the module lock to stop multiple threads from stomping on each other. So my 
> > main point is we need to use the module lock to avoid having multiple 
> > threads doing important work that will cause crashes.
>
>
> Looking at `SymbolFileDWARF`, we only have two methods that take the module 
> lock: `PreloadSymbols` and `CompleteType`.


Most of the locking happens at the SymbolVendor level IIRC. But all virtual 
function SymbolFile entry points need to take the module lock.

> 
> 
>> The only multi-threaded access to DWARF currently should be in the indexing 
>> only and no important parsing stuff should be going on.
> 
> Surely there can be a lot more going on, like two debuggers executing an 
> expression at the same time?

That doesn't matter. One of them will index the DWARF. Both will be able to 
field requests via the virtual functions defined in lldb_private::SymbolFile 
(usually via the lldb_private::SymbolVendor (a class that can combine multiple 
object files/symbol files)) so any query must use the module lock. This is no 
different than two threads making two different requests from a SymbolFileDWARF.

> 
> 
>> If we discover places where multiple threads are making accesses, we just 
>> need to ensure they take the module lock and everything should just work.
> 
> So what you're saying is that we should add the module lock to every endpoint 
> in `SymbolFileDWARF` that can potentially modify our internal data structures 
> (i.e. parsing)?

Yes, any virtual lldb_private::SymbolFile entry point should lock the recursive 
module mutex. Check SymbolVendor as no one directly grabs a SymbolFile and uses 
it, they all go through the module which uses the symbol vendor. So the locking 
will often occur at the module level or the symbol vendor level.


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D48393#1244649, @labath wrote:

> I agree with Greg that it would be best to restrict things such that there is 
> only one instance of parsing going on at any given time for a single module. 
> I think this was pretty much the state we reached when this thread fizzled 
> out the last time (there are some extra emails that are not showing in 
> phabricator history, the interesting ones start around here: 
> http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180618/041937.html).
>  I think the main part that needed to be resolved is whether we need to go 
> anything special when resolving debug info references *between* modules (e.g. 
> to prevent A/B deadlocks).


We don't have to worry about references between modules as no module loads 
_ANY_ debug info from another module. If a module only has a forward 
declaration to a type, we leave it as a forward declaration. Why do we do this? 
So we can cache modules in LLDB and use all the parsed state in the next debug 
session if we rerun. Lets say you have liba.so that has a type "struct Foo { 
int x; };" and libb.so has a "struct Foo; Foo *foo_ptr;". libb.so has debug 
info for "foo_ptr" that says it is a forward declaration. At expression 
evaluation time, we will end up digging up the correct definition for "struct 
Foo" from liba.so, but we must do that each time we evaluate an expression. If 
we change liba.so with "struct Foo { int x; int y; };" and re-run, we don't 
need to reload any debug info for libb.so (or keep track of any definitions we 
might have loaded from another file to know when liba.so changes that we need 
to invalidate any number of types in other shared libraries). So because of 
this, we don't run into the problem. The variable displaying infrastructure in 
ValueObject and the expression parser know how to locate types when they need 
to. This keeps everything clean in the debug info parsing code.


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D52461: [PDB] Introduce `PDBNameParser`

2018-09-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D52461#1244813, @labath wrote:

> I think you should look at CPlusPlusLanguage::MethodName. It already contains 
> a parser (in fact, two of them) of c++ names, and I think it should be easy 
> to extend it to do what you want.


I agree with Pavel here. Try to use and extend CPlusPlusLanguage::MethodName as 
needed. I believe it was recently backed by a new clang parser that knows how 
to chop up C++ demangled names


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52461



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


[Lldb-commits] [PATCH] D52461: [PDB] Introduce `PDBNameParser`

2018-09-25 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ok, I'll look into that, thanks!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52461



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov created this revision.
apolyakov added reviewers: teemperor, labath, tatyana-krasnukha, aprantl.
Herald added a subscriber: ki.stfu.

This patch fixes hanging of the test in case of using python3, changes callback 
function that will be called if the timer ends;
Also, the test didn't work properly since it didn't contain a call of 
filecheck_proc.communicate(), that means that filecheck didn't run and its 
return code was equal to 0 in all cases.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52498

Files:
  lit/tools/lldb-mi/target/inputs/target-select-so-path.py


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -9,22 +9,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,0):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +41,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', 
port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -9,22 +9,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,0):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +41,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added a comment.

Thanks Pavel, I fixed it here https://reviews.llvm.org/D52498.


Repository:
  rL LLVM

https://reviews.llvm.org/D52139



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 166919.
apolyakov added a comment.

Removed the shebang line since we call the script via `python ...` so that line 
doesn't matter.


https://reviews.llvm.org/D52498

Files:
  lit/tools/lldb-mi/target/inputs/target-select-so-path.py


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,0):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', 
port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,0):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52501: [PDB] Restore the calling convention from PDB

2018-09-25 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: clayborg, zturner, labath, asmith.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor.

This patch implements restoring of the calling convention from PDB. It is 
necessary for expressions evaluation, if we want to call a function of the 
debuggee process with a calling convention other than ccall.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52501

Files:
  include/lldb/Symbol/ClangASTContext.h
  lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
  lit/SymbolFile/PDB/ast-restore.test
  lit/SymbolFile/PDB/pointers.test
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Symbol/ClangASTContext.cpp

Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -2058,7 +2058,8 @@
 
 CompilerType ClangASTContext::CreateFunctionType(
 ASTContext *ast, const CompilerType &result_type, const CompilerType *args,
-unsigned num_args, bool is_variadic, unsigned type_quals) {
+unsigned num_args, bool is_variadic, unsigned type_quals,
+clang::CallingConv cc) {
   if (ast == nullptr)
 return CompilerType(); // invalid AST
 
@@ -2086,6 +2087,7 @@
 
   // TODO: Detect calling convention in DWARF?
   FunctionProtoType::ExtProtoInfo proto_info;
+  proto_info.ExtInfo = cc;
   proto_info.Variadic = is_variadic;
   proto_info.ExceptionSpec = EST_None;
   proto_info.TypeQuals = type_quals;
Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -331,6 +331,26 @@
   return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
 }
 
+static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) {
+  switch (pdb_cc) {
+  case llvm::codeview::CallingConvention::NearC:
+return clang::CC_C;
+  case llvm::codeview::CallingConvention::NearStdCall:
+return clang::CC_X86StdCall;
+  case llvm::codeview::CallingConvention::NearFast:
+return clang::CC_X86FastCall;
+  case llvm::codeview::CallingConvention::ThisCall:
+return clang::CC_X86ThisCall;
+  case llvm::codeview::CallingConvention::NearVector:
+return clang::CC_X86VectorCall;
+  case llvm::codeview::CallingConvention::NearPascal:
+return clang::CC_X86Pascal;
+  default:
+assert(false && "Unknown calling convention");
+return clang::CC_C;
+  }
+}
+
 PDBASTParser::PDBASTParser(lldb_private::ClangASTContext &ast) : m_ast(ast) {}
 
 PDBASTParser::~PDBASTParser() {}
@@ -603,9 +623,10 @@
   type_quals |= clang::Qualifiers::Const;
 if (func_sig->isVolatileType())
   type_quals |= clang::Qualifiers::Volatile;
+auto cc = TranslateCallingConvention(func_sig->getCallingConvention());
 CompilerType func_sig_ast_type =
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
- arg_list.size(), is_variadic, type_quals);
+ arg_list.size(), is_variadic, type_quals, cc);
 
 GetDeclarationForSymbol(type, decl);
 return std::make_shared(
Index: lit/SymbolFile/PDB/pointers.test
===
--- lit/SymbolFile/PDB/pointers.test
+++ lit/SymbolFile/PDB/pointers.test
@@ -28,7 +28,7 @@
 MAIN: Variable{{.*}}, name = "p_member_field"
 MAIN-SAME:(int ST::*), scope = local
 MAIN: Variable{{.*}}, name = "p_member_method"
-MAIN-SAME:(int (ST::*)(int)), scope = local
+MAIN-SAME:(int (ST::*)(int) __attribute__((thiscall))), scope = local
 
 F:   Function{[[FID2:.*]]}, demangled = {{.*}}f(int)
 F-NEXT:  Block{[[FID2]]}
Index: lit/SymbolFile/PDB/ast-restore.test
===
--- lit/SymbolFile/PDB/ast-restore.test
+++ lit/SymbolFile/PDB/ast-restore.test
@@ -7,6 +7,7 @@
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CLASS %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=INNER %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=FOO %s
+RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CC %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=MAIN %s
 
 ENUM: Module: {{.*}}
@@ -73,5 +74,10 @@
 FOO: }
 FOO: }
 
+CC: Module: {{.*}}
+CC-DAG: int (*FuncStdCallPtr)() __attribute__((stdcall));
+CC-DAG: int (*FuncFastCallPtr)() __attribute__((fastcall));
+CC-DAG: int (*FuncVectorCallPtr)() __attribute__((vectorcall));
+
 MAIN: Module: {{.*}}
 MAIN: int main();
Index: lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
===
--- lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
+++ lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
@@ -41,6 +41,13 @@
 } // namespace N1
 

[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

`pass_fds` parameter was added in Python 3.7. With version 3.6 the test fails 
with a `TypeError`.


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Hmmm, maybe I mixing up something here, but the docs 
 state 
`pass_fds` was added in 3.2:

> New in version 3.2: The pass_fds parameter was added.


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D52501: [PDB] Restore the calling convention from PDB

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

Looks good as long as all the test suite bots are happy.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52501



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

It seems I ran into an unrelated issue like this 
. If the revision works for 
others, you may ignore this.


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 166936.
apolyakov added a comment.

Changed python version required to use 'pass_fds' argument to 3.2.
I tested this patch with python 2.7 and 3.5.


https://reviews.llvm.org/D52498

Files:
  lit/tools/lldb-mi/target/inputs/target-select-so-path.py


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', 
port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Forget that the test calls default python, not which was passed to cmake. So, 
it is enough to replace (3,0) pair with (3,2) to fix.




Comment at: lit/tools/lldb-mi/target/inputs/target-select-so-path.py:11
+kwargs = {}
+if sys.version_info >= (3,0):
+kwargs['pass_fds'] = [w]

Here should be (3,2)


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Now works with Python 3.1 too. LGTM.


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D51859: [NFC] Turn "load dependent files" boolean into an enum

2018-09-25 Thread Brooks Davis via Phabricator via lldb-commits
brooks added a comment.

Also broke the FreeBSD build:

  
/usr/local/poudriere/ports/brooks/devel/llvm-devel/work/llvm-b418c2351b1fdf6faf6
  
a2d010d804e895ef49932/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.c
  pp:338:50: error: cannot initialize a parameter of type 
'lldb_private::LoadDepen
  dentFiles' with an rvalue of type 'bool'
GetTarget().SetExecutableModule(exe_module_sp, true);   
 
   ^~~~
  
/usr/local/poudriere/ports/brooks/devel/llvm-devel/work/llvm-b418c2351b1fdf6faf6
  a2d010d804e895ef49932/tools/lldb/include/lldb/Target/Target.h:860:26: note: 
pass
  ing argument to parameter 'load_dependent_files' here
LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
   ^
  
/usr/local/poudriere/ports/brooks/devel/llvm-devel/work/llvm-b418c2351b1fdf6faf6
  
a2d010d804e895ef49932/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.c
  pp:522:50: error: cannot initialize a parameter of type 
'lldb_private::LoadDepen
  dentFiles' with an rvalue of type 'bool'
target->SetExecutableModule(exe_module_sp, true);
   ^~~~
  
/usr/local/poudriere/ports/brooks/devel/llvm-devel/work/llvm-b418c2351b1fdf6faf6
  a2d010d804e895ef49932/tools/lldb/include/lldb/Target/Target.h:860:26: note: 
pass
  ing argument to parameter 'load_dependent_files' here
LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
   ^
  2 errors generated.
  ninja: build stopped: subcommand failed.


Repository:
  rL LLVM

https://reviews.llvm.org/D51859



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


[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

In https://reviews.llvm.org/D48393#1245049, @clayborg wrote:

> In https://reviews.llvm.org/D48393#1244649, @labath wrote:
>
> > I agree with Greg that it would be best to restrict things such that there 
> > is only one instance of parsing going on at any given time for a single 
> > module. I think this was pretty much the state we reached when this thread 
> > fizzled out the last time (there are some extra emails that are not showing 
> > in phabricator history, the interesting ones start around here: 
> > http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180618/041937.html).
> >  I think the main part that needed to be resolved is whether we need to go 
> > anything special when resolving debug info references *between* modules 
> > (e.g. to prevent A/B deadlocks).
>
>
> We don't have to worry about references between modules as no module loads 
> _ANY_ debug info from another module.


What about -gmodules? I don't remember where the module debug info is stored, I 
think it is not shared so your statement would conceptually hold, but I'm not 
sure anymore.


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D48393: Make DWARFParsing more thread-safe

2018-09-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D48393#1245342, @friss wrote:

> In https://reviews.llvm.org/D48393#1245049, @clayborg wrote:
>
> > In https://reviews.llvm.org/D48393#1244649, @labath wrote:
> >
> > > I agree with Greg that it would be best to restrict things such that 
> > > there is only one instance of parsing going on at any given time for a 
> > > single module. I think this was pretty much the state we reached when 
> > > this thread fizzled out the last time (there are some extra emails that 
> > > are not showing in phabricator history, the interesting ones start around 
> > > here: 
> > > http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180618/041937.html).
> > >  I think the main part that needed to be resolved is whether we need to 
> > > go anything special when resolving debug info references *between* 
> > > modules (e.g. to prevent A/B deadlocks).
> >
> >
> > We don't have to worry about references between modules as no module loads 
> > _ANY_ debug info from another module.
>
>
> What about -gmodules? I don't remember where the module debug info is stored, 
> I think it is not shared so your statement would conceptually hold, but I'm 
> not sure anymore.


We load the -gmodules DWARF and a stand alone file and then copy the AST types 
over into the AST for the SymbolFileDWARF that uses them. So we are good with 
-gmodules.


https://reviews.llvm.org/D48393



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


[Lldb-commits] [PATCH] D49739: Add new API to SBTarget class

2018-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lit/tools/lldb-mi/target/target-select-so-path.test:4
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+

Could you run the same python that is used for all python tests? (%python)


Repository:
  rL LLVM

https://reviews.llvm.org/D49739



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 166953.
apolyakov edited the summary of this revision.
apolyakov added a comment.

Changed the test to use `%python` variable instead of `python`


https://reviews.llvm.org/D52498

Files:
  lit/tools/lldb-mi/target/inputs/target-select-so-path.py
  lit/tools/lldb-mi/target/target-select-so-path.test


Index: lit/tools/lldb-mi/target/target-select-so-path.test
===
--- lit/tools/lldb-mi/target/target-select-so-path.test
+++ lit/tools/lldb-mi/target/target-select-so-path.test
@@ -1,7 +1,7 @@
 # UNSUPPORTED: windows, darwin
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
-# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" 
%s
 
 # Test that -target-select command can hook up a path
 # added by gdb-set solib-search-path.
Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', 
port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 


Index: lit/tools/lldb-mi/target/target-select-so-path.test
===
--- lit/tools/lldb-mi/target/target-select-so-path.test
+++ lit/tools/lldb-mi/target/target-select-so-path.test
@@ -1,7 +1,7 @@
 # UNSUPPORTED: windows, darwin
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
-# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
 
 # Test that -target-select command can hook up a path
 # added by gdb-set solib-search-path.
Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 final

[Lldb-commits] [lldb] r342998 - Replace boolean parameter with enum value according r342633

2018-09-25 Thread Tatyana Krasnukha via lldb-commits
Author: tkrasnukha
Date: Tue Sep 25 10:59:44 2018
New Revision: 342998

URL: http://llvm.org/viewvc/llvm-project?rev=342998&view=rev
Log:
Replace boolean parameter with enum value according r342633

Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=342998&r1=342997&r2=342998&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Tue Sep 25 
10:59:44 2018
@@ -335,7 +335,7 @@ ProcessFreeBSD::DoAttachToProcessWithID(
 GetTarget().SetArchitecture(module_arch);
 
   // Initialize the target module list
-  GetTarget().SetExecutableModule(exe_module_sp, true);
+  GetTarget().SetExecutableModule(exe_module_sp, eLoadDependentsYes);
 
   SetSTDIOFileDescriptor(m_monitor->GetTerminalFD());
 
@@ -519,7 +519,7 @@ void ProcessFreeBSD::DoDidExec() {
   executable_search_paths.GetSize() ? &executable_search_paths : NULL);
   if (!error.Success())
 return;
-  target->SetExecutableModule(exe_module_sp, true);
+  target->SetExecutableModule(exe_module_sp, eLoadDependentsYes);
 }
   }
 }


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


[Lldb-commits] [PATCH] D49739: Add new API to SBTarget class

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov marked an inline comment as done.
apolyakov added inline comments.



Comment at: lit/tools/lldb-mi/target/target-select-so-path.test:4
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+

tatyana-krasnukha wrote:
> Could you run the same python that is used for all python tests? (%python)
Done in https://reviews.llvm.org/D52498


Repository:
  rL LLVM

https://reviews.llvm.org/D49739



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Looks good and fixes the tests for me, so I think this is good to go. Thanks 
for the patch!


https://reviews.llvm.org/D52498



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


[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

LGTM. (BTW, python 3.1's EOL was 6 years ago)


https://reviews.llvm.org/D52498



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


[Lldb-commits] [lldb] r343016 - XFAIL some tests in TestTargetCreateDeps on linux

2018-09-25 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Sep 25 12:52:04 2018
New Revision: 343016

URL: http://llvm.org/viewvc/llvm-project?rev=343016&view=rev
Log:
XFAIL some tests in TestTargetCreateDeps on linux

On linux, we do not support automatic loading of dependent modules, so
the module list will always contain just one module (until the target is
launched).

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py?rev=343016&r1=343015&r2=343016&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
 Tue Sep 25 12:52:04 2018
@@ -30,12 +30,14 @@ class TargetDependentsTestCase(TestBase)
 self.expect(
 "image list", msg, matching=should_match, substrs=['[  1]'])
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_implicit_default_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
 self.runCmd("target create  " + exe, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(False)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_default_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
@@ -48,6 +50,7 @@ class TargetDependentsTestCase(TestBase)
 self.runCmd("target create -dtrue " + exe, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(True)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_false_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
@@ -81,6 +84,7 @@ class TargetDependentsTestCase(TestBase)
 self.runCmd("target create -dtrue " + lib, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(True)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_false_lib(self):
 ctx = self.platformContext
 dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension


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


[Lldb-commits] [PATCH] D52516: [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: labath, jingham, JDevlieghere.
Herald added subscribers: eraman, aprantl.

Set the "mydir" attribute of an inline test on the test-specific class,
instead of on the base InlineTest class.

This makes it possible to run dotest.py on a directory containing inline
tests. This wasn't really possible prior to this patch, because what
would happen is that one test would just run over and over again, even
though the test infrastructure would claim that different tests were
being run.

Example:

The test infrastructure claimed that all of these different tests were passing,
which couldn't be true --

$ ./bin/lldb-dotest 
/Users/vsk/src/tailcall/lldb/test/testcases/functionalities/tail_call_frames/ 
-G dwarf -t 2>&1 | grep PASS
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguateTailCallSeq)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestArtificialFrameStepOutMessage)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestAmbiguousTailCallSeq1)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguatePathsToCommonSink)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguateCallSite)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestUnambiguousTailCalls)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestAmbiguousTailCallSeq2)
RESULT: PASSED (7 passes, 0 failures, 0 errors, 24 skipped, 0 expected 
failures, 0 unexpected successes)

... because it wasn't even looking at some of these tests:

$ ./bin/lldb-dotest 
/Users/vsk/src/tailcall/lldb/test/testcases/functionalities/tail_call_frames/ 
-G dwarf -t 2>&1 | grep "Change dir"
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2

E.g it was only building one of them:

$ ls lldb-test-build.noindex/functionalities/tail_call_frames/  
  
ambiguous_tail_call_seq2


https://reviews.llvm.org/D52516

Files:
  lldb/packages/Python/lldbsuite/test/lldbinline.py


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.

[Lldb-commits] [PATCH] D52516: [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.

LGTM.


https://reviews.llvm.org/D52516



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


[Lldb-commits] [PATCH] D52516: [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Ooh, nice catch. This must have been fun to debug.


https://reviews.llvm.org/D52516



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


[Lldb-commits] [lldb] r343023 - [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Sep 25 13:20:13 2018
New Revision: 343023

URL: http://llvm.org/viewvc/llvm-project?rev=343023&view=rev
Log:
[lldbinline] Set directory attribute on test-specific classes

Set the "mydir" attribute of an inline test on the test-specific class,
instead of on the base InlineTest class.

This makes it possible to run dotest.py on a directory containing inline
tests. This wasn't really possible prior to this patch, because what
would happen is that one test would just run over and over again, even
though the test infrastructure would claim that different tests were
being run.

Example:

The test infrastructure claimed that all of these different tests were passing,
which couldn't be true --

$ ./bin/lldb-dotest 
/Users/vsk/src/tailcall/lldb/test/testcases/functionalities/tail_call_frames/ 
-G dwarf -t 2>&1 | grep PASS
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguateTailCallSeq)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestArtificialFrameStepOutMessage)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestAmbiguousTailCallSeq1)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguatePathsToCommonSink)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestDisambiguateCallSite)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestUnambiguousTailCalls)
PASS: LLDB (/Users/vsk/src/builds/tailcall-RA/bin/clang-8-x86_64) :: test_dwarf 
(lldbsuite.test.lldbtest.TestAmbiguousTailCallSeq2)
RESULT: PASSED (7 passes, 0 failures, 0 errors, 24 skipped, 0 expected 
failures, 0 unexpected successes)

... because it wasn't even looking at some of these tests:

$ ./bin/lldb-dotest 
/Users/vsk/src/tailcall/lldb/test/testcases/functionalities/tail_call_frames/ 
-G dwarf -t 2>&1 | grep "Change dir"
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2
Change dir to: 
/Users/vsk/src/tailcall/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2

E.g it was only building one of them:

$ ls lldb-test-build.noindex/functionalities/tail_call_frames/  
  
ambiguous_tail_call_seq2

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=343023&r1=343022&r2=343023&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Tue Sep 25 13:20:13 
2018
@@ -195,7 +195,6 @@ def MakeInlineTest(__file, __globals, de
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@ def MakeInlineTest(__file, __globals, de
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class


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


[Lldb-commits] [PATCH] D52516: [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343023: [lldbinline] Set directory attribute on 
test-specific classes (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52516?vs=166980&id=166984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52516

Files:
  lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap

2018-09-25 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 166985.
sgraenitz added a comment.

Revert check_hi_lo_pc and comment out call to AddOSOARanges() for now


https://reviews.llvm.org/D52375

Files:
  include/lldb/Symbol/Symtab.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  source/Symbol/Symtab.cpp

Index: source/Symbol/Symtab.cpp
===
--- source/Symbol/Symtab.cpp
+++ source/Symbol/Symtab.cpp
@@ -509,6 +509,16 @@
   return indexes.size() - prev_size;
 }
 
+bool Symtab::HasSymbolWithTypeAndFlags(lldb::SymbolType symbol_type,
+   uint32_t flags_value) const {
+  std::lock_guard guard(m_mutex);
+  for (const Symbol &symbol : m_symbols)
+if (symbol.GetType() == symbol_type && symbol.GetFlags() == flags_value)
+  return true;
+
+  return false;
+}
+
 uint32_t Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type,
  Debug symbol_debug_type,
  Visibility symbol_visibility,
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -131,7 +131,11 @@
   uint32_t GetPluginVersion() override;
 
 protected:
-  enum { kHaveInitializedOSOs = (1 << 0), kNumFlags };
+  enum {
+kHaveInitializedOSOs = (1 << 0),
+kHaveCheckedCUInfos = (1 << 1),
+kNumFlags
+  };
 
   friend class DebugMapModule;
   friend struct DIERef;
@@ -172,13 +176,17 @@
   first_symbol_id(UINT32_MAX), last_symbol_id(UINT32_MAX),
   file_range_map(), file_range_map_valid(false) {}
 
+bool Init(lldb_private::Symbol *so, lldb_private::Symbol *oso);
 const FileRangeMap &GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile);
   };
 
   //--
   // Protected Member Functions
   //--
   void InitOSO();
+  bool HasCompileUnits();
+  void ReportErrorInitOSO(lldb_private::Symbol *so_symbol,
+  lldb_private::Symbol *oso_symbol, uint32_t oso_idx);
 
   static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) {
 return (uint32_t)((uid >> 32ull) - 1ull);
@@ -247,6 +255,11 @@
 
   lldb::CompUnitSP GetCompileUnit(SymbolFileDWARF *oso_dwarf);
 
+  lldb::CompUnitSP GetCompileUnitByIndex(SymbolFileDWARF *oso_dwarf,
+ uint32_t cu_idx);
+  lldb::CompUnitSP GetCompileUnitByOffset(SymbolFileDWARF *oso_dwarf,
+  dw_offset_t cu_offset);
+
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
   lldb::TypeSP
@@ -297,6 +310,8 @@
   // Member Variables
   //--
   std::bitset m_flags;
+  bool m_has_compile_unit_infos;
+  std::vector m_oso_compile_unit_offset;
   std::vector m_compile_unit_infos;
   std::vector m_func_indexes; // Sorted by address
   std::vector m_glob_indexes;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -37,6 +37,7 @@
 #include "lldb/Symbol/VariableList.h"
 #include "llvm/Support/ScopedPrinter.h"
 
+#include "DWARFCompileUnit.h"
 #include "LogChannelDWARF.h"
 #include "SymbolFileDWARF.h"
 
@@ -169,6 +170,23 @@
   return file_range_map;
 }
 
+bool SymbolFileDWARFDebugMap::CompileUnitInfo::Init(Symbol *so, Symbol *oso) {
+  if (!so || so->GetType() != eSymbolTypeSourceFile)
+return false;
+
+  if (!oso || oso->GetType() != eSymbolTypeObjectFile)
+return false;
+
+  if (so->GetSiblingIndex() == UINT32_MAX)
+return false;
+
+  llvm::StringRef so_file_name = so->GetName().GetStringRef();
+  so_file.SetFile(so_file_name, false, FileSpec::Style::native);
+  oso_mod_time = llvm::sys::toTimePoint(oso->GetIntegerValue(0));
+  oso_path = oso->GetName();
+  return true;
+}
+
 class DebugMapModule : public Module {
 public:
   DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx,
@@ -251,61 +269,63 @@
 }
 
 SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap(ObjectFile *ofile)
-: SymbolFile(ofile), m_flags(), m_compile_unit_infos(), m_func_indexes(),
-  m_glob_indexes(),
+: SymbolFile(ofile), m_flags(), m_has_compile_unit_infos(false),
+  m_compile_unit_infos(), m_func_indexes(), m_glob_indexes(),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
 

[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap

2018-09-25 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:431
 const size_t num_ranges =
-die->GetAttributeAddressRanges(dwarf, this, ranges, false);
+die->GetAttributeAddressRanges(dwarf, this, ranges, check_hi_lo_pc);
 if (num_ranges > 0) {

clayborg wrote:
> sgraenitz wrote:
> > @JDevlieghere Thanks for your feedback!
> > 
> > @everyone:
> > This parameter is, actually, one of the key questions in this review: If 
> > there is no DW_AT_range attribute for the compile unit, can we safely fall 
> > back to DW_AT_low/high_pc?
> I have seen DWARF where the DW_AT_ranges is incorrect and I have seen cases 
> where the low pc is just set to zero and the high pc is set to the max 
> address. So you might have many overlapping ranges between different CUs in 
> the latter case. We might need to be more vigilant with high/low pc values 
> though and that was the reason that we previously ignored high/low pc values. 
> If the stuff is missing, it should index the DWARF and generate the address 
> ranges table manually right? What was the reasoning behind this change?
I had a closer look at the individual fallbacks and you are right. After fixing 
`SymbolFileDWARF::ParseCompileUnit()` we have the correct `CompileUnit` 
pointers in `DWARFUnit::m_user_data` for all CUs. Thus, the below 
`die->BuildAddressRangeTable(dwarf, this, debug_aranges);` now correctly 
constructs the ranges! Great, with this we can keep `check_hi_lo_pc=false`.

I didn't notice this while testing, because of the following issue that kept my 
tests failing: 2 of my LTO object's CUs have no code remaining after 
optimization, so we step into the next fallback assuming 'a line tables only 
situation' and eventually call `AddOSOARanges()`, which adds to `debug_aranges` 
all entries of the CU's FileRangeMap with a zero offset.

Thus, my `debug_aranges` had 28000 entries too much and most requests would 
continue to return `0` as before. For now I commented out the call below.

**What do you think is a good way to avoid this for empty CUs?
IIUC they should have no DW_AT_low/high_pc right? :-D**


https://reviews.llvm.org/D52375



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


[Lldb-commits] [lldb] r343029 - Change the unwinder to not use a hard-coded limit on the

2018-09-25 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Tue Sep 25 14:01:54 2018
New Revision: 343029

URL: http://llvm.org/viewvc/llvm-project?rev=343029&view=rev
Log:
Change the unwinder to not use a hard-coded limit on the
max number of stack frames to backtrace, make it a setting,
target.process.thread.max-backtrace-depth.
Add a test case for the setting.

 

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/main.cpp
Modified:
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=343029&r1=343028&r2=343029&view=diff
==
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Sep 25 14:01:54 2018
@@ -57,6 +57,8 @@ public:
   bool GetStepInAvoidsNoDebug() const;
 
   bool GetStepOutAvoidsNoDebug() const;
+  
+  uint64_t GetMaxBacktraceDepth() const;
 };
 
 typedef std::shared_ptr ThreadPropertiesSP;

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/Makefile?rev=343029&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/Makefile
 Tue Sep 25 14:01:54 2018
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+CXXFLAGS += -std=c++11
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py?rev=343029&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py
 Tue Sep 25 14:01:54 2018
@@ -0,0 +1,31 @@
+"""
+Test that the target.process.thread.max-backtrace-depth setting works.
+"""
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class BacktraceLimitSettingTest(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+def test_backtrace_depth(self):
+"""Test that the max-backtrace-depth setting limits backtraces."""
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.cpp")
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
+"Set a breakpoint here", self.main_source_file)
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand("settings set 
target.process.thread.max-backtrace-depth 30", result)
+self.assertEqual(True, result.Succeeded())
+self.assertEqual(30, thread.GetNumFrames())

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/main.cpp?rev=343029&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/main.cpp
 Tue Sep 25 14:01:54 2018
@@ -0,0 +1,13 @@
+int bottom () { 
+  return 1;  // Set a breakpoint here
+} 
+int foo(int in) { 
+  if (in > 0)
+return foo(--in) + 5; 
+  else
+return bottom();
+}
+int main()
+{
+   return foo(500);
+}

Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=343029&r1=343028&r2=343029&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/UnwindL

[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test

2018-09-25 Thread Alexander Polyakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343033: [lldb-mi] Fix bugs in target-select-so-path.test 
(authored by apolyakov, committed by ).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52498

Files:
  lit/tools/lldb-mi/target/inputs/target-select-so-path.py
  lit/tools/lldb-mi/target/target-select-so-path.test


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', 
port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 
Index: lit/tools/lldb-mi/target/target-select-so-path.test
===
--- lit/tools/lldb-mi/target/target-select-so-path.test
+++ lit/tools/lldb-mi/target/target-select-so-path.test
@@ -1,7 +1,7 @@
 # UNSUPPORTED: windows, darwin
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
-# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" 
%s
 
 # Test that -target-select command can hook up a path
 # added by gdb-set solib-search-path.


Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===
--- lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,22 +7,26 @@
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
 lldbmi = args[2]
 test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
 timer.start()
 
@@ -37,9 +39,10 @@
 with open(test_file, 'r') as f:
 # Replace '$PORT' with a free port number and pass
 # test's content to lldb-mi.
-lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
 out, err = lldbmi_proc.communicate()
 filecheck_proc.stdin.write(out)
+filecheck_proc.communicate()
 finally:
 timer.cancel()
 
Index: lit/tools/lldb-mi/target/target-select-so-path.test
===
--- lit/tools/lldb-mi/target/target-select-so-path.test
+++ lit/tools/lldb-mi/target/target-select-so-path.test
@@ -1,7 +1,7 @@
 # UNSUPPORTED: windows, darwin
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
-# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
 
 # Test that -target-select command

[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap

2018-09-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:425
   const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
 
   const dw_offset_t cu_offset = GetOffset();

Following from inline comment below, you can abort if this CU is empty:

```
// If this DWARF unit has no children, we have no address ranges to add. If
// something is built with line tables only, there will still be function DIEs 
with
// address ranges as children.
if (!die->HasChildren())
  return;
```



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:439
+die->GetAttributeAddressRanges(dwarf, this, ranges, check_hi_lo_pc);
+
 if (num_ranges > 0) {

Empty CUs won't have any children. Easy to skip by getting the CU die and doing:
```
if (!die->HasChildren())
```




Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:488-489
 }
-  } else
-debug_map_sym_file->AddOSOARanges(dwarf, debug_aranges);
+  } //else
+//debug_map_sym_file->AddOSOARanges(dwarf, debug_aranges);
 }

revert if the "if (!die->hasChildren())" trick works.


https://reviews.llvm.org/D52375



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


[Lldb-commits] [PATCH] D50478: Add support for artificial tail call frames

2018-09-25 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 167038.
vsk added a comment.

The bug I thought I saw in CallEdge::GetReturnPCAddress turned out to be an 
issue I introduced in dsymutil. It's not correct for dsymutil to relocate the 
return PC value in TAG_call_site entries, because the correct section slide 
offset can't be applied until we have a running process (and things like dylibs 
are mapped in).

Other changes:

- Add a test which requires both inline frame and tail call frame support.
- Require a call edge’s return PC attribute to match the register context’s PC 
exactly. Otherwise, we report incorrect frames.
- Improve logging and add more tests.


https://reviews.llvm.org/D50478

Files:
  lldb/include/lldb/API/SBFrame.h
  lldb/include/lldb/Core/FormatEntity.h
  lldb/include/lldb/Symbol/Block.h
  lldb/include/lldb/Symbol/Function.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/StackFrame.h
  lldb/include/lldb/Target/StackFrameList.h
  lldb/include/lldb/Target/ThreadPlanStepOut.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp
  lldb/scripts/interface/SBFrame.i
  lldb/source/API/SBFrame.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/FormatEntity.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Symbol/Block.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Target/StackFrame.cpp
  lldb/source/Target/StackFrameList.cpp
  lldb/source/Target/ThreadPlanS